further modal refactor

This commit is contained in:
2014-11-21 18:19:15 +01:00
parent cc081d373c
commit 1d4c1ec964
10 changed files with 75 additions and 119 deletions
@@ -1,8 +0,0 @@
App.ModalConfirmController = Ember.ObjectController.extend
actions:
close: ->
@get('model.cancel').call(@) if @get('model.cancel')
@send 'closeModal'
confirm: ->
@get('model.ok').call(@)
@send 'closeModal'
@@ -1,5 +0,0 @@
App.ModalInfoController = Ember.ObjectController.extend
actions:
close: ->
@get('model.cancel').call(@) if @get('model.cancel')
@send 'closeModal'
@@ -1,13 +1,8 @@
App.ModalSectionAddTablesController = Ember.ObjectController.extend App.modals.SectionAddTablesController = App.modals.BaseController.extend
number_start: 100 number_start: 100
number_end: 110 number_end: 110
title_path: 'section.add_tables.modal.title'
actions: actions:
close: ->
@get('model.cancel').call(@) if @get('model.cancel')
@send 'closeModal'
confirm: ->
@get('model.ok').call(@)
@send 'closeModal'
addTables: -> addTables: ->
s = parseInt(@get('number_start')) s = parseInt(@get('number_start'))
e = parseInt(@get('number_end')) e = parseInt(@get('number_end'))
@@ -1,4 +1,4 @@
App.ModalSectionArrangeTablesController = Ember.ObjectController.extend App.modals.SectionArrangeTablesController = App.modals.BaseController.extend
alert_message: null alert_message: null
arrange_type: 'distributed' # can be distributed, by_row or by_column arrange_type: 'distributed' # can be distributed, by_row or by_column
row_count: 2 row_count: 2
@@ -7,12 +7,6 @@ App.ModalSectionArrangeTablesController = Ember.ObjectController.extend
isByRow: (->@get('arrange_type') is 'by_row').property('arrange_type') isByRow: (->@get('arrange_type') is 'by_row').property('arrange_type')
isByColumn: (->@get('arrange_type') is 'by_column').property('arrange_type') isByColumn: (->@get('arrange_type') is 'by_column').property('arrange_type')
actions: actions:
close: ->
@get('model.cancel').call(@) if @get('model.cancel')
@send 'closeModal'
confirm: ->
@get('model.ok').call(@)
@send 'closeModal'
arrangeTables: -> arrangeTables: ->
Ember.$.post Routes.arrange_tables_suppliers_section_path(@get('model.id')), Ember.$.post Routes.arrange_tables_suppliers_section_path(@get('model.id')),
option: @get('arrange_type') option: @get('arrange_type')
@@ -7,11 +7,8 @@ App.SectionController = Ember.ObjectController.extend
@set('editmode', false) @set('editmode', false)
@get('model').save() @get('model').save()
addSection: -> @modal 'add_section', model: @get('model') addSection: -> @modal 'add_section', model: @get('model')
addTables: -> addTables: -> @modal 'section_add_tables', model: @get('model')
#$('#add-tables-modal').modal() arrangeTables: -> @modal 'section_arrange_tables', model: @get('model')
@send 'openModal', 'modal_section_add_tables', @get('model')
arrangeTables: ->
@send 'openModal', 'modal_section_arrange_tables', @get('model')
editTable: (table)-> editTable: (table)->
@modal 'edit_table', @modal 'edit_table',
model: table model: table
@@ -1,5 +0,0 @@
modal-dialog action="close"
h3.flush--top= title
p==body
hr
button{action "close"}= t 'modal.info.close'
@@ -1,24 +0,0 @@
modal-dialog action="close"
.modal-header
h3.flush--top=t 'section.add_tables.modal.title'
hr
.modal-body
p=t 'section.add_tables.modal.body_header'
form.form-horizontal
.control-group
.form-row
.form-label
label for='add-tables-number-start'
=t 'section.add_tables.modal.number_start'
.form-field
App.NumberField valueBinding="number_start"
.form-row
.form-label
label for='add-tables-number-end'
=t 'section.add_tables.modal.number_end'
.form-field
App.NumberField valueBinding="number_end"
.modal-footer
hr
button.confirm-cancel{action "close"}=t 'section.add_tables.modal.close_button'
button.confirm-ok.right{action "addTables"}=t 'section.add_tables.modal.add_button'
@@ -1,58 +0,0 @@
modal-dialog action="close"
.modal-header
h3.flush--top=t 'section.arrange_tables.modal.title'
hr
.modal-body
.modal-alert== alert_message
p=t 'section.arrange_tables.modal.body_header'
.arrange-type-buttons
if isDistributed
span.arrange-tables-current-type.distributed=t 'section.arrange_tables.modal.distributed.title'
else
button.arrange-tables-type-button.distributed{action "makeDistributed"}=t 'section.arrange_tables.modal.distributed.title'
if isByRow
span.arrange-tables-current-type.by_row=t 'section.arrange_tables.modal.by_row.title'
else
button.arrange-tables-type-button.by_row{action "makeByRow"}=t 'section.arrange_tables.modal.by_row.title'
if isByColumn
span.arrange-tables-current-type.by_column=t 'section.arrange_tables.modal.by_column.title'
else
button.arrange-tables-type-button.by_column{action "makeByColumn"}=t 'section.arrange_tables.modal.by_column.title'
.arrange-content
if isDistributed
==t 'section.arrange_tables.modal.distributed.explanation'
if isByRow
==t 'section.arrange_tables.modal.by_row.before_field'
App.NumberField valueBinding="row_count"
==t 'section.arrange_tables.modal.by_row.after_field'
if isByColumn
==t 'section.arrange_tables.modal.by_column.before_field'
App.NumberField valueBinding="column_count"
==t 'section.arrange_tables.modal.by_column.after_field'
.modal-footer
hr
button.confirm-cancel{action "close"}=t 'section.arrange_tables.modal.close_button'
button.confirm-ok.right{action "arrangeTables"}=t 'section.arrange_tables.modal.arrange_button'
/form.form-horizontal
.control-group
label.control-label for='arrange-tables-distributed' data-t='section.arrange_tables.modal.distributed' = t('supplier.section.arrange_tables.modal.distributed')
.controls
input#arrange-tables-distributed type="radio" name="arrange-table-option" checked=true value="distributed"
.control-group
label.control-label for='arrange-tables-by_row' data-t='section.arrange_tables.modal.by_row' = t('supplier.section.arrange_tables.modal.by_row')
.controls
input#arrange-tables-by_row type="radio" name="arrange-table-option" value="by_row"
label for="arrange-tables-by-row-count" data-t='section.arrange_tables.modal.by_row_count' = t('supplier.section.arrange_tables.modal.by_row_count')
input.input-mini#arrange-tables-by-row-count type="text" value=0
'
span data-t='models.plural.table'
.control-group
label.control-label for='arrange-tables-by_column' data-t='section.arrange_tables.modal.by_column' = t('supplier.section.arrange_tables.modal.by_column')
.controls
input#arrange-tables-by_column type="radio" name="arrange-table-option" value="by_column"
label for="arrange-tables-by-column-count" data-t='section.arrange_tables.modal.by_column_count' = t('supplier.section.arrange_tables.modal.by_column_count')
input.input-mini#arrange-tables-by-column-count type="text" value=0
'
span data-t='models.plural.table'
@@ -0,0 +1,18 @@
p=t 'section.add_tables.modal.body_header'
form.form-horizontal
.control-group
.form-row
.form-label
label for='add-tables-number-start'
=t 'section.add_tables.modal.number_start'
.form-field
App.NumberField valueBinding="number_start"
.form-row
.form-label
label for='add-tables-number-end'
=t 'section.add_tables.modal.number_end'
.form-field
App.NumberField valueBinding="number_end"
hr
button.confirm-cancel{action "close"}=t 'section.add_tables.modal.close_button'
button.confirm-ok.right{action "addTables"}=t 'section.add_tables.modal.add_button'
@@ -0,0 +1,52 @@
.modal-alert== alert_message
p=t 'section.arrange_tables.modal.body_header'
.arrange-type-buttons
if isDistributed
span.arrange-tables-current-type.distributed=t 'section.arrange_tables.modal.distributed.title'
else
button.arrange-tables-type-button.distributed{action "makeDistributed"}=t 'section.arrange_tables.modal.distributed.title'
if isByRow
span.arrange-tables-current-type.by_row=t 'section.arrange_tables.modal.by_row.title'
else
button.arrange-tables-type-button.by_row{action "makeByRow"}=t 'section.arrange_tables.modal.by_row.title'
if isByColumn
span.arrange-tables-current-type.by_column=t 'section.arrange_tables.modal.by_column.title'
else
button.arrange-tables-type-button.by_column{action "makeByColumn"}=t 'section.arrange_tables.modal.by_column.title'
.arrange-content
if isDistributed
==t 'section.arrange_tables.modal.distributed.explanation'
if isByRow
==t 'section.arrange_tables.modal.by_row.before_field'
App.NumberField valueBinding="row_count"
==t 'section.arrange_tables.modal.by_row.after_field'
if isByColumn
==t 'section.arrange_tables.modal.by_column.before_field'
App.NumberField valueBinding="column_count"
==t 'section.arrange_tables.modal.by_column.after_field'
hr
button.confirm-cancel{action "close"}=t 'section.arrange_tables.modal.close_button'
button.confirm-ok.right{action "arrangeTables"}=t 'section.arrange_tables.modal.arrange_button'
/form.form-horizontal
.control-group
label.control-label for='arrange-tables-distributed' data-t='section.arrange_tables.modal.distributed' = t('supplier.section.arrange_tables.modal.distributed')
.controls
input#arrange-tables-distributed type="radio" name="arrange-table-option" checked=true value="distributed"
.control-group
label.control-label for='arrange-tables-by_row' data-t='section.arrange_tables.modal.by_row' = t('supplier.section.arrange_tables.modal.by_row')
.controls
input#arrange-tables-by_row type="radio" name="arrange-table-option" value="by_row"
label for="arrange-tables-by-row-count" data-t='section.arrange_tables.modal.by_row_count' = t('supplier.section.arrange_tables.modal.by_row_count')
input.input-mini#arrange-tables-by-row-count type="text" value=0
'
span data-t='models.plural.table'
.control-group
label.control-label for='arrange-tables-by_column' data-t='section.arrange_tables.modal.by_column' = t('supplier.section.arrange_tables.modal.by_column')
.controls
input#arrange-tables-by_column type="radio" name="arrange-table-option" value="by_column"
label for="arrange-tables-by-column-count" data-t='section.arrange_tables.modal.by_column_count' = t('supplier.section.arrange_tables.modal.by_column_count')
input.input-mini#arrange-tables-by-column-count type="text" value=0
'
span data-t='models.plural.table'