Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

fix(report-row): components from duplication when clicking submit #1157

Merged
merged 3 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/components/report-row/component.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import Component from "@glimmer/component";
import { dropTask } from "ember-concurrency";
import ReportValidations from "timed/validations/report";

export default class ReportRowComponent extends Component {
Expand All @@ -26,9 +27,11 @@ export default class ReportRowComponent extends Component {
* @method save
* @public
*/
@action
save(changeset) {
this.args.onSave(changeset);
@dropTask
*save(changeset) {
if (this.args.onSave) {
yield this.args.onSave(changeset);
}
}
/**
* Delete the row
Expand Down
4 changes: 2 additions & 2 deletions app/components/report-row/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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.save.isRunning (and (not cs.isNew) (or (not cs.isDirty) (not cs.isValid)))}}
{{on "click" (prevent-default (perform this.save cs))}}
><FaIcon @icon="floppy-disk" /></button>
{{/if}}
</div>
Expand Down
Loading