Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename value to control in the context of actions #163

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/Resources/views/themes/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -580,38 +580,38 @@

{# Action type templates #}

{% block action_value_icon %}{% endblock %}
{% block action_control_icon %}{% endblock %}

{% block action_value %}
{% if icon_attr %}{{ block('action_value_icon', theme, _context) }}{% endif %}
{% block action_control %}
{% if icon_attr %}{{ block('action_control_icon', theme, _context) }}{% endif %}
{{- label|trans(translation_parameters, translation_domain) -}}
{% endblock %}

{% block action_link_value %}
{% block action_link_control %}
{% set attr = { href, target }|filter(v => v != null)|merge(attr|default({})) %}

{% if batch %}
{% set attr = { 'data-kreyu--data-table-bundle--batch-target': 'identifierHolder' }|merge(attr) %}
{% endif %}

<a {% with { attr } %}{{- block('attributes') -}}{% endwith %}>
{% with { attr: {} } %}{{- block('action_value', theme, _context) -}}{% endwith %}
{% with { attr: {} } %}{{- block('action_control', theme, _context) -}}{% endwith %}
</a>
{% endblock %}

{% block action_button_value %}
{% block action_button_control %}
{% set attr = { href, target }|filter(v => v != null)|merge(attr|default({})) %}

{% if batch %}
{% set attr = { 'data-kreyu--data-table-bundle--batch-target': 'identifierHolder' }|merge(attr) %}
{% endif %}

<a {% with { attr } %}{{- block('attributes') -}}{% endwith %}>
{% with { attr: {} } %}{{- block('action_value', theme, _context) -}}{% endwith %}
{% with { attr: {} } %}{{- block('action_control', theme, _context) -}}{% endwith %}
</a>
{% endblock %}

{% block action_form_value %}
{% block action_form_control %}
{% set attr = { action, method: html_friendly_method }|merge(attr|default({})) %}

{% if batch %}
Expand All @@ -627,7 +627,7 @@
{% set button_tag = button_tag|default('button') %}

<{{ button_tag }} {% with { attr: { type: 'submit' }|merge(button_attr) } %}{{- block('attributes') -}}{% endwith %}>
{{- block('action_value', theme, _context) -}}
{{- block('action_control', theme, _context) -}}
</{{ button_tag }}>
</form>
{% endblock %}
Expand Down
10 changes: 5 additions & 5 deletions src/Resources/views/themes/bootstrap_5.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@
</li>
{% endblock %}

{% block action_value_icon %}
{% block action_control_icon %}
<i {% with { attr: icon_attr } %}{{ block('attributes') }}{% endwith %}></i>
{% endblock %}

Expand Down Expand Up @@ -642,13 +642,13 @@
</div>
{% endblock %}

{% block action_value %}
{% block action_control %}
<div class="d-inline-block" {{ block('attributes') }}>
{{ parent() }}
</div>
{% endblock %}

{% block action_link_value %}
{% block action_link_control %}
{% set attr = { class: 'text-decoration-none' ~ (label ? ' me-2' : '') }|merge(attr) %}

{% if confirmation %}
Expand All @@ -671,7 +671,7 @@
{{ parent() }}
{% endblock %}

{% block action_button_value %}
{% block action_button_control %}
{% set attr = {
class: 'btn btn-primary' ~ (icon_attr and label is same as false ? ' btn-icon' : ''),
}|merge(attr) %}
Expand All @@ -696,7 +696,7 @@
{{ parent() }}
{% endblock %}

{% block action_form_value %}
{% block action_form_control %}
{% set attr = { class: 'd-inline-block' }|merge(attr) %}

{% set button_attr = {
Expand Down
2 changes: 1 addition & 1 deletion src/Twig/DataTableExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public function renderAction(Environment $environment, ActionView $view, array $
environment: $environment,
dataTable: $this->getDecoratedDataTable($view->getDataTable(), $variables),
blockName: 'kreyu_data_table_action',
context: $this->getDecoratedViewContext($environment, $view, $variables, 'action', 'value'),
context: $this->getDecoratedViewContext($environment, $view, $variables, 'action', 'control'),
);
}

Expand Down
Loading