From 31dff0d35315306123eb19700044e68427fe52e1 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 17 Dec 2021 21:36:51 -0600 Subject: [PATCH] Add some standard CRUD buttons for buefy themes finally! also disable the permalink "feature" since it seems not useful --- tailbone/static/themes/falafel/css/layout.css | 7 +- tailbone/templates/master/delete.mako | 2 +- tailbone/templates/master/edit.mako | 2 +- tailbone/templates/master/form.mako | 2 +- tailbone/templates/master/index.mako | 2 +- tailbone/templates/master/view.mako | 10 ++- tailbone/templates/master/view_row.mako | 2 +- tailbone/templates/themes/falafel/base.mako | 89 ++++++++++++++++--- 8 files changed, 89 insertions(+), 27 deletions(-) diff --git a/tailbone/static/themes/falafel/css/layout.css b/tailbone/static/themes/falafel/css/layout.css index 20fcf36e..3a292cac 100644 --- a/tailbone/static/themes/falafel/css/layout.css +++ b/tailbone/static/themes/falafel/css/layout.css @@ -51,14 +51,9 @@ header .navbar-item.nested { padding-left: 2.5rem; } -header .level #current-context, -header .level-left #current-context { +header span.header-text { font-size: 2em; font-weight: bold; -} - -header .level #current-context span, -header .level-left #current-context span { margin-right: 10px; } diff --git a/tailbone/templates/master/delete.mako b/tailbone/templates/master/delete.mako index 444c4e1d..62f28241 100644 --- a/tailbone/templates/master/delete.mako +++ b/tailbone/templates/master/delete.mako @@ -11,7 +11,7 @@ % if master.editable and request.has_perm('{}.edit'.format(permission_prefix)):
  • ${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)): + % if not use_buefy and master.creatable and master.show_create_link and master.has_perm('create'): % if master.creates_multiple:
  • ${h.link_to("Create new {}".format(model_title_plural), url('{}.create'.format(route_prefix)))}
  • % else: diff --git a/tailbone/templates/master/edit.mako b/tailbone/templates/master/edit.mako index febd0bcd..1aae24b4 100644 --- a/tailbone/templates/master/edit.mako +++ b/tailbone/templates/master/edit.mako @@ -27,7 +27,7 @@
  • ${h.link_to("View this {}".format(model_title), action_url('view', instance))}
  • % endif ${self.context_menu_item_delete()} - % if master.creatable and master.show_create_link and request.has_perm('{}.create'.format(permission_prefix)): + % if not use_buefy and master.creatable and master.show_create_link and master.has_perm('create'): % if master.creates_multiple:
  • ${h.link_to("Create new {}".format(model_title_plural), url('{}.create'.format(route_prefix)))}
  • % else: diff --git a/tailbone/templates/master/form.mako b/tailbone/templates/master/form.mako index 6f67f77e..a37e3f91 100644 --- a/tailbone/templates/master/form.mako +++ b/tailbone/templates/master/form.mako @@ -2,7 +2,7 @@ <%inherit file="/form.mako" /> <%def name="context_menu_item_delete()"> - % if master.deletable and instance_deletable and request.has_perm('{}.delete'.format(permission_prefix)): + % if not use_buefy and master.deletable and instance_deletable and master.has_perm('delete'): % if master.delete_confirm == 'simple':
  • ## note, the `ref` here is for buefy only diff --git a/tailbone/templates/master/index.mako b/tailbone/templates/master/index.mako index de58af83..ca0615ce 100644 --- a/tailbone/templates/master/index.mako +++ b/tailbone/templates/master/index.mako @@ -155,7 +155,7 @@ % if master.results_downloadable_xlsx and request.has_perm('{}.results_xlsx'.format(permission_prefix)):
  • ${h.link_to("Download results as XLSX", url('{}.results_xlsx'.format(route_prefix)))}
  • % endif - % if master.creatable and master.show_create_link and request.has_perm('{}.create'.format(permission_prefix)): + % if not use_buefy and master.creatable and master.show_create_link and master.has_perm('create'): % if master.creates_multiple:
  • ${h.link_to("Create new {}".format(model_title_plural), url('{}.create'.format(route_prefix)))}
  • % else: diff --git a/tailbone/templates/master/view.mako b/tailbone/templates/master/view.mako index 94454bd9..37d60c39 100644 --- a/tailbone/templates/master/view.mako +++ b/tailbone/templates/master/view.mako @@ -48,22 +48,24 @@ <%def name="context_menu_items()"> -
  • ${h.link_to("Permalink for this {}".format(model_title), action_url('view', instance))}
  • + ## TODO: either make this configurable, or just lose it. + ## nobody seems to ever find it useful in practice. + ##
  • ${h.link_to("Permalink for this {}".format(model_title), action_url('view', instance))}
  • % if master.has_versions and request.rattail_config.versioning_enabled() and request.has_perm('{}.versions'.format(permission_prefix)):
  • ${h.link_to("Version History", action_url('versions', instance))}
  • % endif - % if master.editable and instance_editable and request.has_perm('{}.edit'.format(permission_prefix)): + % if not use_buefy and master.editable and instance_editable and master.has_perm('edit'):
  • ${h.link_to("Edit this {}".format(model_title), action_url('edit', instance))}
  • % endif ${self.context_menu_item_delete()} - % if master.creatable and master.show_create_link and request.has_perm('{}.create'.format(permission_prefix)): + % if not use_buefy and master.creatable and master.show_create_link and master.has_perm('create'): % 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 - % if master.cloneable and request.has_perm('{}.clone'.format(permission_prefix)): + % if not use_buefy and master.cloneable and master.has_perm('clone'):
  • ${h.link_to("Clone this as new {}".format(model_title), url('{}.clone'.format(route_prefix), uuid=instance.uuid))}
  • % endif % if master.touchable and request.has_perm('{}.touch'.format(permission_prefix)): diff --git a/tailbone/templates/master/view_row.mako b/tailbone/templates/master/view_row.mako index 29a77497..255caf69 100644 --- a/tailbone/templates/master/view_row.mako +++ b/tailbone/templates/master/view_row.mako @@ -12,7 +12,7 @@ % if master.rows_editable and instance_editable and request.has_perm('{}.edit'.format(permission_prefix)):
  • ${h.link_to("Edit this {}".format(model_title), action_url('edit', instance))}
  • % endif - % if instance_deletable and master.has_perm('delete_row'): + % if not use_buefy and instance_deletable and master.has_perm('delete_row'):
  • ${h.link_to("Delete this {}".format(model_title), action_url('delete', instance))}
  • % endif % if rows_creatable and request.has_perm('{}.create'.format(permission_prefix)): diff --git a/tailbone/templates/themes/falafel/base.mako b/tailbone/templates/themes/falafel/base.mako index 78fcd4d7..7b168a5d 100644 --- a/tailbone/templates/themes/falafel/base.mako +++ b/tailbone/templates/themes/falafel/base.mako @@ -274,24 +274,48 @@
    % if master: % if master.listing: - ${index_title} + + ${index_title} + + % if use_buefy and master.creatable and master.show_create_link and master.has_perm('create'): + + + % endif % elif index_url: - ${h.link_to(index_title, index_url)} + + ${h.link_to(index_title, index_url)} + % if parent_url is not Undefined: -  » - ${h.link_to(parent_title, parent_url)} + +  » + + + ${h.link_to(parent_title, parent_url)} + % elif instance_url is not Undefined: -  » - ${h.link_to(instance_title, instance_url)} + +  » + + + ${h.link_to(instance_title, instance_url)} + % endif % if master.viewing and grid_index: ${grid_index_nav()} % endif % else: - ${index_title} + + ${index_title} + % endif % elif index_title: - ${index_title} + + ${index_title} + % endif
    @@ -384,8 +408,49 @@

    - % if show_prev_next is not Undefined and show_prev_next: -
    +
    + % if use_buefy and master and master.viewing: + ## TODO: is there a better way to check if viewing parent? + % if parent_instance is Undefined: + % if master.editable and instance_editable and master.has_perm('edit'): +
    + + +
    + % endif + % if master.cloneable and master.has_perm('clone'): +
    + + +
    + % endif + % if master.deletable and instance_deletable and master.has_perm('delete'): +
    + + +
    + % endif + % else: + ## viewing row + % if instance_deletable and master.has_perm('delete_row'): +
    + + +
    + % endif + % endif + % endif + % if show_prev_next is not Undefined and show_prev_next: % if prev_url:
    ${h.link_to(u"« Older", prev_url, class_='button autodisable')} @@ -404,8 +469,8 @@ ${h.link_to(u"Newer »", '#', class_='button', disabled='disabled')}
    % endif -
    - % endif + % endif +
    % endif