Rough in detail view for characteristics
This commit is contained in:
parent
f59de829ee
commit
ceccf6e536
9 changed files with 77 additions and 7 deletions
6
app/pods/protected/characteristics/index/controller.js
Normal file
6
app/pods/protected/characteristics/index/controller.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
sortParams: ['characteristicTypeName', 'sortOrder', 'characteristicName'],
|
||||
sortedCharacteristics: Ember.computed.sort('model', 'sortParams'),
|
||||
});
|
|
@ -0,0 +1,28 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
tagName: 'tr',
|
||||
|
||||
actions: {
|
||||
edit: function() {
|
||||
this.set('characteristicName', this.get('row.characteristicName'));
|
||||
this.set('characteristicTypeName', this.get('row.characteristicTypeName'));
|
||||
this.set('sortOrder', this.get('row.sortOrder'));
|
||||
this.toggleProperty('isEditing');
|
||||
},
|
||||
|
||||
save: function() {
|
||||
if (this.get('characteristicName') !== this.get('row.characteristicName') ||
|
||||
this.get('characteristicTypeName') !== this.get('row.characteristicTypeName') ||
|
||||
this.get('sortOrder') !== this.get('row.sortOrder')) {
|
||||
this.set('row.characteristicName', this.get('characteristicName'));
|
||||
this.set('row.characteristicTypeName', this.get('characteristicTypeName'));
|
||||
this.set('row.sortOrder', this.get('sortOrder'));
|
||||
this.get('row').save();
|
||||
}
|
||||
this.toggleProperty('isEditing');
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
});
|
|
@ -0,0 +1,15 @@
|
|||
{{#if isEditing}}
|
||||
<td>{{input value=characteristicName}}</td>
|
||||
<td>{{input value=characteristicTypeName}}</td>
|
||||
<td>{{input value=sortOrder}}</td>
|
||||
<td {{action 'save'}}>Save</td>
|
||||
{{else}}
|
||||
<td>{{row.characteristicName}}</td>
|
||||
<td>{{row.characteristicTypeName}}</td>
|
||||
<td>{{row.sortOrder}}</td>
|
||||
{{#if row.canEdit}}
|
||||
<td {{action 'edit'}}>Edit</td>
|
||||
{{else}}
|
||||
<td></td>
|
||||
{{/if}}
|
||||
{{/if}}
|
8
app/pods/protected/characteristics/index/route.js
Normal file
8
app/pods/protected/characteristics/index/route.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
model: function() {
|
||||
return this.store.findAll('characteristic');
|
||||
},
|
||||
|
||||
});
|
25
app/pods/protected/characteristics/index/template.hbs
Normal file
25
app/pods/protected/characteristics/index/template.hbs
Normal file
|
@ -0,0 +1,25 @@
|
|||
<h2>{{genus-name}} Characteristics</h2>
|
||||
<h3>Total characteristics: {{model.length}}</h3>
|
||||
|
||||
<table class="flakes-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Sort Order</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each sortedCharacteristics as |row|}}
|
||||
<tr>
|
||||
<td>
|
||||
{{#link-to 'protected.characteristics.show' row}}
|
||||
{{row.characteristicName}}
|
||||
{{/link-to}}
|
||||
</td>
|
||||
<td>{{row.characteristicTypeName}}</td>
|
||||
<td>{{row.sortOrder}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
Reference in a new issue