Add Buefy panels support for "view product" page

This commit is contained in:
Lance Edgar 2019-05-23 19:15:47 -05:00
parent 6be4964221
commit 1fb121fb6d
2 changed files with 215 additions and 99 deletions

View file

@ -1,57 +1,17 @@
## -*- coding: utf-8; -*- ## -*- coding: utf-8; -*-
<%inherit file="/master/view.mako" /> <%inherit file="/master/view.mako" />
############################## <%def name="extra_styles()">
## page body ${parent.extra_styles()}
############################## % if use_buefy:
<style type="text/css">
<div style="display: flex; justify-content: space-between;"> #main-product-panel {
margin-right: 2em;
<div class="form-wrapper"> margin-top: 1em;
}
<div style="display: flex; flex-direction: column;"> </style>
<div class="panel" id="product-main">
<h2>Product</h2>
<div class="panel-body">
<div style="display: flex; justify-content: space-between;">
<div>
${self.render_main_fields(form)}
</div>
<div>
% if image_url:
${h.image(image_url, "Product Image", id='product-image', width=150, height=150)}
% endif % endif
</div> </%def>
</div>
</div>
</div>
<div style="display: flex;">
<div class="panel-wrapper"> <!-- left column -->
${self.left_column()}
</div> <!-- left column -->
<div class="panel-wrapper" style="margin-left: 1em;"> <!-- right column -->
${self.right_column()}
</div> <!-- right column -->
</div>
</div>
% if buttons:
${buttons|n}
% endif
</div>
<ul id="context-menu">
${self.context_menu_items()}
</ul>
</div>
##############################
## rendering methods
##############################
<%def name="render_main_fields(form)"> <%def name="render_main_fields(form)">
${form.render_field_readonly('upc')} ${form.render_field_readonly('upc')}
@ -72,6 +32,24 @@
</%def> </%def>
<%def name="left_column()"> <%def name="left_column()">
% if use_buefy:
<nav class="panel">
<p class="panel-heading">Pricing</p>
<div class="panel-block">
<div>
${self.render_price_fields(form)}
</div>
</div>
</nav>
<nav class="panel">
<p class="panel-heading">Flags</p>
<div class="panel-block">
<div>
${self.render_flag_fields(form)}
</div>
</div>
</nav>
% else:
<div class="panel"> <div class="panel">
<h2>Pricing</h2> <h2>Pricing</h2>
<div class="panel-body"> <div class="panel-body">
@ -84,6 +62,7 @@
${self.render_flag_fields(form)} ${self.render_flag_fields(form)}
</div> </div>
</div> </div>
% endif
${self.extra_left_panels()} ${self.extra_left_panels()}
</%def> </%def>
@ -100,12 +79,23 @@
<%def name="extra_main_fields(form)"></%def> <%def name="extra_main_fields(form)"></%def>
<%def name="organization_panel()"> <%def name="organization_panel()">
% if use_buefy:
<nav class="panel">
<p class="panel-heading">Organization</p>
<div class="panel-block">
<div>
${self.render_organization_fields(form)}
</div>
</div>
</nav>
% else:
<div class="panel"> <div class="panel">
<h2>Organization</h2> <h2>Organization</h2>
<div class="panel-body"> <div class="panel-body">
${self.render_organization_fields(form)} ${self.render_organization_fields(form)}
</div> </div>
</div> </div>
% endif
</%def> </%def>
<%def name="render_organization_fields(form)"> <%def name="render_organization_fields(form)">
@ -137,21 +127,30 @@
</%def> </%def>
<%def name="movement_panel()"> <%def name="movement_panel()">
% if use_buefy:
<nav class="panel">
<p class="panel-heading">Movement</p>
<div class="panel-block">
<div>
${self.render_movement_fields(form)}
</div>
</div>
</nav>
% else:
<div class="panel"> <div class="panel">
<h2>Movement</h2> <h2>Movement</h2>
<div class="panel-body"> <div class="panel-body">
${self.render_movement_fields(form)} ${self.render_movement_fields(form)}
</div> </div>
</div> </div>
% endif
</%def> </%def>
<%def name="render_movement_fields(form)"> <%def name="render_movement_fields(form)">
${form.render_field_readonly('last_sold')} ${form.render_field_readonly('last_sold')}
</%def> </%def>
<%def name="lookup_codes_panel()"> <%def name="lookup_codes_grid()">
<div class="panel-grid" id="product-codes">
<h2>Additional Lookup Codes</h2>
<div class="grid full no-border"> <div class="grid full no-border">
<table> <table>
<thead> <thead>
@ -168,12 +167,25 @@
</tbody> </tbody>
</table> </table>
</div> </div>
</div>
</%def> </%def>
<%def name="sources_panel()"> <%def name="lookup_codes_panel()">
<div class="panel-grid" id="product-costs"> % if use_buefy:
<h2>Vendor Sources</h2> <nav class="panel">
<p class="panel-heading">Additional Lookup Codes</p>
<div class="panel-block">
${self.lookup_codes_grid()}
</div>
</nav>
% else:
<div class="panel-grid" id="product-codes">
<h2>Additional Lookup Codes</h2>
${self.lookup_codes_grid()}
</div>
% endif
</%def>
<%def name="sources_grid()">
<div class="grid full no-border"> <div class="grid full no-border">
<table> <table>
<thead> <thead>
@ -206,27 +218,129 @@
</tbody> </tbody>
</table> </table>
</div> </div>
</%def>
<%def name="sources_panel()">
% if use_buefy:
<nav class="panel">
<p class="panel-heading">Vendor Sources</p>
<div class="panel-block">
${self.sources_grid()}
</div> </div>
</nav>
% else:
<div class="panel-grid" id="product-costs">
<h2>Vendor Sources</h2>
${self.sources_grid()}
</div>
% endif
</%def> </%def>
<%def name="notes_panel()"> <%def name="notes_panel()">
% if use_buefy:
<nav class="panel">
<p class="panel-heading">Notes</p>
<div class="panel-block">
<div class="field">${form.render_field_readonly('notes')}</div>
</div>
</nav>
% else:
<div class="panel"> <div class="panel">
<h2>Notes</h2> <h2>Notes</h2>
<div class="panel-body"> <div class="panel-body">
<div class="field">${form.render_field_readonly('notes')}</div> <div class="field">${form.render_field_readonly('notes')}</div>
</div> </div>
</div> </div>
% endif
</%def> </%def>
<%def name="ingredients_panel()"> <%def name="ingredients_panel()">
% if use_buefy:
<nav class="panel">
<p class="panel-heading">Ingredients</p>
<div class="panel-block">
${form.render_field_readonly('ingredients')}
</div>
</nav>
% else:
<div class="panel"> <div class="panel">
<h2>Ingredients</h2> <h2>Ingredients</h2>
<div class="panel-body"> <div class="panel-body">
${form.render_field_readonly('ingredients')} ${form.render_field_readonly('ingredients')}
</div> </div>
</div> </div>
% endif
</%def> </%def>
<%def name="extra_left_panels()"></%def> <%def name="extra_left_panels()"></%def>
<%def name="extra_right_panels()"></%def> <%def name="extra_right_panels()"></%def>
<%def name="render_form()">
% if use_buefy:
<div style="display: flex; flex-direction: column;">
<nav class="panel" id="main-product-panel">
<p class="panel-heading">Product</p>
<div class="panel-block">
<div style="display: flex; justify-content: space-between; width: 100%;">
<div>
${self.render_main_fields(form)}
</div>
<div>
% if image_url:
${h.image(image_url, "Product Image", id='product-image', width=150, height=150)}
% endif
</div>
</div>
</div>
</nav>
<div style="display: flex;">
<div class="panel-wrapper"> <!-- left column -->
${self.left_column()}
</div> <!-- left column -->
<div class="panel-wrapper" style="margin-left: 1em;"> <!-- right column -->
${self.right_column()}
</div> <!-- right column -->
</div>
</div>
% else:
<div style="display: flex; flex-direction: column;">
<div class="panel" id="product-main">
<h2>Product</h2>
<div class="panel-body">
<div style="display: flex; justify-content: space-between;">
<div>
${self.render_main_fields(form)}
</div>
<div>
% if image_url:
${h.image(image_url, "Product Image", id='product-image', width=150, height=150)}
% endif
</div>
</div>
</div>
</div>
<div style="display: flex;">
<div class="panel-wrapper"> <!-- left column -->
${self.left_column()}
</div> <!-- left column -->
<div class="panel-wrapper" style="margin-left: 1em;"> <!-- right column -->
${self.right_column()}
</div> <!-- right column -->
</div>
</div>
% endif
% if buttons:
${buttons|n}
% endif
</%def>
${parent.body()}

View file

@ -104,6 +104,8 @@ class ProductsView(MasterView):
] ]
form_fields = [ form_fields = [
'item_id',
'scancode',
'upc', 'upc',
'brand', 'brand',
'description', 'description',