chore: 🤖 initial auth methods resource filtering by type

This commit is contained in:
Randall Morey committed 2021-11-10 12:40:07 -05:00
1 parent a47657edf4
commit bbd0847a21
3 files changed
+49 -2

No files matched your search

@@ -34,7 +34,6 @@ export class ResourceFilter {
);
})
.flat();
console.log(this.#filterObject, clauses);
return this.and(clauses);
}
@@ -4,6 +4,7 @@ import { action } from '@ember/object';
import loading from 'ember-loading/decorator';
import { confirm } from 'core/decorators/confirm';
import { notifySuccess, notifyError } from 'core/decorators/notify';
import { resourceFilterParam } from 'core/decorators/resource-filter-param';
export default class ScopesScopeAuthMethodsRoute extends Route {
// =services
@@ -12,6 +13,11 @@ export default class ScopesScopeAuthMethodsRoute extends Route {
@service notify;
@service session;
@service can;
@service resourceFilterStore;
// =attributes
@resourceFilterParam(['password', 'oidc']) type;
// =methods
@@ -32,7 +38,12 @@ export default class ScopesScopeAuthMethodsRoute extends Route {
if (
this.can.can('list collection', scope, { collection: 'auth-methods' })
) {
return this.store.query('auth-method', { scope_id });
const { type } = this;
return this.resourceFilterStore.queryBy(
'auth-method',
{ type },
{ scope_id }
);
}
}
@@ -185,4 +196,9 @@ export default class ScopesScopeAuthMethodsRoute extends Route {
const value = { from, to };
array.addObject(value);
}
@action
filterBy(field, value) {
this[field] = value;
}
}
@@ -52,6 +52,38 @@
{{/unless}}
{{/if}}
{{#if (feature-flag 'filter')}}
<Rose::Toolbar>
<Rose::Form as |form|>
{{#with
(resource-filter-param 'scopes.scope.auth-methods' 'type')
as |filter|
}}
<Rose::Dropdown
@text={{t (concat 'form.' filter.name '.label')}}
@ignoreClickInside={{true}}
as |dropdown|
>
<form.checkboxGroup
@name={{filter.name}}
@items={{filter.allowedValues}}
@selectedItems={{filter.selectedValue}}
@onChange={{route-action 'filterBy' filter.name}}
as |group|
>
<dropdown.item>
<group.checkbox
@label={{group.item}}
value={{group.item}}
/>
</dropdown.item>
</form.checkboxGroup>
</Rose::Dropdown>
{{/with}}
</Rose::Form>
</Rose::Toolbar>
{{/if}}
<Rose::Table as |table|>
<table.header as |header|>
<header.row as |row|>