2014-10-30 21:44:22 +01:00
|
|
|
import Ember from "ember";
|
2014-11-02 16:55:10 +01:00
|
|
|
import EmberValidations from 'ember-validations';
|
2014-10-30 21:44:22 +01:00
|
|
|
|
2015-07-01 16:21:18 +02:00
|
|
|
export default Ember.Controller.extend(EmberValidations.Mixin, {
|
2014-07-06 18:56:51 +02:00
|
|
|
actions: {
|
2014-10-26 16:47:15 +01:00
|
|
|
save: function() {
|
2014-07-06 18:56:51 +02:00
|
|
|
// redirect to CreateMeta
|
|
|
|
this.transitionToRoute('create.meta');
|
2014-10-26 16:47:15 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
submit: function(){
|
2015-04-07 13:17:45 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
});
|
2014-10-26 18:19:07 +01:00
|
|
|
});
|
2014-07-06 17:37:54 +02:00
|
|
|
}
|
2014-07-06 18:56:51 +02:00
|
|
|
},
|
|
|
|
|
2015-07-01 16:21:18 +02:00
|
|
|
// proxy needed for validation
|
|
|
|
pollType: function(){
|
|
|
|
return this.get('model.pollType');
|
|
|
|
}.property('model.pollType'),
|
|
|
|
|
2014-07-06 18:56:51 +02:00
|
|
|
pollTypes: function(){
|
|
|
|
return [
|
2014-10-30 21:44:22 +01:00
|
|
|
Ember.Object.extend(Ember.I18n.TranslateableProperties, {}).create({
|
2014-07-06 18:56:51 +02:00
|
|
|
id : "FindADate",
|
2014-10-24 00:39:07 +02:00
|
|
|
labelTranslation : "pollTypes.findADate.label"
|
2014-07-06 18:56:51 +02:00
|
|
|
}),
|
2014-10-30 21:44:22 +01:00
|
|
|
Ember.Object.extend(Ember.I18n.TranslateableProperties, {}).create({
|
2014-07-06 18:56:51 +02:00
|
|
|
id : "MakeAPoll",
|
2014-10-24 00:39:07 +02:00
|
|
|
labelTranslation : "pollTypes.makeAPoll.label"
|
2014-07-06 18:56:51 +02:00
|
|
|
})
|
|
|
|
];
|
|
|
|
}.property(),
|
2014-10-18 21:07:21 +02:00
|
|
|
|
2014-07-06 18:56:51 +02:00
|
|
|
validations: {
|
|
|
|
pollType: {
|
|
|
|
presence: true,
|
|
|
|
inclusion: {
|
|
|
|
in: ['FindADate', 'MakeAPoll']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-07 13:17:45 +02:00
|
|
|
});
|