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"}] 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()} 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()}