From d7c8b80da5df0174ff8da5129e689c1937b4bc15 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 23 May 2019 16:29:29 -0500 Subject: [PATCH] Fix Buefy "row grids" when viewing parent; add basic file upload support --- tailbone/static/js/tailbone.buefy.form.js | 2 - .../static/js/tailbone.buefy.oncebutton.js | 6 +++ tailbone/subscribers.py | 6 ++- tailbone/templates/batch/view.mako | 54 ++++++++----------- tailbone/templates/deform/file_upload.pt | 43 +++++++++++++++ tailbone/templates/form.mako | 2 +- tailbone/templates/forms/deform_buefy.mako | 26 +++++++++ tailbone/templates/master/view.mako | 24 ++++++++- 8 files changed, 125 insertions(+), 38 deletions(-) create mode 100644 tailbone/templates/deform/file_upload.pt diff --git a/tailbone/static/js/tailbone.buefy.form.js b/tailbone/static/js/tailbone.buefy.form.js index e6aa7fa8..77181271 100644 --- a/tailbone/static/js/tailbone.buefy.form.js +++ b/tailbone/static/js/tailbone.buefy.form.js @@ -3,5 +3,3 @@ let TailboneForm = { template: '#tailbone-form-template', methods: {} } - -let TailboneFormData = {} diff --git a/tailbone/static/js/tailbone.buefy.oncebutton.js b/tailbone/static/js/tailbone.buefy.oncebutton.js index dd229791..47dbf79f 100644 --- a/tailbone/static/js/tailbone.buefy.oncebutton.js +++ b/tailbone/static/js/tailbone.buefy.oncebutton.js @@ -5,6 +5,9 @@ const OnceButton = { '', @@ -15,7 +18,10 @@ const OnceButton = { props: { type: String, nativeType: String, + tag: String, + href: String, text: String, + title: String, working: String, workingText: String, disabled: Boolean diff --git a/tailbone/subscribers.py b/tailbone/subscribers.py index 7d81b5b1..4f1d7388 100644 --- a/tailbone/subscribers.py +++ b/tailbone/subscribers.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2018 Lance Edgar +# Copyright © 2010-2019 Lance Edgar # # This file is part of Rattail. # @@ -34,6 +34,8 @@ import rattail from rattail.db import model from rattail.db.auth import cache_permissions +import colander +import deform from pyramid import threadlocal from webhelpers2.html import tags @@ -97,6 +99,8 @@ def before_render(event): renderer_globals['six'] = six renderer_globals['json'] = json renderer_globals['datetime'] = datetime + renderer_globals['colander'] = colander + renderer_globals['deform'] = deform # theme - we only want do this for classic web app, *not* API # TODO: so, clearly we need a better way to distinguish the two diff --git a/tailbone/templates/batch/view.mako b/tailbone/templates/batch/view.mako index 94b9b5f5..07a44a61 100644 --- a/tailbone/templates/batch/view.mako +++ b/tailbone/templates/batch/view.mako @@ -63,10 +63,10 @@ % if master.batch_refreshable(batch) and request.has_perm('{}.refresh'.format(permission_prefix)): % if use_buefy: ## TODO: this should surely use a POST request? - - Refresh Data - + + % else: % endif @@ -74,17 +74,16 @@ <%def name="execute_submit_button()"> - + + <%def name="execute_button()"> @@ -145,30 +144,21 @@ % endif -
+<%def name="render_form()"> + ## TODO: should use self.render_form_buttons() + ## ${form.render(form_id='batch-form', buttons=capture(self.render_form_buttons))|n} + ${form.render(form_id='batch-form', buttons=capture(buttons))|n} + -
- ${form.render(form_id='batch-form', buttons=capture(buttons))|n} -
-
- -
- ${self.object_helpers()} -
- -
    - ${self.context_menu_items()} -
- -
- -
+${self.render_form_complete()} % if use_buefy:

## TODO: stop using |n filter ${rows_grid.render_buefy(allow_save_defaults=False, tools=rows_grid_tools)|n} + ${self.make_tailbone_form_app()} + ${self.make_tailbone_grid_app()} % else: ## no buefy, so do the traditional thing ${rows_grid|n} diff --git a/tailbone/templates/deform/file_upload.pt b/tailbone/templates/deform/file_upload.pt new file mode 100644 index 00000000..8daab2f8 --- /dev/null +++ b/tailbone/templates/deform/file_upload.pt @@ -0,0 +1,43 @@ + + + +
+ ${field.start_mapping()} + + + ${field.end_mapping()} + +
+ +
+ ${field.start_mapping()} + + + + Click to upload + + + + {{ ${vmodel}.name }} + + ${field.end_mapping()} +
+ +
diff --git a/tailbone/templates/form.mako b/tailbone/templates/form.mako index 52a5e297..2fb050ac 100644 --- a/tailbone/templates/form.mako +++ b/tailbone/templates/form.mako @@ -18,7 +18,7 @@ ${self.render_form()} -
+
${self.object_helpers()}
diff --git a/tailbone/templates/forms/deform_buefy.mako b/tailbone/templates/forms/deform_buefy.mako index 69767de9..f97f6a85 100644 --- a/tailbone/templates/forms/deform_buefy.mako +++ b/tailbone/templates/forms/deform_buefy.mako @@ -20,6 +20,10 @@ + +
diff --git a/tailbone/templates/master/view.mako b/tailbone/templates/master/view.mako index 38af7862..7d395de9 100644 --- a/tailbone/templates/master/view.mako +++ b/tailbone/templates/master/view.mako @@ -7,7 +7,7 @@ ${parent.extra_javascript()} % if master.has_rows: % if use_buefy: - ${h.javascript_link(request.static_url('tailbone:static/js/tailbone.buefy.gridfilters.js') + '?ver={}'.format(tailbone.__version__))} + ${h.javascript_link(request.static_url('tailbone:static/js/tailbone.buefy.grid.js') + '?ver={}'.format(tailbone.__version__))} % else: + + ${self.render_form_complete()} @@ -77,12 +96,13 @@ ${self.render_form_complete()}

## TODO: stop using |n filter ${rows_grid.render_buefy(allow_save_defaults=False, tools=capture(self.render_row_grid_tools))|n} + ${self.make_tailbone_grid_app()} % else: ## no buefy, so do the traditional thing ${rows_grid|n} % endif % endif -% if form.use_buefy: +% if use_buefy: ${self.make_tailbone_form_app()} % endif