diff --git a/app/components/treatment/voting/modal.js b/app/components/treatment/voting/modal.js index a1c9ee905..b2edd49dd 100644 --- a/app/components/treatment/voting/modal.js +++ b/app/components/treatment/voting/modal.js @@ -32,13 +32,13 @@ export default class TreatmentVotingModalComponent extends Component { @restartableTask /** @type {import("ember-concurrency").Task} */ - fetchStemmingen = function* () { + *fetchStemmingen() { this.stemmingen = (yield this.args.behandeling.stemmingen).sortBy('position'); - }; + } @task /** @type {import("ember-concurrency").Task} */ - saveStemming = function* () { + *saveStemming() { const isNew = this.editStemming.stemming.isNew; if(isNew) { @@ -51,45 +51,45 @@ export default class TreatmentVotingModalComponent extends Component { this.args.behandeling.save(); } yield this.fetchStemmingen.perform(); - - this.onCancelEdit(); - }; + this.onCancelEdit(); + } @task /** @type {import("ember-concurrency").Task} */ - addStemming = - /** @this {TreatmentVotingModalComponent} */ - function* () { - const richTreatment = yield this.store.query("behandeling-van-agendapunt", { - "filter[:id:]": this.args.behandeling.id, - include: "aanwezigen.bekleedt.bestuursfunctie" - }); - const participants = richTreatment.firstObject.aanwezigen; + *addStemming() { + const richTreatment = yield this.store.query("behandeling-van-agendapunt", { + "filter[:id:]": this.args.behandeling.id, + include: "aanwezigen.bekleedt.bestuursfunctie" + }); + const participants = richTreatment.firstObject.aanwezigen; + + const stemmingToEdit = this.store.createRecord("stemming", { + onderwerp: "", + geheim: false, + aantalVoorstanders: 0, + aantalTegenstanders: 0, + aantalOnthouders: 0, + gevolg: "", + }); + this.editMode = true; + stemmingToEdit.aanwezigen.pushObjects(participants); + stemmingToEdit.stemmers.pushObjects(participants); + this.editStemming.stemming = stemmingToEdit; + } - const stemmingToEdit = this.store.createRecord("stemming", { - onderwerp: "", - geheim: false, - aantalVoorstanders: 0, - aantalTegenstanders: 0, - aantalOnthouders: 0, - gevolg: "", - }); - this.editMode = true; - stemmingToEdit.aanwezigen.pushObjects(participants); - stemmingToEdit.stemmers.pushObjects(participants); - this.editStemming.stemming = stemmingToEdit; - }; @action toggleEditStemming(stemming) { this.editStemming.stemming = stemming; this.editMode = true; } + @task - removeStemming = function* (stemming) { - stemming.deleteRecord(); - yield stemming.save(); + *removeStemming(stemming) { + yield stemming.destroyRecord(); + this.stemmingen = this.stemmingen.reject((x) => x === stemming); } + @action onCancelEdit() { this.editMode = false;