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

Commit

Permalink
refactor(report-row): use dropTask instead of tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
MitanOmar committed Jan 4, 2024
1 parent 834a5ad commit e98f797
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
11 changes: 4 additions & 7 deletions app/components/report-row/component.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { dropTask } from "ember-concurrency";
import ReportValidations from "timed/validations/report";

export default class ReportRowComponent extends Component {
@service abilities;
@tracked inUpdate = false;

ReportValidations = ReportValidations;

Expand All @@ -28,11 +27,9 @@ export default class ReportRowComponent extends Component {
* @method save
* @public
*/
@action
async save(changeset) {
this.inUpdate = true;
await this.args.onSave(changeset);
this.inUpdate = false;
@dropTask
*save(changeset) {
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={{or this.inUpdate (and (not cs.isNew) (or (not cs.isDirty) (not cs.isValid)))}}
{{on "click" (prevent-default (fn (optional this.save) 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

0 comments on commit e98f797

Please sign in to comment.