fix: add click_handler
attr for GridAction
sometimes caller just needs to do something unique, so let them
This commit is contained in:
parent
51c456eb38
commit
740110f87f
|
@ -2284,6 +2284,16 @@ class GridAction:
|
||||||
|
|
||||||
Optional ``target`` attribute for the ``<a>`` tag.
|
Optional ``target`` attribute for the ``<a>`` 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
|
.. attribute:: icon
|
||||||
|
|
||||||
Name of icon to be shown for the action link.
|
Name of icon to be shown for the action link.
|
||||||
|
@ -2302,6 +2312,7 @@ class GridAction:
|
||||||
label=None,
|
label=None,
|
||||||
url=None,
|
url=None,
|
||||||
target=None,
|
target=None,
|
||||||
|
click_handler=None,
|
||||||
icon=None,
|
icon=None,
|
||||||
link_class=None,
|
link_class=None,
|
||||||
):
|
):
|
||||||
|
@ -2311,6 +2322,7 @@ class GridAction:
|
||||||
self.key = key
|
self.key = key
|
||||||
self.url = url
|
self.url = url
|
||||||
self.target = target
|
self.target = target
|
||||||
|
self.click_handler = click_handler
|
||||||
self.label = label or self.app.make_title(key)
|
self.label = label or self.app.make_title(key)
|
||||||
self.icon = icon or key
|
self.icon = icon or key
|
||||||
self.link_class = link_class or ''
|
self.link_class = link_class or ''
|
||||||
|
|
|
@ -183,6 +183,9 @@
|
||||||
% if action.target:
|
% if action.target:
|
||||||
target="${action.target}"
|
target="${action.target}"
|
||||||
% endif
|
% endif
|
||||||
|
% if action.click_handler:
|
||||||
|
@click.prevent="${action.click_handler}"
|
||||||
|
% endif
|
||||||
class="${action.link_class}">
|
class="${action.link_class}">
|
||||||
${action.render_icon_and_label()}
|
${action.render_icon_and_label()}
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Reference in a new issue