Skip to content

Commit

Permalink
Merge pull request #2807 from IDEMSInternational/fix/data-items-actio…
Browse files Browse the repository at this point in the history
…n-value

fix: data-items action value
  • Loading branch information
esmeetewinkel authored Feb 27, 2025
2 parents 777af75 + 543cd57 commit a99064b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,10 @@ describe("TemplateActionService", () => {
expect(service.container.templateRowService.templateRowMapValues.mock_row_1).toEqual("updated");
});

it("Uses latest value for `this.value` arg", async () => {
const _triggeredBy = { _nested_name: "mock_row_1", name: "mock_row_1", type: "" };
it("Uses latest value for `this.value` arg from trigger row", async () => {
const _triggeredBy = { _nested_name: "", name: "", type: "", value: "updated" };
await service.handleActions(
[
{ trigger: "click", action_id: "set_self", args: ["mock_row_1", "updated"] },
{
trigger: "click",
action_id: "set_local",
Expand Down Expand Up @@ -123,7 +122,7 @@ describe("TemplateActionService", () => {
});

it("Uses latest value for `this.value` param", async () => {
const _triggeredBy = { _nested_name: "mock_row_1", name: "mock_row_1", type: "" };
const _triggeredBy = { _nested_name: "", name: "", type: "", value: "updated" };
await service.handleActions(
[
{ trigger: "click", action_id: "set_self", args: ["mock_row_1", "updated"] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export class TemplateActionService extends SyncServiceBase {
action: FlowTypes.TemplateRowAction
): FlowTypes.TemplateRowAction {
// Update action.args and action.params
const currentValue = this.container?.templateRowMap?.[action._triggeredBy?._nested_name]?.value;
const currentValue = action._triggeredBy?.value;
// define a replacer that preserves type if `this.value` specified, replacing as string for
// other expressions `@local.some_field_{this.value}`
function replaceReference(v: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default async (service: DynamicDataService, params: IActionSetDataParams)
params._updates = await generateUpdateList(service, params);
}
const { _list_id, _updates } = params;
console.log("[Set Data]", _list_id, _updates);
// Hack, no current method for bulk update so make successive (changes debounced in component)
for (const { id, ...writeableProps } of _updates) {
await service.update("data_list", _list_id, id, writeableProps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ export class DynamicDataService extends AsyncServiceBase {
}

if (itemDataIDs.includes(targetRowId)) {
console.log("[Set Item]", flow_name, targetRowId, writeableProps);
await this.update("data_list", flow_name, targetRowId, writeableProps);
} else {
console.warn(`[SET ITEM] - No item ${_id ? "with ID " + _id : "at index " + _index}`);
Expand Down

0 comments on commit a99064b

Please sign in to comment.