Commit 14591fe6 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajustement du formulaire de template + retrait des morceaux fantomes d'historisation

parent 12bc7326
Pipeline #11032 passed with stage
in 20 seconds
......@@ -4,7 +4,6 @@ INSERT INTO unicaen_privilege_categorie (id ,code, libelle, ordre, namespace) VA
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'documentmacro_index', 'Afficher l''index des macros', 1);
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'documentmacro_ajouter', 'Ajouter une macro', 10);
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'documentmacro_modifier', 'Modifier une macro', 20);
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'documentmacro_historiser', 'Historiser/Restaure une macro', 30);
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'documentmacro_supprimer', 'Supprimer une macro', 40);
-- TEMPLATE
......@@ -12,7 +11,6 @@ INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre)
INSERT INTO unicaen_privilege_categorie (id, code, libelle, ordre, namespace) VALUES (next_val('unicaen_privilege_categorie_id_seq'), 'documenttemplate', 'UnicaenRenderer - Gestion des templates', 11020, 'UnicaenRenderer\Provider\Privilege');
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'documenttemplate_index', 'Afficher l''index des contenus', 1);
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'documenttemplate_modifier', 'Modifier un contenu', 20);
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'documenttemplate_historiser', 'Historiser/Restaurer un contenu', 30);
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'documenttemplate_supprimer', 'Supprimer un contenu', 40);
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'documenttemplate_ajouter', 'Ajouter un contenu', 15);
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'documenttemplate_afficher', 'Afficher un template', 10);
......
......@@ -45,16 +45,6 @@ return [
DocumentmacroPrivileges::DOCUMENTMACRO_MODIFIER,
],
],
[
'controller' => MacroController::class,
'action' => [
'historiser',
'restaurer',
],
'privileges' => [
DocumentmacroPrivileges::DOCUMENTMACRO_HISTORISER,
],
],
[
'controller' => MacroController::class,
'action' => [
......@@ -136,26 +126,6 @@ return [
],
],
],
'historiser' => [
'type' => Segment::class,
'options' => [
'route' => '/historiser/:macro',
'defaults' => [
'controller' => MacroController::class,
'action' => 'historiser',
],
],
],
'restaurer' => [
'type' => Segment::class,
'options' => [
'route' => '/restaurer/:macro',
'defaults' => [
'controller' => MacroController::class,
'action' => 'restaurer',
],
],
],
'supprimer' => [
'type' => Segment::class,
'options' => [
......
......@@ -53,16 +53,6 @@ return [
DocumenttemplatePrivileges::DOCUMENTTEMPLATE_MODIFIER,
],
],
[
'controller' => TemplateController::class,
'action' => [
'historiser',
'restaurer',
],
'privileges' => [
DocumenttemplatePrivileges::DOCUMENTTEMPLATE_HISTORISER,
],
],
[
'controller' => TemplateController::class,
'action' => [
......@@ -144,26 +134,6 @@ return [
],
],
],
'restaurer' => [
'type' => Segment::class,
'options' => [
'route' => '/restaurer/:template',
'defaults' => [
'controller' => TemplateController::class,
'action' => 'restaurer',
],
],
],
'historiser' => [
'type' => Segment::class,
'options' => [
'route' => '/historiser/:template',
'defaults' => [
'controller' => TemplateController::class,
'action' => 'historiser',
],
],
],
'detruire' => [
'type' => Segment::class,
'options' => [
......
......@@ -116,7 +116,6 @@ Privilèges associés au module
const DOCUMENTMACRO_INDEX = 'documentmacro-documentmacro_index';
const DOCUMENTMACRO_AJOUTER = 'documentmacro-documentmacro_ajouter';
const DOCUMENTMACRO_MODIFIER = 'documentmacro-documentmacro_modifier';
const DOCUMENTMACRO_HISTORISER = 'documentmacro-documentmacro_historiser';
const DOCUMENTMACRO_SUPPRIMER = 'documentmacro-documentmacro_supprimer';
```
......@@ -127,7 +126,6 @@ const DOCUMENTTEMPLATE_INDEX = 'documenttemplate-documenttemplate_index';
const DOCUMENTTEMPLATE_AFFICHER = 'documenttemplate-documenttemplate_afficher';
const DOCUMENTTEMPLATE_AJOUTER = 'documenttemplate-documenttemplate_ajouter';
const DOCUMENTTEMPLATE_MODIFIER = 'documenttemplate-documenttemplate_modifier';
const DOCUMENTTEMPLATE_HISTORISER = 'documenttemplate-documenttemplate_historiser';
const DOCUMENTTEMPLATE_SUPPRIMER = 'documenttemplate-documenttemplate_supprimer';
```
......
......@@ -85,20 +85,6 @@ class MacroController extends AbstractActionController {
return $vm;
}
public function historiserAction()
{
$macro = $this->getMacroService()->getRequestedMacro($this);
$this->getMacroService()->historise($macro);
return $this->redirect()->toRoute('contenu/macro', [], [], true);
}
public function restaurerAction()
{
$macro = $this->getMacroService()->getRequestedMacro($this);
$this->getMacroService()->restore($macro);
return $this->redirect()->toRoute('contenu/macro', [], [], true);
}
public function supprimerAction()
{
$macro = $this->getMacroService()->getRequestedMacro($this);
......
......@@ -83,22 +83,6 @@ class TemplateController extends AbstractActionController {
]);
}
public function historiserAction()
{
$template = $this->getTemplateService()->getRequestedTemplate($this);
$this->getTemplateService()->historise($template);
return $this->redirect()->toRoute('contenu/template', [], [], true);
}
public function restaurerAction()
{
$template = $this->getTemplateService()->getRequestedTemplate($this);
$this->getTemplateService()->restore($template);
return $this->redirect()->toRoute('contenu/template', [], [], true);
}
public function detruireAction()
{
$template = $this->getTemplateService()->getRequestedTemplate($this);
......
......@@ -74,7 +74,7 @@ class TemplateForm extends Form {
]);
//complement
$this->add([
'name' => 'complement',
'name' => 'sujet',
'type' => 'textarea',
'options' => [
'label' => 'Sujet (sujet du courrier électronique, nom du fichier, étiquette, ... ) * : ',
......@@ -83,13 +83,13 @@ class TemplateForm extends Form {
],
],
'attributes' => [
'id' => 'complement',
'class' => 'form-control complement',
'id' => 'sujet',
'class' => 'form-control sujet',
]
]);
//template
$this->add([
'name' => 'template',
'name' => 'corps',
'type' => 'textarea',
'options' => [
'label' => 'Corps * : ',
......@@ -98,8 +98,8 @@ class TemplateForm extends Form {
],
],
'attributes' => [
'id' => 'template',
'class' => 'form-control contenu',
'id' => 'corps',
'class' => 'form-control corps',
]
]);
//css
......@@ -153,8 +153,8 @@ class TemplateForm extends Form {
'old-code' => ['required' => false, ],
'type' => ['required' => true, ],
'description' => ['required' => false, ],
'complement' => ['required' => true, ],
'contenu' => ['required' => true, ],
'sujet' => ['required' => true, ],
'corps' => ['required' => true, ],
'css' => ['required' => false, ],
]));
......
......@@ -17,8 +17,8 @@ class TemplateHydrator implements HydratorInterface {
'code' => ($object)?$object->getCode():null,
'type' => ($object)?$object->getType():null,
'description' => ($object)?$object->getDescription():null,
'complement' => ($object)?$object->getComplement():null,
'template' => ($object)?$object->getTemplate():null,
'sujet' => ($object)?$object->getSujet():null,
'corps' => ($object)?$object->getCorps():null,
'css' => ($object)?$object->getCss():null,
];
......@@ -35,15 +35,15 @@ class TemplateHydrator implements HydratorInterface {
$code = (isset($data['code']) AND trim($data['code']) !== "")?trim($data['code']):null;
$type = (isset($data['type']) AND trim($data['type']) !== "")?trim($data['type']):null;
$description = (isset($data['description']) AND trim($data['description']) !== "")?trim($data['description']):null;
$complement = (isset($data['complement']) AND trim($data['complement']) !== "")?strip_tags(trim($data['complement'])):null;
$template = (isset($data['template']) AND trim($data['template']) !== "")?trim($data['template']):null;
$sujet = (isset($data['sujet']) AND trim($data['sujet']) !== "")?strip_tags(trim($data['sujet'])):null;
$corps = (isset($data['corps']) AND trim($data['corps']) !== "")?trim($data['corps']):null;
$css = (isset($data['css']) AND trim($data['css']) !== "")?strip_tags(trim($data['css'])):null;
$object->setCode($code);
$object->setType($type);
$object->setDescription($description);
$object->setComplement($complement);
$object->setTemplate($contenu);
$object->setSujet($sujet);
$object->setCorps($corps);
$object->setCss($css);
return $object;
......
......@@ -10,6 +10,5 @@ class DocumenttemplatePrivileges extends Privileges
const DOCUMENTTEMPLATE_AJOUTER = 'documenttemplate-documenttemplate_ajouter';
const DOCUMENTTEMPLATE_AFFICHER = 'documenttemplate-documenttemplate_afficher';
const DOCUMENTTEMPLATE_MODIFIER = 'documenttemplate-documenttemplate_modifier';
const DOCUMENTTEMPLATE_HISTORISER = 'documenttemplate-documenttemplate_historiser';
const DOCUMENTTEMPLATE_SUPPRIMER = 'documenttemplate-documenttemplate_supprimer';
}
\ No newline at end of file
......@@ -202,10 +202,8 @@ class MacroService {
$result = "let macros = [\n";
foreach ($macros as $macro) {
if ($macro->estNonHistorise()) {
$result .= " { title:'" . $macro->getCode() . "', description:'" . strip_tags(str_replace("'","\'",$macro->getDescription())) . "', content:'VAR[" . $macro->getCode() . "]' },\n";
}
}
$result .= "];\n";
return $result;
......
......@@ -48,34 +48,6 @@ class TemplateService {
return $template;
}
/**
* @param Template $template
* @return Template
*/
public function historise(Template $template) : Template
{
try {
$this->getEntityManager()->flush($template);
} catch (ORMException $e) {
throw new RuntimeException("Un problème est survenue lors de l'enregistrement en BD du Template.", $e);
}
return $template;
}
/**
* @param Template $template
* @return Template
*/
public function restore(Template $template) : Template
{
try {
$this->getEntityManager()->flush($template);
} catch (ORMException $e) {
throw new RuntimeException("Un problème est survenue lors de l'enregistrement en BD du Template.", $e);
}
return $template;
}
/**
* @param Template $template
* @return Template
......
......@@ -48,7 +48,7 @@ $this->headTitle("Index des macros");
</thead>
<tbody>
<?php foreach($macros as $macro) : ?>
<tr <?php if ($macro->estHistorise()) echo 'class="historise"'; ?> >
<tr>
<td>
<?php echo $macro->getCode(); ?>
<?php if ($macro->getDescription() !== null) : ?>
......@@ -69,21 +69,6 @@ $this->headTitle("Index des macros");
>
<span class="icon editer"></span></a>
<?php endif; ?>
<?php if ($canHistoriser) : ?>
<?php if ($macro->estHistorise()): ?>
<a href="<?php echo $this->url('contenu/macro/restaurer', ['macro' => $macro->getId()], [], true); ?>"
data-toggle="tooltip" data-html="true"
title="Restauration de la macro <span class='highlight macro'><?php echo $macro->getCode(); ?></span>"
>
<span class="icon restaurer"></span></a>
<?php else :?>
<a href="<?php echo $this->url('contenu/macro/historiser', ['macro' => $macro->getId()], [], true); ?>"
data-toggle="tooltip" data-html="true"
title="Historiser de la macro <span class='highlight macro'><?php echo $macro->getCode(); ?></span>"
>
<span class="icon historiser"></span>
<?php endif; ?>
<?php endif; ?>
<?php if ($canSupprimer) : ?>
<a href="<?php echo $this->url('contenu/macro/supprimer', ['macro' => $macro->getId()], [], true); ?>"
class="ajax-modal" data-event="modification" data-toggle="tooltip" data-html="true"
......
<?php
use UnicaenRenderer\Entity\Db\Content;
use UnicaenRenderer\Entity\Db\Template;
/**
* @see \UnicaenRenderer\Controller\ContenuController::afficherAction()
* @var Content $contenu
* @var Template $contenu
*/
?>
......
......@@ -11,7 +11,6 @@ use UnicaenRenderer\Provider\Privilege\DocumenttemplatePrivileges;
$canAjouter = $this->isAllowed(DocumenttemplatePrivileges::getResourceId(DocumenttemplatePrivileges::DOCUMENTTEMPLATE_AJOUTER));
$canAfficher = $this->isAllowed(DocumenttemplatePrivileges::getResourceId(DocumenttemplatePrivileges::DOCUMENTTEMPLATE_AFFICHER));
$canModifier = $this->isAllowed(DocumenttemplatePrivileges::getResourceId(DocumenttemplatePrivileges::DOCUMENTTEMPLATE_MODIFIER));
$canHistoriser = $this->isAllowed(DocumenttemplatePrivileges::getResourceId(DocumenttemplatePrivileges::DOCUMENTTEMPLATE_HISTORISER));
$canDetruire = $this->isAllowed(DocumenttemplatePrivileges::getResourceId(DocumenttemplatePrivileges::DOCUMENTTEMPLATE_SUPPRIMER));
$this->headTitle("Index des templates");
......@@ -40,7 +39,7 @@ $this->headTitle("Index des templates");
</thead>
<tbody>
<?php foreach ($templates as $template) : ?>
<tr class="<?php if ($template->estHistorise()) echo 'historise '; ?>">
<tr>
<td>
<?php echo $template->getCode(); ?>
<?php if ($template->getDescription() !== null) : ?>
......@@ -65,19 +64,6 @@ $this->headTitle("Index des templates");
>
<span class="icon editer"></span></a>
<?php endif; ?>
<?php if ($canHistoriser) : ?>
<?php if ($template->estNonHistorise()) : ?>
<?php /** @see \UnicaenRenderer\Controller\TemplateController::historiserAction() */?>
<a href="<?php echo $this->url('contenu/template/historiser', ['template' => $template->getId()], [], true); ?>"
>
<span class="icon historiser"></span></a>
<?php else : ?>
<?php /** @see \UnicaenRenderer\Controller\TemplateController::restaurerAction() */?>
<a href="<?php echo $this->url('contenu/template/restaurer', ['template' => $template->getId()], [], true); ?>"
>
<span class="icon restaurer"></span></a>
<?php endif; ?>
<?php endif; ?>
<?php if ($canDetruire) : ?>
<?php /** @see \UnicaenRenderer\Controller\TemplateController::detruireAction() */?>
<a href="<?php echo $this->url('contenu/template/detruire', ['template' => $template->getId()], [], true); ?>"
......
<?php
use UnicaenRenderer\Form\Contenu\ContenuForm;
use UnicaenRenderer\Form\Template\TemplateForm;
/**
* @see \UnicaenRenderer\Controller\ContenuController::ajouterAction()
* @see \UnicaenRenderer\Controller\ContenuController::modifierAction()
* @var ContenuForm $form
* @var TemplateForm $form
* @var string $macros
*/
......@@ -46,7 +46,7 @@ use UnicaenRenderer\Form\Contenu\ContenuForm;
}
});
tinymce.init({
selector: '.complement',
selector: '.sujet',
toolbar: 'newdocument undo redo | template',
resize: true,
language: 'fr_FR',
......@@ -56,15 +56,15 @@ use UnicaenRenderer\Form\Contenu\ContenuForm;
browser_spellcheck: true,
branding: false,
menu: {},
body_id: 'complement',
body_id: 'sujet',
setup: function (editor) {
editor.on("focusout", function () {
$('textarea#complement').val(tinymce.get('complement').getContent());
$('textarea#sujet').val(tinymce.get('sujet').getContent());
});
}
});
tinymce.init({
selector: '.contenu',
selector: '.corps',
menubar: 'table',
toolbar: 'newdocument undo redo | bold italic | bullist table | alignjustify alignleft alignright aligncenter | formatselect template',
block_formats: 'Normal=p;Titre 1=h1;Titre 2=h2;Titre 3=h3',
......@@ -76,10 +76,10 @@ use UnicaenRenderer\Form\Contenu\ContenuForm;
browser_spellcheck: true,
branding: false,
menu: {},
body_id: 'contenu',
body_id: 'corps',
setup: function (editor) {
editor.on("focusout", function () {
$('textarea#contenu').val(tinymce.get('contenu').getContent());
$('textarea#corps').val(tinymce.get('corps').getContent());
});
}
});
......
Supports Markdown
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