Compare commits

..

68 commits

Author SHA1 Message Date
ac3781f01c
Merge branch 'develop' 2026-03-09 10:44:05 +01:00
173dc17a89
doc: update changelog 2026-03-09 10:44:00 +01:00
5ba5e93d14
fix(crud/template): use default route params 2026-03-09 10:43:51 +01:00
005dddcea2
Merge branch 'develop' 2026-02-21 23:03:30 +01:00
7fbbad9909
fix(crud/navigation_setting): fix form action 2026-02-21 23:03:20 +01:00
0fb486a383
Merge branch 'develop' 2025-12-23 09:50:13 +01:00
0fa748fd35
fix(crud/index): fix row attribute value render 2025-12-23 09:49:59 +01:00
8a780be0b0
Merge branch 'develop' 2025-12-22 19:32:04 +01:00
2e2b0bce10
feat(repository): add RepositoryQuery::addCaseInsensitiveFilters()
feat(repository): add RepositoryQuery::addForcedFilterHandler()
2025-12-22 19:32:01 +01:00
f17969db04
Merge branch 'develop' 2025-12-22 19:30:33 +01:00
14465d4982
feat(repository): add RepositoryQuery::addCaseInsensitiveFilters()
feat(repository): add RepositoryQuery::addForcedFilterHandler()
2025-12-22 19:30:29 +01:00
d3e0ba7ca5
Merge branch 'develop' 2025-12-22 19:23:47 +01:00
5a01d76883
feat(repository): add RepositoryQuery::addCaseInsensitiveFilters()
feat(repository): add RepositoryQuery::addForcedFilterHandler()
2025-12-22 19:23:39 +01:00
bd5d900b82
Merge branch 'develop' 2025-12-22 17:38:59 +01:00
b1b01b202c
release v1.27.0 2025-12-22 17:38:53 +01:00
895de8a445
Merge branch 'develop' 2025-12-22 17:37:24 +01:00
19a78b9359
feat(crud/index): allow to define row attributes 2025-12-22 17:36:08 +01:00
784288ae1d
Merge branch 'develop' 2025-11-26 15:20:00 +01:00
799ae00730
feat(settings): allow to edit a setting in plain page 2025-11-26 15:19:47 +01:00
63c7ef3b46
Merge branch 'develop' 2025-11-20 11:46:28 +01:00
b609c2fb2e
fix(crud): use route params to redirect after a delation 2025-11-20 11:46:21 +01:00
e851deb17f
Merge branch 'develop' 2025-05-25 18:01:13 +02:00
ab7b15f2c0
feat(builder): allow to define allowed_widgets in form options 2025-05-25 18:00:58 +02:00
15aec91a51
Merge branch 'develop' 2025-05-20 19:30:44 +02:00
acf5255e4e
feat(builder): improve UI to add new block 2025-05-20 19:30:35 +02:00
42900d7e14
Merge branch 'develop' 2025-05-19 19:22:52 +02:00
eb5fd22c27
feat(builder): allow to add block between children 2025-05-19 19:22:47 +02:00
836e685fda
Merge branch 'develop' 2025-05-19 12:11:59 +02:00
22e596bed9
feat(collection): add delete_attr, add_attr options 2025-05-19 12:11:55 +02:00
8ac148b5c0
Merge branch 'develop' 2025-05-19 12:11:16 +02:00
46bde2bb2d
feat(collection): add delete_attr, add_attr options 2025-05-19 12:11:12 +02:00
f6d79ec6c2
Merge branch 'develop' 2025-05-19 12:08:57 +02:00
1f2f05a575
feat(collection): add delete_attr, add_attr options 2025-05-19 12:08:54 +02:00
b91438a647
Merge branch 'develop' 2025-05-19 12:08:01 +02:00
cef0179fa3
feat(collection): add delete_attr, add_attr options 2025-05-19 12:07:52 +02:00
8785b2dd88
Merge branch 'develop' 2025-05-19 12:04:16 +02:00
6da7ad5f30
feat(collection): add delete_attr, add_attr options 2025-05-19 12:04:10 +02:00
318ba4fded
Merge branch 'develop' 2025-05-19 12:02:21 +02:00
b61cdbf322
feat(collection): add delete_attr, add_attr options 2025-05-19 12:01:50 +02:00
978fff3cdb
Merge branch 'develop' 2025-05-17 12:06:29 +02:00
4e8d96888d
feat(builder): add more types for input setting 2025-05-17 12:06:05 +02:00
014e4b824f
Merge branch 'develop' 2025-05-16 16:54:29 +02:00
6c8363a654
add option removeItemButton: true when applying choices.js 2025-05-16 16:54:24 +02:00
82da6c6cf4
Merge branch 'develop' 2025-03-17 11:30:39 +01:00
850098d966
crud: remove whitespaces on dbClick url 2025-03-17 11:30:37 +01:00
784d89d2c3
Merge branch 'develop' 2025-03-17 10:55:14 +01:00
e7bf50fc87
release v1.26.0 2025-03-17 10:55:11 +01:00
1800558624
Merge branch 'develop' 2025-03-17 10:53:13 +01:00
65a86c315f
CrudConfiguration::setShowActions: add context when setting this parameter 2025-03-17 10:53:09 +01:00
275f12dd8d Merge branch 'develop' 2025-03-12 12:55:28 +01:00
b33235b4b2 fix(FsFileManager): fix regression when using UploadHandler 2025-03-12 12:55:02 +01:00
1c977a91a1 fix(node): use false instead of O in query 2025-03-12 12:19:35 +01:00
12f3eaa6ac Merge branch 'develop' 2025-03-11 16:50:04 +01:00
5f07ad2c28 update changelog 2025-03-11 16:50:02 +01:00
a791618369 Merge branch 'develop' 2025-03-11 16:49:28 +01:00
f125d04af7 fix(crud): use context variable to retrieve the form and the form options 2025-03-11 16:49:24 +01:00
637a19f5e1 Merge branch 'develop' 2025-02-28 15:15:21 +01:00
aac4e21a65 fix(form): handle multiple files in form template 2025-02-28 15:15:12 +01:00
c16a73b1ff Merge branch 'develop' 2025-02-28 14:44:36 +01:00
c0db55d467 fix(form): handle multiple files in form template 2025-02-28 14:43:59 +01:00
90202475ab Merge branch 'develop' 2025-02-28 11:38:13 +01:00
05ed084986 feat(CrudController): allow to add callables after creation, update and delation 2025-02-28 11:37:50 +01:00
0b6155c7e0 Merge branch 'develop' 2025-02-28 10:13:11 +01:00
6a977ca029 Merge branch 'feature/upload-multiple-file' into develop 2025-02-28 10:12:48 +01:00
9e1d4a7ae9 update changelog 2025-02-28 10:12:42 +01:00
3755fcccf1 feat(FileUploadHandler): allow to upload multiple files
add specific callback "afterUploadsCallback" when multiple files are uploaded
2025-02-28 10:11:46 +01:00
9da624f363 Merge branch 'develop' 2025-02-07 17:24:13 +01:00
4227400cf9 remove console.log 2025-02-07 17:24:11 +01:00
34 changed files with 735 additions and 291 deletions

