Add new v3 master with v2 forms, with colander/deform

goal here is to replace FormAlchemy dependency, slowly but surely..
so far only the Settings and Stores views use v3 master
This commit is contained in:
Lance Edgar 2017-07-18 12:29:05 -05:00
parent 2b5aaa0753
commit 4dcd89fba7
18 changed files with 718 additions and 59 deletions

View file

@ -0,0 +1,81 @@
## -*- coding: utf-8; -*-
% if not readonly:
<% _focus_rendered = False %>
${h.form(form.action_url, id=dform.formid, method='post', enctype='multipart/form-data')}
${h.csrf_token(request)}
% endif
## % for error in fieldset.errors.get(None, []):
## <div class="fieldset-error">${error}</div>
## % endfor
% for field in form.fields:
## % if readonly or field.name in readonly_fields:
% if readonly:
${render_field_readonly(field)|n}
% elif field not in dform and field in form.readonly_fields:
${render_field_readonly(field)|n}
% elif field in dform:
<% field = dform[field] %>
## % if field.requires_label:
<div class="field-wrapper ${field.name} ${'error' if field.error else ''}">
## % for error in field.errors:
## <div class="field-error">${error}</div>
## % endfor
% if field.error:
<div class="field-error">${field.error.msg}</div>
% endif
<label for="${field.name}">${field.title}</label>
<div class="field">
${field.serialize()|n}
</div>
## % if 'instructions' in field.metadata:
## <span class="instructions">${field.metadata['instructions']}</span>
## % endif
</div>
## % if not _focus_rendered and (fieldset.focus is True or fieldset.focus is field):
% if not readonly and not _focus_rendered:
## % if not field.is_readonly() and getattr(field.renderer, 'needs_focus', True):
% if not field.widget.readonly:
<script type="text/javascript">
$(function() {
## % if hasattr(field.renderer, 'focus_name'):
## $('#${field.renderer.focus_name}').focus();
## % else:
## $('#${field.renderer.name}').focus();
## % endif
$('#${field.oid}').focus();
});
</script>
<% _focus_rendered = True %>
% endif
% endif
## % else:
## ${field.render()|n}
## % endif
% endif
% endfor
% if buttons:
${buttons|n}
% elif not readonly:
<div class="buttons">
## ${h.submit('create', form.create_label if form.creating else form.update_label)}
${h.submit('save', "Save")}
## % if form.creating and form.allow_successive_creates:
## ${h.submit('create_and_continue', form.successive_create_label)}
## % endif
${h.link_to("Cancel", form.cancel_url, class_='button')}
</div>
% endif
% if not readonly:
${h.end_form()}
% endif

View file

@ -0,0 +1,5 @@
## -*- coding: utf-8; -*-
<div class="form">
${form.render_deform()|n}
</div>

View file

@ -0,0 +1,8 @@
## -*- coding: utf-8; -*-
<div class="form">
${form.render_deform(readonly=True)|n}
## % if buttons:
## ${buttons|n}
## % endif
</div><!-- form -->

View file

@ -1,10 +1,10 @@
## -*- coding: utf-8 -*-
## -*- coding: utf-8; -*-
<%inherit file="/base.mako" />
<%def name="title()">${model_title}: ${instance_title}</%def>
<%def name="title()">${model_title_plural} &raquo; ${instance_title}</%def>
<%def name="head_tags()">
${parent.head_tags()}
<%def name="extra_javascript()">
${parent.extra_javascript()}
% if master.has_rows:
${h.javascript_link(request.static_url('tailbone:static/js/jquery.ui.tailbone.js'))}
<script type="text/javascript">
@ -12,6 +12,12 @@
$('.grid-wrapper').gridwrapper();
});
</script>
% endif
</%def>
<%def name="extra_styles()">
${parent.extra_styles()}
% if master.has_rows:
<style type="text/css">
.grid-wrapper {
margin-top: 10px;

View file

@ -7,6 +7,8 @@
## ##############################################################################
<%inherit file="/mobile/base.mako" />
<%def name="title()">${instance_title}</%def>
<%def name="title()">${index_title} &raquo; ${instance_title}</%def>
<%def name="page_title()">${h.link_to(index_title, index_url)} &raquo; ${instance_title}</%def>
${form.render()|n}

View file

@ -1,8 +0,0 @@
## -*- coding: utf-8; -*-
<%inherit file="/mobile/base.mako" />
<%def name="title()">Receiving</%def>
${h.link_to("New Receiving Batch", url('purchases.batch.mobile_create'), class_='ui-btn')}
${h.link_to("View Receiving Batches", url('mobile.purchases.batch'), class_='ui-btn')}

View file

@ -1,7 +1,9 @@
## -*- coding: utf-8; -*-
<%inherit file="/mobile/base.mako" />
<%def name="title()">${h.link_to("Receiving", url('mobile.receiving'))} &raquo; New Batch</%def>
<%def name="title()">Receiving &raquo; New Batch</%def>
<%def name="page_title()">${h.link_to("Receiving", url('mobile.receiving'))} &raquo; New Batch</%def>
${h.form(request.current_route_url(), class_='ui-filterable', name='new-purchasing-batch')}
${h.csrf_token(request)}

View file

@ -1,7 +1,9 @@
## -*- coding: utf-8; -*-
<%inherit file="/mobile/master/view.mako" />
<%def name="title()">${h.link_to("Receiving", url('mobile.receiving'))} &raquo; ${instance.id_str}</%def>
<%def name="title()">Receiving &raquo; ${instance.id_str}</%def>
<%def name="page_title()">${h.link_to("Receiving", url('mobile.receiving'))} &raquo; ${instance.id_str}</%def>
${form.render()|n}
<br />

View file

@ -2,8 +2,9 @@
<%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'))} &raquo; ${h.link_to(instance.batch.id_str, url('mobile.receiving.view', uuid=instance.batch_uuid))} &raquo; ${row.upc.pretty()}</%def>
<%def name="title()">Receiving &raquo; ${instance.batch.id_str} &raquo; ${row.upc.pretty()}</%def>
<%def name="page_title()">${h.link_to("Receiving", url('mobile.receiving'))} &raquo; ${h.link_to(instance.batch.id_str, url('mobile.receiving.view', uuid=instance.batch_uuid))} &raquo; ${row.upc.pretty()}</%def>
<%
unit_uom = 'LB' if row.product and row.product.weighed else 'EA'