From 5b699d69034a8ee54878d3e7af47875f07a3f214 Mon Sep 17 00:00:00 2001 From: Arthur Deierlein Date: Tue, 25 Feb 2025 14:32:03 +0100 Subject: [PATCH] refactor(frontend/activties/edit): hack around PromiseProxy --- .../app/index/activities/edit/controller.js | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/frontend/app/index/activities/edit/controller.js b/frontend/app/index/activities/edit/controller.js index b75f6350a..0608f7500 100644 --- a/frontend/app/index/activities/edit/controller.js +++ b/frontend/app/index/activities/edit/controller.js @@ -19,6 +19,7 @@ import { timeout } from "ember-concurrency"; export default class IndexActivitiesEditController extends Controller { @service notify; @service router; + @service store; @tracked changeset; /** @@ -56,7 +57,29 @@ export default class IndexActivitiesEditController extends Controller { } try { - await this.changeset.save(); + // this is an ugly mess, to get around the changeset using a PromiseProxy + + const changeset = this.changeset; + const { comment, from, to, review, notBillable } = changeset; + + const attributes = { + comment, + from, + to, + review, + notBillable, + }; + + const ref = this.model; + ref.task = + (await changeset.get("task.id")) && + this.store.peekRecord("task", changeset.get("task.id")); + + Object.entries(attributes).forEach(([k, v]) => { + ref[k] = v; + }); + + await ref.save(); this.notify.success("Activity was saved");