Supplier adding and arranging tables
This commit is contained in:
+16
-1
@@ -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
|
||||
|
||||
|
||||
|
||||
+20
@@ -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
|
||||
|
||||
@@ -132,6 +132,7 @@ module Suppliers
|
||||
table = Table.new(number: table_number)
|
||||
table.supplier = current_supplier
|
||||
table.section = @section
|
||||
table.save
|
||||
end
|
||||
@section.arrange_tables_in_grid
|
||||
table_json = ActiveModel::ArraySerializer.new(@section.tables, each_serializer: SupplierTableSerializer, root: false).as_json
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ class List
|
||||
|
||||
attr_protected :supplier_id
|
||||
|
||||
validates :table_id, presence: true
|
||||
#validates :table_id, presence: true, table can be deleted
|
||||
validates :supplier_id, presence: true
|
||||
|
||||
view :by_supplier_id_and_id, key: [:supplier_id, :_id]
|
||||
|
||||
+12
-8
@@ -46,28 +46,32 @@ class Section
|
||||
|
||||
def width=(val)
|
||||
val = val.to_f
|
||||
return val if width == val
|
||||
self.path[0] ||= [0.0, 0.0]
|
||||
self.path[1] ||= [0.0, 0.0]
|
||||
self.path[2] ||= [0.0, 0.0]
|
||||
self.path[3] ||= [0.0, 0.0]
|
||||
unless path[1][0] == val && path[2][0] == val
|
||||
self.path[1][0] = val
|
||||
self.path[2][0] = val
|
||||
path[0][0] = 0
|
||||
path[1][0] = val
|
||||
path[2][0] = val
|
||||
path[3][0] = 0
|
||||
path_will_change!
|
||||
end
|
||||
val
|
||||
end
|
||||
|
||||
def height=(val)
|
||||
val = val.to_f
|
||||
return val if height == val
|
||||
self.path[0] ||= [0.0, 0.0]
|
||||
self.path[1] ||= [0.0, 0.0]
|
||||
self.path[2] ||= [0.0, 0.0]
|
||||
self.path[3] ||= [0.0, 0.0]
|
||||
unless path[2][1] == val && path[3][1] == val
|
||||
self.path[2][1] = val
|
||||
self.path[3][1] = val
|
||||
path[0][1] = 0
|
||||
path[1][1] = 0
|
||||
path[2][1] = val
|
||||
path[3][1] = val
|
||||
path_will_change!
|
||||
end
|
||||
val
|
||||
end
|
||||
|
||||
def tables_with_active_list_id
|
||||
|
||||
@@ -2,7 +2,7 @@ require 'spec_helper'
|
||||
|
||||
describe :section do
|
||||
before :each do
|
||||
@section = build :section
|
||||
@section = build :section, path: [[10, 30], [20,30], [20,40], [10, 40]]
|
||||
end
|
||||
|
||||
describe :path do
|
||||
|
||||
+1693
-772
File diff suppressed because it is too large
Load Diff
+21853
-21065
File diff suppressed because it is too large
Load Diff
+5
-5
File diff suppressed because one or more lines are too long
+20
-21
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user