Supplier adding and arranging tables

This commit is contained in:
2014-07-01 17:46:19 +02:00
parent de576d54d9
commit 639a707679
14 changed files with 24448 additions and 22627 deletions
@@ -21,5 +21,20 @@ Qsupplier.App.ModalSectionAddTablesController = Ember.ObjectController.extend
number_start: s
number_end: e
, (result,state,xhr)=>
@store.pushPayload 'table', result
#@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
@@ -0,0 +1,20 @@
Qsupplier.App.ModalSectionArrangeTablesController = Ember.ObjectController.extend
arrange_type: 'distributed'
by_row_count: 0
by_column_count: 0
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')
actions:
close: ->
@get('model.cancel').call(@) if @get('model.cancel')
@send 'closeModal'
confirm: ->
@get('model.ok').call(@)
@send 'closeModal'
arrangeTables: ->
debugger
3
makeDistributed: -> @set 'arrange_type', 'distributed'
makeByRow: -> @set 'arrange_type', 'by_row'
makeByColumn: -> @set 'arrange_type', 'by_column'
@@ -12,7 +12,7 @@ Qsupplier.App.SectionController = Ember.ObjectController.extend
#$('#add-tables-modal').modal()
@send 'openModal', 'modal_section_add_tables', @get('model')
arrangeTables: ->
$('#arrange-tables-modal').modal()
@send 'openModal', 'modal_section_arrange_tables', @get('model')
textures: ['wood1', 'wood2']
sections: (-> @get('controllers.sections.model')).property('controllers.sections.model')
@@ -0,0 +1,67 @@
modal-dialog action="close"
.modal-header
h3.flush--top=t 'section.arrange_tables.modal.title'
hr
.modal-body
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'
else
button.arrange-tables-type-button.distributed{action 'makeDistributed'}=t 'section.arrange_tables.modal.distributed'
if isByRow
span.arrange-tables-current-type.by_row=t 'section.arrange_tables.modal.by_row'
else
button.arrange-tables-type-button.by_row{action 'makeByRow'}=t 'section.arrange_tables.modal.by_row'
if isByColumn
span.arrange-tables-current-type.by_column=t 'section.arrange_tables.modal.by_column'
else
button.arrange-tables-type-button.by_column{action 'makeByColumn'}=t 'section.arrange_tables.modal.by_column'
.arrange-content
if isDistributed
span.explanation
if isByRow
.form-row
.form-label
label for="arrange-tables-by-row-count"
= t 'section.arrange_tables.modal.by_row_count'
.form-field
Qsupplier.App.NumberField valueBinding="by_row_count"
/input.input-mini#arrange-tables-by-row-count type="text" value=0
=t 'models.plural.table'
if isByColumn
.form-row
.form-label
label for="arrange-tables-by-column-count"
= t 'section.arrange_tables.modal.by_column_count'
.form-field
Qsupplier.App.NumberField valueBinding="by_column_count"
/input.input-mini#arrange-tables-by-row-count type="text" value=0
=t 'models.plural.table'
.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'
@@ -1,6 +1,6 @@
.modal
margin: 10px auto
width: 300px
width: 500px
background-color: #fff
padding: 1em
@@ -15,6 +15,12 @@
@extend .fa
@extend .fa-lg
@extend .fa-save
.arrange-tables-type-button
+button($bg: $secondary-color, $padding: $button-tny)
.arrange-tables-current-type
display: inline-block
margin-left: 10px
margin-right: 10px
.section-actions-menu-header
padding-top: 4px
padding-bottom: 4px