Browse Source

backports murph-skeleton

develop
Simon Vieille 2 weeks ago
parent
commit
b76b9123e5
  1. 13
      core/Crud/CrudConfiguration.php
  2. 10
      core/Entity/Site/Page/Page.php
  3. 2
      core/Form/Site/Page/PageType.php
  4. 2
      core/Resources/views/admin/crud/_form_translations.html.twig
  5. 6
      core/Resources/views/admin/crud/edit.html.twig
  6. 4
      core/Resources/views/admin/crud/filter.html.twig
  7. 22
      core/Resources/views/admin/crud/index.html.twig
  8. 2
      core/Resources/views/admin/crud/new.html.twig
  9. 6
      core/Resources/views/form/bootstrap_4_form_theme.html.twig
  10. 2
      core/Resources/views/site/page_admin/_form.html.twig

13
core/Crud/CrudConfiguration.php

@ -13,6 +13,7 @@ class CrudConfiguration
{
protected array $pageTitles = [];
protected array $pageRoutes = [];
protected array $pageRouteParams = [];
protected array $actions = [];
protected array $batchActions = [];
protected array $actionTitles = [];
@ -67,6 +68,18 @@ class CrudConfiguration
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

10
core/Entity/Site/Page/Page.php

@ -53,7 +53,7 @@ class Page implements EntityInterface
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $metaDescrition;
protected $metaDescription;
/**
* @ORM\Column(type="string", length=255, nullable=true)
@ -192,14 +192,14 @@ class Page implements EntityInterface
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;
}

2
core/Form/Site/Page/PageType.php

@ -44,7 +44,7 @@ class PageType extends AbstractType
);
$builder->add(
'metaDescrition',
'metaDescription',
TextType::class,
[
'label' => 'Description',

2
core/Resources/views/admin/crud/_form_translations.html.twig

@ -16,7 +16,7 @@
<div class="tab-content">
{% for locale in configuration.locales %}
<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 %}
{% set doRender = true %}
{% endif %}

6
core/Resources/views/admin/crud/edit.html.twig

@ -18,14 +18,14 @@
{% block header_actions_before %}{% endblock %}
{% 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>
{{ configuration.actionTitle(context, 'back', 'Back to the list')|trans }}
</a>
{% endif %}
{% 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>
{{ configuration.actionTitle(context, 'show', 'Show')|trans|build_string(entity) }}
</a>
@ -87,7 +87,7 @@
{% endblock %}
{% 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="_token" value="{{ csrf_token('delete' ~ entity.id) }}">
</form>

4
core/Resources/views/admin/crud/filter.html.twig

@ -9,12 +9,12 @@
</button>
</div>
<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>
</div>
<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>
</div>
</div>

22
core/Resources/views/admin/crud/index.html.twig

@ -30,7 +30,7 @@
{% block header_actions_before %}{% endblock %}
{% 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>
{{ configuration.actionTitle(context, 'new', 'New')|trans }}
</a>
@ -64,7 +64,7 @@
{% if filters.show %}
<div class="row pb-3">
<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 %}
</button>
</div>
@ -113,12 +113,12 @@
{% set url = path(configuration.getPageRoute(context), {
_sort: config.options.sort[0],
_sort_direction: newDirection,
}) %}
}|merge(configuration.pageRouteParams(context))) %}
{% else %}
{% set url = path(configuration.getPageRoute(context), {
_sort: config.options.sort[0],
_sort_direction: 'asc',
}) %}
}|merge(configuration.pageRouteParams(context))) %}
{% set icon = null %}
{% endif %}
@ -155,7 +155,7 @@
_token: csrf_token('sort'),
page: pager.currentPageNumber,
context: context,
}
}|merge(configuration.pageRouteParams('sort'))
) ~ '"' %}
{% else %}
{% set dataSortable = '' %}
@ -173,9 +173,9 @@
{% block list_item %}
{%- set dbClick %}
{% 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) %}
{{ path(configuration.pageRoute('edit'), {entity: item.id}) }}
{{ path(configuration.pageRoute('edit'), {entity: item.id}|merge(configuration.pageRouteParams('show'))) }}
{% endif %}
{% endset -%}
@ -209,13 +209,13 @@
{% block list_item_actions_before %}{% endblock %}
{% 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>
</a>
{% endif %}
{% 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>
</a>
{% endif %}
@ -225,7 +225,7 @@
<span class="fa fa-trash"></span>
</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="_token" value="{{ csrf_token('delete' ~ item.id) }}">
</form>
@ -256,7 +256,7 @@
{% if configuration.hasBatchAction(context) %}
<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]">
<option value="selection">{{ 'For selection'|trans }}</option>
<option value="all">{{ 'For all items'|trans }}</option>

2
core/Resources/views/admin/crud/new.html.twig

@ -18,7 +18,7 @@
{% block header_actions_before %}{% endblock %}
{% 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>
{{ configuration.actionTitle(context, 'back', 'Back to the list')|trans }}
</a>

6
core/Resources/views/form/bootstrap_4_form_theme.html.twig

@ -146,18 +146,18 @@
<div class="p-2 text-center">
<span class="form-filepicker-container">
<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 }}
</span>
</span>
{% if value %}
{% 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 }}
</a>
{% 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 }}
</a>
{% endif %}

2
core/Resources/views/site/page_admin/_form.html.twig

@ -1,5 +1,5 @@
{% set formMetas %}
{% for item in ['metaTitle', 'metaDescrition'] %}
{% for item in ['metaTitle', 'metaDescription'] %}
{{ form_row(form[item]) }}
{% endfor %}
{% endset %}

Loading…
Cancel
Save