Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scope): sort by full (hierarchical) name #565

Merged
merged 1 commit into from
Sep 26, 2022
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
8 changes: 4 additions & 4 deletions addon/components/acl-wizzard.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{#if this.modelToSelect}}
<div class="uk-margin">
<SectionTitle @model="{{this.modelToSelect}}s" @noCreateLink="true" />
<DataTable @modelName={{this.modelToSelect}} as |table|>
<DataTable @modelName={{this.modelToSelect}} @defaultSort={{this.sort}} as |table|>
<table.head>
{{#each (get this.fields this.modelToSelect) as |field|}}
<th>
Expand Down Expand Up @@ -37,7 +37,7 @@
@selected={{this.user}}
@header={{this.user.username}}
@model="user"
@selectEntry={{set this.modelToSelect "user"}}
@selectEntry={{fn this.openModel "user"}}
data-test-select-user
>
<div uk-grid data-test-body>
Expand All @@ -61,7 +61,7 @@
<AclWizzard::SelectCard
@selected={{this.role}}
@model="role"
@selectEntry={{set this.modelToSelect "role"}}
@selectEntry={{fn this.openModel "role"}}
data-test-select-role
/>

Expand All @@ -78,7 +78,7 @@
<AclWizzard::SelectCard
@selected={{this.scope}}
@model="scope"
@selectEntry={{set this.modelToSelect "scope"}}
@selectEntry={{fn this.openModel "scope"}}
data-test-select-scope
/>
{{/unless}}
Expand Down
10 changes: 10 additions & 0 deletions addon/components/acl-wizzard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { action } from "@ember/object";
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";

const DEFAULT_SORT = {
scope: "full_name",
};

export default class AclWizzardComponent extends Component {
@tracked modelToSelect;
@tracked user;
Expand Down Expand Up @@ -31,4 +35,10 @@ export default class AclWizzardComponent extends Component {
this[this.modelToSelect] = model;
this.modelToSelect = null;
}

@action
openModel(model) {
this.modelToSelect = model;
this.sort = DEFAULT_SORT[model];
}
}
2 changes: 1 addition & 1 deletion addon/routes/scopes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default class ScopesRoute extends Route {
model() {
// this eager fetching is necessary, since we need a store-independent result set
// for use-cases where we have other non-relevant scopes in store
return this.store.query("scope", {});
return this.store.query("scope", { sort: "full_name" });
}

redirect(scopes, transition) {
Expand Down