Misc. tweaks for App Details / Configure Menus

This commit is contained in:
Lance Edgar 2023-01-16 21:55:52 -06:00
parent 9b21d52206
commit 98fa6eea05
7 changed files with 68 additions and 22 deletions

View file

@ -501,20 +501,10 @@ class MenuHandler(GenericHandler):
'perm': 'luigi.list',
},
{
'title': "Tables",
'route': 'tables',
'perm': 'tables.list',
},
{
'title': "App Info",
'title': "App Details",
'route': 'appinfo',
'perm': 'appinfo.list',
},
{
'title': "Configure App",
'route': 'appinfo.configure',
'perm': 'appinfo.configure',
},
{
'title': "Upgrades",
'route': 'upgrades',

View file

@ -3,6 +3,31 @@
<%def name="render_grid_component()">
<div class="buttons">
<once-button type="is-primary"
tag="a" href="${url('tables')}"
icon-pack="fas"
icon-left="eye"
text="Tables">
</once-button>
<once-button type="is-primary"
tag="a" href="${url('model_views')}"
icon-pack="fas"
icon-left="eye"
text="Model Views">
</once-button>
<once-button type="is-primary"
tag="a" href="${url('configure_menus')}"
icon-pack="fas"
icon-left="cog"
text="Configure Menus">
</once-button>
</div>
<b-collapse class="panel" open>
<template #trigger="props">

View file

@ -14,6 +14,12 @@
</%def>
<%def name="form_content()">
## nb. must be root to configure menus! otherwise some of the
## currently-defined menus may not appear on the page, so saving
## would inadvertently remove them!
% if request.is_root:
${h.hidden('menus', **{':value': 'JSON.stringify(allMenuData)'})}
<h3 class="is-size-3">Top-Level Menus</h3>
@ -182,6 +188,24 @@
</div>
% else:
## not root!
<b-notification type="is-warning">
You must become root to configure menus!
</b-notification>
% endif
</%def>
## TODO: should probably make some global "editable" flag that the
## base configure template has knowledge of, and just set that to
## false for this view
<%def name="purge_button()">
% if request.is_root:
${parent.purge_button()}
% endif
</%def>
<%def name="modify_this_page_vars()">

View file

@ -383,7 +383,7 @@
tag="a"
href="${url('{}.configure'.format(route_prefix))}"
icon-left="cog"
text="Configure">
text="${(configure_button_title or "Configure") if configure_button_title is not Undefined else "Configure"}">
</once-button>
</div>
% endif

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar
# Copyright © 2010-2023 Lance Edgar
#
# This file is part of Rattail.
#
@ -63,8 +63,8 @@ class MenuConfigView(View):
context = {
'config_title': "Menus",
'use_buefy': True,
'index_title': "App Settings",
'index_url': self.request.route_url('appsettings'),
'index_title': "App Details",
'index_url': self.request.route_url('appinfo'),
}
possible_index_options = sorted(
@ -173,9 +173,7 @@ class MenuConfigView(View):
'/configure-menus')
config.add_view(cls, attr='configure',
route_name='configure_menus',
# nb. must be root to configure menus! b/c
# otherwise some route options may be hidden
permission='admin',
permission='appinfo.configure',
renderer='/configure-menus.mako')
config.add_tailbone_config_page('configure_menus', "Menus", 'admin')

View file

@ -54,7 +54,7 @@ class AppInfoView(MasterView):
route_prefix = 'appinfo'
model_key = 'UNUSED'
model_title = "UNUSED"
model_title_plural = "App Info"
model_title_plural = "App Details"
creatable = False
viewable = False
editable = False
@ -70,7 +70,8 @@ class AppInfoView(MasterView):
]
def get_index_title(self):
return "App Info for {}".format(self.rattail_config.app_title())
return "{} for {}".format(self.get_model_title_plural(),
self.rattail_config.app_title())
def get_data(self, session=None):
pip = os.path.join(sys.prefix, 'bin', 'pip')
@ -95,6 +96,11 @@ class AppInfoView(MasterView):
'editable_project_location', foldcase=True)
g.set_searchable('editable_project_location')
def template_kwargs_index(self, **kwargs):
kwargs = super(AppInfoView, self).template_kwargs_index(**kwargs)
kwargs['configure_button_title'] = "Configure App"
return kwargs
def configure_get_context(self, **kwargs):
context = super(AppInfoView, self).configure_get_context(**kwargs)

View file

@ -86,6 +86,7 @@ class ModelViewView(MasterView):
g.sorters['label'] = g.make_simple_sorter('label')
g.set_sort_defaults('label')
g.set_link('label')
g.set_searchable('label')
# model_name
g.sorters['model_name'] = g.make_simple_sorter('model_name', foldcase=True)
@ -93,12 +94,14 @@ class ModelViewView(MasterView):
# route
g.sorters['route'] = g.make_simple_sorter('route')
g.set_searchable('route')
# permission
g.sorters['permission'] = g.make_simple_sorter('permission')
g.set_searchable('permission')
def default_view_url(self, view, i=None):
return self.request.route_url(view['route_prefix'])
def default_view_url(self):
return lambda view, i: self.request.route_url(view['route_prefix'])
def make_form_schema(self):
return ModelViewSchema()