From 964ad0d370135dda87693fda5ce54ce5a31a91c0 Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Wed, 30 May 2018 17:33:12 +0200 Subject: [PATCH] dev #75742 : Thesauri list view mode , edition and visualisation --- .../admin/views/scripts/thesauri/edit.phtml | 2 + library/Class/CodifThesaurus.php | 8 +++ .../Controller/Plugin/Manager/Thesauri.php | 32 ++++++++++- library/ZendAfi/Form/Admin/Thesauri.php | 54 +++++++++++++++++++ library/ZendAfi/View/Helper/TagModelTable.php | 2 +- public/admin/skins/bokeh74/form.css | 7 +++ tests/scenarios/Thesauri/ThesauriTest.php | 19 ++++++- 7 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 application/modules/admin/views/scripts/thesauri/edit.phtml create mode 100644 library/ZendAfi/Form/Admin/Thesauri.php diff --git a/application/modules/admin/views/scripts/thesauri/edit.phtml b/application/modules/admin/views/scripts/thesauri/edit.phtml new file mode 100644 index 00000000000..ac736335975 --- /dev/null +++ b/application/modules/admin/views/scripts/thesauri/edit.phtml @@ -0,0 +1,2 @@ +<?php +echo $this->renderForm($this->form); diff --git a/library/Class/CodifThesaurus.php b/library/Class/CodifThesaurus.php index 10830d8297c..2cf69d3a00f 100644 --- a/library/Class/CodifThesaurus.php +++ b/library/Class/CodifThesaurus.php @@ -608,6 +608,14 @@ class Class_CodifThesaurus extends Storm_Model_Abstract { return $this->getLoader()->findParent($this->getIdThesaurus()); } + + public function getParentId() { + return $this->getParent() + ? $this->getParent()->getId() + : null; + } + + public function getTitre() { return $this->getLibelleFacette(); } diff --git a/library/ZendAfi/Controller/Plugin/Manager/Thesauri.php b/library/ZendAfi/Controller/Plugin/Manager/Thesauri.php index 7468ea6ac06..ae1608134ce 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/Thesauri.php +++ b/library/ZendAfi/Controller/Plugin/Manager/Thesauri.php @@ -23,15 +23,43 @@ class ZendAfi_Controller_Plugin_Manager_Thesauri extends ZendAfi_Controller_Plugin_Manager_Manager { - public function getActions() { + public function getActions($model) { + if(!$model) + return []; + return [ + ['url' => $this->_view->url(['module' => 'admin', + 'controller' => 'thesauri', + 'action' => 'index', + 'parent_id' => $model->getParentId(), + 'id' => $model->getId() + ],null,true), + 'icon' => 'back', + 'label' => $this->_('Afficher dans l\'arborescence '), + 'condition' => function ($model) { + return $this->_getParam('title_search'); + } + ], + ['url' => ['module' => 'admin', 'controller' => 'thesauri', 'action' => 'edit', 'id' => '%s'], 'icon' => 'edit', 'label' => $this->_('Modifier le thesaurus')], -]; + ['url' => ['module' => 'opac', + 'controller' => 'recherche', + 'action' => 'simple', + 'facette' => $model->getFacetteIndex() + ], + 'icon' => 'view', + 'label' => $this->_('Voir les documents rattachés au thésaurus "%s"',$model->getLibelleFacette()), + 'anchorOptions' => ['target' => '_blank'], + 'condition' => function ($model) { + return (strlen($model->getIdThesaurus()) > Class_CodifThesaurus::ID_KEY_LENGTH); + } + ], + ]; } } diff --git a/library/ZendAfi/Form/Admin/Thesauri.php b/library/ZendAfi/Form/Admin/Thesauri.php new file mode 100644 index 00000000000..c9d93fc3f05 --- /dev/null +++ b/library/ZendAfi/Form/Admin/Thesauri.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_Form_Admin_Thesauri extends ZendAfi_Form { + + public function init() { + parent::init(); + $this->addElement('text', + 'libelle', + ['label' => $this->_('Libellé'), + 'disabled' => 'disabled']) + ->addElement('text', + 'libelle_facette', + ['label' => $this->_('Libellé facette')]) + ->addElement('text', + 'code', + ['label' => $this->_('Code'), + 'disabled' => 'disabled']) + ->addElement('text', + 'id_thesaurus', + ['label' => $this->_('Identifiant thésaurus'), + 'disabled' => 'disabled']) + ->addElement('text', + 'rules', + ['label' => $this->_('Règle'), + 'disabled' => 'disabled']) + ->addUniqDisplayGroup('thesauri'); + + + + } + + +} +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/TagModelTable.php b/library/ZendAfi/View/Helper/TagModelTable.php index d63054d27a4..6d06b16a0ac 100644 --- a/library/ZendAfi/View/Helper/TagModelTable.php +++ b/library/ZendAfi/View/Helper/TagModelTable.php @@ -56,5 +56,5 @@ class ZendAfi_View_Helper_TagModelTable extends ZendAfi_View_Helper_BaseHelper { ['sorter' => $sorter, 'pager' => $pager]); } -}n +} ?> diff --git a/public/admin/skins/bokeh74/form.css b/public/admin/skins/bokeh74/form.css index 280a459a464..47c94588503 100644 --- a/public/admin/skins/bokeh74/form.css +++ b/public/admin/skins/bokeh74/form.css @@ -10,6 +10,13 @@ background: var(--widget-background); } +.admin-form select:disabled, +.admin-form input:disabled { + background: var(--line-locked-highlight); + cursor: not-allowed; +} + + .admin-form .input_connect_list h2 { color: var(--main-text); background: var(--main-background); diff --git a/tests/scenarios/Thesauri/ThesauriTest.php b/tests/scenarios/Thesauri/ThesauriTest.php index 84b38f2a14a..1d0b0342fe8 100644 --- a/tests/scenarios/Thesauri/ThesauriTest.php +++ b/tests/scenarios/Thesauri/ThesauriTest.php @@ -154,4 +154,21 @@ class Thesauri_ThesauriIndexOrderTest extends Thesauri_ThesauriTestCase { public function libelleFacetOrderLinkShouldDesc() { $this->assertXpathContentContains('//table//a[contains(@href, "order/libelle_facette+desc")]', 'Libellé facette'); } -} \ No newline at end of file +} + + + + +class Thesauri_ThesauriEditTest extends Thesauri_ThesauriTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/thesauri/edit/id/3', true); + } + + + /** @test */ + public function inputLibelleShouldContainsDocument() { + $this->assertXpath('//form//input[@value="Document"][@type="text"][@name="libelle"]'); + } +} -- GitLab