add adminOrOwner in afterModel
This commit is contained in:
parent
20e191e73a
commit
ec8399fcd3
@ -1,8 +0,0 @@
|
||||
import { helper } from '@ember/component/helper';
|
||||
|
||||
export function applicationAdminOrOwner(params/*, hash*/) {
|
||||
const user = params[1];
|
||||
return user.admin || params[0].filterBy('owner', user.id).length;
|
||||
}
|
||||
|
||||
export default helper(applicationAdminOrOwner);
|
@ -2,4 +2,10 @@ import BaseListRoute from './../base-list';
|
||||
|
||||
export default BaseListRoute.extend({
|
||||
breadcrumbs: [{text: 'Customer Application'}],
|
||||
afterModel(model) {
|
||||
const me = this;
|
||||
me._super(...arguments);
|
||||
const user = me.get('ajax.user');
|
||||
model.adminOrOwner = user.admin || model.data.filterBy('owner', user.id).length > 0;
|
||||
}
|
||||
});
|
||||
|
@ -44,7 +44,7 @@
|
||||
}}
|
||||
</th>
|
||||
{{/if}}
|
||||
{{#if (application/admin-or-owner model.data ajax.user)}}
|
||||
{{#if model.adminOrOwner}}
|
||||
<th>
|
||||
<i class="ace-icon fa fa-exchange bigger-110 hidden-480"></i>
|
||||
Enabled
|
||||
@ -76,7 +76,7 @@
|
||||
{{option-text model.users it.owner 'id' 'name' '$.employeeId ($.name)'}}
|
||||
</td>
|
||||
{{/if}}
|
||||
{{#if (application/admin-or-owner model.data ajax.user)}}
|
||||
{{#if model.adminOrOwner}}
|
||||
<td>
|
||||
{{#if (or ajax.user.admin (eq ajax.user.id it.owner))}}
|
||||
{{status-cell model=it enabledText='TRUE' disabledText='FALSE'}}
|
||||
|
@ -1,17 +0,0 @@
|
||||
|
||||
import { moduleForComponent, test } from 'ember-qunit';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
|
||||
moduleForComponent('application/admin-or-owner', 'helper:application/admin-or-owner', {
|
||||
integration: true
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it renders', function(assert) {
|
||||
this.set('inputValue', '1234');
|
||||
|
||||
this.render(hbs`{{application/admin-or-owner inputValue}}`);
|
||||
|
||||
assert.equal(this.$().text().trim(), '1234');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user