From 8a5dbc33a789de428d5e2dd44fab77f17fd40676 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 11 Jul 2017 21:05:26 -0500 Subject: [PATCH] Refactor keypad widget for mobile receiving logic for this is now held in common --- tailbone/static/js/tailbone.mobile.js | 6 +-- .../templates/mobile/receiving/view_row.mako | 46 ++++--------------- 2 files changed, 13 insertions(+), 39 deletions(-) diff --git a/tailbone/static/js/tailbone.mobile.js b/tailbone/static/js/tailbone.mobile.js index 9a377e18..35d691e5 100644 --- a/tailbone/static/js/tailbone.mobile.js +++ b/tailbone/static/js/tailbone.mobile.js @@ -192,10 +192,10 @@ $(document).on('change', 'fieldset.receiving-mode input[name="mode"]', function( // handle receiving action buttons $(document).on('click', '.receiving-actions button', function() { var action = $(this).data('action'); - var form = $('form.receiving-update'); - var uom = form.find('[name="receiving-uom"]:checked').val(); + var form = $(this).parents('form:first'); + var uom = form.find('[name="keypad-uom"]:checked').val(); var mode = form.find('[name="mode"]:checked').val(); - var qty = form.find('.receiving-quantity').text(); + var qty = form.find('.keypad-quantity').text(); if (action == 'add' || action == 'subtract') { if (qty != '0') { if (action == 'subtract') { diff --git a/tailbone/templates/mobile/receiving/view_row.mako b/tailbone/templates/mobile/receiving/view_row.mako index ecc4d156..a1649560 100644 --- a/tailbone/templates/mobile/receiving/view_row.mako +++ b/tailbone/templates/mobile/receiving/view_row.mako @@ -1,10 +1,18 @@ ## -*- coding: utf-8; -*- <%inherit file="/mobile/master/view_row.mako" /> +<%namespace file="/mobile/keypad.mako" import="keypad" /> ## TODO: this is broken for actual page (header) title <%def name="title()">${h.link_to("Receiving", url('mobile.receiving'))} » ${h.link_to(instance.batch.id_str, url('mobile.receiving.view', uuid=instance.batch_uuid))} » ${row.upc.pretty()} -<% unit_uom = 'LB' if row.product and row.product.weighed else 'EA' %> +<% + unit_uom = 'LB' if row.product and row.product.weighed else 'EA' + + uom = 'CS' + if row.units_ordered and not row.cases_ordered: + uom = 'EA' +%> +
@@ -49,30 +57,6 @@ % endif % if not instance.batch.executed and not instance.batch.complete: - - - - - - - - - - - - - - - - - - - - - - - -
${h.link_to("7", '#', class_='keypad-button ui-btn ui-btn-inline ui-corner-all')}${h.link_to("8", '#', class_='keypad-button ui-btn ui-btn-inline ui-corner-all')}${h.link_to("9", '#', class_='keypad-button ui-btn ui-btn-inline ui-corner-all')}
${h.link_to("4", '#', class_='keypad-button ui-btn ui-btn-inline ui-corner-all')}${h.link_to("5", '#', class_='keypad-button ui-btn ui-btn-inline ui-corner-all')}${h.link_to("6", '#', class_='keypad-button ui-btn ui-btn-inline ui-corner-all')}
${h.link_to("1", '#', class_='keypad-button ui-btn ui-btn-inline ui-corner-all')}${h.link_to("2", '#', class_='keypad-button ui-btn ui-btn-inline ui-corner-all')}${h.link_to("3", '#', class_='keypad-button ui-btn ui-btn-inline ui-corner-all')}
${h.link_to("0", '#', class_='keypad-button ui-btn ui-btn-inline ui-corner-all')}${h.link_to(".", '#', class_='keypad-button ui-btn ui-btn-inline ui-corner-all')}${h.link_to("Del", '#', class_='keypad-button ui-btn ui-btn-inline ui-corner-all')}
${h.form(request.current_route_url(), class_='receiving-update')} ${h.csrf_token(request)} @@ -80,17 +64,7 @@ ${h.hidden('cases')} ${h.hidden('units')} - <% - uom = 'CS' - if row.units_ordered and not row.cases_ordered: - uom = 'EA' - %> -
- - - ${h.radio('receiving-uom', value='CS', checked=uom == 'CS', label="CS")} - ${h.radio('receiving-uom', value=unit_uom, checked=uom == unit_uom, label=unit_uom)} -
+ ${keypad(unit_uom, uom)}