Преглед на файлове

Merge branch 'develop' of https://gitea.laclic.fr/Laclic/CaracoleBundle into develop

feature/ticket
Fab преди 3 години
родител
ревизия
829d02f905
променени са 6 файла, в които са добавени 67 реда и са изтрити 53 реда
  1. +6
    -2
      Controller/Setting/SettingAdminController.php
  2. +11
    -2
      Form/Setting/MerchantSettingsFormType.php
  3. +12
    -1
      Form/Setting/SectionSettingsFormType.php
  4. +1
    -1
      Model/Setting/SettingTrait.php
  5. +3
    -0
      Resources/translations/admin.fr.yaml
  6. +34
    -47
      Resources/views/admin/setting/form.html.twig

+ 6
- 2
Controller/Setting/SettingAdminController.php Целия файл

@@ -9,6 +9,7 @@ use Lc\CaracoleBundle\Form\Setting\SectionSettingsFormType;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\CaracoleBundle\Definition\SectionSettingDefinitionInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;

@@ -19,19 +20,22 @@ class SettingAdminController extends AbstractController
protected $merchantSettingDefinition;
protected $sectionResolver;
protected $sectionSettingDefinition;
protected $translatorAdmin;

public function __construct(
EntityManagerInterface $em,
MerchantResolver $merchantResolver,
SectionResolver $sectionResolver,
MerchantSettingDefinitionInterface $merchantSettingDefinition,
SectionSettingDefinitionInterface $sectionSettingDefinition
SectionSettingDefinitionInterface $sectionSettingDefinition,
TranslatorAdmin $translatorAdmin
) {
$this->em = $em;
$this->merchantResolver = $merchantResolver;
$this->sectionResolver = $sectionResolver;
$this->merchantSettingDefinition = $merchantSettingDefinition;
$this->sectionSettingDefinition = $sectionSettingDefinition;
$this->translatorAdmin = $translatorAdmin ;
}

public function manageMerchant(Request $request)
@@ -69,7 +73,7 @@ class SettingAdminController extends AbstractController
$this->em->update($entity);
$this->em->flush();

$this->addFlash('success', 'Paramètres mis à jour');
$this->addFlash('success', $this->translatorAdmin->transFlashMessage('settings_saved'));
}

return $this->render(

+ 11
- 2
Form/Setting/MerchantSettingsFormType.php Целия файл

@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\Form\Setting;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
@@ -14,12 +15,13 @@ use Symfony\Component\OptionsResolver\OptionsResolver;

class MerchantSettingsFormType extends AbstractType
{

protected $em;
protected $translatorAdmin;

public function __construct(EntityManagerInterface $em)
public function __construct(EntityManagerInterface $em, TranslatorAdmin $translatorAdmin)
{
$this->em = $em;
$this->translatorAdmin = $translatorAdmin;
}

public function buildForm(FormBuilderInterface $builder, array $options)
@@ -35,6 +37,13 @@ class MerchantSettingsFormType extends AbstractType
'by_reference' => false
]
);

$builder->add('submit', SubmitType::class, [
'label' => $this->translatorAdmin->transAction('save'),
'attr' => [
'class' => 'btn btn-primary float-right'
]
]) ;
}

