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

dev #48349 : domain select with specific decorator

parent e27caffd
Branches
Tags
2 merge requests!2334Master,!2104Dev#48349 ux versionning
Pipeline #921 failed with stage
in 11 minutes and 46 seconds
......@@ -235,8 +235,9 @@ class ZendAfi_Form extends Zend_Form {
protected function _versionCompareDecoratorFor($element, $datas) {
$class_name = 'ZendAfi_Form_Decorator_VersionCompare';
if ('DateRangePicker' == $this->_getElementType($element))
$class_name .= '_DateRangePicker';
if (in_array($type = $this->_getElementType($element),
['DateRangePicker', 'DomainSelect']))
$class_name .= '_' . $type;
return new $class_name(['datas' => $datas]);
}
......
......@@ -124,21 +124,6 @@ class ZendAfi_Form_Decorator_VersionCompare extends Zend_Form_Decorator_Abstract
}
protected function _renderDomainSelect($value) {
if (!$value)
return $this->_('Non renseigné');
$selected = explode(';', $value);
$html = [];
foreach($selected as $domain_id)
$html[] = $this->_tag('li', ($domain = Class_Catalogue::find($domain_id))
? implode(' > ', $domain->getPathParts())
: $this->_('Inconnu ou Supprimé'));
return $this->_tag('ul', implode('', $html));
}
protected function _tag($name, $content=null, $attribs=[]) {
return $this->getElement()->getView()->tag($name, $content, $attribs);
}
......
<?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_Decorator_VersionCompare_DomainSelect
extends ZendAfi_Form_Decorator_VersionCompare {
protected function _renderCurrentValue() {
return $this->_renderValue($this->_renderFromList($this->_getCurrentIds()));
}
protected function _getCurrentIds() {
return $this->_getIds($this->getElement()->getValue(), ';');
}
protected function _renderVersionValue() {
return $this->_renderValue(($ids = $this->_getVersionIds())
? $this->_renderFromList($ids)
: $this->_('Non renseigné'));
}
protected function _getVersionIds() {
$datas = $this->getOption('datas');
return $datas && array_key_exists($name = $this->getElement()->getName(), $datas)
? $this->_getIds($datas[$name], '-')
: [];
}
protected function _renderFromList($ids) {
if (!$ids)
return $this->_('Non renseigné');
$html = [];
foreach($ids as $id)
$html[] = $this->_tag('li', ($domain = Class_Catalogue::find($id))
? implode(' > ', $domain->getPathParts())
: $this->_('Inconnu ou Supprimé'));
sort($html);
return $this->_tag('ul', implode('', $html));
}
protected function _getIds($value, $separator) {
return $value ? explode($separator, $value) : [];
}
protected function _isModified() {
$current = $this->_getCurrentIds();
$version = $this->_getVersionIds();
sort($current);
sort($version);
return $current != $version;
}
}
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