Refactor the Ordering Worksheet generator, per Buefy
This commit is contained in:
parent
eddbfcab36
commit
2ebae17839
|
@ -24,8 +24,6 @@
|
||||||
App Menus
|
App Menus
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
import warnings
|
import warnings
|
||||||
|
@ -527,6 +525,19 @@ class MenuHandler(GenericHandler):
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
if kwargs.get('include_worksheets', False):
|
||||||
|
items.extend([
|
||||||
|
{'type': 'sep'},
|
||||||
|
{
|
||||||
|
'title': "Ordering Worksheet",
|
||||||
|
'route': 'reports.ordering',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'title': "Inventory Worksheet",
|
||||||
|
'route': 'reports.inventory',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
if kwargs.get('include_trainwreck', False):
|
if kwargs.get('include_trainwreck', False):
|
||||||
items.extend([
|
items.extend([
|
||||||
{'type': 'sep'},
|
{'type': 'sep'},
|
||||||
|
|
|
@ -111,7 +111,7 @@
|
||||||
<td class="brand">${cost.product.brand or ''}</td>
|
<td class="brand">${cost.product.brand or ''}</td>
|
||||||
<td class="desc">${cost.product.description}</td>
|
<td class="desc">${cost.product.description}</td>
|
||||||
<td class="size">${cost.product.size or ''}</td>
|
<td class="size">${cost.product.size or ''}</td>
|
||||||
<td class="case-qty">${cost.case_size} ${"LB" if cost.product.weighed else "EA"}</td>
|
<td class="case-qty">${app.render_quantity(cost.case_size)} ${"LB" if cost.product.weighed else "EA"}</td>
|
||||||
<td class="code">${cost.code or ''}</td>
|
<td class="code">${cost.code or ''}</td>
|
||||||
<td class="preferred">${'X' if cost.preference == 1 else ''}</td>
|
<td class="preferred">${'X' if cost.preference == 1 else ''}</td>
|
||||||
% for i in range(14):
|
% for i in range(14):
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
## -*- coding: utf-8; -*-
|
|
||||||
<%inherit file="/page.mako" />
|
|
||||||
|
|
||||||
${parent.body()}
|
|
|
@ -1,7 +1,7 @@
|
||||||
## -*- coding: utf-8 -*-
|
## -*- coding: utf-8 -*-
|
||||||
<%inherit file="/reports/base.mako" />
|
<%inherit file="/page.mako" />
|
||||||
|
|
||||||
<%def name="title()">Report : Inventory Worksheet</%def>
|
<%def name="title()">Inventory Worksheet</%def>
|
||||||
|
|
||||||
<%def name="page_content()">
|
<%def name="page_content()">
|
||||||
|
|
||||||
|
|
|
@ -1,89 +1,120 @@
|
||||||
## -*- coding: utf-8 -*-
|
## -*- coding: utf-8 -*-
|
||||||
<%inherit file="/reports/base.mako" />
|
<%inherit file="/page.mako" />
|
||||||
|
|
||||||
<%def name="title()">Report : Ordering Worksheet</%def>
|
<%def name="title()">Ordering Worksheet</%def>
|
||||||
|
|
||||||
<%def name="head_tags()">
|
<%def name="page_content()">
|
||||||
${parent.head_tags()}
|
|
||||||
<style type="text/css">
|
|
||||||
|
|
||||||
div.grid {
|
<p class="block">
|
||||||
clear: none;
|
Please provide the following criteria to generate your report:
|
||||||
}
|
</p>
|
||||||
|
|
||||||
|
<div style="max-width: 50%;">
|
||||||
|
${h.form(request.current_route_url(), **{'@submit': 'validateForm'})}
|
||||||
|
${h.csrf_token(request)}
|
||||||
|
${h.hidden('departments', **{':value': 'departmentUUIDs'})}
|
||||||
|
|
||||||
|
<b-field label="Vendor">
|
||||||
|
<tailbone-autocomplete v-model="vendorUUID"
|
||||||
|
service-url="${url('vendors.autocomplete')}"
|
||||||
|
name="vendor"
|
||||||
|
@input="vendorChanged">
|
||||||
|
</tailbone-autocomplete>
|
||||||
|
</b-field>
|
||||||
|
|
||||||
|
<b-field label="Departments">
|
||||||
|
<b-table v-if="fetchedDepartments"
|
||||||
|
:data="departments"
|
||||||
|
narrowed
|
||||||
|
checkable
|
||||||
|
:checked-rows.sync="checkedDepartments"
|
||||||
|
:loading="fetchingDepartments">
|
||||||
|
|
||||||
|
<b-table-column field="number"
|
||||||
|
label="Number"
|
||||||
|
v-slot="props">
|
||||||
|
{{ props.row.number }}
|
||||||
|
</b-table-column>
|
||||||
|
|
||||||
|
<b-table-column field="name"
|
||||||
|
label="Name"
|
||||||
|
v-slot="props">
|
||||||
|
{{ props.row.name }}
|
||||||
|
</b-table-column>
|
||||||
|
|
||||||
|
</b-table>
|
||||||
|
</b-field>
|
||||||
|
|
||||||
|
<b-field>
|
||||||
|
<b-checkbox name="preferred_only" :value="true"
|
||||||
|
native-value="1">
|
||||||
|
Only include products for which this vendor is preferred.
|
||||||
|
</b-checkbox>
|
||||||
|
</b-field>
|
||||||
|
|
||||||
|
${self.extra_fields()}
|
||||||
|
|
||||||
|
<div class="buttons">
|
||||||
|
<b-button type="is-primary"
|
||||||
|
native-type="submit"
|
||||||
|
icon-pack="fas"
|
||||||
|
icon-left="arrow-circle-right">
|
||||||
|
Generate Report
|
||||||
|
</b-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
${h.end_form()}
|
||||||
|
</div>
|
||||||
|
|
||||||
</style>
|
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<p>Please provide the following criteria to generate your report:</p>
|
<%def name="extra_fields()"></%def>
|
||||||
<br />
|
|
||||||
|
|
||||||
${h.form(request.current_route_url())}
|
<%def name="modify_this_page_vars()">
|
||||||
${h.hidden('departments', value='')}
|
${parent.modify_this_page_vars()}
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
<div class="field-wrapper">
|
ThisPageData.vendorUUID = null
|
||||||
${h.hidden('vendor', value='')}
|
ThisPageData.departments = []
|
||||||
<label for="vendor-name">Vendor:</label>
|
ThisPageData.checkedDepartments = []
|
||||||
${h.text('vendor-name', size='40', value='')}
|
ThisPageData.fetchingDepartments = false
|
||||||
<div id="vendor-display" style="display: none;">
|
ThisPageData.fetchedDepartments = false
|
||||||
<span>(no vendor)</span>
|
|
||||||
<button type="button" id="change-vendor">Change</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="field-wrapper">
|
ThisPage.computed.departmentUUIDs = function() {
|
||||||
<label>Departments:</label>
|
let uuids = []
|
||||||
<div class="grid"></div>
|
for (let dept of this.checkedDepartments) {
|
||||||
</div>
|
uuids.push(dept.uuid)
|
||||||
|
}
|
||||||
<div class="field-wrapper">
|
return uuids.join(',')
|
||||||
${h.checkbox('preferred_only', label="Include only those products for which this vendor is preferred.", checked=True)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="buttons">
|
|
||||||
${h.submit('submit', "Generate Report")}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
${h.end_form()}
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
|
|
||||||
$(function() {
|
|
||||||
|
|
||||||
var autocompleter = $('#vendor-name').autocomplete({
|
|
||||||
serviceUrl: '${url('vendors.autocomplete')}',
|
|
||||||
width: 300,
|
|
||||||
onSelect: function(value, data) {
|
|
||||||
$('#vendor').val(data);
|
|
||||||
$('#vendor-name').hide();
|
|
||||||
$('#vendor-name').val('');
|
|
||||||
$('#vendor-display span').html(value);
|
|
||||||
$('#vendor-display').show();
|
|
||||||
loading($('div.grid'));
|
|
||||||
$('div.grid').load('${url('departments.by_vendor')}', {'uuid': data});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#vendor-name').focus();
|
|
||||||
|
|
||||||
$('#change-vendor').click(function() {
|
|
||||||
$('#vendor').val('');
|
|
||||||
$('#vendor-display').hide();
|
|
||||||
$('#vendor-name').show();
|
|
||||||
$('#vendor-name').focus();
|
|
||||||
$('div.grid').empty();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('form').submit(function() {
|
|
||||||
var depts = [];
|
|
||||||
$('div.grid table tbody tr').each(function() {
|
|
||||||
if ($(this).find('td.checkbox input[type=checkbox]').is(':checked')) {
|
|
||||||
depts.push(get_uuid(this));
|
|
||||||
}
|
}
|
||||||
$('#departments').val(depts.toString());
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
ThisPage.methods.vendorChanged = function(uuid) {
|
||||||
|
if (uuid) {
|
||||||
|
this.fetchingDepartments = true
|
||||||
|
|
||||||
</script>
|
let url = '${url('departments.by_vendor')}'
|
||||||
|
let params = {uuid: uuid}
|
||||||
|
this.$http.get(url, {params: params}).then(response => {
|
||||||
|
this.departments = response.data
|
||||||
|
this.fetchingDepartments = false
|
||||||
|
this.fetchedDepartments = true
|
||||||
|
})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.departments = []
|
||||||
|
this.fetchedDepartments = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ThisPage.methods.validateForm = function(event) {
|
||||||
|
if (!this.departmentUUIDs.length) {
|
||||||
|
alert("You must select at least one Department.")
|
||||||
|
event.preventDefault()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
|
||||||
|
${parent.body()}
|
||||||
|
|
|
@ -135,6 +135,7 @@ class OrderingWorksheet(View):
|
||||||
time=now.strftime('%I:%M %p'),
|
time=now.strftime('%I:%M %p'),
|
||||||
get_upc=self.upc_getter,
|
get_upc=self.upc_getter,
|
||||||
rattail=rattail,
|
rattail=rattail,
|
||||||
|
app=self.get_rattail_app(),
|
||||||
)
|
)
|
||||||
|
|
||||||
template_path = resource_path(self.report_template_path)
|
template_path = resource_path(self.report_template_path)
|
||||||
|
|
Loading…
Reference in a new issue