poc: basic user capabilities UI
This commit is contained in:
5 files changed
+32
-16
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import Model from '@ember-data/model';
|
||||
import { attr } from '@ember-data/model';
|
||||
import { fragment } from 'ember-data-model-fragments/attributes';
|
||||
import { computed } from '@ember/object';
|
||||
|
||||
@@ -35,6 +36,11 @@ export default class BaseModel extends Model {
|
||||
|
||||
// =attributes
|
||||
|
||||
@attr({
|
||||
readOnly: true,
|
||||
emptyArrayIfMissing: true,
|
||||
}) authorized_actions;
|
||||
|
||||
set scopeModel(model) {
|
||||
if (model) {
|
||||
const json = model.serialize();
|
||||
|
||||
@@ -61,6 +61,8 @@ export default RestSerializer.extend({
|
||||
type: model.scope.type,
|
||||
};
|
||||
}
|
||||
// TODO: make these toggleable
|
||||
json.authorized_actions = ['read', 'update', 'delete'];
|
||||
return json;
|
||||
},
|
||||
|
||||
|
||||
@@ -46,11 +46,13 @@
|
||||
{{/if}}
|
||||
</form.textarea>
|
||||
|
||||
<form.actions
|
||||
@disabled={{if @model.cannotSave @model.cannotSave}}
|
||||
@enableEditText={{t 'actions.edit-form'}}
|
||||
@submitText={{t 'actions.save'}}
|
||||
@cancelText={{t 'actions.cancel'}}
|
||||
/>
|
||||
{{#if (can 'save model' @model)}}
|
||||
<form.actions
|
||||
@disabled={{if @model.cannotSave @model.cannotSave}}
|
||||
@enableEditText={{t 'actions.edit-form'}}
|
||||
@submitText={{t 'actions.save'}}
|
||||
@cancelText={{t 'actions.cancel'}}
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
</Rose::Form>
|
||||
@@ -37,9 +37,13 @@
|
||||
{{#each @model as |user|}}
|
||||
<body.row as |row|>
|
||||
<row.headerCell>
|
||||
<LinkTo @route='scopes.scope.users.user' @model={{user.id}}>
|
||||
{{#if (can 'read model' user)}}
|
||||
<LinkTo @route='scopes.scope.users.user' @model={{user.id}}>
|
||||
{{user.displayName}}
|
||||
</LinkTo>
|
||||
{{else}}
|
||||
{{user.displayName}}
|
||||
</LinkTo>
|
||||
{{/if}}
|
||||
<p>{{user.description}}</p>
|
||||
</row.headerCell>
|
||||
<row.cell>
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
<dropdown.link @route='scopes.scope.users.user.add-accounts'>
|
||||
{{t 'resources.user.actions.add-accounts'}}
|
||||
</dropdown.link>
|
||||
<dropdown.separator />
|
||||
<dropdown.button
|
||||
@style='danger'
|
||||
@disabled={{@model.canSave}}
|
||||
{{on 'click' (route-action 'delete' @model)}}
|
||||
>
|
||||
{{t 'resources.user.actions.delete'}}
|
||||
</dropdown.button>
|
||||
{{#if (can 'delete model' @model)}}
|
||||
<dropdown.separator />
|
||||
<dropdown.button
|
||||
@style='danger'
|
||||
@disabled={{@model.canSave}}
|
||||
{{on 'click' (route-action 'delete' @model)}}
|
||||
>
|
||||
{{t 'resources.user.actions.delete'}}
|
||||
</dropdown.button>
|
||||
{{/if}}
|
||||
</Rose::Dropdown>
|
||||
Reference in new issue
Block a user