/**

+ 12
- 1
Form/Setting/SectionSettingsFormType.php Целия файл

@@ -4,18 +4,22 @@ namespace Lc\CaracoleBundle\Form\Setting;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class SectionSettingsFormType extends AbstractType
{
protected $em;
protected $translatorAdmin;

public function __construct(EntityManagerInterface $em)
public function __construct(EntityManagerInterface $em, TranslatorAdmin $translatorAdmin)
{
$this->em = $em;
$this->translatorAdmin = $translatorAdmin;
}

public function buildForm(FormBuilderInterface $builder, array $options)
@@ -31,6 +35,13 @@ class SectionSettingsFormType extends AbstractType
'by_reference' => false
]
);

$builder->add('submit', SubmitType::class, [
'label' => $this->translatorAdmin->transAction('save'),
'attr' => [
'class' => 'btn btn-primary float-right'
]
]) ;
}

/**

+ 1
- 1
Model/Setting/SettingTrait.php Целия файл

@@ -66,7 +66,7 @@ trait SettingTrait
return $this->date;
}

public function setDate(\DateTimeInterface $date): self
public function setDate(?\DateTimeInterface $date): self
{
$this->date = $date;


+ 3
- 0
Resources/translations/admin.fr.yaml Целия файл

@@ -8,6 +8,9 @@ menu:
admin_section: Sections
admin_tva: TVA

flash_message:
settings_saved: Paramètres mis à jour

entity:
default:
fields:

+ 34
- 47
Resources/views/admin/setting/form.html.twig Целия файл

@@ -1,62 +1,49 @@

<div class="card card-outline">
<div class="card-header p-0 border-bottom-0">
<ul id="nav-params" class="nav nav-pills" role="navigation">
{% for index, category in setting_definition.getCategories() %}
<li class="nav-item">
<a href="#panel-{{ category }} " class="nav-link {{ index == 0 ? 'active' }}"
data-toggle="tab" role="tab"
aria-controls="panel-{{ category }}">
{{ ('setting_definition.'~trans_category~'.categories.'~category)|trans({}, 'admin') }}
<i class="fa fa-exclamation-circle invalid-form"></i>
</a>
</li>
{% endfor %}
</ul>
</div>
</div>
{% embed '@LcSov/adminlte/embed/tabs/tabs.html.twig' %}
{# items menu #}
{% import '@LcSov/adminlte/macro/tabs.html.twig' as mtabs %}
{% block menu_items %}
{% for index, category in setting_definition.getCategories() %}
{{ mtabs.menu_item(category, loop.first, ('setting_definition.'~trans_category~'.categories.'~category)|trans({}, 'admin')) }}
{% endfor %}
{% endblock %}

{% form_theme form '@LcSov/adminlte/crud/form_theme.html.twig' %}
{{ form_start(form) }}
<div class="tab-content">
{% set childSettings = form.settings %}
{% for index, category in setting_definition.getCategories() %}
<div class="tab-pane {{ index == 0 ? 'active' }}" id="panel-{{ category }}">
{% embed '@LcSov/adminlte/embed/card.html.twig' %}
{% block header_wrapper %}{% endblock %}
{% block body %}
{# content #}
{% block content %}
{% form_theme form '@LcSov/adminlte/crud/form_theme.html.twig' %}
{{ form_start(form) }}

{# panes #}
{% for index, category in setting_definition.getCategories() %}
{% embed '@LcSov/adminlte/embed/tabs/pane.html.twig' %}
{% block class %}{{ index == 0 ? 'active' }}{% endblock %}
{% block id %}{{ category }}{% endblock %}
{% block content %}
{% set count = 0 %}
{% for name, setting in setting_definition.getSettingsByCategory(category) %}
{% for child in childSettings %}
{% for child in form.settings %}
{% if child.children.name.vars.value == name %}
{{ form_widget(child) }}
{% set count = count + 1 %}
{% endif %}
{% endfor %}
{% endfor %}

{% if count == 0 %}
<div class="callout callout-warning">
Aucun paramètre disponible dans cet onglet.
</div>
{% import '@LcSov/adminlte/macro/callout.html.twig' as mcallout %}
{{ mcallout.callout_warning('Aucun paramètre disponible dans cet onglet.') }}
{% endif %}
{% endblock %}
{% block footer_wrapper %}{% endblock %}
{% endembed %}
</div>
{% endfor %}
</div>
{% endfor %}

{# form footer #}
{% embed '@LcSov/adminlte/embed/form_footer.html.twig' %}
{% block width %}12{% endblock %}
{% block content %}
{{ form_widget(form.submit) }}
{% endblock %}
{% endembed %}

<div class="form-footer">
<div class="row">
<div class="col-sm-12">
<div class="btn-list">
<button class="btn btn-info float-right" type="submit" name="submit" value="submit"
data-action-name="submit">
<span class="btn-label">Sauvegarder</span>
</button>
</div>
</div>
</div>
</div>
{{ form_end(form) }}
{{ form_end(form) }}
{% endblock %}
{% endembed %}

Loading…
Отказ
Запис