flask-construct-ui 0.12.2__tar.gz → 0.13.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/PKG-INFO +1 -1
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/base.py +92 -18
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/rcrud.py +4 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/schema.py +8 -8
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/css/whitelabel.css +25 -0
- flask_construct_ui-0.13.0/flask_construct_ui/templates/crud/_actions.html +46 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/crud/edit.html +3 -13
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/crud/listindex.html +2 -5
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/crud/related_crud_tab_form.html +2 -8
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/crud/related_crud_tab_list.html +2 -8
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/crud/view.html +2 -7
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui.egg-info/PKG-INFO +1 -1
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui.egg-info/SOURCES.txt +1 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/pyproject.toml +1 -1
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/LICENSE +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/README.md +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/__init__.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/app_hooks.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/auth.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/capabilities.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/cli.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/__init__.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/calendar.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/chart.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/chart_native.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/content.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/core.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/grid.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/kanban.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/layout.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/live.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/period.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/pivot.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/contrast.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/crud.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/crud_forms.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/csrf.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/data.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/data_sqlalchemy.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/dragdrop.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/errors.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/flashes.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/forms.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/grid.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/headless.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/icons.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/l10n/en/main.flt +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/l10n/sv/main.flt +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/language.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/layout.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/live.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/menu.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/navbar.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/navigation.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/orgmode.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/pagination.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/py.typed +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/resume.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/sanitize.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/css/grid.css +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/css/prosemirror-bundle.min.css +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/css/unpoly.min.css +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/designs/adminlte.css +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/designs/sandstone.css +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/fonts/bootstrap-icons/LICENSE.txt +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/fonts/bootstrap-icons/bootstrap-icons.min.css +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/fonts/bootstrap-icons/fonts/bootstrap-icons.woff +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/fonts/bootstrap-icons/fonts/bootstrap-icons.woff2 +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/fonts/material-symbols/LICENSE.txt +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/fonts/material-symbols/material-symbols-outlined.woff2 +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/fonts/material-symbols/material-symbols.css +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/fonts/material-symbols/names.txt +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/js/construct-core.min.js +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/js/construct-grid.min.js +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/js/kanban-dnd.js +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/js/prosemirror-bundle.min.js +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/js/unpoly.min.js +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/_form_field.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/button.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/calendar.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/calendarmini.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/card.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/chart.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/chart_native.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/form.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/grid.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/grid_layout.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/grid_notice.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/horizontal_layout.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/kanban.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/live.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/live_refresh.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/main.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/markup.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/period_nav.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/pivot_form.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/rich_text.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/table.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/tabs.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/text.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/components/vertical_layout.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/crud/_macros.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/crud/_many_related_options.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/crud/_related_options.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/crud/create.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/crud/tab_view.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/errors/error.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/errors/forbidden.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/navbar/notifications.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/navbar/search_results.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/structure/base.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/structure/public.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/style/_flashes.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/style/_footer.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/style/_menu.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/style/base_full.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/style/base_partial.html +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/testing.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/urls.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/validation.py +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui.egg-info/dependency_links.txt +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui.egg-info/requires.txt +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui.egg-info/top_level.txt +0 -0
- {flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/setup.cfg +0 -0
|
@@ -45,9 +45,76 @@ from .urls import apply_trailing_slash as apply_trailing_slash
|
|
|
45
45
|
logger = logging.getLogger("flask_construct_ui")
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
_ACTION_METHODS = ("get", "post")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _action_info(kind, name, icon, method, confirm):
|
|
52
|
+
"""Validate an action decorator's arguments and return its info dict.
|
|
53
|
+
|
|
54
|
+
The route-dependent checks (does the route accept *method*?) need the
|
|
55
|
+
method's ``@expose`` routes, which may be applied before or after the
|
|
56
|
+
action decorator, so they run in ``PageMeta`` (see ``_resolve_action``).
|
|
57
|
+
"""
|
|
58
|
+
if method is not None:
|
|
59
|
+
if not isinstance(method, str) or method.lower() not in _ACTION_METHODS:
|
|
60
|
+
raise ValueError(
|
|
61
|
+
f"@{kind}({name!r}): method must be 'get' or 'post', got {method!r}"
|
|
62
|
+
)
|
|
63
|
+
method = method.lower()
|
|
64
|
+
return {"name": name, "icon": icon, "method": method, "confirm": confirm}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _resolve_action(kind, cls, attr_name, info, url, methods):
|
|
68
|
+
"""Build the action entry for one ``@expose`` route of a page method.
|
|
69
|
+
|
|
70
|
+
Without an explicit ``method`` the action follows the route: a route
|
|
71
|
+
that accepts GET is a link (as before), a POST-only route a form.
|
|
72
|
+
"""
|
|
73
|
+
accepted = {m.upper() for m in methods}
|
|
74
|
+
where = f"@{kind}({info['name']!r}) on {cls.__name__}.{attr_name} (route {url!r})"
|
|
75
|
+
method = info["method"]
|
|
76
|
+
if method is None:
|
|
77
|
+
if "GET" in accepted:
|
|
78
|
+
method = "get"
|
|
79
|
+
elif "POST" in accepted:
|
|
80
|
+
method = "post"
|
|
81
|
+
else:
|
|
82
|
+
raise ValueError(
|
|
83
|
+
f"{where}: the route accepts neither GET nor POST "
|
|
84
|
+
f"({', '.join(sorted(accepted))}), so it cannot be an action"
|
|
85
|
+
)
|
|
86
|
+
elif method.upper() not in accepted:
|
|
87
|
+
raise ValueError(
|
|
88
|
+
f"{where}: method={method!r} but the route only accepts "
|
|
89
|
+
f"{', '.join(sorted(accepted))}; add {method.upper()!r} to its "
|
|
90
|
+
f"@expose methods"
|
|
91
|
+
)
|
|
92
|
+
if info["confirm"] and method != "post":
|
|
93
|
+
raise ValueError(
|
|
94
|
+
f"{where}: confirm= needs a POST action; an action that is worth "
|
|
95
|
+
f"confirming changes state and should not be a GET link"
|
|
96
|
+
)
|
|
97
|
+
return {
|
|
98
|
+
"endpoint": attr_name,
|
|
99
|
+
"name": info["name"],
|
|
100
|
+
"icon": info["icon"],
|
|
101
|
+
"url": url,
|
|
102
|
+
"method": method,
|
|
103
|
+
"confirm": info["confirm"],
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def list_action(name, icon, method=None, confirm=None):
|
|
108
|
+
"""Add a per-row action to the CRUD list.
|
|
109
|
+
|
|
110
|
+
``method`` is ``"get"`` (a link) or ``"post"`` (a small form carrying the
|
|
111
|
+
CSRF token). Left out, it follows the route: GET when the route accepts
|
|
112
|
+
GET, otherwise POST. ``confirm`` is an l10n key for a confirmation text
|
|
113
|
+
shown before a POST action is sent.
|
|
114
|
+
"""
|
|
115
|
+
|
|
49
116
|
def decorator(f):
|
|
50
|
-
f._list_action_info =
|
|
117
|
+
f._list_action_info = _action_info("list_action", name, icon, method, confirm)
|
|
51
118
|
return f
|
|
52
119
|
|
|
53
120
|
return decorator
|
|
@@ -61,9 +128,14 @@ def tab_action(name, icon):
|
|
|
61
128
|
return decorator
|
|
62
129
|
|
|
63
130
|
|
|
64
|
-
def edit_action(name, icon):
|
|
131
|
+
def edit_action(name, icon, method=None, confirm=None):
|
|
132
|
+
"""Add an action to the record's edit/view header.
|
|
133
|
+
|
|
134
|
+
``method`` and ``confirm`` work as for :func:`list_action`.
|
|
135
|
+
"""
|
|
136
|
+
|
|
65
137
|
def decorator(f):
|
|
66
|
-
f._edit_action_info =
|
|
138
|
+
f._edit_action_info = _action_info("edit_action", name, icon, method, confirm)
|
|
67
139
|
return f
|
|
68
140
|
|
|
69
141
|
return decorator
|
|
@@ -203,14 +275,15 @@ class PageMeta(type):
|
|
|
203
275
|
cls._default_view = p
|
|
204
276
|
|
|
205
277
|
if hasattr(attr, "_list_action_info"):
|
|
206
|
-
info = attr._list_action_info
|
|
207
278
|
cls.list_actions.append(
|
|
208
|
-
|
|
209
|
-
"
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
279
|
+
_resolve_action(
|
|
280
|
+
"list_action",
|
|
281
|
+
cls,
|
|
282
|
+
p,
|
|
283
|
+
attr._list_action_info,
|
|
284
|
+
url,
|
|
285
|
+
methods,
|
|
286
|
+
)
|
|
214
287
|
)
|
|
215
288
|
|
|
216
289
|
if hasattr(attr, "_tab_action_info"):
|
|
@@ -225,14 +298,15 @@ class PageMeta(type):
|
|
|
225
298
|
)
|
|
226
299
|
|
|
227
300
|
if hasattr(attr, "_edit_action_info"):
|
|
228
|
-
info = attr._edit_action_info
|
|
229
301
|
cls.edit_actions.append(
|
|
230
|
-
|
|
231
|
-
"
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
302
|
+
_resolve_action(
|
|
303
|
+
"edit_action",
|
|
304
|
+
cls,
|
|
305
|
+
p,
|
|
306
|
+
attr._edit_action_info,
|
|
307
|
+
url,
|
|
308
|
+
methods,
|
|
309
|
+
)
|
|
236
310
|
)
|
|
237
311
|
|
|
238
312
|
# Wrap views
|
|
@@ -462,6 +462,8 @@ class RelatedCrudTab:
|
|
|
462
462
|
"endpoint": f"rcrud_{tab_key}_{a['endpoint']}",
|
|
463
463
|
"name": a["name"],
|
|
464
464
|
"icon": a["icon"],
|
|
465
|
+
"method": a["method"],
|
|
466
|
+
"confirm": a["confirm"],
|
|
465
467
|
}
|
|
466
468
|
for a in (
|
|
467
469
|
rct.child_crud_class.list_actions if rct.child_crud_class else []
|
|
@@ -646,6 +648,8 @@ class RelatedCrudTab:
|
|
|
646
648
|
),
|
|
647
649
|
"name": _ea["name"],
|
|
648
650
|
"icon": _ea["icon"],
|
|
651
|
+
"method": _ea["method"],
|
|
652
|
+
"confirm": _ea["confirm"],
|
|
649
653
|
}
|
|
650
654
|
)
|
|
651
655
|
return render_template(
|
|
@@ -15,7 +15,7 @@ class DisplayContext:
|
|
|
15
15
|
``"grid"`` (a data grid cell, which is plain text only).
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
__slots__ = ("
|
|
18
|
+
__slots__ = ("field", "name", "row", "surface")
|
|
19
19
|
|
|
20
20
|
def __init__(self, row, name, field, surface):
|
|
21
21
|
self.row = row
|
|
@@ -48,7 +48,7 @@ class SchemaField:
|
|
|
48
48
|
self.placeholder = kwargs.get("placeholder", None)
|
|
49
49
|
self.help = kwargs.get("help", None)
|
|
50
50
|
# Display-only filter, ``fn(value, ctx)`` — see ``display_value``.
|
|
51
|
-
self.
|
|
51
|
+
self.display_filter = kwargs.get("display_filter", None)
|
|
52
52
|
self.kwargs = kwargs
|
|
53
53
|
matches = kwargs.get("matches", None)
|
|
54
54
|
self._matches_fn = None
|
|
@@ -92,9 +92,9 @@ class SchemaField:
|
|
|
92
92
|
"""
|
|
93
93
|
return getattr(row, field)
|
|
94
94
|
|
|
95
|
-
def
|
|
96
|
-
if self.
|
|
97
|
-
return self.
|
|
95
|
+
def _resolve_display_filter(self):
|
|
96
|
+
if self.display_filter is not None:
|
|
97
|
+
return self.display_filter
|
|
98
98
|
from flask import has_app_context, current_app
|
|
99
99
|
|
|
100
100
|
if has_app_context():
|
|
@@ -111,13 +111,13 @@ class SchemaField:
|
|
|
111
111
|
"""
|
|
112
112
|
if type(self).display_value is not SchemaField.display_value:
|
|
113
113
|
return True
|
|
114
|
-
return self.
|
|
114
|
+
return self._resolve_display_filter() is not None
|
|
115
115
|
|
|
116
116
|
def display_value(self, field, row, surface="list"):
|
|
117
117
|
"""The value as it is shown — never typed — in lists, related tabs,
|
|
118
118
|
read-only views and grid cells.
|
|
119
119
|
|
|
120
|
-
Resolved, most specific first: the field's ``
|
|
120
|
+
Resolved, most specific first: the field's ``display_filter=`` callable, the
|
|
121
121
|
app's ``CONSTRUCT_DISPLAY_FILTERS[field_type]``, then ``format_value``
|
|
122
122
|
unchanged. A filter is called as ``fn(value, ctx)`` with the
|
|
123
123
|
``format_value`` result and a :class:`DisplayContext`. It may return
|
|
@@ -125,7 +125,7 @@ class SchemaField:
|
|
|
125
125
|
Subclasses may override this for full control.
|
|
126
126
|
"""
|
|
127
127
|
value = self.format_value(field, row)
|
|
128
|
-
fn = self.
|
|
128
|
+
fn = self._resolve_display_filter()
|
|
129
129
|
if fn is None:
|
|
130
130
|
return value
|
|
131
131
|
return fn(value, DisplayContext(row, field, self, surface))
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/css/whitelabel.css
RENAMED
|
@@ -886,6 +886,31 @@ a:hover {
|
|
|
886
886
|
color: var(--fcu-danger-fg);
|
|
887
887
|
}
|
|
888
888
|
|
|
889
|
+
/* @edit_action / @list_action controls (crud/_actions.html). A POST action
|
|
890
|
+
is a <form> around a <button>; the form must not break the row/header
|
|
891
|
+
flex layout, and the button must look like the GET action's link. */
|
|
892
|
+
.fcu-action-form {
|
|
893
|
+
display: inline-flex;
|
|
894
|
+
align-items: center;
|
|
895
|
+
margin: 0;
|
|
896
|
+
}
|
|
897
|
+
/* Bare header icon (edit/view page header). */
|
|
898
|
+
.fcu-icon-action {
|
|
899
|
+
display: inline-flex;
|
|
900
|
+
align-items: center;
|
|
901
|
+
padding: 4px;
|
|
902
|
+
border: none;
|
|
903
|
+
background: transparent;
|
|
904
|
+
color: var(--fcu-text-muted);
|
|
905
|
+
font: inherit;
|
|
906
|
+
text-decoration: none;
|
|
907
|
+
cursor: pointer;
|
|
908
|
+
}
|
|
909
|
+
.fcu-icon-action:hover,
|
|
910
|
+
.fcu-icon-action:focus-visible {
|
|
911
|
+
color: var(--fcu-primary);
|
|
912
|
+
}
|
|
913
|
+
|
|
889
914
|
/* Picker result rows. The hover tint was an inline handler; as CSS it also
|
|
890
915
|
applies on keyboard focus. The `.active` roving highlight (above) wins. */
|
|
891
916
|
.fcu-dropdown-item:hover,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{# One @edit_action / @list_action control.
|
|
2
|
+
|
|
3
|
+
A GET action is a link; a POST action is a small form carrying the CSRF
|
|
4
|
+
token, so it can change state safely and ask for confirmation first
|
|
5
|
+
(up-confirm, only allowed on POST actions). Both look the same.
|
|
6
|
+
|
|
7
|
+
variant: "button" (labelled .fcu-btn), "icon" (bare header icon) or
|
|
8
|
+
"row" (list row icon).
|
|
9
|
+
target: Unpoly target. A GET link is only followed by Unpoly when one is
|
|
10
|
+
given; a POST form falls back to #main-content.
|
|
11
|
+
history: carry up-history="true" (RCRUD tab content).
|
|
12
|
+
next: optional return URL, posted as "next" for the handler. #}
|
|
13
|
+
{% macro action_control(construct, action, href, variant="button", target=none, history=false, next=none) %}
|
|
14
|
+
{%- set label = construct.t(action.name) -%}
|
|
15
|
+
{%- set cls = {"button": "fcu-btn", "icon": "fcu-icon-action", "row": "fcu-row-action"}[variant] -%}
|
|
16
|
+
{%- if action.method == "post" -%}
|
|
17
|
+
{# nosemgrep: django-no-csrf-token — Flask app; CSRF is handled by {{ csrf_field() }} below, not Django's {% csrf_token %}. #}
|
|
18
|
+
<form method="post" action="{{ href }}" class="fcu-action-form"
|
|
19
|
+
up-target="{{ target or '#main-content' }}"
|
|
20
|
+
{%- if history %} up-history="true"{% endif %}
|
|
21
|
+
{%- if action.confirm %} up-confirm="{{ construct.t(action.confirm) }}"{% endif %}>
|
|
22
|
+
{{ csrf_field() }}
|
|
23
|
+
{%- if next %}
|
|
24
|
+
<input type="hidden" name="next" value="{{ next }}">
|
|
25
|
+
{%- endif %}
|
|
26
|
+
<button type="submit" class="{{ cls }}"{% if variant != "button" %} title="{{ label }}"{% endif %}>
|
|
27
|
+
{{- _action_content(action, label, variant) -}}
|
|
28
|
+
</button>
|
|
29
|
+
</form>
|
|
30
|
+
{%- else -%}
|
|
31
|
+
<a href="{{ href }}" class="{{ cls }}"
|
|
32
|
+
{%- if variant != "button" %} title="{{ label }}"{% endif %}
|
|
33
|
+
{%- if target %} up-follow up-target="{{ target }}"{% endif %}
|
|
34
|
+
{%- if history %} up-history="true"{% endif %}>
|
|
35
|
+
{{- _action_content(action, label, variant) -}}
|
|
36
|
+
</a>
|
|
37
|
+
{%- endif -%}
|
|
38
|
+
{% endmacro %}
|
|
39
|
+
|
|
40
|
+
{% macro _action_content(action, label, variant) -%}
|
|
41
|
+
{%- if variant == "button" -%}
|
|
42
|
+
{{ icon(action.icon, size="sm") }} {{ label }}
|
|
43
|
+
{%- else -%}
|
|
44
|
+
{{ icon(action.icon, label=label) }}
|
|
45
|
+
{%- endif -%}
|
|
46
|
+
{%- endmacro %}
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/crud/edit.html
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{% extends "structure/base.html" %}
|
|
2
2
|
{% from 'crud/_macros.html' import render_field, render_form_errors, render_layout %}
|
|
3
|
+
{% from 'crud/_actions.html' import action_control %}
|
|
3
4
|
{% block title %}{{ construct.compose_title(construct.t("crud-edit-rec", {'recname': construct.t(view.name, {'count': 1})})) }}{% endblock %}
|
|
4
5
|
{# This view renders its own visible <h1>, so suppress the layout default. #}
|
|
5
6
|
{% block page_heading %}{% endblock %}
|
|
@@ -38,12 +39,7 @@
|
|
|
38
39
|
{% if edit_actions %}
|
|
39
40
|
<div style="display: flex; gap: 8px; margin-bottom: 16px;">
|
|
40
41
|
{% for action in edit_actions %}
|
|
41
|
-
|
|
42
|
-
class="fcu-btn"
|
|
43
|
-
up-follow
|
|
44
|
-
up-target="#main-content">
|
|
45
|
-
{{ icon(action.icon, size="sm") }} {{ construct.t(action.name) }}
|
|
46
|
-
</a>
|
|
42
|
+
{{ action_control(construct, action, url_for(view.endpoint + '.' + action.endpoint, id=data[primary_key]), "button", target="#main-content") }}
|
|
47
43
|
{% endfor %}
|
|
48
44
|
</div>
|
|
49
45
|
{% endif %}
|
|
@@ -81,13 +77,7 @@
|
|
|
81
77
|
{% if edit_actions %}
|
|
82
78
|
<div style="display: flex; gap: 8px;">
|
|
83
79
|
{% for action in edit_actions %}
|
|
84
|
-
|
|
85
|
-
style="color: var(--fcu-text-muted); text-decoration: none; display: inline-flex; align-items: center; padding: 4px;"
|
|
86
|
-
title="{{ construct.t(action.name) }}"
|
|
87
|
-
up-follow
|
|
88
|
-
up-target="#main-content">
|
|
89
|
-
{{ icon(action.icon, label=construct.t(action.name)) }}
|
|
90
|
-
</a>
|
|
80
|
+
{{ action_control(construct, action, url_for(view.endpoint + '.' + action.endpoint, id=data[primary_key]), "icon", target="#main-content") }}
|
|
91
81
|
{% endfor %}
|
|
92
82
|
</div>
|
|
93
83
|
{% endif %}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{% extends "structure/base.html" %}
|
|
2
2
|
{% from 'crud/_macros.html' import shown %}
|
|
3
|
+
{% from 'crud/_actions.html' import action_control %}
|
|
3
4
|
{% block title %}{{ construct.compose_title(construct.t(view.name)) }}{% endblock %}
|
|
4
5
|
{# This view renders its own visible <h1>, so suppress the layout default. #}
|
|
5
6
|
{% block page_heading %}{% endblock %}
|
|
@@ -179,11 +180,7 @@
|
|
|
179
180
|
{% endif %}
|
|
180
181
|
{% if list_actions %}
|
|
181
182
|
{% for action in list_actions %}
|
|
182
|
-
|
|
183
|
-
class="fcu-row-action"
|
|
184
|
-
title="{{ construct.t(action.name) }}">
|
|
185
|
-
{{ icon(action.icon, label=construct.t(action.name)) }}
|
|
186
|
-
</a>
|
|
183
|
+
{{ action_control(construct, action, url_for(view.endpoint + '.' + action.endpoint, id=row[primary_key]), "row", next=return_here) }}
|
|
187
184
|
{% endfor %}
|
|
188
185
|
{% endif %}
|
|
189
186
|
{# nosemgrep: django-no-csrf-token — Flask app; CSRF is handled by {{ csrf_field() }} below, not Django's {% csrf_token %}. #}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{% extends "crud/tab_view.html" %}
|
|
2
2
|
{% from 'crud/_macros.html' import render_field, render_form_errors, render_layout, render_newrel_panel, field_help, error_attrs %}
|
|
3
|
+
{% from 'crud/_actions.html' import action_control %}
|
|
3
4
|
|
|
4
5
|
{#
|
|
5
6
|
render_child_field: renders a child form field without needing the parent
|
|
@@ -91,14 +92,7 @@
|
|
|
91
92
|
{% if edit_actions %}
|
|
92
93
|
<div style="display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;">
|
|
93
94
|
{% for action in edit_actions %}
|
|
94
|
-
|
|
95
|
-
class="fcu-btn"
|
|
96
|
-
up-follow
|
|
97
|
-
up-target="{{ content_target }}"
|
|
98
|
-
up-history="true">
|
|
99
|
-
{{ icon(action.icon, size="sm") }}
|
|
100
|
-
{{ construct.t(action.name) }}
|
|
101
|
-
</a>
|
|
95
|
+
{{ action_control(construct, action, action.href, "button", target=content_target, history=true) }}
|
|
102
96
|
{% endfor %}
|
|
103
97
|
</div>
|
|
104
98
|
{% endif %}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{% extends "crud/tab_view.html" %}
|
|
2
2
|
{% from 'crud/_macros.html' import shown %}
|
|
3
|
+
{% from 'crud/_actions.html' import action_control %}
|
|
3
4
|
{% block tab_content %}
|
|
4
5
|
{%- set is_advanced_filter = request.args.get('advanced_filter') if filter_enabled else none -%}
|
|
5
6
|
{%- set tab_list_url = url_for(view.endpoint + '.' + list_ep, id=parent_id) -%}
|
|
@@ -191,14 +192,7 @@
|
|
|
191
192
|
</a>
|
|
192
193
|
{% endif %}
|
|
193
194
|
{% for action in list_actions %}
|
|
194
|
-
|
|
195
|
-
class="fcu-row-action"
|
|
196
|
-
title="{{ construct.t(action.name) }}"
|
|
197
|
-
up-follow
|
|
198
|
-
up-target="{{ content_target }}"
|
|
199
|
-
up-history="true">
|
|
200
|
-
{{ icon(action.icon, label=construct.t(action.name)) }}
|
|
201
|
-
</a>
|
|
195
|
+
{{ action_control(construct, action, url_for(view.endpoint + '.' + action.endpoint, id=parent_id, child_id=row[primary_key]), "row", target=content_target, history=true) }}
|
|
202
196
|
{% endfor %}
|
|
203
197
|
{% if rct.permits('delete', construct, row) %}
|
|
204
198
|
{# nosemgrep: django-no-csrf-token — Flask app; CSRF is handled by {{ csrf_field() }} below, not Django's {% csrf_token %}. #}
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/templates/crud/view.html
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{% extends "structure/base.html" %}
|
|
2
2
|
{% from 'crud/_macros.html' import render_field, render_layout %}
|
|
3
|
+
{% from 'crud/_actions.html' import action_control %}
|
|
3
4
|
{% block title %}{{ construct.compose_title(construct.t("crud-view-rec", {'recname': construct.t(view.name, {'count': 1})})) }}{% endblock %}
|
|
4
5
|
{# This view renders its own visible <h1>, so suppress the layout default. #}
|
|
5
6
|
{% block page_heading %}{% endblock %}
|
|
@@ -22,13 +23,7 @@
|
|
|
22
23
|
{% if edit_actions %}
|
|
23
24
|
<div style="display: flex; gap: 8px;">
|
|
24
25
|
{% for action in edit_actions %}
|
|
25
|
-
|
|
26
|
-
style="color: var(--fcu-text-muted); text-decoration: none; display: inline-flex; align-items: center; padding: 4px;"
|
|
27
|
-
title="{{ construct.t(action.name) }}"
|
|
28
|
-
up-follow
|
|
29
|
-
up-target="#main-content">
|
|
30
|
-
{{ icon(action.icon, label=construct.t(action.name)) }}
|
|
31
|
-
</a>
|
|
26
|
+
{{ action_control(construct, action, url_for(view.endpoint + '.' + action.endpoint, id=data[primary_key]), "icon", target="#main-content") }}
|
|
32
27
|
{% endfor %}
|
|
33
28
|
</div>
|
|
34
29
|
{% endif %}
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui.egg-info/SOURCES.txt
RENAMED
|
@@ -98,6 +98,7 @@ flask_construct_ui/templates/components/table.html
|
|
|
98
98
|
flask_construct_ui/templates/components/tabs.html
|
|
99
99
|
flask_construct_ui/templates/components/text.html
|
|
100
100
|
flask_construct_ui/templates/components/vertical_layout.html
|
|
101
|
+
flask_construct_ui/templates/crud/_actions.html
|
|
101
102
|
flask_construct_ui/templates/crud/_macros.html
|
|
102
103
|
flask_construct_ui/templates/crud/_many_related_options.html
|
|
103
104
|
flask_construct_ui/templates/crud/_related_options.html
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/__init__.py
RENAMED
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/calendar.py
RENAMED
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/chart.py
RENAMED
|
File without changes
|
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/content.py
RENAMED
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/core.py
RENAMED
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/grid.py
RENAMED
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/kanban.py
RENAMED
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/layout.py
RENAMED
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/live.py
RENAMED
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/period.py
RENAMED
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/components/pivot.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/data_sqlalchemy.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/css/grid.css
RENAMED
|
File without changes
|
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/css/unpoly.min.css
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/js/kanban-dnd.js
RENAMED
|
File without changes
|
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui/static/js/unpoly.min.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui.egg-info/requires.txt
RENAMED
|
File without changes
|
{flask_construct_ui-0.12.2 → flask_construct_ui-0.13.0}/flask_construct_ui.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|