replaced ember-form by ember-easyForm
ember-easyForm seems to have better support for i18n also seems to be more stable
This commit is contained in:
parent
7ce3fc6a92
commit
18a77d1523
10 changed files with 91 additions and 98 deletions
|
@ -18,7 +18,7 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, {
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}.property(),
|
}.property(),
|
||||||
|
|
||||||
validations: {
|
validations: {
|
||||||
pollType: {
|
pollType: {
|
||||||
presence: true,
|
presence: true,
|
||||||
|
|
|
@ -1,47 +1,36 @@
|
||||||
export default Ember.ObjectController.extend(Ember.Validations.Mixin, {
|
export default Ember.ObjectController.extend(Ember.Validations.Mixin, {
|
||||||
actions: {
|
actions: {
|
||||||
/*
|
submit: function() {
|
||||||
* handles submit of option input for poll of type MakeAPoll
|
var pollType = this.get('pollType');
|
||||||
*/
|
|
||||||
submitMakeAPoll: function() {
|
if (pollType === 'MakeAPoll') {
|
||||||
var options = this.get('model.options'),
|
var options = this.get('model.options'),
|
||||||
newOptions = [];
|
newOptions = [];
|
||||||
|
|
||||||
// remove options without value
|
// remove options without value
|
||||||
options.forEach(function(option) {
|
options.forEach(function(option) {
|
||||||
if (option.title !== '') {
|
if (option.title !== '') {
|
||||||
newOptions.pushObject(option);
|
newOptions.pushObject(option);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// set updated options
|
// set updated options
|
||||||
//
|
//
|
||||||
// we have to hardly set new options even if they wasn't changed to
|
// we have to hardly set new options even if they wasn't changed to
|
||||||
// trigger computed property; push on array doesn't trigger computed
|
// trigger computed property; push on array doesn't trigger computed
|
||||||
// property to recalculate
|
// property to recalculate
|
||||||
this.set('model.options', newOptions);
|
this.set('model.options', newOptions);
|
||||||
|
|
||||||
// tricker save action
|
this.transitionToRoute('create.settings');
|
||||||
this.send('save');
|
|
||||||
},
|
|
||||||
|
|
||||||
/*
|
|
||||||
* handles submit of selected dates for poll of type MakeAPoll
|
|
||||||
*/
|
|
||||||
submitFindADate: function() {
|
|
||||||
// tricker save action
|
|
||||||
this.send('save');
|
|
||||||
},
|
|
||||||
|
|
||||||
save: function(){
|
|
||||||
// redirect to crate/options-datetime route if datetime is true
|
|
||||||
// otherwise redirect directly to create/settings
|
|
||||||
if (this.get('isDateTime')) {
|
|
||||||
this.transitionToRoute('create.options-datetime');
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.transitionToRoute('create.settings');
|
if (this.get('isDateTime')) {
|
||||||
}
|
this.transitionToRoute('create.options-datetime');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.transitionToRoute('create.settings');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
<script src="/vendor/ic-ajax/dist/named-amd/main.js"></script>
|
<script src="/vendor/ic-ajax/dist/named-amd/main.js"></script>
|
||||||
<script src="/vendor/ember-load-initializers/ember-load-initializers.js"></script>
|
<script src="/vendor/ember-load-initializers/ember-load-initializers.js"></script>
|
||||||
<script src="/vendor/ember-validations/index.js"></script>
|
<script src="/vendor/ember-validations/index.js"></script>
|
||||||
<script src="/vendor/ember-forms/dist/ember_forms.js"></script>
|
<script src="/vendor/ember-easyForm/index.js"></script>
|
||||||
<script src="/vendor/sjcl/sjcl.js"></script>
|
<script src="/vendor/sjcl/sjcl.js"></script>
|
||||||
<script src="/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
|
<script src="/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
|
||||||
<script src="/vendor/moment/moment.js"></script>
|
<script src="/vendor/moment/moment.js"></script>
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
<div class="box">
|
<div class="box">
|
||||||
{{#em-form model=controller submit_button=false}}
|
{{#form-for controller}}
|
||||||
{{em-select
|
{{input pollType as='select'
|
||||||
property="pollType"
|
collection="pollTypes"
|
||||||
label="poll type"
|
value="pollType"
|
||||||
prompt="-select-"
|
optionValuePath="content.id"
|
||||||
contentBinding="pollTypes"
|
optionLabelPath="content.label"
|
||||||
optionValuePath="content.id"
|
prompt="Please select a poll type"
|
||||||
optionLabelPath="content.label"
|
}}
|
||||||
prompt="Please select a poll type"}}
|
{{submit 'next'}}
|
||||||
{{em-form-submit text="next"}}
|
{{/form-for}}
|
||||||
{{/em-form}}
|
|
||||||
</div>
|
</div>
|
|
@ -1,14 +1,14 @@
|
||||||
<div class="box">
|
<div class="box">
|
||||||
{{#em-form model=controller submit_button=false}}
|
{{#form-for controller}}
|
||||||
{{em-input
|
{{input title
|
||||||
property="title"
|
label="title"
|
||||||
label="title"
|
placeholder="Enter a title..."
|
||||||
placeholder="Enter a title..."}}
|
}}
|
||||||
{{em-text
|
{{input description as='text'
|
||||||
property="description"
|
label="description"
|
||||||
label="description"
|
placeholder="Enter a description if you like..."
|
||||||
placeholder="Enter a description if you like..."
|
rows=4
|
||||||
rows=4}}
|
}}
|
||||||
{{em-form-submit text="next"}}
|
{{submit 'next'}}
|
||||||
{{/em-form}}
|
{{/form-for}}
|
||||||
</div>
|
</div>
|
|
@ -19,8 +19,10 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{{em-form-control-help text="Hours and minutes have to be seperated by a color (e.g. 12:30).
|
<p class="help-text">
|
||||||
You have to enter atleast one valid time for each date."}}
|
Hours and minutes have to be seperated by a color (e.g. 12:30).
|
||||||
|
You have to enter atleast one valid time for each date.
|
||||||
|
</p>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button {{action "moreTimes"}} class="btn btn-default"> more inputs for time </button>
|
<button {{action "moreTimes"}} class="btn btn-default"> more inputs for time </button>
|
||||||
|
|
|
@ -5,14 +5,16 @@
|
||||||
<label class="control-label">options</label>
|
<label class="control-label">options</label>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
{{#each option in options}}
|
{{#each option in options}}
|
||||||
{{view Ember.TextField valueBinding="option.title" class="form-control"}}<br/>
|
{{#form-for option}}
|
||||||
|
{{input option.title label=" "}}<br/>
|
||||||
|
{{/form-for}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{em-form-control-help text="You have to enter at least two options."}}
|
<p class="help-text">You have to enter at least two options.</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button {{action "moreOptions" target="view"}} class="btn btn-default"> add another option </button>
|
<button {{action "moreOptions" target="view"}} class="btn btn-default"> add another option </button>
|
||||||
<button {{action "submitMakeAPoll"}} class="btn btn-default" {{bind-attr disabled=isNotValid}}> next </button>
|
<button {{action "submit"}} class="btn btn-default" {{bind-attr disabled=isNotValid}}> next </button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -20,15 +22,14 @@
|
||||||
{{#if isFindADate}}
|
{{#if isFindADate}}
|
||||||
<div id="datepicker">
|
<div id="datepicker">
|
||||||
{{view 'datepicker'}}
|
{{view 'datepicker'}}
|
||||||
{{em-form-control-help text="You have to select at least two dates."}}
|
<p class="help-text">You have to select at least two dates."</p>
|
||||||
|
|
||||||
{{#em-form model=controller submit_button=false}}
|
{{#form-for controller}}
|
||||||
{{em-checkbox label="Define times?" property="isDateTime"}}
|
{{input isDateTime as='checkbox'
|
||||||
{{/em-form}}
|
label="Define times?"
|
||||||
|
}}
|
||||||
<div class="form-group">
|
{{submit 'next'}}
|
||||||
<button {{action "submitFindADate"}} class="btn btn-default" {{bind-attr disabled=isNotValid}}> next </button>
|
{{/form-for}}
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
|
@ -1,15 +1,19 @@
|
||||||
<div class="box">
|
<div class="box">
|
||||||
{{#em-form model=controller submit_button=false}}
|
{{#form-for controller}}
|
||||||
{{em-select
|
{{input answerType as='select'
|
||||||
property="answerType"
|
collection="answerTypes"
|
||||||
label="available answers"
|
value="answerType"
|
||||||
prompt="-select-"
|
|
||||||
contentBinding="answerTypes"
|
|
||||||
optionValuePath="content.id"
|
optionValuePath="content.id"
|
||||||
optionLabelPath="content.label"
|
optionLabelPath="content.label"
|
||||||
prompt="Please define available answers"}}
|
label="available answers"
|
||||||
{{em-checkbox label="Allow anonym participation?" property="anonymousUser"}}
|
prompt="Please define available answers"
|
||||||
{{em-checkbox label="Force an answer?" property="forceAnswer"}}
|
}}
|
||||||
{{em-form-submit text="save"}}
|
{{input anonymousUser as='checkbox'
|
||||||
{{/em-form}}
|
label="Allow anonym participation?"
|
||||||
|
}}
|
||||||
|
{{input forceAnswer as='checkbox'
|
||||||
|
label="Force an answer?"
|
||||||
|
}}
|
||||||
|
{{submit 'save'}}
|
||||||
|
{{/form-for}}
|
||||||
</div>
|
</div>
|
|
@ -56,16 +56,18 @@
|
||||||
handlebar each helper
|
handlebar each helper
|
||||||
}}
|
}}
|
||||||
<td>
|
<td>
|
||||||
{{#em-form model=controller submit_button=false}}
|
{{#form-for controller}}
|
||||||
{{em-form-label text="name" extraClass="sr-only"}}
|
{{input newUserName
|
||||||
{{em-input property="newUserName" placeholder="Enter your name..."}}
|
label=" "
|
||||||
{{/em-form}}
|
placeholder="Enter your name..."
|
||||||
|
}}
|
||||||
|
{{/form-for}}
|
||||||
</td>
|
</td>
|
||||||
{{#each newUserSelection in controller.newUserSelections}}
|
{{#each newUserSelection in controller.newUserSelections}}
|
||||||
<td>
|
<td>
|
||||||
{{#em-form model=newUserSelection submit_button=false}}
|
{{#form-for newUserSelection}}
|
||||||
{{#if isFreeText}}
|
{{#if isFreeText}}
|
||||||
{{em-input property="value"}}
|
{{input value label=" "}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#each answer in answers}}
|
{{#each answer in answers}}
|
||||||
<div class="radio">
|
<div class="radio">
|
||||||
|
@ -75,7 +77,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/em-form}}
|
{{/form-for}}
|
||||||
</td>
|
</td>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
<td>
|
<td>
|
||||||
|
|
|
@ -17,13 +17,9 @@
|
||||||
"ember-validations": "http://builds.dockyard.com.s3.amazonaws.com/ember-validations/tags/v1.0.0/ember-validations.js",
|
"ember-validations": "http://builds.dockyard.com.s3.amazonaws.com/ember-validations/tags/v1.0.0/ember-validations.js",
|
||||||
"bootstrap": "~3.2.0",
|
"bootstrap": "~3.2.0",
|
||||||
"bootstrap-datepicker": "~1.3.0",
|
"bootstrap-datepicker": "~1.3.0",
|
||||||
"ember-forms": "f6456c334a07950365ecfebd087596dedc1bdec5",
|
"ember-easyForm": "http://builds.dockyard.com/ember-easyForm/latest/ember-easyForm.js",
|
||||||
"floatThead": "~1.2.8",
|
"floatThead": "~1.2.8",
|
||||||
"webshim": "~1.15.3",
|
"webshim": "~1.15.3",
|
||||||
"modernizr": "~2.8.3"
|
"modernizr": "~2.8.3"
|
||||||
},
|
|
||||||
"resolutions": {
|
|
||||||
"ember": "~1.7.0",
|
|
||||||
"jquery": "~1.11.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue