Skip to content

Commit

Permalink
refactor(frontend/activties/edit): hack around PromiseProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
c0rydoras committed Feb 26, 2025
1 parent 66f6a3f commit 5b699d6
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion frontend/app/index/activities/edit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { timeout } from "ember-concurrency";
export default class IndexActivitiesEditController extends Controller {
@service notify;
@service router;
@service store;
@tracked changeset;

/**
Expand Down Expand Up @@ -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");

Expand Down

0 comments on commit 5b699d6

Please sign in to comment.