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

Commit

Permalink
Merge pull request #1187 from derrabauke/fix-analysis-restore-selecte…
Browse files Browse the repository at this point in the history
…d-rows

fix(analysis): skip reset if edit is cancled
  • Loading branch information
derrabauke authored Mar 13, 2024
2 parents d84c3be + 83d44ab commit bba5fd2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
5 changes: 4 additions & 1 deletion app/analysis/index/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ export default class AnalysisIndexRoute extends Route {
model() {
/* eslint-disable-next-line ember/no-controller-access-in-routes */
const controller = this.controllerFor("analysis.index");
const skipReset = controller.skipResetOnSetup;
next(() => {
controller._reset();
if (!skipReset) {
controller._reset();
}
});
}

Expand Down
8 changes: 5 additions & 3 deletions app/components/task-selection/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export default class TaskSelectionComponent extends Component {
task: null,
};

const options = { preventAction: true };

// the objects are possibily wrapped in a proxy which would
// confuse the upcoming null check
const [customer, project, task] = await Promise.all([
Expand All @@ -106,11 +108,11 @@ export default class TaskSelectionComponent extends Component {
]);

if (task) {
this.onTaskChange(task);
this.onTaskChange(task, options);
} else if (project) {
this.onProjectChange(project);
this.onProjectChange(project, options);
} else if (customer) {
this.onCustomerChange(customer);
this.onCustomerChange(customer, options);
} else {
this.tracking.fetchCustomers.perform();
}
Expand Down
10 changes: 10 additions & 0 deletions tests/acceptance/analysis-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ module("Acceptance | analysis", function (hooks) {
await authenticateSession({ user_id: this.user.id });

this.server.createList("report", 40, { userId: this.user.id });
this.reportIntersection = this.server.create("report-intersection", {
verified: false,
review: true,
});
});

test("can visit /analysis", async function (assert) {
Expand Down Expand Up @@ -169,6 +173,12 @@ module("Acceptance | analysis", function (hooks) {

assert.ok(find("tbody > tr:first-child.selected"));

// check if selection remains after canceling the edit
await click("button[data-test-edit-selected]");
await click("button[data-test-cancel]");

assert.ok(find("tbody > tr:first-child.selected"));

await click("tbody > tr:first-child");

assert.notOk(find("tbody > tr:first-child.selected"));
Expand Down

0 comments on commit bba5fd2

Please sign in to comment.