Changeset 145e7f5 in tailbone


Ignore:
Timestamp:
02/19/19 21:11:49 (7 months ago)
Author:
Lance Edgar <ledgar@…>
Branches:
master
Children:
4b97b40
Parents:
1908092
Message:

Allow vendor field to be dropdown, for mobile ordering/receiving

based on config. useful for apps which have very few vendors

Location:
tailbone
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • tailbone/static/js/tailbone.mobile.receiving.js

    r1908092 r145e7f5  
    1515$(document).on('autocompleteitemcleared', 'form[name="new-receiving-batch"] .vendor', function(event) {
    1616    $('#new-receiving-types').hide();
     17});
     18$(document).on('change', 'form[name="new-receiving-batch"] select[name="vendor"]', function(event) {
     19    if ($(this).val()) {
     20        $('#new-receiving-types').show();
     21    } else {
     22        $('#new-receiving-types').hide();
     23    }
    1724});
    1825
  • tailbone/templates/mobile/ordering/create.mako

    r1908092 r145e7f5  
    1010
    1111<div class="field-wrapper vendor">
    12   <div class="field autocomplete" data-url="${url('vendors.autocomplete')}">
    13     ${h.hidden('vendor')}
    14     ${h.text('new-purchasing-batch-vendor-text', placeholder="Vendor name", autocomplete='off', data_type='search')}
    15     <ul data-role="listview" data-inset="true" data-filter="true" data-input="#new-purchasing-batch-vendor-text"></ul>
    16     <button type="button" style="display: none;">Change Vendor</button>
    17   </div>
     12  % if vendor_use_autocomplete:
     13      <div class="field autocomplete" data-url="${url('vendors.autocomplete')}">
     14        ${h.hidden('vendor')}
     15        ${h.text('new-purchasing-batch-vendor-text', placeholder="Vendor name", autocomplete='off', data_type='search')}
     16        <ul data-role="listview" data-inset="true" data-filter="true" data-input="#new-purchasing-batch-vendor-text"></ul>
     17        <button type="button" style="display: none;">Change Vendor</button>
     18      </div>
     19  % else:
     20      <div class="field-row">
     21        <label for="vendor">Vendor</label>
     22        <div class="field">
     23          ${h.select('vendor', None, vendor_options)}
     24        </div>
     25      </div>
     26  % endif
    1827</div>
    1928
  • tailbone/templates/mobile/receiving/create.mako

    r1908092 r145e7f5  
    1111% if phase == 1:
    1212
    13     <div class="field-wrapper vendor">
    14       <div class="field autocomplete" data-url="${url('vendors.autocomplete')}">
    15         ${h.hidden('vendor')}
    16         ${h.text('new-receiving-batch-vendor-text', placeholder="Vendor name", autocomplete='off', **{'data-type': 'search'})}
    17         <ul data-role="listview" data-inset="true" data-filter="true" data-input="#new-receiving-batch-vendor-text"></ul>
    18         <button type="button" style="display: none;">Change Vendor</button>
    19       </div>
    20     </div>
     13    % if vendor_use_autocomplete:
     14        <div class="field-wrapper vendor">
     15          <div class="field autocomplete" data-url="${url('vendors.autocomplete')}">
     16            ${h.hidden('vendor')}
     17            ${h.text('new-receiving-batch-vendor-text', placeholder="Vendor name", autocomplete='off', **{'data-type': 'search'})}
     18            <ul data-role="listview" data-inset="true" data-filter="true" data-input="#new-receiving-batch-vendor-text"></ul>
     19            <button type="button" style="display: none;">Change Vendor</button>
     20          </div>
     21        </div>
     22    % else:
     23        <div class="field-row">
     24          <label for="vendor">Vendor</label>
     25          <div class="field">
     26            ${h.select('vendor', None, vendor_options)}
     27          </div>
     28        </div>
     29    % endif
    2130
    2231    <br />
  • tailbone/views/purchasing/ordering.py

    r1908092 r145e7f5  
    33#
    44#  Rattail -- Retail Software Framework
    5 #  Copyright © 2010-2017 Lance Edgar
     5#  Copyright © 2010-2019 Lance Edgar
    66#
    77#  This file is part of Rattail.
     
    3636from rattail.core import Object
    3737from rattail.time import localtime
     38
     39from webhelpers2.html import tags
    3840
    3941from tailbone.views.purchasing import PurchasingBatchView
     
    318320        data['index_url'] = self.get_index_url(mobile=True)
    319321        data['mode_title'] = self.enum.PURCHASE_BATCH_MODE[mode].capitalize()
     322
     323        data['vendor_use_autocomplete'] = self.rattail_config.getbool(
     324            'rattail', 'vendor.use_autocomplete', default=True)
     325        if not data['vendor_use_autocomplete']:
     326            vendors = self.Session.query(model.Vendor)\
     327                                  .order_by(model.Vendor.name)
     328            options = [(tags.Option(vendor.name, vendor.uuid))
     329                       for vendor in vendors]
     330            options.insert(0, tags.Option("(please choose)", ''))
     331            data['vendor_options'] = options
     332
    320333        return self.render_to_response('create', data, mobile=True)
    321334
  • tailbone/views/purchasing/receiving.py

    r1908092 r145e7f5  
    33#
    44#  Rattail -- Retail Software Framework
    5 #  Copyright © 2010-2018 Lance Edgar
     5#  Copyright © 2010-2019 Lance Edgar
    66#
    77#  This file is part of Rattail.
     
    678678        data['mode_title'] = self.enum.PURCHASE_BATCH_MODE[mode].capitalize()
    679679        data['phase'] = phase
    680         if phase == 2:
     680
     681        if phase == 1:
     682            data['vendor_use_autocomplete'] = self.rattail_config.getbool(
     683                'rattail', 'vendor.use_autocomplete', default=True)
     684            if not data['vendor_use_autocomplete']:
     685                vendors = self.Session.query(model.Vendor)\
     686                                      .order_by(model.Vendor.name)
     687                options = [(tags.Option(vendor.name, vendor.uuid))
     688                           for vendor in vendors]
     689                options.insert(0, tags.Option("(please choose)", ''))
     690                data['vendor_options'] = options
     691
     692        elif phase == 2:
    681693            purchases = self.eligible_purchases(vendor.uuid, mode=mode)
    682694            data['purchases'] = [(p['key'], p['display']) for p in purchases['purchases']]
    683695            data['purchase_order_fieldname'] = self.purchase_order_fieldname
     696
    684697        return self.render_to_response('create', data, mobile=True)
    685698
Note: See TracChangeset for help on using the changeset viewer.