This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName:'Ember Twiddle', | |
owner: Ember.computed(function() { | |
return this.store.createRecord('owner'); | |
}), | |
allItems: Ember.computed(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
pretendSaveModel() { | |
return Ember.RSVP.resolve(); | |
}, | |
init() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/componets/action-details/component.js | |
setStatus(newStatus) { | |
const model = get(this, 'model'); | |
if ([0, 10].includes(get(model, 'status')) && [50, 60].includes(newStatus)) { | |
set(model, 'completedAt', new Date()); | |
} | |
set(model, 'status', newStatus); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/constants/actions.js | |
const STATUS_TO_DO = { value: 0 }; | |
const STATUS_IN_PROGRESS = { value: 10 }; | |
const STATUS_DONE = { value: 50 }; | |
const STATUS_CANT_DO = { value: 60 }; | |
const STATUS_OVERDUE = { value: -1 }; | |
export { | |
STATUS_TO_DO, STATUS_IN_PROGRESS, STATUS_DONE, STATUS_CANT_DO, STATUS_OVERDUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/models/action.js | |
import Model from 'ember-data/model'; | |
import attr from 'ember-data/attr'; | |
export default Model.extend({ | |
label: attr('string'), | |
status: attr('action-status') // before it was attr('number') | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/transforms/action-status.js | |
import Transform from 'ember-data/transform'; | |
import { STATUSES } from '../constants/actions'; | |
export default Transform.extend({ | |
deserialize(serialized) { | |
return STATUSES.findBy('value', serialized); | |
}, | |
serialize(deserialized = {}) { | |
return deserialized.value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/constants/actions.js | |
const STATUS_TO_DO = { value: 0 }; | |
const STATUS_IN_PROGRESS = { value: 10 }; | |
const STATUS_DONE = { value: 50 }; | |
const STATUS_CANT_DO = { value: 60 }; | |
const STATUS_OVERDUE = { value: -1 }; | |
const STATUSES = [STATUS_TO_DO, STATUS_IN_PROGRESS, STATUS_DONE, STATUS_CANT_DO]; |
OlderNewer