From 834a5adfc65f88aa7965b329550df20964879844 Mon Sep 17 00:00:00 2001 From: Mitan Omar Date: Thu, 21 Dec 2023 17:15:42 +0100 Subject: [PATCH] fix(report-row): components from duplication when clicking submit multible time --- app/components/report-row/component.js | 8 ++++++-- app/components/report-row/template.hbs | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/components/report-row/component.js b/app/components/report-row/component.js index a117f90ae..d694cdbf2 100644 --- a/app/components/report-row/component.js +++ b/app/components/report-row/component.js @@ -1,10 +1,12 @@ import { action } from "@ember/object"; import { inject as service } from "@ember/service"; import Component from "@glimmer/component"; +import { tracked } from "@glimmer/tracking"; import ReportValidations from "timed/validations/report"; export default class ReportRowComponent extends Component { @service abilities; + @tracked inUpdate = false; ReportValidations = ReportValidations; @@ -27,8 +29,10 @@ export default class ReportRowComponent extends Component { * @public */ @action - save(changeset) { - this.args.onSave(changeset); + async save(changeset) { + this.inUpdate = true; + await this.args.onSave(changeset); + this.inUpdate = false; } /** * Delete the row diff --git a/app/components/report-row/template.hbs b/app/components/report-row/template.hbs index fd3e0df07..9bd6a660e 100644 --- a/app/components/report-row/template.hbs +++ b/app/components/report-row/template.hbs @@ -109,8 +109,8 @@ type="submit" data-test-save-report class="btn btn-primary" - disabled={{and (not cs.isNew) (or (not cs.isDirty) (not cs.isValid))}} - {{on "click" (prevent-default (fn (optional @onSave) cs))}} + disabled={{or this.inUpdate (and (not cs.isNew) (or (not cs.isDirty) (not cs.isValid)))}} + {{on "click" (prevent-default (fn (optional this.save) cs))}} > {{/if}}