Dropping ember-can

This commit is contained in:
Matthew Dillon 2015-06-05 09:36:51 -08:00
parent 3501dc1986
commit 53be80d617
13 changed files with 57 additions and 75 deletions

View file

@ -0,0 +1,8 @@
import Ember from 'ember';
export default Ember.Component.extend({
canAdd: function() {
let role = this.get('session.currentUser.role');
return (role === 'W') || (role === 'A');
}.property('session.currentUser.role')
});

View file

@ -0,0 +1,5 @@
{{#if canAdd}}
{{#link-to link class="button-gray smaller"}}
{{label}}
{{/link-to}}
{{/if}}

View file

@ -3,6 +3,14 @@ import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['grid-1'],
isEditing: false,
canEdit: function() {
let role = this.get('session.currentUser.role');
let id = this.get('session.currentUser.id');
let author = this.get('species.createdBy');
return (role === 'W' && (+id === author)) || (role === 'A');
}.property('session.currentUser.role', 'session.currentUser.id', 'species.createdBy'),
actions: {
save: function() {
this.sendAction('save');

View file

@ -21,16 +21,9 @@
{{strain.strainName}}
{{/link-to}}
{{/each}}
{{#if (can "edit species" species)}}
{{#if species.isNew}}
PENDING SAVE
{{else}}
<br>
{{#link-to 'strains.new' class="button-gray smaller"}}
Add Strain
{{/link-to}}
{{/if}}
{{/if}}
{{#unless species.isNew}}
{{add-button label="Add Strain" link="strains.new"}}
{{/unless}}
</dd>
</dl>
<dl class="span-2">
@ -78,10 +71,9 @@
</div>
{{! ROW 4 }}
{{#if (can "edit species" species)}}
{{#if canEdit}}
<div class="grid-4">
<div class="span-1">
{{! Does nothing ATM }}
<a {{bind-attr class=":smaller isEditing:button-red:button-gray"}} {{action 'cancel'}}>
{{#if isEditing}}Cancel{{else}}Edit{{/if}}
</a>

View file

@ -3,6 +3,14 @@ import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['grid-1'],
isEditing: false,
canEdit: function() {
let role = this.get('session.currentUser.role');
let id = this.get('session.currentUser.id');
let author = this.get('strain.createdBy');
return (role === 'W' && (+id === author)) || (role === 'A');
}.property('session.currentUser.role', 'session.currentUser.id', 'strain.createdBy'),
actions: {
save: function() {
this.sendAction('save');

View file

@ -116,7 +116,7 @@
</div>
{{! ROW 6 }}
{{#if (can "edit strain" strain)}}
{{#if canEdit}}
<div class="grid-4">
<div class="span-1">
{{! Does nothing ATM }}

View file

@ -1,11 +1,6 @@
<h2>{{genus-name}} Species</h2>
<h3>Total species: {{controller.length}}</h3>
{{#if (can "add species")}}
{{! Does nothing ATM }}
{{#link-to 'species.new' class="button-gray smaller"}}
Add Species
{{/link-to}}
{{/if}}
{{add-button label="Add Species" link="species.new"}}
{{sortable-table content=model tableAttrs=tableAttrs row=row}}

View file

@ -1,11 +1,6 @@
<h2>{{genus-name}} Strains</h2>
<h3>Total strains: {{model.length}}</h3>
{{#if (can "add strain")}}
{{! Does nothing ATM }}
{{#link-to 'strains.new' class="button-gray smaller"}}
Add Strain
{{/link-to}}
{{/if}}
{{add-button label="Add Strain" link="strains.new"}}
{{sortable-table content=model tableAttrs=tableAttrs row=row}}