View file

@ -1,5 +1,37 @@
## [Unreleased]
### Added
* feat(repository): add RepositoryQuery::addCaseInsensitiveFilters()
* feat(repository): add RepositoryQuery::addForcedFilterHandler()
### Fixed
* fix(crud/index): fix row attribute value render
* fix(crud/navigation_setting): fix form action
* fix(crud/template): use default route params
## [v1.27.0] - 2025-12-22
### Fixed
* fix(crud): use route params to redirect after a delation
### Added
* add option `removeItemButton: true` when applying choices.js
* feat(builder): allow to define `allowed_widgets` in form options
* feat(collection): add delete_attr, add_attr options
* feat(builder): allow to add block between children
* feat(builder): improve UI to add new block
* feat(settings): allow to edit a setting in plain page
* feat(crud/index): allow to define row attributes
## [v1.26.0] - 2025-03-17
### Added
* FileUploadHandler: allow to upload multiple files
* CrudController: allow to add callables after creation, update and delation
### Fixed
* fix(crud): use context variable to retrieve the form and the form options
* fix(node): use `false` instead of `O` in query
### Changed
* CrudConfiguration::setShowActions: add context when setting this parameter
## [v1.25.2] - 2025-02-07
### Added
* allow to set `data-*` attributes on modal

View file

