Commit 5015f2c7 by Julien Jorry

Update : Add CKEditor with image / media + Add Page BO + Add reconversion + Add…

Update : Add CKEditor with image / media + Add Page BO + Add reconversion + Add reconverti on transfert groupe comptoir...
parent 99f8ef01
......@@ -37,7 +37,6 @@ return [
Hautelook\AliceBundle\HautelookAliceBundle::class => ['dev' => true, 'test' => true],
JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true],
Sonata\MediaBundle\SonataMediaBundle::class => ['all' => true],
FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true],
App\Application\Sonata\MediaBundle\ApplicationSonataMediaBundle::class => ['all' => true],
Bazinga\GeocoderBundle\BazingaGeocoderBundle::class => ['all' => true],
Sonata\TranslationBundle\SonataTranslationBundle::class => ['all' => true],
......@@ -46,4 +45,7 @@ return [
Prodigious\Sonata\MenuBundle\ProdigiousSonataMenuBundle::class => ['all' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
Knp\Bundle\MarkdownBundle\KnpMarkdownBundle::class => ['all' => true],
FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true],
Sonata\FormatterBundle\SonataFormatterBundle::class => ['all' => true],
];
......@@ -17,18 +17,18 @@ fos_ck_editor:
Blockquote, -, Image, Link, Unlink, Table]
- [Format, Maximize, Source]
# filebrowserBrowseRoute: admin_sonata_media_media_ckeditor_browser
# filebrowserImageBrowseRoute: admin_sonata_media_media_ckeditor_browser
# # Display images by default when clicking the image dialog browse button
# filebrowserImageBrowseRouteParameters:
# provider: sonata.media.provider.image
# filebrowserUploadMethod: form
# filebrowserUploadRoute: admin_sonata_media_media_ckeditor_upload
# filebrowserUploadRouteParameters:
# provider: sonata.media.provider.file
# # Upload file as image when sending a file from the image dialog
# filebrowserImageUploadRoute: admin_sonata_media_media_ckeditor_upload
# filebrowserImageUploadRouteParameters:
# provider: sonata.media.provider.image
# context: my-context # Optional, to upload in a custom context
# format: my-big # Optional, media format or original size returned to editor
\ No newline at end of file
filebrowserBrowseRoute: admin_sonata_media_media_ckeditor_browser
filebrowserImageBrowseRoute: admin_sonata_media_media_ckeditor_browser
# Display images by default when clicking the image dialog browse button
filebrowserImageBrowseRouteParameters:
provider: sonata.media.provider.image
filebrowserUploadMethod: form
filebrowserUploadRoute: admin_sonata_media_media_ckeditor_upload
filebrowserUploadRouteParameters:
provider: sonata.media.provider.file
# Upload file as image when sending a file from the image dialog
filebrowserImageUploadRoute: admin_sonata_media_media_ckeditor_upload
filebrowserImageUploadRouteParameters:
provider: sonata.media.provider.image
context: default # Optional, to upload in a custom context
#format: my-big # Optional, media format or original size returned to editor
\ No newline at end of file
......@@ -28,4 +28,20 @@ sonata_block:
sonata.admin.block.admin_list:
contexts: [admin]
sonata.admin.block.search_result:
contexts: [admin]
\ No newline at end of file
contexts: [admin]
sonata.formatter.block.formatter:
contexts: [admin]
sonata_formatter:
default_formatter: text
formatters:
text:
service: sonata.formatter.text.text
extensions:
- sonata.formatter.twig.control_flow
- sonata.formatter.twig.gist
ckeditor:
templates:
browser: '@SonataFormatter/Ckeditor/browser.html.twig'
upload: '@SonataFormatter/Ckeditor/upload.html.twig'
......@@ -198,6 +198,14 @@ sonata_admin:
icon: '<i class="fa fa-file-text"></i>'
items:
- admin.document.gerer
sonata.admin.group.page:
keep_open: false
on_top: true
label: "Pages"
label_catalogue: SonataAdminBundle
icon: '<i class="fa fa-newspaper-o"></i>'
items:
- admin.page.gerer
sonata.admin.group.rubrique:
keep_open: false
on_top: true
......@@ -232,6 +240,7 @@ sonata_admin:
- admin.all.cotisations
- admin.transfert.gerer
- admin.transaction.gerer
- admin.reconversion.gerer
sonata.admin.group.menu_builder:
keep_open: false
on_top: true
......
......@@ -2,4 +2,6 @@ twig:
default_path: '%kernel.project_dir%/templates'
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
form_themes: ['bootstrap_4_layout.html.twig']
\ No newline at end of file
form_themes:
- 'bootstrap_4_layout.html.twig'
- '@SonataFormatter/Form/formatter.html.twig'
\ No newline at end of file
......@@ -302,6 +302,31 @@ services:
calls:
- [ setSecurity, ['@security.helper']]
admin.reconversion.gerer:
class: App\Admin\ReconversionAdmin
arguments: [~, App\Entity\Transfert, ~]
tags:
- name: sonata.admin
manager_type: orm
group: "Flux"
label: "Reconversion"
pager_type: "simple"
public: true
calls:
- [ setSecurity, ['@security.helper']]
admin.page.gerer:
class: App\Admin\PageAdmin
arguments: [~, App\Entity\Page, ~]
tags:
- name: sonata.admin
manager_type: orm
group: "Pages"
label: "Pages"
public: true
calls:
- [ setSecurity, ['@security.helper']]
# admin.flux.gerer:
# class: App\Admin\FluxAdmin
# arguments: [~, App\Entity\Transaction, ~]
......
......@@ -38,6 +38,7 @@ App\Entity\Usergroup:
'ROLE_ADMIN_DOCUMENT_GERER_ALL',
'ROLE_ADMIN_RUBRIQUE_GERER_ALL',
'ROLE_ADMIN_FAQ_GERER_ALL',
'ROLE_ADMIN_PAGE_GERER_ALL',
'ROLE_ADMIN_TRADUCTION_GERER_ALL']]
usergroup_controleur:
__construct: ['Contrôleur', [
......@@ -52,6 +53,7 @@ App\Entity\Usergroup:
'ROLE_ADMIN_PRESTATAIRE_GERER_ALL',
'ROLE_ADMIN_PRESTATAIRE_COTISATIONS_ALL',
'ROLE_ADMIN_ALL_COTISATIONS_ALL',
'ROLE_ADMIN_RECONVERSION_GERER_ALL',
'ROLE_ADMIN_TRANSFERT_GERER_ALL']]
usergroup_gestiongroupe:
__construct: ['Gestionnaire de Groupe', [
......
......@@ -11,6 +11,7 @@ use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\FormatterBundle\Form\Type\SimpleFormatterType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
......@@ -53,6 +54,12 @@ class GroupeAdmin extends AbstractAdmin
'label' => 'Description :',
'required' => false,
))
// ->add('content', SimpleFormatterType::class, [
// 'format' => 'richhtml',
// 'ckeditor_context' => 'default',
// 'label' => 'Description :',
// 'required' => false,
// ])
->add('comptoirs', CollectionType::class, array(
'label' => 'Comptoirs',
'entry_type' => EntityType::class,
......
......@@ -17,7 +17,6 @@ use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Security\Core\Security;
class GroupeprestataireAdmin extends AbstractAdmin
......
<?php
namespace App\Admin;
use App\Entity\User;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\MediaBundle\Form\Type\MediaType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Security\Core\Security;
class PageAdmin extends AbstractAdmin
{
protected $security;
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'updatedAt',
];
public function setSecurity(Security $security)
{
$this->security = $security;
}
public function configure()
{
parent::configure();
}
/**
* {@inheritdoc}
*/
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{
parent::configureDatagridFilters($datagridMapper);
$datagridMapper
->add('user')
;
}
/**
* {@inheritdoc}
*/
protected function configureFormFields(FormMapper $formMapper)
{
$page = $this->getSubject();
if ($this->isCurrentRoute('create')) {
$page->setUser($this->security->getUser());
}
$formMapper
->add('user', HiddenType::class, array(
'data' => $this->getConfigurationPool()->getContainer()->get('security.token_storage')->getToken()->getUser()->getId(),
'data_class' => null,
'entity_class' => User::class,
'em' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getEntityManager()
))
->add('name', TextType::class, array(
'label' => 'Titre :',
'required' => true
))
->add('content', CKEditorType::class, array(
'label' => 'Contenu :',
'required' => true
))
->add('metaDescription', TextType::class, array(
'label' => 'Meta Description :',
'required' => true
))
->add('metaKeywords', TextType::class, array(
'label' => 'Meta Keywords :',
'required' => true
))
->add('template', TextType::class, array(
'label' => 'Template :',
'required' => false
))
->add('css', TextareaType::class, array(
'label' => 'CSS :',
'required' => false
))
->add('js', TextareaType::class, array(
'label' => 'JS :',
'required' => false
))
->add('enabled', CheckboxType::class, array(
'label' => 'Activé ?',
'label_attr' => array('class' => 'checkbox-inline'),
'required' => false
))
;
}
/**
* {@inheritdoc}
*/
protected function configureListFields(ListMapper $listMapper)
{
unset($this->listModes['mosaic']);
$listMapper
->addIdentifier('user', null, array('label' => 'Auteur'))
->addIdentifier('name', null, array('label' => 'Titre'))
// ->addIdentifier('enabled', null, array('label' => 'Activé', 'datatype' => 'App.Page', 'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'))
;
}
protected function configureRoutes(RouteCollection $collection)
{
$collection->remove('delete');
}
public function getBatchActions()
{
$actions = parent::getBatchActions();
unset($actions['delete']);
return $actions;
}
}
......@@ -111,9 +111,13 @@ class PrestataireAdmin extends AbstractAdmin
$now = new \DateTime();
$cotisation = null;
if ($this->isCurrentRoute('create')) {
if ($user->isGranted('ROLE_CONTACT') or $user->isGranted('ROLE_COMPTOIR')) {
$user->setEnabled(false);
} else {
$user->setEnabled(true);
}
$user = $this->userManager->createUser();
$groupe = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Usergroup::class)->findOneByName('Prestataire');
$user->setEnabled(true);
$user->addGroup($groupe);
$user->addRole('ROLE_PRESTATAIRE');
$user->setPrestataire($presta);
......@@ -416,7 +420,13 @@ class PrestataireAdmin extends AbstractAdmin
'sort_field_mapping' => array('fieldName' => 'name'),
'sort_parent_association_mappings' => array(array('fieldName' => 'groupe'))
))
->addIdentifier('user.enabled', null, array('label' => 'Activé', 'datatype' => 'App.User', 'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'))
;
if ($user->isGranted('ROLE_GESTION_GROUPE')) {
$listMapper
->addIdentifier('user.enabled', null, array('label' => 'Activé', 'datatype' => 'App.User', 'template' => '@SonataAdmin/Boolean/editable_boolean.html.twig'))
;
}
$listMapper
->addIdentifier('user.createdAt')
;
......
<?php
namespace App\Admin;
use App\Admin\FluxAdmin;
use App\Entity\User;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Form\Type\Filter\ChoiceType;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Show\ShowMapper;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType as SChoiceType;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Translation\TranslatorInterface;
class ReconversionAdmin extends FluxAdmin
{
protected $security;
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
];
public function setSecurity(Security $security)
{
$this->security = $security;
}
/**
* {@inheritdoc}
*/
public function createQuery($context = 'list')
{
$user = $this->security->getUser();
$query = parent::createQuery($context);
$query->andWhere($query->getRootAliases()[0].".type = :type")
->setParameter('type', 'prestataire_siege');
;
return $query;
}
/**
* {@inheritdoc}
*/
protected function configureListFields(ListMapper $listMapper)
{
unset($this->listModes['mosaic']);
$listMapper
->addIdentifier('createdAt', null, array('label' => 'Date'))
->addIdentifier('type', null, array('label' => 'Type'))
->addIdentifier('operateur', User::class, array('label' => 'Operateur'))
->addIdentifier('expediteur', null, array('label' => 'Expediteur'))
->addIdentifier('destinataire', null, array('label' => 'Destinataire'))
->addIdentifier('montant', null, array('label' => 'Montant'))
->addIdentifier('reference', null, array('label' => 'Reference'))
->addIdentifier('reconverti', null, array('label' => 'Reconverti ?', 'datatype' => 'App.Flux', 'template' => 'block/reconverti_field.html.twig'))
;
}
/**
* {@inheritdoc}
*/
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{
$datagridMapper
->remove('transfert_or_transaction')
->remove('type')
->remove('operateur')
;
}
}
......@@ -2,6 +2,7 @@
namespace App\Controller;
use App\Entity\TransfertPrestataireSiege;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
......@@ -46,6 +47,33 @@ class AdminController extends Controller
return new JsonResponse(array('status' => $status, 'newvalue' => ($object->isEnabled()?'true':'false')));
}
/**
* @Route("/setreconverti/{id}", name="setreconverti")
*/
public function setReconvertiAction($id, Request $request)
{
$referer = $request->headers->get('referer');
if ($referer && !$request->isXmlHttpRequest()) {
return $this->redirect($referer);
} elseif (!$request->isXmlHttpRequest()) {
return new Response('', Response::HTTP_BAD_REQUEST);
}
$status = 'success';
try {
$object = $this->em->getRepository(TransfertPrestataireSiege::class)->findOneById($id);
if ($object && method_exists($object, 'setReconverti')) {
$object->setReconverti(!$object->getReconverti());
$this->em->persist($object);
$this->em->flush();
} else {
$status = 'error';
}
} catch (\Exception $e) {
$status = 'error';
}
return new JsonResponse(array('status' => $status, 'newvalue' => ($object->getReconverti()?'true':'false')));
}
// /**
// * Voir tous les dashboards
// * Route admin_index
......
......@@ -71,6 +71,11 @@ class Page
*/
private $user;
public function getId()
{
return $this->getId();
}
/**
* @return null|string
*/
......@@ -178,4 +183,9 @@ class Page
$this->user = $user;
return $this;
}
public function __toString(): string
{
return $this->getName()?$this->getName():'Page';
}
}
......@@ -32,6 +32,12 @@ class TransfertPrestataireSiege extends Transfert
*/
protected $reconverti = false;
public function __construct()
{
parent::__construct();
$this->reconverti = false;
}
public function getReconverti(): bool
{
return $this->reconverti;
......
......@@ -102,6 +102,12 @@ class User extends BaseUser
*/
private $news;
/**
* @var ArrayCollection|Page[]
* @ORM\OneToMany(targetEntity="App\Entity\Page", mappedBy="user", cascade={"persist"})
*/
private $pages;
public function __construct()
{
parent::__construct();
......@@ -433,4 +439,35 @@ class User extends BaseUser
return $this;
}
/**
* @return Collection|Page[]
*/
public function getPage(): Collection
{
return $this->page;
}
public function addPage(Page $page): self
{
if (!$this->page->contains($page)) {
$this->page[] = $page;
$page->setUser($this);
}
return $this;
}
public function removePage(Page $page): self
{
if ($this->page->contains($page)) {
$this->page->removeElement($page);
// set the owning side to null (unless already changed)
if ($page->getUser() === $this) {
$page->setUser(null);
}
}
return $this;
}
}
......@@ -123,13 +123,7 @@
"version": "1.0.0"
},
"friendsofsymfony/ckeditor-bundle": {
"version": "2.0",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "master",
"version": "2.0",
"ref": "8eb1cd0962ded6a6d6e1e5a9b6d3e888f9f94ff6"
}
"version": "1.2.0"
},
"friendsofsymfony/rest-bundle": {
"version": "2.2",
......@@ -212,6 +206,9 @@
"knplabs/knp-components": {
"version": "v1.3.10"
},
"knplabs/knp-markdown-bundle": {
"version": "1.7.1"
},
"knplabs/knp-menu": {
"version": "2.3.0"
},
......@@ -236,6 +233,9 @@
"ref": "523b4b0cfb88dc8637cb56e427e6be7718bdce32"
}
},
"michelf/php-markdown": {
"version": "1.8.0"
},
"monolog/monolog": {
"version": "1.24.0"
},
......@@ -410,6 +410,9 @@
"sonata-project/exporter": {
"version": "1.9.1"
},
"sonata-project/formatter-bundle": {
"version": "4.1.2"
},
"sonata-project/intl-bundle": {
"version": "2.5.0"
},
......
{% extends '@SonataAdmin/CRUD/base_list_field.html.twig' %}
{% if object is instanceof("App\\Entity\\Flux") and (app.user.isGranted('ROLE_SUPER_ADMIN') or app.user.isGranted('ROLE_TRESORIER')) %}
{% block field%}
{%- spaceless %}
{% if value %}
{% set text = 'label_type_yes'|trans({}, 'SonataAdminBundle') %}
{% else %}
{% set text = 'label_type_no'|trans({}, 'SonataAdminBundle') %}
{% endif %}
{% if field_description.options.inverse|default(false) ? not value : value %}
{% set class = 'label-success' %}
{% else %}
{% set class = 'label-danger' %}
{% endif %}
<span class="label {{ class }} editableboolean" data-value="{{value ? 'true' : 'false'}}" data-url="{{path('setreconverti', {'id': object.id})}}" style='cursor:pointer;'>{{ text }}</span>
{% endspaceless -%}
{% endblock %}
{% endif %}
\ No newline at end of file
{% set title = page.metatitle %}
{% set title = page.name %}
{% set description = page.metadescription %}
{% set keywords = page.metakeywords %}
{% extends 'common/layout.html.twig' %}
{% if page.css %}
{% block css %}
{{parent()}}
{{ page.css|raw }}
{% endblock css %}
{% endif %}
{% if page.js %}
{% block js %}
{{parent()}}
{{ page.js|raw }}
{% endblock js %}
{% endif %}
{% block content %}
<div class='container'>
<h4>{{page.title}}</h4>
<p class="paragraf">
{{page.content|raw}}
{# Cette Charte des valeurs a été adoptée lors de l'assemblée générale du 25 janvier 2014.<br>
<br>
<strong>En signant cette Charte des valeurs, je m'engage en tant que consommateur ou prestataire à utiliser la monnaie locale comme </strong>&nbsp;: <br>
porteuse de valeurs éthiques, écologiques et sociales dans une recherche de mieux être collectif, outil pour inciter chacun à mieux comprendre sa façon de produire et de consommer, moyen de contribuer à une alternative non-spéculative au modèle économique actuel<br>
<strong>En signant cette Charte des valeurs, je m'engage en tant que consommateur ou prestataire à favoriser&nbsp;</strong>: #}
</p>
{# <p class="paragraf" style="min-height:60px;">
<img src="./pictocharte/proximite.gif" style="float:left;margin-right:10px;width:36px;"> L'activité et les emplois locaux en privilégiant les productions, les services et les commerces de proximité, dans une démarche de qualité.<br>
</p><p class="paragraf" style="min-height:60px;">
<img src="./pictocharte/environnement.gif" style="float:left;margin-right:10px;width:36px;"> Les pratiques respectueuses de la nature et de notre environnement.<br>
</p>
<p class="paragraf" style="min-height:60px;">
<img src="./pictocharte/cooperation.gif" style="float:left;margin-right:10px;width:36px;"> Les échanges entre acteurs locaux dans un esprit de complémentarité, de coopération et de solidarité.<br>
</p>
<p class="paragraf" style="min-height:60px;">
<img src="./pictocharte/populaire.gif" style="float:left;margin-right:10px;width:36px;"> L'accès à la qualité des biens et des services au plus grand nombre.<br>
</p>
<p class="paragraf" style="min-height:60px;">
<img src="./pictocharte/relations.gif" style="float:left;margin-right:10px;width:36px;"> De bonnes relations et conditions de travail.<br>
</p>
<p class="paragraf" style="min-height:60px;">
<img src="./pictocharte/biologique.gif" style="float:left;margin-right:10px;width:36px;"> Le bio avant tout.<br>
</p>
<p class="paragraf" style="min-height:60px;">
<img src="./pictocharte/motivation.gif" style="float:left;margin-right:10px;width:36px;"> Le degré de motivation.<br>
</p> #}
</div>
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment