Skip to content

Commit

Permalink
Storage zone now only displays storage name
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Duporge committed Sep 11, 2017
1 parent f346740 commit 6ed3901
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 41 deletions.
70 changes: 36 additions & 34 deletions app/assets/javascripts/backend/deliveries.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
options = element.data("product-of-delivery-item")
product_id = element.selector('value')
reg = new RegExp("\\bRECORD_ID\\b", "g")
scope = options['scope']
if product_id?
item = element.closest(".delivery-item")
$.ajax
Expand Down Expand Up @@ -60,45 +61,46 @@

item.find('*[data-when-item]').each ->
if typeof data[$(this).data('when-item')] != "undefined"
if typeof $(this).data("when-set-value") != "undefined"
if $(this).data("when-set-value") == "RECORD_VALUE"
newVal = data[$(this).data("when-item")]
if typeof $(this).data('when-scope') == "undefined" or $(this).data('when-scope') == scope
if typeof $(this).data("when-set-value") != "undefined"
if $(this).data("when-set-value") == "RECORD_VALUE"
newVal = data[$(this).data("when-item")]

if $(this).is ":ui-selector"
$(this).selector("value", newVal)
else if $(this).is "input"
$(this).val(newVal)
else
$(this).html(newVal)

$(this).trigger 'change'

if typeof newVal == "string"
element = $(@)
element.is(":ui-mapeditor")
try
value = $.parseJSON(newVal)

if (value.geometries? and value.geometries.length > 0) || (value.coordinates? and value.coordinates.length > 0)
element.mapeditor "show", value
element.mapeditor "edit", value
try
element.mapeditor "view", "edit"

catch

if $(this).is ":ui-selector"
$(this).selector("value", newVal)
else if $(this).is "input"
$(this).val(newVal)
else
$(this).html(newVal)
$(this).val($(this).data("when-set-value"))

$(this).trigger 'change'
if typeof $(this).data("when-prop-value") != "undefined"
$(this).prop($(this).data("when-prop-value"), true)

if typeof newVal == "string"
element = $(@)
element.is(":ui-mapeditor")
try
value = $.parseJSON(newVal)

if (value.geometries? and value.geometries.length > 0) || (value.coordinates? and value.coordinates.length > 0)
element.mapeditor "show", value
element.mapeditor "edit", value
try
element.mapeditor "view", "edit"

catch

$(this).val(newVal)
else
$(this).val($(this).data("when-set-value"))

if typeof $(this).data("when-prop-value") != "undefined"
$(this).prop($(this).data("when-prop-value"), true)

if typeof $(this).data("when-display-value") != "undefined"
if $(this).data("when-display-value") == true
$(this).show()
else
$(this).hide()
if typeof $(this).data("when-display-value") != "undefined"
if $(this).data("when-display-value") == true
$(this).show()
else
$(this).hide()

else
if typeof $(this).data("when-prop-value") != "undefined"
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/cocoon/iceberg.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@
form.find('.storing-fields').not('.removed-nested-fields').each ->
zones.push
quantity: $(this).find('input.storing-quantity').val()
unit: $(this).find('.item-population-unit-name').html()
name: $(this).find('input.storing-storage').val()
unit: $(this).find('.storage-unit-name').html()
name: $(this).find('input.hidden').val()
data = zones: zones

unless @vm?
Expand Down
6 changes: 3 additions & 3 deletions app/views/backend/receptions/_item_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
.item-block.merchandise
- if f.object.role == 'merchandise'
= f.referenced_association(:variant, source: { scope: :stockables_or_depreciables }, input_html: { class: 'parcel-item-variant', data: { product_of_delivery_item: {url: backend_product_nature_variant_path("RECORD_ID", format: :json)}, required: true }})
= f.referenced_association(:variant, source: { scope: :stockables_or_depreciables }, input_html: { class: 'parcel-item-variant', data: { product_of_delivery_item: {url: backend_product_nature_variant_path("RECORD_ID", format: :json), scope: 'unit'}, required: true }})
- elsif f.object.role == 'service' || f.object.role == 'fees'
= f.referenced_association(:variant, source: { scope: :services }, input_html: { class: 'parcel-item-variant', data: { product_of_delivery_item: {url: backend_product_nature_variant_path("RECORD_ID", format: :json)}, required: true }})
= f.referenced_association(:variant, source: { scope: :services }, input_html: { class: 'parcel-item-variant', data: { product_of_delivery_item: {url: backend_product_nature_variant_path("RECORD_ID", format: :json), scope: 'unit'}, required: true }})
- if f.object.role == 'merchandise' || f.object.role == 'service'
.non-compliant
Expand All @@ -68,7 +68,7 @@
%span.item-population-unit-name
= variant.unit_name.or_else('#')
.item-block.item-delivery-mode
= f.input :delivery_mode, as: :radio_buttons, collection: f.object.class.delivery_mode.values - ['none'], label_method: :l, input_html: { class: 'item-delivery-mode', data: { input_to_show: '.transporter-delivery-mode', with_value: "transporter", use_as_value: '.delivery-item > input.hidden' } }
= f.input :delivery_mode, as: :radio_buttons, collection: f.object.class.delivery_mode.values - ['none'], label_method: :l, input_html: { class: 'item-delivery-mode', data: { input_to_show: '.transporter-delivery-mode', with_value: "transporter", use_as_value: '.transporter-delivery-mode > input.hidden' } }
.transporter-delivery-mode.hidden.delivery-item
= f.referenced_association :transporter, source: :transporters, new: {transporter: 1}, input_html: { class: 'transporter-delivery-mode', data: { product_of_delivery_item: { url: backend_entity_path("RECORD_ID", format: :json) } } }
- full_name = f.object.transporter.full_name if f.object.transporter
Expand Down
6 changes: 4 additions & 2 deletions app/views/backend/receptions/_storing_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
- variant = Maybe(storing.parcel_item.variant)

.nested-fields.storing-fields
= f.referenced_association :storage, source: :storage, label: false, input_html: { class: 'storing-storage', data: { required: true } }
.delivery-item
= f.referenced_association :storage, source: :storage, label: false, input_html: { class: 'storing-storage', data: { product_of_delivery_item: { url: backend_product_path("RECORD_ID", format: :json), scope: 'storage' }, required: true } }
%input.hidden{data: { 'when-item': 'name', 'when-set-value': 'RECORD_VALUE', 'when-scope': 'storage'}}
.storing-quantifier
= f.input :quantity, label: false, wrapper: :append do
= f.input_field :quantity, class: 'storing-quantity', placeholder: '0', data: { required: true }
%span.add-on.item-population-unit-name
%span.add-on.storage-unit-name{data: { 'when-item': 'unit_name', 'when-set-value': 'RECORD_VALUE', 'when-scope': 'unit'}}
= variant.unit_name.or_else('#')
.nested-remove.act
- if f.object.destroyable?
Expand Down

0 comments on commit 6ed3901

Please sign in to comment.