From d3a0852c99edd9d6ff7d52fcc836febe5e041a22 Mon Sep 17 00:00:00 2001 From: davidspilka Date: Wed, 5 Oct 2022 17:35:00 +0200 Subject: [PATCH] Defining blocks for column actions and inline add/edit buttons - defining blocks for column actions and inline add/edit buttons - these blocks can be overwritten and custom render can be used (change order, grouping of buttons, etc.) --- src/templates/datagrid.latte | 46 ++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/templates/datagrid.latte b/src/templates/datagrid.latte index 3a70f59b..61f86891 100644 --- a/src/templates/datagrid.latte +++ b/src/templates/datagrid.latte @@ -270,8 +270,10 @@ {/foreach} - {input $filter['inline_edit']['cancel'], class => 'btn btn-xs btn-danger'} - {input $filter['inline_edit']['submit'], class => 'btn btn-xs btn-primary'} + {block inline-edit-buttons} + {input $filter['inline_edit']['cancel'], class => 'btn btn-xs btn-danger'} + {input $filter['inline_edit']['submit'], class => 'btn btn-xs btn-primary'} + {/block} {input $filter['inline_edit']['_id']} {input $filter['inline_edit']['_primary_where_column']} @@ -292,24 +294,26 @@ {$td->endTag()|noescape} {/foreach} - {foreach $actions as $key => $action} - {if $row->hasAction($key)} - {if $action->hasTemplate()} - {include $action->getTemplate(), item => $item, (expand) $action->getTemplateVariables(), row => $row} - {else} - {$action->render($row)|noescape} + {block col-actions} + {foreach $actions as $key => $action} + {if $row->hasAction($key)} + {if $action->hasTemplate()} + {include $action->getTemplate(), item => $item, (expand) $action->getTemplateVariables(), row => $row} + {else} + {$action->render($row)|noescape} + {/if} {/if} + {/foreach} + + + + {if $inlineEdit && $row->hasInlineEdit()} + {$inlineEdit->renderButton($row)|noescape} {/if} - {/foreach} - - - - {if $inlineEdit && $row->hasInlineEdit()} - {$inlineEdit->renderButton($row)|noescape} - {/if} - {if $itemsDetail && $itemsDetail->shouldBeRendered($row)} - {$itemsDetail->renderButton($row)|noescape} - {/if} + {if $itemsDetail && $itemsDetail->shouldBeRendered($row)} + {$itemsDetail->renderButton($row)|noescape} + {/if} + {/block} {/if} @@ -437,8 +441,10 @@ {/foreach} - {input $filter['inline_add']['cancel']} - {input $filter['inline_add']['submit']} + {block inline-add-buttons} + {input $filter['inline_add']['cancel']} + {input $filter['inline_add']['submit']} + {/block} {/if}