End of train commit

This commit is contained in:
2014-07-02 12:35:48 +02:00
parent cddff247a4
commit 8ab355460c
9 changed files with 96 additions and 46 deletions
@@ -1,7 +1,8 @@
Qsupplier.App.ModalSectionArrangeTablesController = Ember.ObjectController.extend
alert_message: null
arrange_type: 'distributed' # can be distributed, by_row or by_column
by_row_count: 0
by_column_count: 0
row_count: 2
column_count: 2
isDistributed: (->@get('arrange_type') is 'distributed').property('arrange_type')
isByRow: (->@get('arrange_type') is 'by_row').property('arrange_type')
isByColumn: (->@get('arrange_type') is 'by_column').property('arrange_type')
@@ -13,8 +14,26 @@ Qsupplier.App.ModalSectionArrangeTablesController = Ember.ObjectController.exten
@get('model.ok').call(@)
@send 'closeModal'
arrangeTables: ->
debugger
3
Ember.$.post Routes.arrange_tables_suppliers_section_path(@get('model.id')),
option: @get('arrange_type')
row_count: @get('row_count')
column_count: @get('column_count')
, (result,state,xhr)=>
#@store.pushPayload 'table', result
@store.pushPayload result
@send 'close'
##TODO remove followin code if Ember pushPayload is working
##properly with associations
#section_id = @get('model.id')
#tables_that_should_be_in_section = @store.all('table').filter((t)->t.get('section.id') == section_id)
#current_table_ids = @get('model.tables').mapProperty('id')
#for table in tables_that_should_be_in_section.toArray()
#@get('model.tables').pushObject(table) unless table.get('id') in current_table_ids
##TODO it still does not work for the second client side action,
##soo the good old reload for now for the failing case
#window.location.reload() if result.tables.length != tables_that_should_be_in_section.toArray().length
return
makeDistributed: -> @set 'arrange_type', 'distributed'
makeByRow: -> @set 'arrange_type', 'by_row'
makeByColumn: -> @set 'arrange_type', 'by_column'
@@ -1,4 +1,4 @@
a.dropdown-trigger.button.tiny.dropdown href="#"
span.dropdown-trigger.button.tiny.dropdown
span.dropdown-trigger-text= view.title
/span.dropdown-trigger-icon
.dropdown-list-container
@@ -3,31 +3,32 @@ modal-dialog action="close"
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'
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'
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'
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'
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'
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'
button.arrange-tables-type-button.by_column{action 'makeByColumn'}=t 'section.arrange_tables.modal.by_column.title'
.arrange-content
if isDistributed
span.explanation
==t 'section.arrange_tables.modal.distributed.explanation'
if isByRow
= t 'section.arrange_tables.modal.by_row_count'
Qsupplier.App.NumberField valueBinding="by_row_count"
=t 'models.plural.table'
==t 'section.arrange_tables.modal.by_row.before_field'
Qsupplier.App.NumberField valueBinding="row_count"
==t 'section.arrange_tables.modal.by_row.after_field'
if isByColumn
= t 'section.arrange_tables.modal.by_column_count'
Qsupplier.App.NumberField valueBinding="by_column_count"
=t 'models.plural.table'
==t 'section.arrange_tables.modal.by_column.before_field'
Qsupplier.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'