Skip to content
Snippets Groups Projects
Commit 17cf1088 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

dev #75882 refacto flat codification list view mode

parent 0fb87951
Branches
Tags
3 merge requests!2711Dev#75882 minsoc faire des filtres sur des facettes et des domaines au moment de la recherche s2,!2707Tessadoc lost pass,!2699Dev#75882 minsoc faire des filtres sur des facettes et des domaines au moment de la recherche s2
Pipeline #4384 passed with stage
in 35 minutes and 39 seconds
......@@ -20,18 +20,25 @@
*/
class ZendAfi_Controller_Action_Helper_SectionListViewMode
abstract class ZendAfi_Controller_Action_Helper_AbstractCodificationListViewMode
extends ZendAfi_Controller_Action_Helper_AbstractListViewMode {
protected $_model_class;
public function sectionListViewMode($params) {
protected function _initParams($params) {
$this->_params = $params;
return $this;
$this->_model_class = get_class($this->getModel());
}
protected function _getBreadcrumbLabel() {
return $this->_params['label'];
}
public function direct($params) {
return $this->sectionListViewMode($params);
protected function _getControllerName() {
return $this->_params['controller'];
}
......@@ -40,6 +47,11 @@ class ZendAfi_Controller_Action_Helper_SectionListViewMode
}
protected function _callOnLoader($method, $params=[]) {
return call_user_func_array([$this->_model_class, $method], $params);
}
protected function _describeItemsIn($description) {
return $description
->addColumn($this->_('Libellé'), ['attribute' => 'libelle',
......@@ -47,8 +59,9 @@ class ZendAfi_Controller_Action_Helper_SectionListViewMode
{
return $this->_renderItem($model, $attrib);
}])
->addColumn($this->_('Code facette'), ['attribute' => 'facet_code',
'sort_attribute' => 'id_section'])
->addColumn($this->_('Code facette'),
['attribute' => 'facet_code',
'sort_attribute' => $this->_callOnLoader('getIdField')])
->setSorterServer();
}
......@@ -60,21 +73,12 @@ class ZendAfi_Controller_Action_Helper_SectionListViewMode
'label' => $this->_('Racine'),
'options' => []],
['url' => ['module' => 'admin',
'controller' => 'section-browser',
'action' => 'index'],
'label' => $this->_('Sections'),
['url' => $this->getBaseUrl(),
'label' => $this->_getBreadcrumbLabel(),
'options' => []]];
}
public function getBaseUrl() {
return ['module' => 'admin',
'controller' => 'section-browser',
'action' => 'index'];
}
public function getItems() {
$default_params = ['limitPage' => [$this->getPage(), $this->_items_by_page],
'order' => $this->getOrder()];
......@@ -83,13 +87,12 @@ class ZendAfi_Controller_Action_Helper_SectionListViewMode
? $this->getSearchParams()
: [];
return Class_CodifSection::findAllBy(array_merge($params, $default_params));
return $this->_callOnLoader('findAllBy', [array_merge($params, $default_params)]);
}
public function getSearchColumns() {
return ['libelle',
'id_section'];
return ['libelle', $this->_callOnLoader('getIdField')];
}
......@@ -99,7 +102,7 @@ class ZendAfi_Controller_Action_Helper_SectionListViewMode
public function countItemsFor($model) {
return Class_CodifSection::count();
return $this->_callOnLoader('count');
}
......@@ -107,11 +110,19 @@ class ZendAfi_Controller_Action_Helper_SectionListViewMode
$params = array_merge($this->getItemsParams(),
$this->getSearchParams());
unset($params['limitPage']);
return Class_CodifSection::countBy($params);
return $this->_callOnLoader('countBy', [$params]);
}
public function getOrder() {
return $this->getParam('order', 'libelle');
}
public function getBaseUrl() {
return ['module' => 'admin',
'controller' => $this->_getControllerName(),
'action' => 'index'];
}
}
\ No newline at end of file
<?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_Controller_Action_Helper_FlatCodificationListViewMode
extends ZendAfi_Controller_Action_Helper_AbstractCodificationListViewMode {
public function flatCodificationListViewMode($params) {
$this->_initParams($params);
return $this;
}
public function direct($params) {
return $this->flatCodificationListViewMode($params);
}
}
\ No newline at end of file
......@@ -20,7 +20,8 @@
*/
class ZendAfi_Controller_Action_Helper_LocationListViewMode extends ZendAfi_Controller_Action_Helper_AbstractListViewMode {
class ZendAfi_Controller_Action_Helper_LocationListViewMode
extends ZendAfi_Controller_Action_Helper_AbstractListViewMode {
public function locationListViewMode($params) {
......
......@@ -307,10 +307,20 @@ abstract class ZendAfi_Controller_Plugin_ResourceDefinition_Abstract extends Zen
? call_user_func($this->_attribs['listViewMode']['model'])
: new $model_class;
$controller_name = (isset($this->_attribs['listViewMode']['controller']))
? $this->_attribs['listViewMode']['controller']
: '';
$breadcrumb_label = (isset($this->_attribs['listViewMode']['label']))
? $this->_attribs['listViewMode']['label']
: '';
return $this->_helper->$listViewMode(['model' => $model,
'order' => $this->_getParam('order'),
'page' => $this->_getParam('page', 0),
'search_value' => $this->_getParam('title_search', '')]);
'search_value' => $this->_getParam('title_search', ''),
'controller' => $controller_name,
'label' => $breadcrumb_label]);
}
......
......@@ -28,7 +28,9 @@ class ZendAfi_Controller_Plugin_ResourceDefinition_Section extends ZendAfi_Contr
'order' => 'libelle',
'model_id' => 'id_section'],
'listViewMode' => ['helper_method' => 'sectionListViewMode'],
'listViewMode' => ['helper_method' => 'flatCodificationListViewMode',
'label' => $this->_('Sections'),
'controller' => 'section-browser'],
'messages' => ['successful_save' => $this->_('La section "%s" a été modifée'),
'successful_add' => $this->_('La section "%s" a été ajoutée'),
......
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