From b829cd260c6e4ba5025258586c725bb194d4b889 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 23 May 2019 13:11:26 -0500 Subject: [PATCH] Assume forms support Buefy if theme does; fix basic CRUD views --- tailbone/static/themes/falafel/css/layout.css | 1 + tailbone/templates/form.mako | 38 +++++++++++----- tailbone/templates/forms/deform_buefy.mako | 2 + tailbone/templates/forms/form.mako | 2 +- tailbone/templates/master/delete.mako | 45 ++++++++++--------- tailbone/templates/master/edit.mako | 19 +++----- tailbone/templates/master/view.mako | 26 +++-------- tailbone/views/bouncer.py | 1 - tailbone/views/master.py | 6 +-- 9 files changed, 67 insertions(+), 73 deletions(-) diff --git a/tailbone/static/themes/falafel/css/layout.css b/tailbone/static/themes/falafel/css/layout.css index b964d476..5aa0e745 100644 --- a/tailbone/static/themes/falafel/css/layout.css +++ b/tailbone/static/themes/falafel/css/layout.css @@ -70,6 +70,7 @@ header .level .theme-picker { ******************************/ #context-menu { + margin-bottom: 1em; text-align: right; white-space: nowrap; } diff --git a/tailbone/templates/form.mako b/tailbone/templates/form.mako index ccf13eea..290c989a 100644 --- a/tailbone/templates/form.mako +++ b/tailbone/templates/form.mako @@ -3,8 +3,32 @@ <%def name="context_menu_items()"> +<%def name="object_helpers()"> + +<%def name="render_form_buttons()"> + <%def name="render_form()"> - ${form.render()|n} + ${form.render(buttons=capture(self.render_form_buttons))|n} + + +<%def name="render_form_complete()"> +
+ +
+ ${self.render_form()} +
+ +
+
+ ${self.object_helpers()} +
+ +
    + ${self.context_menu_items()} +
+
+ +
<%def name="make_buefy_form_app()"> @@ -24,17 +48,7 @@ -
- -
- ${self.render_form()} -
- - - -
+${self.render_form_complete()} % if form.use_buefy: ${self.make_buefy_form_app()} diff --git a/tailbone/templates/forms/deform_buefy.mako b/tailbone/templates/forms/deform_buefy.mako index 6307515f..56be0a31 100644 --- a/tailbone/templates/forms/deform_buefy.mako +++ b/tailbone/templates/forms/deform_buefy.mako @@ -1,6 +1,7 @@ ## -*- coding: utf-8; -*- diff --git a/tailbone/templates/forms/form.mako b/tailbone/templates/forms/form.mako index 2ee96e3c..3cf1a625 100644 --- a/tailbone/templates/forms/form.mako +++ b/tailbone/templates/forms/form.mako @@ -1,5 +1,5 @@ ## -*- coding: utf-8; -*-
- ${form.render_deform()|n} + ${form.render_deform(buttons=buttons)|n}
diff --git a/tailbone/templates/master/delete.mako b/tailbone/templates/master/delete.mako index a23c9a79..edfcada0 100644 --- a/tailbone/templates/master/delete.mako +++ b/tailbone/templates/master/delete.mako @@ -1,5 +1,5 @@ ## -*- coding: utf-8; -*- -<%inherit file="/base.mako" /> +<%inherit file="/form.mako" /> <%def name="title()">Delete ${model_title}: ${instance_title} @@ -12,39 +12,40 @@
  • ${h.link_to("Edit this {}".format(model_title), action_url('edit', instance))}
  • % endif % if master.creatable and master.show_create_link and request.has_perm('{}.create'.format(permission_prefix)): -
  • ${h.link_to("Create a new {}".format(model_title), url('{}.create'.format(route_prefix)))}
  • + % if master.creates_multiple: +
  • ${h.link_to("Create new {}".format(model_title_plural), url('{}.create'.format(route_prefix)))}
  • + % else: +
  • ${h.link_to("Create a new {}".format(model_title), url('{}.create'.format(route_prefix)))}
  • + % endif % endif -<%def name="confirmation()"> +<%def name="render_form()"> +
    +

    You are about to delete the following ${model_title} and all associated data:

    + + ${parent.render_form()} + + +<%def name="render_form_buttons()">

    Are you sure about this?


    - ${h.form(request.current_route_url(), class_='autodisable')} + ${h.form(request.current_route_url(), class_=None if form.use_buefy else 'autodisable')} ${h.csrf_token(request)}
    Whoops, nevermind... - ${h.submit('submit', "Yes, please DELETE this data forever!", class_='button is-primary')} + % if form.use_buefy: + + + % else: + ${h.submit('submit', "Yes, please DELETE this data forever!", class_='button is-primary')} + % endif
    ${h.end_form()} -
    -
    -
    -

    You are about to delete the following ${model_title} and all associated data:

    - -
    - ${form.render()|n} -
    - - ${self.confirmation()} -
    - - - -
    +${parent.body()} diff --git a/tailbone/templates/master/edit.mako b/tailbone/templates/master/edit.mako index ceb7eda7..b0aa8b60 100644 --- a/tailbone/templates/master/edit.mako +++ b/tailbone/templates/master/edit.mako @@ -1,5 +1,5 @@ ## -*- coding: utf-8; -*- -<%inherit file="/base.mako" /> +<%inherit file="/form.mako" /> <%def name="title()">Edit: ${instance_title} @@ -28,18 +28,13 @@
  • ${h.link_to("Delete this {}".format(model_title), action_url('delete', instance))}
  • % endif % if master.creatable and master.show_create_link and request.has_perm('{}.create'.format(permission_prefix)): -
  • ${h.link_to("Create a new {}".format(model_title), url('{}.create'.format(route_prefix)))}
  • + % if master.creates_multiple: +
  • ${h.link_to("Create new {}".format(model_title_plural), url('{}.create'.format(route_prefix)))}
  • + % else: +
  • ${h.link_to("Create a new {}".format(model_title), url('{}.create'.format(route_prefix)))}
  • + % endif % endif -
    -
    - ${form.render()|n} -
    - - - -
    +${parent.body()} diff --git a/tailbone/templates/master/view.mako b/tailbone/templates/master/view.mako index 046da46d..a47a121d 100644 --- a/tailbone/templates/master/view.mako +++ b/tailbone/templates/master/view.mako @@ -1,5 +1,5 @@ ## -*- coding: utf-8; -*- -<%inherit file="/base.mako" /> +<%inherit file="/form.mako" /> <%def name="title()">${index_title} » ${instance_title} @@ -65,30 +65,12 @@ % endif -<%def name="object_helpers()"> - <%def name="render_row_grid_tools()"> ${rows_grid_tools} -
    - -
    - ${form.render()|n} -
    - -
    -
    - ${self.object_helpers()} -
    - -
      - ${self.context_menu_items()} -
    -
    - -
    +${self.render_form_complete()} % if master.has_rows: % if use_buefy: @@ -100,3 +82,7 @@ ${rows_grid|n} % endif % endif + +% if form.use_buefy: + ${self.make_buefy_form_app()} +% endif diff --git a/tailbone/views/bouncer.py b/tailbone/views/bouncer.py index 5ecfca2e..a4833962 100644 --- a/tailbone/views/bouncer.py +++ b/tailbone/views/bouncer.py @@ -51,7 +51,6 @@ class EmailBouncesView(MasterView): url_prefix = '/email-bounces' creatable = False editable = False - supports_buefy_forms = True labels = { 'config_key': "Source", diff --git a/tailbone/views/master.py b/tailbone/views/master.py index 091f4a81..79e23751 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -97,10 +97,6 @@ class MasterView(View): supports_prev_next = False supports_import_batch_from_file = False - # whether or not Buefy is supported for CRUD forms. we're turning this on, - # "one view at a time" until it makes sense for that to be global default. - supports_buefy_forms = False - # quickie (search) supports_quickie_search = False expose_quickie_search = False @@ -2827,7 +2823,7 @@ class MasterView(View): 'readonly': self.viewing, 'model_class': getattr(self, 'model_class', None), 'action_url': self.request.current_route_url(_query=None), - 'use_buefy': self.supports_buefy_forms and self.get_use_buefy(), + 'use_buefy': self.get_use_buefy(), } if self.creating: kwargs.setdefault('cancel_url', self.get_index_url())