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'
@@ -33,19 +33,22 @@
result = result.replace("%{#{variable}}", value)
isafety = 0
while result.indexOf("${") > -1
m = result.match(/\${([\w\.]+(\|\w+)?)}/)
if m[2]
translatable = m[1].replace(m[2], "")
operation = $transformation_mappings[m[2].substr(1) or m[2].substr(1)]
else
translatable = m[1]
operation = null
replacable = t(translatable)
replacable = replacable[operation]() if operation
result = result.replace(m[0], replacable)
break if isafety > 10 # referencing other translations may cause infinite loops
isafety += 1
try
while result.indexOf("${") > -1
m = result.match(/\${([\w\.]+(\|\w+)?)}/)
if m[2]
translatable = m[1].replace(m[2], "")
operation = $transformation_mappings[m[2].substr(1) or m[2].substr(1)]
else
translatable = m[1]
operation = null
replacable = t(translatable)
replacable = replacable[operation]() if operation
result = result.replace(m[0], replacable)
break if isafety > 10 # referencing other translations may cause infinite loops
isafety += 1
catch err
console.log "translation #{result} cannot be interpolated"
result
@setLocale = (locale, options={}) ->
@@ -5,6 +5,7 @@
padding-top: 4px
padding-bottom: 4px
margin-bottom: 0
cursor: pointer
.dropdown-trigger-icon
@extend .fa
@extend .fa-lg
@@ -142,11 +142,23 @@ module Suppliers
# POST /sections/1/arrange_tables {number_start: 1423, number_end: 234234}
def arrange_tables
@section = Section.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
case params[:option]
when 'distributed' then render(json: (@section.arrange_tables_in_grid ? {ok: true} : json_alert('messages.could_not_arrange_tables_distributed')))
when 'by_row' then render(json: (@section.arrange_tables_in_rows_of(params[:row_count].to_i) ? {ok: true} : json_alert('messages.could_not_arrange_tables_by_row')))
when 'by_column' then render(json: (@section.arrange_tables_in_columns_of(params[:column_count].to_i) ? {ok: true} : json_alert('messages.could_not_arrange_tables_by_column')))
else render(json: json_alert('messages.could_not_arrange_tables'))
#TODO handle messages client side
#json_alert('messages.could_not_arrange_tables_distributed')
#json_alert('messages.could_not_arrange_tables_by_row')
#json_alert('messages.could_not_arrange_tables_by_column')))
#json_alert('messages.could_not_arrange_tables')
success = case params[:option]
when 'distributed' then @section.arrange_tables_in_grid
when 'by_row' then @section.arrange_tables_in_rows_of(params[:row_count].to_i)
when 'by_column' then @section.arrange_tables_in_columns_of(params[:column_count].to_i)
else false
end
if success
table_json = ActiveModel::ArraySerializer.new(@section.tables, each_serializer: SupplierTableSerializer, root: false).as_json
render json: {tables: table_json}
else
render json: {}, status: 500
end
end
+11 -5
View File
@@ -65,11 +65,17 @@ en:
modal:
title: Arrange tables
body_header: ""
distributed: Distributed
by_row: By row
by_row_count: of
by_column: By column
by_column_count: of
distributed:
title: Distributed
explanation: Distribute ${models.plural.table|downcase} as good as possible in the ${models.section|downcase}
by_row:
title: By row
before_field: 'make rows each having '
after_field: ' ${models.plural.table}'
by_column:
title: By column
before_field: 'make columns each having '
after_field: ' ${models.plural.table}'
close_button: Close
arrange_button: Distribute
settings:
+11 -5
View File
@@ -65,11 +65,17 @@ nl:
modal:
title: Positioneer tafels
body_header: ""
distributed: Verspreid
by_row: Per rij
by_row_count: van
by_column: Per kolom
by_column_count: van
distributed:
title: Verspreid
explanation: Versprijd de ${models.plural.table|downcase} zo goed mogelijk over de ${models.section|downcase}
by_row:
title: Per rij
before_field: 'maak rijen met elk '
after_field: ' ${models.plural.table}'
by_column:
title: Per kolom
before_field: 'maak kolommen met elk '
after_field: ' ${models.plural.table}'
close_button: Sluiten
arrange_button: Positioneer
settings:
+2
View File
@@ -45,6 +45,8 @@ General:
needed
Bugs:
- Dragging supplier table from one section to the other fails
- Supplier section print qr codes does not give proper images
- Supplier tables pagination styling
Post release
------------