From 32f9c3e633b2b2ac05291a5c0c0c0f5876226004 Mon Sep 17 00:00:00 2001 From: jelhan Date: Thu, 26 May 2016 13:01:23 +0200 Subject: [PATCH] use ember-bootstrap in create/index, create/meta, create/settings --- app/components/simple-select.js | 5 ++ app/controllers/create/meta.js | 2 + app/templates/create/index.hbs | 41 ++++++++++------ app/templates/create/meta.hbs | 36 ++++++++------ app/templates/create/settings.hbs | 80 ++++++++++++++++++------------- package.json | 1 + 6 files changed, 102 insertions(+), 63 deletions(-) create mode 100644 app/components/simple-select.js diff --git a/app/components/simple-select.js b/app/components/simple-select.js new file mode 100644 index 0000000..46cd23c --- /dev/null +++ b/app/components/simple-select.js @@ -0,0 +1,5 @@ +import SimpleSelect from 'ember-simple-select/components/simple-select'; + +export default SimpleSelect.reopen({ + classNames: ['form-control'] +}); diff --git a/app/controllers/create/meta.js b/app/controllers/create/meta.js index 4bd48d1..2506ae4 100644 --- a/app/controllers/create/meta.js +++ b/app/controllers/create/meta.js @@ -26,6 +26,8 @@ export default Ember.Controller.extend(Validations, { } }, + description: Ember.computed.alias('model.description'), + init() { this.get('i18n.locale'); }, diff --git a/app/templates/create/index.hbs b/app/templates/create/index.hbs index 8015ab0..28761a4 100644 --- a/app/templates/create/index.hbs +++ b/app/templates/create/index.hbs @@ -1,19 +1,30 @@
- {{#fm-form action='submit'}} - {{fm-field - type='select' - value=pollType - content=pollTypes - optionValuePath='id' - optionLabelPath='label' + {{#bs-form + formLayout="horizontal" + model=this + action="submit" + }} + {{#bs-form-element + classNames='poll-type' label=(t 'create.index.input.pollType.label') - errors=validations.attrs.pollType.messages - class='poll-type' + property="pollType" + as |value id| }} - {{#fm-submit - inputWrapperClass='col-sm-10 col-sm-offset-2' - }} - {{t 'create.next'}} - {{/fm-submit}} - {{/fm-form}} + {{simple-select + id=id + content=pollTypes + optionLabelPath="label" + optionValuePath="id" + value=value + action=(action (mut value) value='id') + }} + {{/bs-form-element}} + {{#bs-form-element}} + {{bs-button + defaultText=(t 'create.next') + type="primary" + buttonType="submit" + }} + {{/bs-form-element}} + {{/bs-form}}
diff --git a/app/templates/create/meta.hbs b/app/templates/create/meta.hbs index e738ae2..a182e99 100644 --- a/app/templates/create/meta.hbs +++ b/app/templates/create/meta.hbs @@ -1,23 +1,29 @@
- {{#fm-form action='submit'}} - {{fm-field - value=title + {{#bs-form + formLayout="horizontal" + model=this + action="submit" + }} + {{bs-form-element + classNames='title' + controlType="text" label=(t 'create.meta.input.title.label') placeholder=(t 'create.meta.input.title.placeholder') - errors=validations.attrs.title.messages - class='title' + property="title" }} - {{fm-field - type='textarea' - value=model.description + {{bs-form-element + classNames='description' + controlType="textarea" label=(t 'create.meta.input.description.label') placeholder=(t 'create.meta.input.description.placeholder') - class='description' + property="description" }} - {{#fm-submit - inputWrapperClass='col-sm-10 col-sm-offset-2' - }} - {{t 'create.next'}} - {{/fm-submit}} - {{/fm-form}} + {{#bs-form-element}} + {{bs-button + defaultText=(t 'create.next') + type="primary" + buttonType="submit" + }} + {{/bs-form-element}} + {{/bs-form}}
diff --git a/app/templates/create/settings.hbs b/app/templates/create/settings.hbs index 5349b36..c3eda4d 100644 --- a/app/templates/create/settings.hbs +++ b/app/templates/create/settings.hbs @@ -1,43 +1,57 @@
- {{#fm-form action='submit'}} - {{fm-field - type='select' - content=answerTypes - value=answerType - optionValuePath='id' - optionLabelPath='label' + {{#bs-form + formLayout="horizontal" + model=this + action="submit" + }} + {{#bs-form-element + classNames='answer-type' label=(t 'create.settings.answerType.label') - errors=validations.attrs.answerType.messages - class='answer-type' + property="answerType" + as |value id| }} - {{fm-field - type='select' - content=expirationDurations - value=expirationDuration - optionValuePath='id' - optionLabelPath='label' + {{simple-select + id=id + content=answerTypes + optionLabelPath="label" + optionValuePath="id" + value=value + action=(action (mut value) value='id') + }} + {{/bs-form-element}} + {{#bs-form-element + classNames='expiration-duration' label=(t 'create.settings.expirationDate.label') - errors=validations.attrs.expirationDuration.messages - class='expiration-duration' + property='expirationDuration' + as |value id| }} - {{fm-checkbox - checked=anonymousUser + {{simple-select + id=id + content=expirationDurations + optionLabelPath='label' + optionValuePath='id' + value=value + action=(action (mut value) value='id') + }} + {{/bs-form-element}} + {{bs-form-element + classNames='anonymous-user' + controlType='checkbox' label=(t 'create.settings.anonymousUser.label') - errors=validations.attrs.anonymousUser.messages - class='anonymous-user' - inputWrapperClass='col-sm-10 col-sm-offset-2' + value=anonymousUser }} - {{fm-checkbox - checked=forceAnswer + {{bs-form-element + classNames='force-answer' + controlType='checkbox' label=(t 'create.settings.forceAnswer.label') - errors=validations.attrs.forceAnswer.messages - class='force-answer' - inputWrapperClass='col-sm-10 col-sm-offset-2' + value=forceAnswer }} - {{#fm-submit - inputWrapperClass='col-sm-10 col-sm-offset-2' - }} - {{t 'create.next'}} - {{/fm-submit}} - {{/fm-form}} + {{#bs-form-element}} + {{bs-button + defaultText=(t 'create.next') + type="primary" + buttonType="submit" + }} + {{/bs-form-element}} + {{/bs-form}}
diff --git a/package.json b/package.json index eada710..cf5dd24 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "ember-i18n-cp-validations": "2.2.0", "ember-moment": "4.1.0", "ember-radio-button": "^0.1.2", + "ember-simple-select": "0.5.0", "ember-suave": "1.2.3", "ember-truth-helpers": "1.2.0", "express": "^4.8.5",