@ -5,7 +5,7 @@ namespace App\Core\BuilderBlock\Block\Bootstrap;
use App\Core\BuilderBlock\BuilderBlock;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
class BootstrapBlock extends BuilderBlock
abstract class BootstrapBlock extends BuilderBlock
{
public function configure()
{

View file

@ -5,7 +5,7 @@ namespace App\Core\BuilderBlock\Block\Editor;
use App\Core\BuilderBlock\BuilderBlock;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
class EditorBlock extends BuilderBlock
abstract class EditorBlock extends BuilderBlock
{
public function configure()
{

View file

@ -26,7 +26,13 @@ abstract class CrudController extends AdminController
abstract protected function getConfiguration(): CrudConfiguration;
protected function doIndex(int $page, RepositoryQuery $query, Request $request, Session $session, string $context = 'index'): Response
protected function doIndex(
int $page,
RepositoryQuery $query,
Request $request,
Session $session,
string $context = 'index'
): Response
{
$configuration = $this->getConfiguration();
@ -50,13 +56,20 @@ abstract class CrudController extends AdminController
]);
}
protected function doNew(EntityInterface $entity, EntityManager $entityManager, Request $request, callable $beforeCreate = null, string $context = 'new'): Response
protected function doNew(
EntityInterface $entity,
EntityManager $entityManager,
Request $request,
callable $beforeCreate = null,
callable $afterCreate = null,
string $context = 'new'
): Response
{
$configuration = $this->getConfiguration();
$this->prepareEntity($entity);
$form = $this->createForm($configuration->getForm('new'), $entity, $configuration->getFormOptions($context));
$form = $this->createForm($configuration->getForm($context), $entity, $configuration->getFormOptions($context));
if ($request->isMethod('POST')) {
$form->handleRequest($request);
@ -67,6 +80,11 @@ abstract class CrudController extends AdminController
}
$entityManager->create($entity);
if (null !== $afterCreate) {
call_user_func_array($afterCreate, [$entity, $form, $request]);
}
$this->addFlash('success', 'The data has been saved.');
return $this->redirectToRoute($configuration->getPageRoute('edit'), array_merge(
@ -96,13 +114,20 @@ abstract class CrudController extends AdminController
]);
}
protected function doEdit(EntityInterface $entity, EntityManager $entityManager, Request $request, callable $beforeUpdate = null, string $context = 'edit'): Response
protected function doEdit(
EntityInterface $entity,
EntityManager $entityManager,
Request $request,
callable $beforeUpdate = null,
callable $afterUpdate = null,
string $context = 'edit'
): Response
{
$configuration = $this->getConfiguration();
$this->prepareEntity($entity);
$form = $this->createForm($configuration->getForm('edit'), $entity, $configuration->getFormOptions($context));
$form = $this->createForm($configuration->getForm($context), $entity, $configuration->getFormOptions($context));
if ($request->isMethod('POST')) {
$form->handleRequest($request);
@ -113,6 +138,11 @@ abstract class CrudController extends AdminController
}
$entityManager->update($entity);
if (null !== $afterUpdate) {
call_user_func_array($afterUpdate, [$entity, $form, $request]);
}
$this->addFlash('success', 'The data has been saved.');
return $this->redirectToRoute($configuration->getPageRoute($context), array_merge(
@ -131,7 +161,15 @@ abstract class CrudController extends AdminController
]);
}
protected function doInlineEdit(string $context, string $label, EntityInterface $entity, EntityManager $entityManager, Request $request, callable $beforeUpdate = null): Response
protected function doInlineEdit(
string $context,
string $label,
EntityInterface $entity,
EntityManager $entityManager,
Request $request,
callable $beforeUpdate = null,
callable $afterUpdate = null
): Response
{
$configuration = $this->getConfiguration();
@ -192,6 +230,11 @@ abstract class CrudController extends AdminController
$session->remove($lastRequestId);
$entityManager->update($entity);
if (null !== $afterUpdate) {
call_user_func_array($afterUpdate, [$entity, $form, $request]);
}
$this->addFlash('success', 'The data has been saved.');
return $this->redirect($redirectTo);
@ -217,7 +260,13 @@ abstract class CrudController extends AdminController
]);
}
protected function doSort(int $page, RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session): Response
protected function doSort(
int $page,
RepositoryQuery $query,
EntityManager $entityManager,
Request $request,
Session $session
): Response
{
$configuration = $this->getConfiguration();
$context = $request->query->get('context', 'index');
@ -255,7 +304,13 @@ abstract class CrudController extends AdminController
return $this->json([]);
}
protected function doBatch(int $page, RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session): Response
protected function doBatch(
int $page,
RepositoryQuery $query,
EntityManager $entityManager,
Request $request,
Session $session
): Response
{
$configuration = $this->getConfiguration();
$datas = $request->request->get('batch', []);
@ -326,7 +381,14 @@ abstract class CrudController extends AdminController
return $this->json([]);
}
protected function doDelete(EntityInterface $entity, EntityManager $entityManager, Request $request, callable $beforeDelete = null, string $route = 'index'): Response
protected function doDelete(
EntityInterface $entity,
EntityManager $entityManager,
Request $request,
callable $beforeDelete = null,
callable $afterDelete = null,
string $route = 'index'
): Response
{
$configuration = $this->getConfiguration();
@ -337,22 +399,26 @@ abstract class CrudController extends AdminController
$entityManager->delete($entity);
if (null !== $afterDelete) {
call_user_func($afterDelete, $entity);
}
$this->addFlash('success', 'The data has been removed.');
}
return $this->redirectToRoute($configuration->getPageRoute($route));
return $this->redirectToRoute($configuration->getPageRoute($route), $configuration->getPageRouteParams($route));
}
protected function doFilter(Session $session, string $context = 'filter'): Response
{
$configuration = $this->getConfiguration();
$type = $configuration->getForm('filter');
$type = $configuration->getForm($context);
if (null === $type) {
throw $this->createNotFoundException();
}
$form = $this->createForm($type, null, $configuration->getFormOptions('filter'));
$form = $this->createForm($type, null, $configuration->getFormOptions($context));
$form->submit($session->get($form->getName(), []));
return $this->render($configuration->getView($context), [

View file

@ -35,6 +35,8 @@ class NavigationSettingAdminController extends AdminController
$session = $request->getSession();
$lastRequestId = sprintf('setting_request_%s_%s', get_class($entity), $entity->getId());
$lastRequest = $session->get($lastRequestId);
$options = $entity->getOptions();
$optionView = $options['view'] ?? 'modal';
if (null !== $lastRequest && !$request->isMethod('POST')) {
$fakeRequest = Request::create(
@ -64,17 +66,19 @@ class NavigationSettingAdminController extends AdminController
$session->set($lastRequestId, $request->request->get('form'));
$this->addFlash('warning', 'The form is not valid.');
return $this->redirect(sprintf(
'%s?data-modal=%s',
$redirectTo,
urlencode($request->getUri())
));
if ($optionView === 'modal') {
return $this->redirect(sprintf(
'%s?data-modal=%s',
$redirectTo,
urlencode($request->getUri())
));
}
}
return $this->render('@Core/setting/navigation_setting_admin/edit.html.twig', [
'form' => $form->createView(),
'entity' => $entity,
'options' => $event->getData()['options'],
'options' => $options,
'redirectTo' => $redirectTo,
]);
}

View file

@ -55,6 +55,8 @@ class SettingAdminController extends AdminController
$session = $request->getSession();
$lastRequestId = sprintf('setting_request_%s_%s', get_class($entity), $entity->getId());
$lastRequest = $session->get($lastRequestId);
$options = $entity->getOptions();
$optionView = $options['view'] ?? 'modal';
if (null !== $lastRequest && !$request->isMethod('POST')) {
$fakeRequest = Request::create(
@ -82,11 +84,13 @@ class SettingAdminController extends AdminController
$session->set($lastRequestId, $request->request->get('form'));
$this->addFlash('warning', 'The form is not valid.');
return $this->redirect(sprintf(
'%s?data-modal=%s',
$redirectTo,
urlencode($request->getUri())
));
if ($optionView === 'modal') {
return $this->redirect(sprintf(
'%s?data-modal=%s',
$redirectTo,
urlencode($request->getUri())
));
}
}
return $this->render('@Core/setting/setting_admin/edit.html.twig', [

View file

@ -2,6 +2,8 @@
namespace App\Core\Crud;
use App\Core\Entity\EntityInterface;
/**
* class CrudConfiguration.
*
@ -27,7 +29,8 @@ class CrudConfiguration
protected array $isSortableCollection = [];
protected string $sortableCollectionProperty = 'sortOrder';
protected ?string $defaultLocale = null;
protected bool $showActions = true;
protected array $showActions = [];
protected array $listRowAttributes = [];
protected static $self;
@ -247,6 +250,26 @@ class CrudConfiguration
return $this->viewDatas[$context][$name] ?? $defaultValue;
}
public function setListRowAttributes(string $context, array $attributes): self
{
$this->listRowAttributes[$context] = $attributes;
return $this;
}
public function getListRowAttributes(string $context, EntityInterface $entity): array
{
$attributes = $this->listRowAttributes[$context] ?? [];
foreach ($attributes as $key => $attribute) {
if (is_callable($attribute)) {
$attributes[$key] = $attribute($entity);
}
}
return $attributes;
}
// --
public function setField(string $context, string $label, string $field, array $options): self
@ -369,15 +392,15 @@ class CrudConfiguration
return $this->sortableCollectionProperty;
}
public function setShowActions(bool $showActions): self
public function setShowActions(string $page, bool $showActions): self
{
$this->showActions = $showActions;
$this->showActions[$page] = $showActions;
return $this;
}
public function getShowActions(): bool
public function getShowActions(string $page): bool
{
return $this->showActions;
return $this->showActions[$page] ?? true;
}
}

View file

@ -26,6 +26,9 @@ class NavigationSetting implements EntityInterface
#[ORM\Column(type: 'text', nullable: true)]
protected $value;
#[ORM\Column(type: 'text', nullable: true)]
protected $options;
#[ORM\ManyToOne(targetEntity: Navigation::class, inversedBy: 'navigationSettings')]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
protected $navigation;
@ -94,4 +97,16 @@ class NavigationSetting implements EntityInterface
return $this;
}
public function getOptions()
{
return json_decode($this->options, true) ?? [];
}
public function setOptions(?array $options): self
{
$this->options = json_encode($options ?? []);
return $this;
}
}

View file

@ -25,6 +25,9 @@ class Setting implements EntityInterface
#[ORM\Column(type: 'text', nullable: true)]
protected $value;
#[ORM\Column(type: 'text', nullable: true)]
protected $options;
public function getId(): ?int
{
return $this->id;
@ -77,4 +80,16 @@ class Setting implements EntityInterface
return $this;
}
public function getOptions()
{
return json_decode($this->options, true) ?? [];
}
public function setOptions(?array $options): self
{
$this->options = json_encode($options ?? []);
return $this;
}
}

View file

@ -233,7 +233,7 @@ class FsFileManager
$directory .= '/'.trim(dirname($fullPaths[$key]), '/');
}
$this->uploadHandler->handleForm($file, $directory, null, true);
$this->uploadHandler->handleForm($file, $directory, keepOriginalFilename: true);
}
}

View file

@ -20,27 +20,53 @@ class FileUploadHandler
return $this;
}
public function handleForm(?UploadedFile $uploadedFile, string $path, ?callable $afterUploadCallback = null, bool $keepOriginalFilename = false): void
public function handleForm(
null|array|UploadedFile $uploadedFile,
string $path,
?callable $afterUploadCallback = null,
?callable $afterUploadsCallback = null,
bool $keepOriginalFilename = false
): null|array|string
{
if (null === $uploadedFile) {
return;
return null;
}
$originalFilename = pathinfo($uploadedFile->getClientOriginalName(), PATHINFO_FILENAME);
if (is_array($uploadedFile)) {
$filenames = [];
if ($keepOriginalFilename) {
$filename = $originalFilename.'.'.$uploadedFile->guessExtension();
} elseif (!is_callable($this->filenameGenerator)) {
$safeFilename = transliterator_transliterate('Any-Latin; Latin-ASCII; [^A-Za-z0-9_] remove; Lower()', $originalFilename);
$filename = date('Ymd-his').$safeFilename.'.'.$uploadedFile->guessExtension();
foreach ($uploadedFile as $file) {
$filename = $this->handleForm($file, $path, $afterUploadCallback, null, $keepOriginalFilename);
if ($filename !== null) {
$filenames[] = $filename;
}
}
if (!empty($filenames) && $afterUploadsCallback) {
$afterUploadsCallback($filenames);
}
return $filenames;
} else {
$filename = call_user_func($this->filenameGenerator, $uploadedFile);
}
$originalFilename = pathinfo($uploadedFile->getClientOriginalName(), PATHINFO_FILENAME);
$uploadedFile->move($path, $filename);
if ($keepOriginalFilename) {
$filename = $originalFilename.'.'.$uploadedFile->guessExtension();
} elseif (!is_callable($this->filenameGenerator)) {
$safeFilename = transliterator_transliterate('Any-Latin; Latin-ASCII; [^A-Za-z0-9_] remove; Lower()', $originalFilename);
$filename = date('Ymd-his').$safeFilename.'.'.$uploadedFile->guessExtension();
} else {
$filename = call_user_func($this->filenameGenerator, $uploadedFile);
}
if ($afterUploadCallback) {
$afterUploadCallback($filename);
$uploadedFile->move($path, $filename);
if ($afterUploadCallback) {
$afterUploadCallback($filename);
}
return $filename;
}
}
}

View file

@ -19,6 +19,7 @@ class BuilderType extends AbstractType
parent::buildView($view, $form, $options);
$view->vars = array_replace($view->vars, [
'allowed_widgets' => $options['allowed_widgets'],
]);
}
@ -28,7 +29,10 @@ class BuilderType extends AbstractType
$resolver->setDefaults([
'compound' => false,
'allowed_widgets' => [],
]);
$resolver->setAllowedTypes('allowed_widgets', 'array');
}
public function getBlockPrefix()

View file

@ -16,12 +16,23 @@ class CollectionType extends BaseCollectionType
{
parent::buildView($view, $form, $options);
$classes = [
'add_attr' => 'collection-add',
'delete_attr' => 'text-right',
];
foreach ($classes as $key => $class) {
$options[$key]['class'] = $class.' '.($options[$key]['class'] ?? '');
}
$view->vars = array_replace($view->vars, [
'collection_name' => $options['collection_name'],
'label_add' => $options['label_add'],
'label_delete' => $options['label_delete'],
'allow_add' => $options['allow_add'],
'allow_delete' => $options['allow_delete'],
'add_attr' => $options['add_attr'],
'delete_attr' => $options['delete_attr'],
'template_before_item' => $options['template_before_item'],
'template_after_item' => $options['template_after_item'],
]);
@ -37,6 +48,8 @@ class CollectionType extends BaseCollectionType
'label_delete' => 'Delete',
'template_before_item' => null,
'template_after_item' => null,
'add_attr' => [],
'delete_attr' => [],
]);
}

View file

@ -3,7 +3,7 @@
namespace App\Core;
if (!defined('MURPH_VERSION')) {
define('MURPH_VERSION', 'v1.25.1');
define('MURPH_VERSION', 'v1.27.0');
}
/**

View file

@ -18,6 +18,7 @@ abstract class RepositoryQuery
protected PaginatorInterface $paginator;
protected string $id;
protected array $forcedFilterHandlers = [];
protected array $caseInsensitiveFilters = [];
public function __construct(ServiceEntityRepository $repository, string $id, PaginatorInterface $paginator = null)
{
@ -88,7 +89,11 @@ abstract class RepositoryQuery
$this->andWhere('.'.$name.' = :'.$name);
$this->setParameter(':'.$name, $value);
} elseif (is_string($value)) {
$this->andWhere('.'.$name.' LIKE :'.$name);
if (in_array($name, $this->caseInsensitiveFilters)) {
$this->andWhere(sprintf('LOWER ( .%1$s) LIKE LOWER(:%1$s)', $name));
} else {
$this->andWhere('.'.$name.' LIKE :'.$name);
}
$this->setParameter(':'.$name, '%'.$value.'%');
} else {
$this->filterHandler($name, $value);
@ -142,4 +147,18 @@ abstract class RepositoryQuery
protected function filterHandler(string $name, $value)
{
}
protected function addCaseInsensitiveFilters(string $name): self
{
$this->caseInsensitiveFilters[] = $name;
return $this;
}
protected function addForcedFilterHandlers(string $name): self
{
$this->forcedFilterHandlers[] = $name;
return $this;
}
}

View file

@ -18,7 +18,7 @@ class NodeRepository extends NestedTreeRepository
$query = $this->createQueryBuilder('n')
->join('n.menu', 'm')
->where('n.url = :url')
->andWhere('n.disableUrl = 0')
->andWhere('n.disableUrl = false')
->andWhere('n.aliasNode is null')
->andWhere('m.navigation = :navigation')
->setParameter(':url', $url)

View file

@ -761,16 +761,19 @@ label.required::after {
}
.builder-widget {
.container {
max-width: 100%;
}
.block {
border: 1px solid rgba(map-get($theme-colors, 'dark-blue'), 0.3);
padding: 10px;
box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px;
padding: 15px;
border-radius: 4px;
margin-bottom: 10px;
background: rgba(map-get($theme-colors, 'dark-blue'), 0.02);
}
> .block {
border: 1px solid map-get($theme-colors, 'dark-blue');
box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px;
}
.block-header {
@ -784,9 +787,6 @@ label.required::after {
}
}
$block-colors: #E183F5 #E3F7C6 #82DDF5 #F5BA82 #A088A6;
$block-colors-length: length($block-colors);
.block .block-icon {
> * {
display: inline-block;
@ -794,38 +794,36 @@ label.required::after {
}
}
@for $i from 1 through 100 {
$block-color-index: ($block-colors-length + $i) % $block-colors-length + 1;
.block-depth-#{$i} {
.block-label {
background: nth($block-colors, $block-color-index);
border: 1px solid darken(nth($block-colors, $block-color-index), 50%);
color: darken(nth($block-colors, $block-color-index), 50%);
}
.builder-add .btn {
background: nth($block-colors, $block-color-index);
border: 1px solid darken(nth($block-colors, $block-color-index), 50%);
color: darken(nth($block-colors, $block-color-index), 50%);
}
}
}
.builder-add {
width: 100%;
&-top {
margin-top: 7px;
}
.btn {
font-size: 12px;
line-height: 14px;
padding: 3px 5px;
&-button {
cursor: pointer;
background: rgba(map-get($theme-colors, 'dark-blue'), 0.1);
text-align: center;
padding-bottom: 5px;
margin: 8px 0;
border-radius: 4px;
&:hover {
background: rgba(map-get($theme-colors, 'dark-blue'), 0.2);
}
.btn {
font-size: 12px;
line-height: 14px;
padding: 3px 5px;
}
}
}
.block-root {
border: 1px solid map-get($theme-colors, 'dark-blue');
box-shadow: none;
}
.block-root > .container .builder-add {
margin-top: 0;
}
@ -840,10 +838,6 @@ label.required::after {
}
}
.block .block {
margin-top: 10px;
}
.block-id {
font-size: 12px;
margin-right: 5px;
@ -874,4 +868,32 @@ label.required::after {
min-height: 50vh;
}
}
.dragger {
cursor: pointer;
color: #6c757d;
border-color: #6c757d;
text-align: center;
vertical-align: middle;
}
$block-colors: #E183F5 #E3F7C6 #82DDF5 #F5BA82 #A088A6;
$block-colors-length: length($block-colors);
@for $i from 1 through 100 {
$block-color-index: ($block-colors-length + $i) % $block-colors-length + 1;
.block-depth-#{$i} {
.block-label {
background: nth($block-colors, $block-color-index);
border: 1px solid darken(nth($block-colors, $block-color-index), 50%);
color: darken(nth($block-colors, $block-color-index), 50%);
}
.builder-add-button:hover {
background: nth($block-colors, $block-color-index);
color: darken(nth($block-colors, $block-color-index), 50%);
}
}
}
}

View file

@ -8,7 +8,7 @@
:container="value"
:widgets="widgets"
:openedBlocks="openedBlocks"
:allowedWidgets="[]"
:allowedWidgets="allowedWidgets"
v-if="value.length > 0"
position="top"
/>
@ -34,16 +34,26 @@
@remove-item="removeBlock(key)"
@drag-start="dragStart"
@drag-end="dragEnd"
/>
<div class="container">
<div class="d-flex justify-content-between">
>
<template #action v-if="(key+1) !== value.length">
<BuilderBlockCreate
:container="value"
:widgets="widgets"
:openedBlocks="openedBlocks"
:allowedWidgets="[]"
position="bottom"
:allowedWidgets="allowedWidgets"
:position="key"
/>
</template>
</BuilderBlockItem>
<div class="container">
<BuilderBlockCreate
:container="value"
:widgets="widgets"
:openedBlocks="openedBlocks"
:allowedWidgets="allowedWidgets"
position="bottom"
/>
<div class="text-right">
<div>
<BuilderBlockCodeEditor
ref="dialog"
@ -90,6 +100,11 @@ export default {
initialValue: {
type: Array,
required: false,
},
allowedWidgets: {
type: Array,
required: false,
default: [],
}
},
data() {

View file

@ -47,9 +47,9 @@
<template>
<div class="builder-add" :class="{'builder-add-top': position === 'top'}">
<button type="button" class="btn btn-secondary" v-on:click="togglePicker">
<span class="fa fa-plus"></span>
</button>
<div class="builder-add-button" v-on:click="togglePicker">
+
</div>
<div class="builder-block-picker mt-2 row" :class="{'d-none': !showPicker}">
<div class="col-auto builder-block-picker-menu">
@ -116,7 +116,7 @@ export default {
required: true
},
position: {
type: String,
type: [String, Number],
required: true
},
},
@ -142,10 +142,14 @@ export default {
children: [],
}
if (this.position === 'bottom') {
this.container.push(block)
} else {
this.$emit('updateContainer', this.container)
} else if (this.position === 'top') {
this.container.unshift(block)
} else {
this.container.splice(this.position+1, 0, block)
}
this.$emit('updateContainer', this.container)

View file

@ -1,116 +1,122 @@
<template>
<div
class="block"
:class="'block-depth-' + depth"
v-if="widget"
:key="blockKey"
>
<div class="block-header d-flex justify-content-between">
<div>
<div
class="block-header-item block-label"
:title="item.widget"
>
<span
class="block-icon"
v-if="widget.icon"
v-html="widget.icon"
<div>
<div
class="block"
:class="'block-depth-' + depth"
v-if="widget"
:key="blockKey"
>
<div class="block-header d-flex justify-content-between">
<div>
<div
class="block-header-item block-label"
:title="item.widget"
>
</span>
<span
class="block-icon"
v-if="widget.icon"
v-html="widget.icon"
>
</span>
{{ widget.label }}
{{ widget.label }}
</div>
<button
type="button"
class="block-header-item btn btn-sm btn-outline-secondary"
v-on:click="toggleSettings"
v-if="Object.keys(widget.settings).length"
>
<span class="fa fa-cog"></span>
</button>
<span class="fa fa-arrows-alt dragger"></span>
</div>
<button
type="button"
class="block-header-item btn btn-sm btn-outline-secondary"
v-on:click="toggleSettings"
v-if="Object.keys(widget.settings).length"
<div
v-if="widget.preview && typeof item.settings[widget.preview] == 'string'"
class="block-preview"
>
<span class="fa fa-cog"></span>
</button>
{{ truncate(item.settings[widget.preview]) }}
</div>
<button
type="button"
class="block-header-item btn btn-sm btn-outline-secondary dragger"
>
<span class="fa fa-arrows-alt dragger"></span>
</button>
<div>
<span class="block-id">
{{ item.id }}
</span>
<button
type="button"
class="block-header-item btn btn-sm text-white bg-danger"
v-on:click="removeMe(item)"
>
<span class="fa fa-trash"></span>
</button>
</div>
</div>
<div
v-if="widget.preview && typeof item.settings[widget.preview] == 'string'"
class="block-preview"
>
{{ truncate(item.settings[widget.preview]) }}
<div class="block-settings" v-if="Object.keys(widget.settings).length" :class="{'d-none': !showSettings}">
<div class="row">
<BuilderBlockSetting
class="mb-0"
v-for="(params, setting) in widget.settings"
:key="item.id + '-' + setting"
:class="widget.class"
:item="item"
:params="params"
:setting="setting"
/>
</div>
</div>
<div>
<span class="block-id">
{{ item.id }}
</span>
<button
type="button"
class="block-header-item btn btn-sm text-white bg-danger"
v-on:click="removeMe(item)"
>
<span class="fa fa-trash dragger"></span>
</button>
</div>
</div>
<div class="block-settings" v-if="Object.keys(widget.settings).length" :class="{'d-none': !showSettings}">
<div class="row">
<BuilderBlockSetting
class="mb-0"
v-for="(params, setting) in widget.settings"
:key="item.id + '-' + setting"
:class="widget.class"
:item="item"
:params="params"
:setting="setting"
<div v-if="widget.isContainer" class="container">
<BuilderBlockCreate
:container="item.children"
:widgets="widgets"
:openedBlocks="openedBlocks"
:allowedWidgets="widget.widgets"
v-if="item.children.length > 0"
position="top"
/>
</div>
</div>
<div v-if="widget.isContainer" class="container">
<BuilderBlockCreate
:container="item.children"
:widgets="widgets"
:openedBlocks="openedBlocks"
:allowedWidgets="widget.widgets"
v-if="item.children.length > 0"
position="top"
/>
</div>
<Draggable
v-if="widget.isContainer"
v-model="item.children"
ghost-class="ghost"
group="children"
@start="dragStart"
@end="dragEnd"
:animation="200"
handle=".dragger"
class="block-dropzone"
>
<template v-if="item.children !== null && item.children.length > 0">
<BuilderBlockItem
v-for="(child, key) in item.children"
:key="child.id"
:item="child"
:widgets="widgets"
:openedBlocks="openedBlocks"
:depth="depth + 1"
@remove-item="removeBlock(key)"
@drag-start="dragStart"
@drag-end="dragEnd"
>
<template #action v-if="(key+1) !== item.children.length">
<BuilderBlockCreate
:container="item.children"
:widgets="widgets"
:position="key"
:openedBlocks="openedBlocks"
:allowedWidgets="widget.widgets"
/>
</template>
</BuilderBlockItem>
</template>
</Draggable>
<Draggable
v-if="widget.isContainer"
v-model="item.children"
ghost-class="ghost"
group="children"
@start="dragStart"
@end="dragEnd"
:animation="200"
handle=".dragger"
class="block-dropzone"
>
<BuilderBlockItem
v-if="item.children !== null && item.children.length > 0"
v-for="(child, key) in item.children"
:key="child.id"
:item="child"
:widgets="widgets"
:openedBlocks="openedBlocks"
:depth="depth + 1"
@remove-item="removeBlock(key)"
@drag-start="dragStart"
@drag-end="dragEnd"
/>
</Draggable>
<div v-if="widget.isContainer" class="container">
<div class="d-flex justify-content-between">
<div v-if="widget.isContainer" class="container">
<BuilderBlockCreate
:container="item.children"
:widgets="widgets"
@ -118,14 +124,17 @@
:allowedWidgets="widget.widgets"
position="bottom"
/>
<BuilderBlockCodeEditor
ref="dialog"
:value="item.children"
:widgets="widgets"
@update="codeUpdate"
/>
<div class="text-right">
<BuilderBlockCodeEditor
ref="dialog"
:value="item.children"
:widgets="widgets"
@update="codeUpdate"
/>
</div>
</div>
</div>
<slot name="action"></slot>
</div>
</template>
@ -159,7 +168,7 @@ export default {
depth: {
type: Number,
required: true
}
},
},
data() {
return {

View file

@ -3,7 +3,7 @@
<span v-if="params.label && params.type !== 'checkbox'" v-text="params.label"></span>
<input
v-if="['number', 'checkbox', 'text'].includes(params.type)"
v-if="['number', 'checkbox', 'text', 'color', 'range'].includes(params.type)"
v-model="item.settings[setting]"
v-bind="params.attr"
:type="params.type"

View file

@ -12,12 +12,14 @@ module.exports = () => {
el: component,
template: `<BuilderBlock
:initialValue="value"
:allowedWidgets="allowedWidgets"
name="${component.getAttribute('data-name')}"
id="${component.getAttribute('data-id')}"
/>`,
data() {
return {
value: JSON.parse(component.getAttribute('data-value'))
value: JSON.parse(component.getAttribute('data-value')),
allowedWidgets: JSON.parse(component.getAttribute('data-allowedwidgets')),
}
},
components: {

View file

@ -4,6 +4,7 @@ module.exports = () => {
document.querySelectorAll('*[data-jschoice]').forEach((item) => {
return new Choices(item, {
searchFields: ['label'],
removeItemButton: true,
})
})
}

View file

@ -104,8 +104,6 @@ module.exports = function () {
}
}
console.log(dataAttributes)
openModal(url, createModal, dataAttributes)
}, 250)
})

View file

@ -149,7 +149,7 @@
</th>
{% endblock %}
{% endfor %}
{% if configuration.showActions %}
{% if configuration.showActions(context) %}
<th class="crud-action-column">
{{ 'Actions'|trans }}
</th>
@ -183,15 +183,20 @@
{% endif %}
{% block list_item %}
{%- set dbClick %}
{% if configuration.action(context, 'show', true, [item]) %}
{{ path(configuration.pageRoute('show'), {entity: item.id}|merge(configuration.pageRouteParams('show'))) }}
{% elseif configuration.action(context, 'edit', true, [item]) %}
{{ path(configuration.pageRoute('edit'), {entity: item.id}|merge(configuration.pageRouteParams('show'))) }}
{% endif %}
{% endset -%}
{%- set dbClick -%}
{%- if configuration.doubleClick(context) -%}
{%- if configuration.action(context, 'show', true, [item]) -%}
{{- path(configuration.pageRoute('show'), {entity: item.id}|merge(configuration.pageRouteParams('show'))) -}}
{%- elseif configuration.action(context, 'edit', true, [item]) -%}
{{- path(configuration.pageRoute('edit'), {entity: item.id}|merge(configuration.pageRouteParams('show'))) -}}
{%- endif -%}
{%- endif -%}
{%- endset -%}
<tr {{ dataSortableItem|raw }} {% if configuration.doubleClick(context) %}data-dblclick="{{ dbClick }}"{% endif %} class="{{ loop.index is odd ? 'is-odd' : 'is-even' }}">
{% set rowAttributes = configuration.listRowAttributes(context, item) %}
{% set rowClasses = rowAttributes['class']|default('') %}
<tr {{ dataSortableItem|raw }} {% if configuration.doubleClick(context) %}data-dblclick="{{- dbClick -}}"{% endif %} class="{{ loop.index is odd ? 'is-odd' : 'is-even' }} {{ rowClasses }}" {% for attr, attrValue in rowAttributes %}{% if attr != 'class' %}{{ attr }}="{{ attrValue }}" {% endif %}{% endfor %}>
{% if configuration.hasBatchAction(context) %}
<td class="crud-batch-column">
<input type="checkbox" class="batch_form" name="batch[items][{{ loop.index }}]" form="form-batch" value="{{ loop.index }}">
@ -228,7 +233,7 @@
</td>
{% endfor %}
{% if configuration.showActions %}
{% if configuration.showActions(context) %}
<td class="crud-action-column">
{% block list_item_actions %}
{% block list_item_actions_before %}{% endblock %}

View file

@ -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>
<span class="d-none d-md-inline">
{{ configuration.actionTitle(context, 'back', 'Back to the list')|trans }}
@ -27,7 +27,7 @@
{% endif %}
{% if configuration.action(context, 'edit', true, [entity]) %}
<a href="{{ path(configuration.pageRoute('edit'), {entity: entity.id}) }}" class="btn btn-primary">
<a href="{{ path(configuration.pageRoute('edit'), {entity: entity.id}|merge(configuration.pageRouteParams('edit'))) }}" class="btn btn-primary">
<span class="fa fa-edit pr-1"></span>
<span class="d-none d-md-inline">

View file

@ -1,4 +1,5 @@
{% apply spaceless %}
{% block html %}
<!DOCTYPE html>
<html>
<head>
@ -62,4 +63,5 @@
{% endblock %}
</body>
</html>
{% endblock %}
{% endapply %}

View file

@ -3,13 +3,14 @@
{% block builder_widget %}
{% set row_attr = row_attr|merge({class: 'builder-widget ' ~ (row_attr.class ?? '')}) %}
{% set value = value is iterable ? value|json_encode : value %}
{% set allowed_widgets = allowed_widgets is iterable ? allowed_widgets|json_encode : allowed_widgets %}
{% if value == '' %}
{% set value = '[]' %}
{% endif %}
<div {% for attr, value in row_attr %}{{ attr }}="{{ value }}" {% endfor %}>
<div class="builder-widget-component" data-value="{{ value }}" data-name="{{ full_name }}" data-id="{{ id }}">
<div class="builder-widget-component" data-value="{{ value }}" data-name="{{ full_name }}" data-id="{{ id }}" data-allowedwidgets="{{ allowed_widgets }}">
</div>
</div>
{% endblock %}
@ -33,7 +34,7 @@
{% block file_widget -%}
<div class="row">
<div class="col-12">
{% set value = form.vars.data %}
{% set data = form.vars.data %}
{% if form.parent.vars.file_type is defined %}
{% set fileType = form.parent.vars.file_type %}
@ -41,31 +42,33 @@
{% set fileType = 'auto' %}
{% endif %}
{% if value %}
{% if fileType in ['auto', 'image'] and value.extension in ['jpeg', 'jpg', 'gif', 'png', 'svg', 'webp'] %}
<div class="card">
<div class="card-img-top bg-tiles text-center">
<a href="{{ asset(value.pathname) }}" target="_blank">
<img src="{{ asset(value.pathname) }}" class="img-fluid">
</a>
</div>
<div class="card-body">
{{- parent() -}}
</div>
</div>
{% else %}
<div class="card">
<div class="card-body">
{{- parent() -}}
{% if data and form.vars.errors|length == 0 %}
{% if not data is iterable %}
{% set data = [data] %}
{% endif %}
<div class="p-2 text-center">
<a class="btn btn-primary" href="{{ asset(value.pathname) }}" target="_blank">
{{ 'Download'|trans }}
<div class="card">
{% for item in data %}
{% if fileType in ['auto', 'image'] and item.extension in ['jpeg', 'jpg', 'gif', 'png', 'svg', 'webp'] %}
<div class="card-img-top bg-tiles text-center">
<a href="{{ asset(item.pathname) }}" target="_blank">
<img src="{{ asset(item.pathname) }}" class="img-fluid">
</a>
</div>
</div>
{% else %}
<div class="card-body">
<div class="p-2 text-center">
<a class="btn btn-primary" href="{{ asset(item.pathname) }}" target="_blank">
{{ 'Download'|trans }}
</a>
</div>
</div>
{% endif %}
{% endfor %}
<div class="card-body">
{{- parent() -}}
</div>
{% endif %}
</div>
{% else %}
{{- parent() -}}
{% endif %}
@ -76,6 +79,8 @@
{% block collection_block_widget %}
{% set allow_delete = allow_delete|default(false) %}
{% set allow_add = allow_add|default(false) %}
{% set add_attr = add_attr|default({}) %}
{% set delete_attr = delete_attr|default({}) %}
<div data-collection="collection-{{ collection_name }}">
{% for item in form.value %}
@ -85,7 +90,7 @@
{% endfor %}
{% if allow_delete %}
<div class="text-right">
<div {% for k, v in delete_attr %}{{ k }}="{{ v }}"{% endfor %}>
<span data-collection-delete-container class="btn btn-sm btn-danger">
<span data-collection-delete="{{ loop.index }}">
<span data-collection-delete="{{ loop.index }}" class="fa fa-trash"></span>
@ -99,7 +104,7 @@
</div>
{% if allow_add %}
<div data-collection-add="collection-{{ collection_name }}" class="collection-add">
<div data-collection-add="collection-{{ collection_name }}" {% for k, v in add_attr %}{{ k }}="{{ v }}"{% endfor %}>
<span class="btn btn-sm btn-primary" data-collection-add="collection-{{ collection_name }}">
<span data-collection-add="collection-{{ collection_name }}" class="fa fa-plus"></span>
{{ label_add|trans }}
@ -111,7 +116,7 @@
{{ form_rest(form.value.vars.prototype) }}
{% if allow_delete %}
<div class="text-right">
<div {% for k, v in delete_attr %}{{ k }}="{{ v }}"{% endfor %}>
<span data-collection-delete-container class="btn btn-sm btn-danger">
{{ label_delete|trans }}
</span>
@ -126,6 +131,8 @@
{% set attrs = attr|merge({class: 'mb-1 ' ~ (attr.class ?? '')}) %}
{% set allow_delete = allow_delete|default(false) %}
{% set allow_add = allow_add|default(false) %}
{% set add_attr = add_attr|default({}) %}
{% set delete_attr = delete_attr|default({}) %}
<div data-collection="collection-{{ collection_name }}" {% for attr, value in row_attr %}{{ attr }}="{{ value }}"{% endfor %}>
{% for item in form %}
@ -143,7 +150,7 @@
{% endif %}
{% if allow_delete %}
<div class="text-right">
<div {% for k, v in delete_attr %}{{ k }}="{{ v }}"{% endfor %}>
<span data-collection-delete-container class="btn btn-sm btn-danger">
<span data-collection-delete="{{ loop.index }}">
<span data-collection-delete="{{ loop.index }}" class="fa fa-trash"></span>
@ -157,7 +164,7 @@
</div>
{% if allow_add %}
<div data-collection-add="collection-{{ collection_name }}" class="collection-add">
<div data-collection-add="collection-{{ collection_name }}" {% for k, v in add_attr %}{{ k }}="{{ v }}"{% endfor %}>
<span class="btn btn-sm btn-primary" data-collection-add="collection-{{ collection_name }}">
<span data-collection-add="collection-{{ collection_name }}" class="fa fa-plus"></span>
{{ label_add|trans }}
@ -169,7 +176,7 @@
{{ form_rest(form.vars.prototype) }}
{% if allow_delete %}
<div class="text-right">
<div {% for k, v in delete_attr %}{{ k }}="{{ v }}"{% endfor %}>
<span data-collection-delete-container class="btn btn-sm btn-danger">
{{ label_delete|trans }}
</span>

View file

@ -1,20 +1,77 @@
<div class="modal-dialog {% if options['view']|default('') == 'large' %}modal-dialog-large{% endif %}">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{{ entity.section|trans }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form action="{{ path('admin_navigation_setting_edit', {entity: entity.id, redirectTo: redirectTo}) }}" id="form-entity-edit" method="POST">
{{ include('@Core/setting/navigation_setting_admin/_form.html.twig') }}
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ 'Cancel'|trans }}</button>
<button type="submit" form="form-entity-edit" class="btn btn-primary">{{ 'Save'|trans }}</button>
</div>
</div>
</div>
{% extends '@Core/admin/layout.html.twig' %}
{% set view = entity.options['view']|default('modal') %}
{% block html %}
{% if view == 'modal' %}
<div class="modal-dialog {% if options['view']|default('') == 'large' %}modal-dialog-large{% endif %}">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{{ entity.section|trans }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form action="{{ path('admin_navigation_setting_edit', {entity: entity.id, redirectTo: redirectTo}) }}" id="form-entity-edit" method="POST">
{{ include('@Core/setting/navigation_setting_admin/_form.html.twig') }}
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ 'Cancel'|trans }}</button>
<button type="submit" form="form-entity-edit" class="btn btn-primary">{{ 'Save'|trans }}</button>
</div>
</div>
</div>
{% else %}
{{ parent() }}
{% endif %}
{% endblock %}
{% block body_class %}has-form{% endblock %}
{% block title %}{{ entity.label }}{% endblock %}
{% block body %}
{% block header %}
<div class="bg-light">
<div class="crud-header">
{% block header_title %}
<h1 class="crud-header-title">{{ entity.label }}</h1>
{% endblock %}
{% block header_actions %}
<div class="crud-header-actions">
<div class="btn-group">
<a href="{{ path('admin_setting_index') }}" class="btn btn-light">
<span class="fa fa-list pr-1"></span>
<span class="d-none d-md-inline">
{{ 'Back to the list'|trans }}
</span>
</a>
<button type="submit" form="form-main" class="btn btn-primary">
<span class="fa fa-save pr-1"></span>
<span class="d-none d-md-inline">
{{ 'Save'|trans|build_string(entity) }}
</span>
</button>
</div>
</div>
{% endblock %}
</div>
</div>
{% endblock %}
{% block form %}
<form action="{{ app.request.uri }}" method="post" id="form-main" enctype="multipart/form-data">
<div class="tab-content">
<div class="tab-pane active">
<div class="tab-form">
{{ include('@Core/setting/navigation_setting_admin/_form.html.twig') }}
</div>
</div>
</div>
</form>
{% endblock %}
{% endblock %}

View file

@ -1,20 +1,77 @@
<div class="modal-dialog {% if options['view']|default('') == 'large' %}modal-dialog-large{% endif %}">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{{ entity.section|trans }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form action="{{ path('admin_setting_edit', {entity: entity.id, redirectTo: redirectTo}) }}" id="form-entity-edit" method="POST">
{{ include('@Core/setting/setting_admin/_form.html.twig') }}
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ 'Cancel'|trans }}</button>
<button type="submit" form="form-entity-edit" class="btn btn-primary">{{ 'Save'|trans }}</button>
</div>
</div>
</div>
{% extends '@Core/admin/layout.html.twig' %}
{% set view = entity.options['view']|default('modal') %}
{% block html %}
{% if view == 'modal' %}
<div class="modal-dialog {% if options['view']|default('') == 'large' %}modal-dialog-large{% endif %}">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{{ entity.section|trans }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form action="{{ path('admin_setting_edit', {entity: entity.id, redirectTo: redirectTo}) }}" id="form-entity-edit" method="POST">
{{ include('@Core/setting/setting_admin/_form.html.twig') }}
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ 'Cancel'|trans }}</button>
<button type="submit" form="form-entity-edit" class="btn btn-primary">{{ 'Save'|trans }}</button>
</div>
</div>
</div>
{% else %}
{{ parent() }}
{% endif %}
{% endblock %}
{% block body_class %}has-form{% endblock %}
{% block title %}{{ entity.label }}{% endblock %}
{% block body %}
{% block header %}
<div class="bg-light">
<div class="crud-header">
{% block header_title %}
<h1 class="crud-header-title">{{ entity.label }}</h1>
{% endblock %}
{% block header_actions %}
<div class="crud-header-actions">
<div class="btn-group">
<a href="{{ path('admin_setting_index') }}" class="btn btn-light">
<span class="fa fa-list pr-1"></span>
<span class="d-none d-md-inline">
{{ 'Back to the list'|trans }}
</span>
</a>
<button type="submit" form="form-main" class="btn btn-primary">
<span class="fa fa-save pr-1"></span>
<span class="d-none d-md-inline">
{{ 'Save'|trans|build_string(entity) }}
</span>
</button>
</div>
</div>
{% endblock %}
</div>
</div>
{% endblock %}
{% block form %}
<form action="{{ app.request.uri }}" method="post" id="form-main" enctype="multipart/form-data">
<div class="tab-content">
<div class="tab-pane active">
<div class="tab-form">
{{ include('@Core/setting/setting_admin/_form.html.twig') }}
</div>
</div>
</div>
</form>
{% endblock %}
{% endblock %}

View file

@ -22,21 +22,35 @@
</thead>
<tbody>
{% for item in pager %}
{% set view = item.options['view']|default('modal') %}
{% set edit = path('admin_setting_edit', {entity: item.id, redirectTo: app.request.pathInfo}) %}
<tr>
<td class="col-5">
<a href="#" data-modal="{{ edit }}" data-modal-create class="font-weight-bold text-body d-block">
{{ item.label|trans }}
</a>
{% if view == 'modal' %}
<a href="#" data-modal="{{ edit }}" data-modal-create class="font-weight-bold text-body d-block">
{{ item.label }}
</a>
{% else %}
<a href="{{ edit }}" class="font-weight-bold text-body d-block">
{{ item.label }}
</a>
{% endif %}
</td>
<td class="col-5">
<span class="btn btn-light">{{ item.section|trans }}</span>
</td>
<td class="col-2 miw-100 text-right">
<span data-modal="{{ edit }}" data-modal-create class="btn btn-sm btn-primary mr-1">
<span data-modal="{{ edit }}" class="fa fa-edit"></span>
</span>
{% if view == 'modal' %}
<span data-modal="{{ edit }}" data-modal-create class="btn btn-sm btn-primary mr-1">
<span data-modal="{{ edit }}" class="fa fa-edit"></span>
</span>
{% else %}
<a href="{{ edit }}" class="btn btn-sm btn-primary mr-1">
<span class="fa fa-edit"></span>
</a>
{% endif %}
<button type="submit" form="form-delete-{{ item.id }}" class="btn btn-sm btn-danger">
<span class="fa fa-trash"></span>
</button>

View file

@ -54,21 +54,36 @@
</thead>
<tbody>
{% for item in datas.settings %}
{% set view = item.options['view']|default('modal') %}
{% set edit = path('admin_navigation_setting_edit', {entity: item.id, redirectTo: app.request.pathInfo}) %}
<tr data-dblclick="{{ edit }}">
<td class="col-5">
<a href="#" data-modal="{{ edit }}" class="font-weight-bold text-body d-block">
{{ item.label|trans }}
</a>
{% if view == 'modal' %}
<a href="#" data-modal="{{ edit }}" data-modal-create class="font-weight-bold text-body d-block">
{{ item.label }}
</a>
{% else %}
<a href="{{ edit }}" class="font-weight-bold text-body d-block">
{{ item.label }}
</a>
{% endif %}
</td>
<td class="col-5">
<span class="btn btn-light">{{ item.section|trans }}</span>
</td>
<td class="col-2 miw-100 text-right">
<span data-modal="{{ edit }}" class="btn btn-sm btn-primary mr-1">
<span data-modal="{{ edit }}" class="fa fa-edit"></span>
</span>
{% if view == 'modal' %}
<span data-modal="{{ edit }}" data-modal-create class="btn btn-sm btn-primary mr-1">
<span data-modal="{{ edit }}" class="fa fa-edit"></span>
</span>
{% else %}
<a href="{{ edit }}" class="btn btn-sm btn-primary mr-1">
<span class="fa fa-edit"></span>
</a>
{% endif %}
<button type="submit" form="form-delete-{{ item.id }}" class="btn btn-sm btn-danger">
<span class="fa fa-trash"></span>
</button>

View file

@ -24,7 +24,14 @@ class NavigationSettingManager
) {
}
public function init($navigation, string $code, string $section, string $label, $value = null)
public function init(
$navigation,
string $code,
string $section,
string $label,
$value = null,
array $options = [],
)
{
$entity = $this->get($this->getNavigation($navigation), $code);
$isNew = null === $entity;
@ -37,6 +44,7 @@ class NavigationSettingManager
$entity
->setSection($section)
->setLabel($label)
->setOptions($options)
;
if ($isNew) {

View file

@ -21,7 +21,13 @@ class SettingManager
) {
}
public function init(string $code, string $section, string $label, $value = null)
public function init(
string $code,
string $section,
string $label,
$value = null,
array $options = [],
)
{
$entity = $this->get($code);
$isNew = null === $entity;
@ -34,6 +40,7 @@ class SettingManager
$entity
->setSection($section)
->setLabel($label)
->setOptions($options)
;
if ($isNew) {