From 740110f87f6a44a980746255478978007bd997df Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 14 Jan 2025 18:15:22 -0600 Subject: [PATCH 1/3] fix: add `click_handler` attr for GridAction sometimes caller just needs to do something unique, so let them --- src/wuttaweb/grids/base.py | 12 ++++++++++++ src/wuttaweb/templates/grids/vue_template.mako | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/wuttaweb/grids/base.py b/src/wuttaweb/grids/base.py index e65a22e..33269f2 100644 --- a/src/wuttaweb/grids/base.py +++ b/src/wuttaweb/grids/base.py @@ -2284,6 +2284,16 @@ class GridAction: Optional ``target`` attribute for the ```` tag. + .. attribute:: click_handler + + Optional JS click handler for the action. This value will be + rendered as-is within the final grid template, hence the JS + string must be callable code. Note that ``props.row`` will be + available in the calling context, so a couple of examples: + + * ``deleteThisThing(props.row)`` + * ``$emit('do-something', props.row)`` + .. attribute:: icon Name of icon to be shown for the action link. @@ -2302,6 +2312,7 @@ class GridAction: label=None, url=None, target=None, + click_handler=None, icon=None, link_class=None, ): @@ -2311,6 +2322,7 @@ class GridAction: self.key = key self.url = url self.target = target + self.click_handler = click_handler self.label = label or self.app.make_title(key) self.icon = icon or key self.link_class = link_class or '' diff --git a/src/wuttaweb/templates/grids/vue_template.mako b/src/wuttaweb/templates/grids/vue_template.mako index ac0a2a9..ba548cb 100644 --- a/src/wuttaweb/templates/grids/vue_template.mako +++ b/src/wuttaweb/templates/grids/vue_template.mako @@ -183,6 +183,9 @@ % if action.target: target="${action.target}" % endif + % if action.click_handler: + @click.prevent="${action.click_handler}" + % endif class="${action.link_class}"> ${action.render_icon_and_label()} From 0ddf4d2ab9fe0e2d6cdb819595bb2ca08a3f9516 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 14 Jan 2025 18:16:21 -0600 Subject: [PATCH 2/3] fix: add `render_grid_tag()` as separate def block for index templates sometimes caller needs to inject custom attrs to the grid tag --- src/wuttaweb/templates/master/index.mako | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wuttaweb/templates/master/index.mako b/src/wuttaweb/templates/master/index.mako index bf32c6f..fbc87a3 100644 --- a/src/wuttaweb/templates/master/index.mako +++ b/src/wuttaweb/templates/master/index.mako @@ -8,10 +8,14 @@ <%def name="page_content()"> % if grid is not Undefined: - ${grid.render_vue_tag()} + ${self.render_grid_tag()} % endif +<%def name="render_grid_tag()"> + ${grid.render_vue_tag()} + + <%def name="render_vue_templates()"> ${parent.render_vue_templates()} ${self.render_vue_template_grid()} From 3041e0118411704f245798809e26e10efb877e5b Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 14 Jan 2025 18:19:29 -0600 Subject: [PATCH 3/3] =?UTF-8?q?bump:=20version=200.20.2=20=E2=86=92=200.20?= =?UTF-8?q?.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 7 +++++++ pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc241e5..7b38913 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to wuttaweb will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## v0.20.3 (2025-01-14) + +### Fix + +- add `render_grid_tag()` as separate def block for index templates +- add `click_handler` attr for GridAction + ## v0.20.2 (2025-01-14) ### Fix diff --git a/pyproject.toml b/pyproject.toml index a7a756e..7798cb3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "WuttaWeb" -version = "0.20.2" +version = "0.20.3" description = "Web App for Wutta Framework" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@wuttaproject.org"}]