Roughing in ember-can: placeholders for strain mod
This commit is contained in:
parent
b337ca0ee4
commit
ce40ef6071
7 changed files with 53 additions and 0 deletions
17
app/abilities/strain.js
Normal file
17
app/abilities/strain.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { Ability } from 'ember-can';
|
||||
|
||||
export default Ability.extend({
|
||||
// Only admins and writers can create a new strain
|
||||
canAdd: function() {
|
||||
let role = this.get('session.currentUser.role');
|
||||
return (role === 'W') || (role === 'A');
|
||||
}.property('session.currentUser.role'),
|
||||
|
||||
// Only admins and the person who created can edit
|
||||
canEdit: function() {
|
||||
let role = this.get('session.currentUser.role');
|
||||
let id = this.get('session.currentUser.id');
|
||||
let author = this.get('model.author');
|
||||
return (role === 'W' && (+id === author)) || (role === 'A');
|
||||
}.property('session.currentUser.role', 'session.currentUser.id', 'model.author')
|
||||
});
|
|
@ -13,6 +13,7 @@ export default DS.Model.extend({
|
|||
createdAt: DS.attr('date'),
|
||||
updatedAt: DS.attr('date'),
|
||||
deletedAt: DS.attr('date'),
|
||||
author: DS.attr('number'),
|
||||
totalMeasurements: DS.attr('number'),
|
||||
fullName: Ember.computed('speciesName', 'strainName', function() {
|
||||
return this.get('speciesName') + ' (' + this.get('strainName') + ')';
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
<h2>{{genus-name}} Strains</h2>
|
||||
<h3>Total strains: {{controller.length}}</h3>
|
||||
|
||||
{{#if (can "add strain")}}
|
||||
{{! Does nothing ATM }}
|
||||
<a class="button-gray smaller">Add Strain</a>
|
||||
{{/if}}
|
||||
|
||||
<table class="flakes-table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
@ -51,9 +51,19 @@
|
|||
</dl>
|
||||
<dl class="span-1"></dl>
|
||||
</div>
|
||||
{{#if (can "edit strain" model)}}
|
||||
{{! ROW 5 }}
|
||||
<div class="grid-4">
|
||||
<div class="span-1">
|
||||
{{! Does nothing ATM }}
|
||||
<a class="button-gray smaller">Edit Strain</a>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="measurements-container">
|
||||
{{outlet}}
|
||||
</div>
|
||||
|
|
Reference in a new issue