2014-09-24 05:12:01 +08:00
|
|
|
export default Ember.ObjectController.extend({
|
|
|
|
saving: false,
|
|
|
|
saved: false,
|
2013-04-05 00:59:44 +08:00
|
|
|
|
|
|
|
saveDisabled: function() {
|
2013-06-26 22:57:35 +08:00
|
|
|
if (this.get('saving')) { return true; }
|
2014-12-11 02:15:30 +08:00
|
|
|
if ((!this.get('allow_blank')) && Ember.isEmpty(this.get('value'))) { return true; }
|
2013-04-05 00:59:44 +08:00
|
|
|
return false;
|
2014-09-25 02:45:35 +08:00
|
|
|
}.property('saving', 'value'),
|
2013-04-05 00:59:44 +08:00
|
|
|
|
2013-09-17 02:08:55 +08:00
|
|
|
actions: {
|
|
|
|
saveChanges: function() {
|
|
|
|
var self = this;
|
|
|
|
self.setProperties({saving: true, saved: false});
|
2014-09-24 05:12:01 +08:00
|
|
|
self.get('model').save().then(function () {
|
2013-09-17 02:08:55 +08:00
|
|
|
self.setProperties({saving: false, saved: true});
|
|
|
|
});
|
|
|
|
}
|
2013-04-05 00:59:44 +08:00
|
|
|
}
|
2013-09-17 02:08:55 +08:00
|
|
|
});
|