67cc41973f
Ember.ObjectController was proxying model properties to controller. Ember.Controller which should be used is not. Therefore we have to define if it's a property of controller or model. Also added two more tests: * anonymous participation * do not force an answer for all options
38 lines
813 B
JavaScript
38 lines
813 B
JavaScript
import Ember from "ember";
|
|
import EmberValidations from 'ember-validations';
|
|
|
|
export default Ember.Controller.extend(EmberValidations.Mixin, {
|
|
actions: {
|
|
save: function() {
|
|
// redirect to CreateOptions
|
|
this.transitionToRoute('create.options');
|
|
},
|
|
|
|
submit: function(){
|
|
var self = this;
|
|
this.validate().then(function() {
|
|
self.send('save');
|
|
}).catch(function(){
|
|
Ember.$.each(Ember.View.views, function(id, view) {
|
|
if(view.isEasyForm) {
|
|
view.focusOut();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
},
|
|
|
|
// proxy needed for validation
|
|
title: function(){
|
|
return this.get('model.title');
|
|
}.property('model.title'),
|
|
|
|
validations: {
|
|
title: {
|
|
presence: true,
|
|
length: {
|
|
minimum: 2
|
|
}
|
|
}
|
|
}
|
|
});
|