backports murph-skeleton
This commit is contained in:
parent
508e0bf26e
commit
b76b9123e5
|
@ -13,6 +13,7 @@ class CrudConfiguration
|
||||||
{
|
{
|
||||||
protected array $pageTitles = [];
|
protected array $pageTitles = [];
|
||||||
protected array $pageRoutes = [];
|
protected array $pageRoutes = [];
|
||||||
|
protected array $pageRouteParams = [];
|
||||||
protected array $actions = [];
|
protected array $actions = [];
|
||||||
protected array $batchActions = [];
|
protected array $batchActions = [];
|
||||||
protected array $actionTitles = [];
|
protected array $actionTitles = [];
|
||||||
|
@ -67,6 +68,18 @@ class CrudConfiguration
|
||||||
return $this->pageRoutes[$page];
|
return $this->pageRoutes[$page];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setPageRouteParams(string $page, array $params): self
|
||||||
|
{
|
||||||
|
$this->pageRouteParams[$page] = $params;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPageRouteParams(string $page): array
|
||||||
|
{
|
||||||
|
return $this->pageRouteParams[$page] ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
/* -- */
|
/* -- */
|
||||||
|
|
||||||
public function setForm(string $context, string $form, array $options = []): self
|
public function setForm(string $context, string $form, array $options = []): self
|
||||||
|
|
|
@ -53,7 +53,7 @@ class Page implements EntityInterface
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=255, nullable=true)
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
*/
|
*/
|
||||||
protected $metaDescrition;
|
protected $metaDescription;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=255, nullable=true)
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
|
@ -192,14 +192,14 @@ class Page implements EntityInterface
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMetaDescrition(): ?string
|
public function getMetaDescription(): ?string
|
||||||
{
|
{
|
||||||
return $this->metaDescrition;
|
return $this->metaDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMetaDescrition(?string $metaDescrition): self
|
public function setMetaDescription(?string $metaDescription): self
|
||||||
{
|
{
|
||||||
$this->metaDescrition = $metaDescrition;
|
$this->metaDescription = $metaDescription;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class PageType extends AbstractType
|
||||||
);
|
);
|
||||||
|
|
||||||
$builder->add(
|
$builder->add(
|
||||||
'metaDescrition',
|
'metaDescription',
|
||||||
TextType::class,
|
TextType::class,
|
||||||
[
|
[
|
||||||
'label' => 'Description',
|
'label' => 'Description',
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
{% for locale in configuration.locales %}
|
{% for locale in configuration.locales %}
|
||||||
<div class="tab-pane {% if loop.first %}show active{% endif %}" id="form-locale-{{ loop.index }}">
|
<div class="tab-pane {% if loop.first %}show active{% endif %}" id="form-locale-{{ loop.index }}">
|
||||||
{% for item in item.children[locale] %}
|
{% for item in form.children[locale] %}
|
||||||
{% if not item.isRendered %}
|
{% if not item.isRendered %}
|
||||||
{% set doRender = true %}
|
{% set doRender = true %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -18,14 +18,14 @@
|
||||||
{% block header_actions_before %}{% endblock %}
|
{% block header_actions_before %}{% endblock %}
|
||||||
|
|
||||||
{% if configuration.action(context, 'back', true) %}
|
{% if configuration.action(context, 'back', true) %}
|
||||||
<a href="{{ path(configuration.pageRoute('index')) }}" class="btn btn-light">
|
<a href="{{ path(configuration.pageRoute('index'), configuration.pageRouteParams('index')) }}" class="btn btn-light">
|
||||||
<span class="fa fa-list pr-1"></span>
|
<span class="fa fa-list pr-1"></span>
|
||||||
{{ configuration.actionTitle(context, 'back', 'Back to the list')|trans }}
|
{{ configuration.actionTitle(context, 'back', 'Back to the list')|trans }}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if configuration.action(context, 'show', true) %}
|
{% if configuration.action(context, 'show', true) %}
|
||||||
<a href="{{ path(configuration.pageRoute('show'), {entity: entity.id}) }}" class="btn btn-secondary">
|
<a href="{{ path(configuration.pageRoute('show'), {entity: entity.id}|merge(configuration.pageRouteParams('show'))) }}" class="btn btn-secondary">
|
||||||
<span class="fa fa-eye pr-1"></span>
|
<span class="fa fa-eye pr-1"></span>
|
||||||
{{ configuration.actionTitle(context, 'show', 'Show')|trans|build_string(entity) }}
|
{{ configuration.actionTitle(context, 'show', 'Show')|trans|build_string(entity) }}
|
||||||
</a>
|
</a>
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% if configuration.action(context, 'delete', true) %}
|
{% if configuration.action(context, 'delete', true) %}
|
||||||
<form method="post" action="{{ path(configuration.pageRoute('delete'), {entity: entity.id}) }}" id="form-delete" data-form-confirm>
|
<form method="post" action="{{ path(configuration.pageRoute('delete'), {entity: entity.id}|merge(configuration.pageRouteParams('delete'))) }}" id="form-delete" data-form-confirm>
|
||||||
<input type="hidden" name="_method" value="DELETE">
|
<input type="hidden" name="_method" value="DELETE">
|
||||||
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ entity.id) }}">
|
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ entity.id) }}">
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<form action="{{ path(configuration.pageRoute('index')) }}" id="form-filters" method="GET">
|
<form action="{{ path(configuration.pageRoute('index'), configuration.pageRouteParams('index')) }}" id="form-filters" method="GET">
|
||||||
{{ form_widget(form) }}
|
{{ form_widget(form) }}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a href="{{ path(configuration.pageRoute('index'), {(form.vars.name): 0}) }}" class="btn btn-secondary">{{ 'Reset'|trans }}</a>
|
<a href="{{ path(configuration.pageRoute('index'), {(form.vars.name): 0}|merge(configuration.pageRouteParams('index'))) }}" class="btn btn-secondary">{{ 'Reset'|trans }}</a>
|
||||||
<button type="submit" form="form-filters" class="btn btn-primary">{{ 'Filter'|trans }}</button>
|
<button type="submit" form="form-filters" class="btn btn-primary">{{ 'Filter'|trans }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
{% block header_actions_before %}{% endblock %}
|
{% block header_actions_before %}{% endblock %}
|
||||||
|
|
||||||
{% if configuration.action(context, 'new', true) %}
|
{% if configuration.action(context, 'new', true) %}
|
||||||
<a href="{{ path(configuration.pageRoute('new')) }}" class="btn btn-primary">
|
<a href="{{ path(configuration.pageRoute('new'), configuration.pageRouteParams('new')) }}" class="btn btn-primary">
|
||||||
<span class="fa fa-plus pr-1"></span>
|
<span class="fa fa-plus pr-1"></span>
|
||||||
{{ configuration.actionTitle(context, 'new', 'New')|trans }}
|
{{ configuration.actionTitle(context, 'new', 'New')|trans }}
|
||||||
</a>
|
</a>
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
{% if filters.show %}
|
{% if filters.show %}
|
||||||
<div class="row pb-3">
|
<div class="row pb-3">
|
||||||
<div class="col-auto ml-auto {% if pager.getPaginationData.pageCount > 1 %}mr-3{% endif %}">
|
<div class="col-auto ml-auto {% if pager.getPaginationData.pageCount > 1 %}mr-3{% endif %}">
|
||||||
<button data-modal="{{ path(configuration.pageRoute('filter')) }}" class="btn btn-sm btn-secondary">
|
<button data-modal="{{ path(configuration.pageRoute('filter'), configuration.pageRouteParams('filter')) }}" class="btn btn-sm btn-secondary">
|
||||||
{{ 'Filter'|trans }} {% if not filters.isEmpty %}({{ 'yes'|trans }}){% endif %}
|
{{ 'Filter'|trans }} {% if not filters.isEmpty %}({{ 'yes'|trans }}){% endif %}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -113,12 +113,12 @@
|
||||||
{% set url = path(configuration.getPageRoute(context), {
|
{% set url = path(configuration.getPageRoute(context), {
|
||||||
_sort: config.options.sort[0],
|
_sort: config.options.sort[0],
|
||||||
_sort_direction: newDirection,
|
_sort_direction: newDirection,
|
||||||
}) %}
|
}|merge(configuration.pageRouteParams(context))) %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set url = path(configuration.getPageRoute(context), {
|
{% set url = path(configuration.getPageRoute(context), {
|
||||||
_sort: config.options.sort[0],
|
_sort: config.options.sort[0],
|
||||||
_sort_direction: 'asc',
|
_sort_direction: 'asc',
|
||||||
}) %}
|
}|merge(configuration.pageRouteParams(context))) %}
|
||||||
|
|
||||||
{% set icon = null %}
|
{% set icon = null %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -155,7 +155,7 @@
|
||||||
_token: csrf_token('sort'),
|
_token: csrf_token('sort'),
|
||||||
page: pager.currentPageNumber,
|
page: pager.currentPageNumber,
|
||||||
context: context,
|
context: context,
|
||||||
}
|
}|merge(configuration.pageRouteParams('sort'))
|
||||||
) ~ '"' %}
|
) ~ '"' %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set dataSortable = '' %}
|
{% set dataSortable = '' %}
|
||||||
|
@ -173,9 +173,9 @@
|
||||||
{% block list_item %}
|
{% block list_item %}
|
||||||
{%- set dbClick %}
|
{%- set dbClick %}
|
||||||
{% if configuration.action(context, 'show', true) %}
|
{% if configuration.action(context, 'show', true) %}
|
||||||
{{ path(configuration.pageRoute('show'), {entity: item.id}) }}
|
{{ path(configuration.pageRoute('show'), {entity: item.id}|merge(configuration.pageRouteParams('show'))) }}
|
||||||
{% elseif configuration.action(context, 'edit', true) %}
|
{% elseif configuration.action(context, 'edit', true) %}
|
||||||
{{ path(configuration.pageRoute('edit'), {entity: item.id}) }}
|
{{ path(configuration.pageRoute('edit'), {entity: item.id}|merge(configuration.pageRouteParams('show'))) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endset -%}
|
{% endset -%}
|
||||||
|
|
||||||
|
@ -209,13 +209,13 @@
|
||||||
{% block list_item_actions_before %}{% endblock %}
|
{% block list_item_actions_before %}{% endblock %}
|
||||||
|
|
||||||
{% if configuration.action(context, 'show', true) %}
|
{% if configuration.action(context, 'show', true) %}
|
||||||
<a href="{{ path(configuration.pageRoute('show'), {entity: item.id}) }}" class="btn btn-sm btn-secondary mr-1">
|
<a href="{{ path(configuration.pageRoute('show'), {entity: item.id}|merge(configuration.pageRouteParams('show'))) }}" class="btn btn-sm btn-secondary mr-1">
|
||||||
<span class="fa fa-eye"></span>
|
<span class="fa fa-eye"></span>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if configuration.action(context, 'edit', true) %}
|
{% if configuration.action(context, 'edit', true) %}
|
||||||
<a href="{{ path(configuration.pageRoute('edit'), {entity: item.id}) }}" class="btn btn-sm btn-primary mr-1">
|
<a href="{{ path(configuration.pageRoute('edit'), {entity: item.id}|merge(configuration.pageRouteParams('edit'))) }}" class="btn btn-sm btn-primary mr-1">
|
||||||
<span class="fa fa-edit"></span>
|
<span class="fa fa-edit"></span>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -225,7 +225,7 @@
|
||||||
<span class="fa fa-trash"></span>
|
<span class="fa fa-trash"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<form method="post" action="{{ path(configuration.pageRoute('delete'), {entity: item.id}) }}" id="form-delete-{{ item.id }}" data-form-confirm>
|
<form method="post" action="{{ path(configuration.pageRoute('delete'), {entity: item.id}|merge(configuration.pageRouteParams('delete'))) }}" id="form-delete-{{ item.id }}" data-form-confirm>
|
||||||
<input type="hidden" name="_method" value="DELETE">
|
<input type="hidden" name="_method" value="DELETE">
|
||||||
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ item.id) }}">
|
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ item.id) }}">
|
||||||
</form>
|
</form>
|
||||||
|
@ -256,7 +256,7 @@
|
||||||
|
|
||||||
{% if configuration.hasBatchAction(context) %}
|
{% if configuration.hasBatchAction(context) %}
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<form class="form-inline" action="{{ path(configuration.pageRoute('batch'), {page: pager.currentPageNumber}) }}" id="form-batch" method="POST">
|
<form class="form-inline" action="{{ path(configuration.pageRoute('batch'), {page: pager.currentPageNumber}|merge(configuration.pageRouteParams('batch'))) }}" id="form-batch" method="POST">
|
||||||
<select class="form-control my-1 mr-sm-2" name="batch[target]">
|
<select class="form-control my-1 mr-sm-2" name="batch[target]">
|
||||||
<option value="selection">{{ 'For selection'|trans }}</option>
|
<option value="selection">{{ 'For selection'|trans }}</option>
|
||||||
<option value="all">{{ 'For all items'|trans }}</option>
|
<option value="all">{{ 'For all items'|trans }}</option>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
{% block header_actions_before %}{% endblock %}
|
{% block header_actions_before %}{% endblock %}
|
||||||
|
|
||||||
{% if configuration.action(context, 'back', true) %}
|
{% if configuration.action(context, 'back', true) %}
|
||||||
<a href="{{ path(configuration.pageRoute('index')) }}" class="btn btn-light">
|
<a href="{{ path(configuration.pageRoute('index'), configuration.pageRouteParams('index')) }}" class="btn btn-light">
|
||||||
<span class="fa fa-list pr-1"></span>
|
<span class="fa fa-list pr-1"></span>
|
||||||
{{ configuration.actionTitle(context, 'back', 'Back to the list')|trans }}
|
{{ configuration.actionTitle(context, 'back', 'Back to the list')|trans }}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -146,18 +146,18 @@
|
||||||
<div class="p-2 text-center">
|
<div class="p-2 text-center">
|
||||||
<span class="form-filepicker-container">
|
<span class="form-filepicker-container">
|
||||||
<input class="form-control form-filepicker-picker mb-3" data-target="{{ id }}" readonly type="text" value="{{ value }}">
|
<input class="form-control form-filepicker-picker mb-3" data-target="{{ id }}" readonly type="text" value="{{ value }}">
|
||||||
<span class="btn btn-primary form-filepicker-picker" data-target="{{ id }}">
|
<span class="btn btn-sm btn-primary form-filepicker-picker" data-target="{{ id }}">
|
||||||
{{ 'Choose'|trans }}
|
{{ 'Choose'|trans }}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{% if value %}
|
{% if value %}
|
||||||
{% if value.pathname is defined %}
|
{% if value.pathname is defined %}
|
||||||
<a class="btn btn-success ml-1" href="{{ asset(value.pathname) }}" target="_blank">
|
<a class="btn btn-sm btn-success ml-1" href="{{ asset(value.pathname) }}" target="_blank">
|
||||||
{{ 'Download'|trans }}
|
{{ 'Download'|trans }}
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="btn btn-success ml-1" href="{{ asset(value) }}" target="_blank">
|
<a class="btn btn-sm btn-success ml-1" href="{{ asset(value) }}" target="_blank">
|
||||||
{{ 'Download'|trans }}
|
{{ 'Download'|trans }}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% set formMetas %}
|
{% set formMetas %}
|
||||||
{% for item in ['metaTitle', 'metaDescrition'] %}
|
{% for item in ['metaTitle', 'metaDescription'] %}
|
||||||
{{ form_row(form[item]) }}
|
{{ form_row(form[item]) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endset %}
|
{% endset %}
|
||||||
|
|
Loading…
Reference in New Issue