Commit 74179683 authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Finalisation du module d'administration des structures

parent d5515a75
......@@ -10,6 +10,7 @@
* Formule de calcul de Lyon2
* L'administrateur se voit attibuer systématiquement l'accès à toutes les nouvelles fonctionnalités
* L'interface d'administration des structures est maintenant opérationelle
## Notes de mise à jour
......
......@@ -6,7 +6,7 @@
#
###########################################################################################
FROM unicaen-dev-php7.3-apache
FROM unicaen-dev-php7.4-apache
LABEL maintainer="Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>"
ENV APACHE_CONF_DIR=/etc/apache2 \
......
......@@ -16,7 +16,7 @@
"unicaen/bjy-authorize" : "3.0.4",
"zendframework/zend-file": "2.8.3",
"unicaen/code" : "3.0.0",
"unicaen/import" : "3.0.0",
"unicaen/import" : "3.0.1",
"unicaen/tbl" : "3.0.0",
"unicaen/open-document" : "3.0.1",
"ocramius/proxy-manager" : "2.2.3"
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0399ad7d82979439052f9b2571b583be",
"content-hash": "d6ea41a1721e4e6de1c6be27d4992612",
"packages": [
{
"name": "beberlei/assert",
......@@ -1028,16 +1028,16 @@
},
{
"name": "doctrine/persistence",
"version": "1.2.0",
"version": "1.3.3",
"source": {
"type": "git",
"url": "https://github.com/doctrine/persistence.git",
"reference": "43526ae63312942e5316100bb3ed589ba1aba491"
"reference": "99b196bbd4715a94fa100fac664a351ffa46d6a5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/persistence/zipball/43526ae63312942e5316100bb3ed589ba1aba491",
"reference": "43526ae63312942e5316100bb3ed589ba1aba491",
"url": "https://api.github.com/repos/doctrine/persistence/zipball/99b196bbd4715a94fa100fac664a351ffa46d6a5",
"reference": "99b196bbd4715a94fa100fac664a351ffa46d6a5",
"shasum": ""
},
"require": {
......@@ -1052,19 +1052,20 @@
"doctrine/common": "<2.10@dev"
},
"require-dev": {
"doctrine/coding-standard": "^5.0",
"phpstan/phpstan": "^0.8",
"doctrine/coding-standard": "^6.0",
"phpstan/phpstan": "^0.11",
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
"dev-master": "1.3.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\": "lib/Doctrine/Common"
"Doctrine\\Common\\": "lib/Doctrine/Common",
"Doctrine\\Persistence\\": "lib/Doctrine/Persistence"
}
},
"notification-url": "https://packagist.org/downloads/",
......@@ -1106,7 +1107,7 @@
"orm",
"persistence"
],
"time": "2019-04-23T12:39:21+00:00"
"time": "2019-12-13T10:43:02+00:00"
},
{
"name": "doctrine/reflection",
......@@ -1355,16 +1356,16 @@
},
{
"name": "myclabs/deep-copy",
"version": "1.9.3",
"version": "1.9.4",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea"
"reference": "579bb7356d91f9456ccd505f24ca8b667966a0a7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/007c053ae6f31bba39dfa19a7726f56e9763bbea",
"reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/579bb7356d91f9456ccd505f24ca8b667966a0a7",
"reference": "579bb7356d91f9456ccd505f24ca8b667966a0a7",
"shasum": ""
},
"require": {
......@@ -1399,7 +1400,7 @@
"object",
"object graph"
],
"time": "2019-08-09T12:45:53+00:00"
"time": "2019-12-15T19:12:40+00:00"
},
{
"name": "ocramius/package-versions",
......@@ -1759,22 +1760,22 @@
},
{
"name": "ramsey/uuid",
"version": "3.9.1",
"version": "3.9.2",
"source": {
"type": "git",
"url": "https://github.com/ramsey/uuid.git",
"reference": "5ac2740e0c8c599d2bbe7f113a939f2b5b216c67"
"reference": "7779489a47d443f845271badbdcedfe4df8e06fb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ramsey/uuid/zipball/5ac2740e0c8c599d2bbe7f113a939f2b5b216c67",
"reference": "5ac2740e0c8c599d2bbe7f113a939f2b5b216c67",
"url": "https://api.github.com/repos/ramsey/uuid/zipball/7779489a47d443f845271badbdcedfe4df8e06fb",
"reference": "7779489a47d443f845271badbdcedfe4df8e06fb",
"shasum": ""
},
"require": {
"ext-json": "*",
"paragonie/random_compat": "^1 | ^2 | 9.99.99",
"php": "^5.4 | ^7",
"php": "^5.4 | ^7 | ^8",
"symfony/polyfill-ctype": "^1.8"
},
"replace": {
......@@ -1784,13 +1785,13 @@
"codeception/aspect-mock": "^1 | ^2",
"doctrine/annotations": "^1.2",
"goaop/framework": "1.0.0-alpha.2 | ^1 | ^2.1",
"jakub-onderka/php-parallel-lint": "^0.9.0",
"mockery/mockery": "^0.9.9",
"jakub-onderka/php-parallel-lint": "^1",
"mockery/mockery": "^0.9.11 | ^1",
"moontoast/math": "^1.1",
"paragonie/random-lib": "^2",
"php-mock/php-mock-phpunit": "^0.3 | ^1.1",
"phpunit/phpunit": "^4.8 | ^5.4 | ^6.5",
"squizlabs/php_codesniffer": "^2.3"
"squizlabs/php_codesniffer": "^3.5"
},
"suggest": {
"ext-ctype": "Provides support for PHP Ctype functions",
......@@ -1842,7 +1843,7 @@
"identifier",
"uuid"
],
"time": "2019-12-01T04:55:27+00:00"
"time": "2019-12-17T08:18:51+00:00"
},
{
"name": "setasign/fpdi",
......@@ -2443,11 +2444,11 @@
},
{
"name": "unicaen/import",
"version": "3.0.0",
"version": "3.0.1",
"source": {
"type": "git",
"url": "https://git.unicaen.fr/lib/unicaen/import.git",
"reference": "5c1d5f7f0ad0af0bb94347eba23eb446695cca92"
"reference": "a30dd89d0c18541bead527902565c7267fff01d5"
},
"require": {
"unicaen/auth": "dev-zf-3.x || ^3.0",
......@@ -2467,7 +2468,7 @@
]
},
"description": "Module d'import de données vers une base Oracle",
"time": "2019-09-27T13:46:53+00:00"
"time": "2019-12-19T11:21:23+00:00"
},
{
"name": "unicaen/open-document",
......@@ -3012,6 +3013,7 @@
"debug",
"zf"
],
"abandoned": true,
"time": "2018-04-30T20:10:31+00:00"
},
{
......@@ -3507,16 +3509,16 @@
},
{
"name": "zendframework/zend-i18n",
"version": "2.10.0",
"version": "2.10.1",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-i18n.git",
"reference": "561a815ce32c86b0f1de11135477e637926d56b6"
"reference": "84038e6a1838b611dcc491b1c40321fa4c3a123c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-i18n/zipball/561a815ce32c86b0f1de11135477e637926d56b6",
"reference": "561a815ce32c86b0f1de11135477e637926d56b6",
"url": "https://api.github.com/repos/zendframework/zend-i18n/zipball/84038e6a1838b611dcc491b1c40321fa4c3a123c",
"reference": "84038e6a1838b611dcc491b1c40321fa4c3a123c",
"shasum": ""
},
"require": {
......@@ -3524,6 +3526,9 @@
"php": "^5.6 || ^7.0",
"zendframework/zend-stdlib": "^2.7 || ^3.0"
},
"conflict": {
"phpspec/prophecy": "<1.9.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.16",
"zendframework/zend-cache": "^2.6.1",
......@@ -3571,7 +3576,7 @@
"i18n",
"zf"
],
"time": "2019-11-18T20:31:29+00:00"
"time": "2019-12-12T14:08:22+00:00"
},
{
"name": "zendframework/zend-i18n-resources",
......@@ -6141,33 +6146,33 @@
},
{
"name": "phpspec/prophecy",
"version": "1.9.0",
"version": "1.10.0",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203"
"reference": "d638ebbb58daba25a6a0dc7969e1358a0e3c6682"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203",
"reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/d638ebbb58daba25a6a0dc7969e1358a0e3c6682",
"reference": "d638ebbb58daba25a6a0dc7969e1358a0e3c6682",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"php": "^5.3|^7.0",
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0",
"sebastian/comparator": "^1.1|^2.0|^3.0",
"sebastian/comparator": "^1.2.3|^2.0|^3.0",
"sebastian/recursion-context": "^1.0|^2.0|^3.0"
},
"require-dev": {
"phpspec/phpspec": "^2.5|^3.2",
"phpspec/phpspec": "^2.5 || ^3.2",
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.8.x-dev"
"dev-master": "1.10.x-dev"
}
},
"autoload": {
......@@ -6200,7 +6205,7 @@
"spy",
"stub"
],
"time": "2019-10-03T11:07:50+00:00"
"time": "2019-12-17T16:54:23+00:00"
},
{
"name": "phpunit/php-code-coverage",
......@@ -6456,16 +6461,16 @@
},
{
"name": "phpunit/phpunit",
"version": "8.4.3",
"version": "8.5.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "67f9e35bffc0dd52d55d565ddbe4230454fd6a4e"
"reference": "3ee1c1fd6fc264480c25b6fb8285edefe1702dab"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/67f9e35bffc0dd52d55d565ddbe4230454fd6a4e",
"reference": "67f9e35bffc0dd52d55d565ddbe4230454fd6a4e",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3ee1c1fd6fc264480c25b6fb8285edefe1702dab",
"reference": "3ee1c1fd6fc264480c25b6fb8285edefe1702dab",
"shasum": ""
},
"require": {
......@@ -6509,7 +6514,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "8.4-dev"
"dev-master": "8.5-dev"
}
},
"autoload": {
......@@ -6535,7 +6540,7 @@
"testing",
"xunit"
],
"time": "2019-11-06T09:42:23+00:00"
"time": "2019-12-06T05:41:38+00:00"
},
{
"name": "sabre/event",
......
......@@ -14,7 +14,7 @@ return [
],
'entity_source_injector' => [
// Code unique de la source à injecter (null pour désactiver le mécanisme).
'source_code' => null,
'source_code' => 'OSE',
],
],
......
......@@ -6,15 +6,15 @@ use Application\Provider\Privilege\Privileges;
use UnicaenAuth\Guard\PrivilegeController;
return [
'router' => [
'router' => [
'routes' => [
'administration' => [
'administration' => [
'type' => 'Literal',
'options' => [
'route' => '/administration',
'defaults' => [
'controller' => 'Application\Controller\Administration',
'action' => 'index',
'controller' => 'Application\Controller\Administration',
'action' => 'index',
],
],
'may_terminate' => true,
......@@ -22,7 +22,7 @@ return [
],
],
'navigation' => [
'navigation' => [
'default' => [
'home' => [
'pages' => [
......@@ -38,7 +38,7 @@ return [
],
],
],
'bjyauthorize' => [
'bjyauthorize' => [
'guards' => [
PrivilegeController::class => [
[
......@@ -68,15 +68,16 @@ return [
Privileges::DOMAINES_FONCTIONNELS_ADMINISTRATION_VISUALISATION,
Privileges::MOTIFS_MODIFICATION_SERVICE_DU_VISUALISATION,
Privileges::MOTIF_NON_PAIEMENT_VISUALISATION,
Privileges::STRUCTURES_ADMINISTRATION_VISUALISATION,
],
'assertion' => Assertion\GestionAssertion::class,
],
],
],
],
'controllers' => [
'controllers' => [
'factories' => [
'Application\Controller\Administration' => Controller\Factory\AdministrationControllerFactory::class,
'Application\Controller\Administration' => Controller\Factory\AdministrationControllerFactory::class,
],
],
];
\ No newline at end of file
......@@ -67,7 +67,7 @@ return [
'administration' => [
'pages' => [
'structure' => [
'label' => 'Structure',
'label' => 'Structures',
'icon' => 'fa fa-graduation-cap',
'route' => 'structure',
'resource' => PrivilegeController::getResourceId('Application\Controller\Structure', 'index'),
......@@ -125,8 +125,8 @@ return [
],
],
'form_elements' => [
'invokables' => [
Form\Structure\StructureSaisieForm::class => Form\Structure\StructureSaisieForm::class,
'factories' => [
Form\Structure\StructureSaisieForm::class => Form\Structure\StructureSaisieFormFactory::class,
],
],
];
......@@ -20,6 +20,7 @@ class StructureController extends AbstractController
use StructureSaisieFormAwareTrait;
public function indexAction()
{
$this->em()->getFilters()->enable('historique')->init([
......@@ -41,15 +42,18 @@ class StructureController extends AbstractController
$form = $this->getFormStructureSaisie();
if (empty($structure)) {
$title = 'Création d\'une nouvelle Structure';
$title = 'Création d\'une nouvelle Structure';
$structure = $this->getServiceStructure()->newEntity();
} else {
$title = 'Édition d\'une Structure';
}
$form->bindRequestSave($structure, $this->getRequest(), function (Structure $fr) {
$form->bindRequestSave($structure, $this->getRequest(), function (Structure $structure) {
try {
$this->getServiceStructure()->save($fr);
if (empty($structure->getSourceCode()) || !$structure->getSource()->getImportable()) {
$structure->setSourceCode($structure->getCode());
}
$this->getServiceStructure()->save($structure);
$this->flashMessenger()->addSuccessMessage('Enregistrement effectué');
} catch (\Exception $e) {
$this->flashMessenger()->addErrorMessage($this->translate($e));
......@@ -59,19 +63,29 @@ class StructureController extends AbstractController
return compact('form', 'title');
}
public function deleteAction()
{
/** @var Structure $structure */
$structure = $this->getEvent()->getParam('structure');
if ($structure->getSource()->getImportable()) {
throw new \LogicException('Une structure importée ne peut pas être supprimée dans l\'application');
}
try {
$this->getServiceStructure()->delete($structure);
$this->flashMessenger()->addSuccessMessage("Structure supprimée avec succès.");
} catch (\Exception $e) {
$this->flashMessenger()->addErrorMessage($this->translate($e));
}
return new MessengerViewModel(compact('structure'));
}
public function voirAction()
{
$structure = $this->getEvent()->getParam('structure');
......@@ -81,6 +95,7 @@ class StructureController extends AbstractController
}
$title = (string)$structure;
return compact('structure', 'title');
}
......
......@@ -2,9 +2,14 @@
namespace Application\Form\Structure;
use Application\Entity\Db\Structure;
use Application\Form\AbstractForm;
use UnicaenApp\Service\EntityManagerAwareInterface;
use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenImport\Service\Traits\SchemaServiceAwareTrait;
use Zend\Form\Element\Csrf;
use Zend\Stdlib\Hydrator\HydratorInterface;
use Zend\Form\FormInterface;
use Zend\Hydrator\HydratorInterface;
use Application\Service\Traits\SourceServiceAwareTrait;
use Application\Filter\FloatFromString;
use Application\Filter\StringFromFloat;
......@@ -14,9 +19,11 @@ use Application\Filter\StringFromFloat;
*
* @author ZVENIGOROSKY Alexandre <alexandre.zvenigorosky@unicaen.fr>
*/
class StructureSaisieForm extends AbstractForm
class StructureSaisieForm extends AbstractForm implements EntityManagerAwareInterface
{
use EntityManagerAwareTrait;
use SourceServiceAwareTrait;
use SchemaServiceAwareTrait;
......@@ -34,60 +41,40 @@ class StructureSaisieForm extends AbstractForm
'type' => 'Text',
]);
$this->add([
'name' => 'libelle-court',
'name' => 'libelleCourt',
'options' => [
'label' => "Libelle Court",
'label' => "Libellé Court",
],
'type' => 'Text',
]);
$this->add([
'name' => 'libelle-long',
'name' => 'libelleLong',
'options' => [
'label' => "Libelle Long",
'label' => "Libellé Long",
],
'type' => 'Text',
]);
$this->add([
'name' => 'enseignement',
'options' => [
'label' => "Enseignement",
'label' => "Peut porter des enseignements",
],
'type' => 'Checkbox',
]);
$this->add([
'name' => 'source-code',
'name' => 'plafondReferentiel',
'options' => [
'label' => "Source Code",
'label' => "Plafond d'heures pour le référentiel",
],
'type' => 'Text',
]);
$this->add([
'name' => 'plafond-referentiel',
'name' => 'affAdresseContrat',
'options' => [
'label' => "Plafond Referentiel",
],
'type' => 'Text',
]);
$this->add([
'name' => 'aff-adresse-contrat',
'options' => [
'label' => "Aff Adresse Contrat",
'label' => "Affichage de l'adresse sur le contrat de travail",
],
'type' => 'Checkbox',
]);
$this->add([
'name' => 'source',
'options' => [
'label' => 'Source',
],
'attributes' => [
'class' => 'selectpicker',
'data-live-search' => 'true',
],
'type' => 'Select',
]);
$this->get('source')
->setValueOptions(\UnicaenApp\Util::collectionAsOptions($this->getServiceSource()->getList()));
$this->add(new Csrf('security'));
$this->add([
......@@ -104,6 +91,24 @@ class StructureSaisieForm extends AbstractForm
public function bind($object, $flags = FormInterface::VALUES_NORMALIZED)
{
/* @var $object Structure */
parent::bind($object, $flags);
if ($object->getSource() && $object->getSource()->getImportable()) {
foreach ($this->getElements() as $element) {
if ($this->getServiceSchema()->isImportedProperty($object, $element->getName())) {
$element->setAttribute('readonly', true);
}
}
}
return $this;
}
/**
* Should return an array specification compatible with
* {@link Zend\InputFilter\Factory::createInputFilter()}.
......@@ -117,27 +122,22 @@ class StructureSaisieForm extends AbstractForm
'required' => true,
],
'libelle-court' => [
'libelleCourt' => [
'required' => true,
],
'libelle-long' => [
'libelleLong' => [
'required' => true,
],
'enseignement' => [
'enseignement' => [
'required' => true,
],
'source' => [
'required' => true,
],
'aff-adresse-contrat' => [
'affAdresseContrat' => [
'required' => true,