Skip to content

Commit

Permalink
fix: tree search expansion (#501)
Browse files Browse the repository at this point in the history
* fix(scopes): tree search with only one root

* fix(scopes): refresh scopes index on create

Storing new scopes didn't trigger an update of the scope index list.
  • Loading branch information
derrabauke authored Jun 10, 2022
1 parent 5592acc commit 5eb804c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions addon/components/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class TreeComponent extends Component {
// we need the children in the list of expanded items, so we can expand the "searched" items.
item.children.forEach((child) => expanded.push(child));
});
return expanded.map((item) => item.id);
return expanded;
}
const rootNodes = this.args.items?.filter((i) => i.level === 0);
return this.args.activeItem?.findParents
Expand Down Expand Up @@ -72,6 +72,6 @@ export default class TreeComponent extends Component {

@action
filterItemList(item) {
return this.expandedItems.includes(item);
return this.expandedItems.find(({ id }) => id === item);
}
}
3 changes: 2 additions & 1 deletion addon/controllers/scopes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { inject as service } from "@ember/service";

export default class ScopesController extends Controller {
@service router;
@service store;

get activeScope() {
if (!this.router.currentRouteName.includes("scopes.edit")) {
Expand All @@ -12,6 +13,6 @@ export default class ScopesController extends Controller {
}

get rootScopes() {
return this.model?.filter((scope) => !scope.parent);
return this.store.peekAll("scope").filter((scope) => !scope.parent);
}
}
2 changes: 1 addition & 1 deletion addon/routes/scopes/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export default class ScopesNewRoute extends CreateRoute {
detailView = "scopes.edit";

model() {
return this.store.createRecord("scope");
return this.store.createRecord("scope", { isActive: true });
}
}

0 comments on commit 5eb804c

Please sign in to comment.