Skip to content

Commit

Permalink
Merge pull request #188 from lblod/bugfix/delete-vote
Browse files Browse the repository at this point in the history
correctly delete vote
  • Loading branch information
nvdk authored Sep 17, 2021
2 parents 5983335 + 2cd7bbb commit 85bc8f6
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions app/components/treatment/voting/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit 85bc8f6

Please sign in to comment.