From 1fb121fb6d1df57c70fe510a095e00ff4f40029a Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 23 May 2019 19:15:47 -0500 Subject: [PATCH] Add Buefy panels support for "view product" page --- tailbone/templates/products/view.mako | 312 ++++++++++++++++++-------- tailbone/views/products.py | 2 + 2 files changed, 215 insertions(+), 99 deletions(-) diff --git a/tailbone/templates/products/view.mako b/tailbone/templates/products/view.mako index db73208f..6836c974 100644 --- a/tailbone/templates/products/view.mako +++ b/tailbone/templates/products/view.mako @@ -1,57 +1,17 @@ ## -*- coding: utf-8; -*- <%inherit file="/master/view.mako" /> -############################## -## page body -############################## - -
- -
- -
- -
-

Product

-
-
-
- ${self.render_main_fields(form)} -
-
- % if image_url: - ${h.image(image_url, "Product Image", id='product-image', width=150, height=150)} - % endif -
-
-
-
- -
-
- ${self.left_column()} -
-
- ${self.right_column()} -
-
- -
- - % if buttons: - ${buttons|n} - % endif -
- - - -
- -############################## -## rendering methods -############################## +<%def name="extra_styles()"> + ${parent.extra_styles()} + % if use_buefy: + + % endif + <%def name="render_main_fields(form)"> ${form.render_field_readonly('upc')} @@ -72,6 +32,24 @@ <%def name="left_column()"> + % if use_buefy: + + + % else:

Pricing

@@ -84,6 +62,7 @@ ${self.render_flag_fields(form)}
+ % endif ${self.extra_left_panels()} @@ -100,12 +79,23 @@ <%def name="extra_main_fields(form)"> <%def name="organization_panel()"> + % if use_buefy: + + % else:

Organization

${self.render_organization_fields(form)}
+ % endif <%def name="render_organization_fields(form)"> @@ -137,96 +127,220 @@ <%def name="movement_panel()"> + % if use_buefy: + + % else:

Movement

${self.render_movement_fields(form)}
+ % endif <%def name="render_movement_fields(form)"> ${form.render_field_readonly('last_sold')} +<%def name="lookup_codes_grid()"> +
+ + + + + + + % for code in instance._codes: + + + + + % endfor + +
SeqCode
${code.ordinal}${code.code}
+
+ + <%def name="lookup_codes_panel()"> + % if use_buefy: + + % else:

Additional Lookup Codes

-
- - - - - - - % for code in instance._codes: - - - - - % endfor - -
SeqCode
${code.ordinal}${code.code}
-
+ ${self.lookup_codes_grid()} +
+ % endif + + +<%def name="sources_grid()"> +
+ + + + + + + + + + + + % for i, cost in enumerate(instance.costs, 1): + + + + + + + + + + % endfor + +
${costs_label_preferred}${costs_label_vendor}${costs_label_code}${costs_label_case_size}Case CostUnit CostStatus
${'X' if cost.preference == 1 else ''} + % if request.has_perm('vendors.view'): + ${h.link_to(cost.vendor, request.route_url('vendors.view', uuid=cost.vendor_uuid))} + % else: + ${cost.vendor} + % endif + ${cost.code or ''}${h.pretty_quantity(cost.case_size)}${'$ %0.2f' % cost.case_cost if cost.case_cost is not None else ''}${'$ %0.4f' % cost.unit_cost if cost.unit_cost is not None else ''}${"discontinued" if cost.discontinued else "available"}
<%def name="sources_panel()"> + % if use_buefy: + + % else:

Vendor Sources

-
- - - - - - - - - - - - % for i, cost in enumerate(instance.costs, 1): - - - - - - - - - - % endfor - -
${costs_label_preferred}${costs_label_vendor}${costs_label_code}${costs_label_case_size}Case CostUnit CostStatus
${'X' if cost.preference == 1 else ''} - % if request.has_perm('vendors.view'): - ${h.link_to(cost.vendor, request.route_url('vendors.view', uuid=cost.vendor_uuid))} - % else: - ${cost.vendor} - % endif - ${cost.code or ''}${h.pretty_quantity(cost.case_size)}${'$ %0.2f' % cost.case_cost if cost.case_cost is not None else ''}${'$ %0.4f' % cost.unit_cost if cost.unit_cost is not None else ''}${"discontinued" if cost.discontinued else "available"}
-
+ ${self.sources_grid()}
+ % endif <%def name="notes_panel()"> + % if use_buefy: + + % else:

Notes

${form.render_field_readonly('notes')}
+ % endif <%def name="ingredients_panel()"> + % if use_buefy: + + % else:

Ingredients

${form.render_field_readonly('ingredients')}
+ % endif <%def name="extra_left_panels()"> <%def name="extra_right_panels()"> + +<%def name="render_form()"> + % if use_buefy: +
+ + + +
+
+ ${self.left_column()} +
+
+ ${self.right_column()} +
+
+ +
+ % else: +
+ +
+

Product

+
+
+
+ ${self.render_main_fields(form)} +
+
+ % if image_url: + ${h.image(image_url, "Product Image", id='product-image', width=150, height=150)} + % endif +
+
+
+
+ +
+
+ ${self.left_column()} +
+
+ ${self.right_column()} +
+
+ +
+ % endif + + % if buttons: + ${buttons|n} + % endif + + + +${parent.body()} diff --git a/tailbone/views/products.py b/tailbone/views/products.py index 0ee2b7d7..e15154cd 100644 --- a/tailbone/views/products.py +++ b/tailbone/views/products.py @@ -104,6 +104,8 @@ class ProductsView(MasterView): ] form_fields = [ + 'item_id', + 'scancode', 'upc', 'brand', 'description',