Merge branch 'master' into feat/i18n
Conflicts: app/index.html app/templates/create/options.hbs bower.json
This commit is contained in:
commit
018fcf7f1f
13 changed files with 184 additions and 96 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/cldr/plurals.js"></script>
|
<script src="/vendor/cldr/plurals.js"></script>
|
||||||
<script src="/vendor/ember-i18n/lib/i18n.js"></script>
|
<script src="/vendor/ember-i18n/lib/i18n.js"></script>
|
||||||
<script src="/vendor/sjcl/sjcl.js"></script>
|
<script src="/vendor/sjcl/sjcl.js"></script>
|
||||||
|
|
76
app/initializers/ember-easyForm.js
Normal file
76
app/initializers/ember-easyForm.js
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* make ember-easyForm support Bootstrap 3
|
||||||
|
* https://github.com/dockyard/ember-easyForm/wiki/Bootstrap-3-and-Ember-Data-With-Server-Side-Validations
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
name: 'easyForm',
|
||||||
|
initialize: function() {
|
||||||
|
|
||||||
|
Ember.EasyForm.Input.reopen({
|
||||||
|
errorsChanged: function() {
|
||||||
|
this.set('hasFocusedOut', true);
|
||||||
|
this.showValidationError();
|
||||||
|
},
|
||||||
|
classNameBindings: ['wrapperConfig.inputClass', 'wrapperErrorClass'],
|
||||||
|
didInsertElement: function() {
|
||||||
|
this.addObserver('context.errors.' + this.property + '.@each', this, 'errorsChanged');
|
||||||
|
},
|
||||||
|
isCheckbox: function() {
|
||||||
|
if (this.get('inputOptionsValues.as') === 'checkbox') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}.property('inputOptionsValues'),
|
||||||
|
divWrapperClass: function() {
|
||||||
|
if (this.get('inputOptionsValues.as') === 'checkbox') {
|
||||||
|
return 'checkbox';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}.property('inputOptionsValues')
|
||||||
|
});
|
||||||
|
|
||||||
|
Ember.EasyForm.Error.reopen({
|
||||||
|
errorText: function() {
|
||||||
|
return this.get('errors.firstObject');
|
||||||
|
}.property('errors.firstObject').cacheable(),
|
||||||
|
updateParentView: function() {
|
||||||
|
var parentView = this.get('parentView');
|
||||||
|
if(this.get('errors.length') > 0) {
|
||||||
|
parentView.set('wrapperErrorClass', 'has-error');
|
||||||
|
}else{
|
||||||
|
parentView.set('wrapperErrorClass', false);
|
||||||
|
}
|
||||||
|
}.observes('errors.firstObject')
|
||||||
|
});
|
||||||
|
|
||||||
|
Ember.EasyForm.Submit.reopen({
|
||||||
|
disabled: function() {
|
||||||
|
return this.get('formForModel.disableSubmit');
|
||||||
|
}.property('formForModel.disableSubmit')
|
||||||
|
});
|
||||||
|
|
||||||
|
//-- Bootstrap 3 Class Names --------------------------------------------
|
||||||
|
//-- https://github.com/dockyard/ember-easyForm/issues/47
|
||||||
|
Ember.TextSupport.reopen({
|
||||||
|
classNames: ['form-control']
|
||||||
|
});
|
||||||
|
// And add the same classes to Select inputs
|
||||||
|
Ember.Select.reopen({
|
||||||
|
classNames: ['form-control']
|
||||||
|
});
|
||||||
|
|
||||||
|
Ember.EasyForm.Config.registerWrapper('default', {
|
||||||
|
inputTemplate: 'form-fields/input',
|
||||||
|
|
||||||
|
labelClass: 'control-label',
|
||||||
|
inputClass: 'form-group',
|
||||||
|
buttonClass: 'btn btn-primary',
|
||||||
|
fieldErrorClass: 'has-error',
|
||||||
|
errorClass: 'help-block'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
|
@ -14,7 +14,7 @@ body {
|
||||||
background-color:#d3d3d3;
|
background-color:#d3d3d3;
|
||||||
}
|
}
|
||||||
.box {
|
.box {
|
||||||
padding:10px 10px 0 10px;
|
padding:10px;
|
||||||
margin-bottom:10px;
|
margin-bottom:10px;
|
||||||
background-color:#ffffff;
|
background-color:#ffffff;
|
||||||
border:#556b2f 1px solid;
|
border:#556b2f 1px solid;
|
||||||
|
|
|
@ -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">{{t "create.options-datetime.more-inputs"}}</button>
|
<button {{action "moreTimes"}} class="btn btn-default">{{t "create.options-datetime.more-inputs"}}</button>
|
||||||
|
|
|
@ -5,14 +5,16 @@
|
||||||
<label class="control-label">{{t "create.options.label"}}</label>
|
<label class="control-label">{{t "create.options.label"}}</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">{{t "create.options.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}}>{{t "create.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>
|
15
app/templates/form-fields/input.hbs
Normal file
15
app/templates/form-fields/input.hbs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{{#unless view.isCheckbox}}
|
||||||
|
{{label-field propertyBinding="view.property" textBinding="view.label"}}
|
||||||
|
{{/unless}}
|
||||||
|
<div {{bind-attr class=view.divWrapperClass}}>
|
||||||
|
{{input-field propertyBinding='view.property' inputOptionsBinding='view.inputOptionsValues'}}
|
||||||
|
{{#if view.isCheckbox}}
|
||||||
|
{{label-field propertyBinding="view.property" textBinding="view.label"}}
|
||||||
|
{{/if}}
|
||||||
|
{{#if view.hint}}
|
||||||
|
{{hint-field propertyBinding="view.property" textBinding="view.hint"}}
|
||||||
|
{{/if}}
|
||||||
|
{{#if view.showError}}
|
||||||
|
{{error-field propertyBinding="view.property"}}
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
|
@ -53,16 +53,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">
|
||||||
|
@ -76,7 +78,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/em-form}}
|
{{/form-for}}
|
||||||
</td>
|
</td>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
<td>
|
<td>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
"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",
|
||||||
|
|
Loading…
Reference in a new issue