Skip to content
Snippets Groups Projects
Commit 5064888a authored by Ghislain Loas's avatar Ghislain Loas
Browse files

CIP #57858 replace treeselect with listCoche

parent 866774ca
Branches
Tags
5 merge requests!2334Master,!2102#57574 : correction orthographe des jours de la semaine,!2088Master,!2087Dev#57858 remplacer le treeselect en front par le composant multiselect,!2076Dev#57858 remplacer le treeselect en front par le composant multiselect
Pipeline #801 failed with stage
in 11 minutes and 46 seconds
......@@ -16,7 +16,7 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
abstract class ZendAfi_Form_Element_AbstractSuggest extends Zend_Form_Element_Xhtml {
/** @var string */
......@@ -63,7 +63,7 @@ abstract class ZendAfi_Form_Element_AbstractSuggest extends Zend_Form_Element_Xh
* @return ZendAfi_Form_Element_ListeSuggestion
*/
public function setRubrique($rubrique) {
$this->_rubrique = (string)$rubrique;
$this->_rubrique = $rubrique;
return $this;
}
......
......@@ -54,24 +54,49 @@ class ZendAfi_Form_User_Settings extends ZendAfi_Form {
protected function addLibrariesElement() {
if (!Class_User_Settings::isBookmarkLibraryReady())
return false;
return $this->addElement('domainSelect',
return $this->addElement('cochesSuggestion',
'library_ids',
['label' => $this->_('Mes bibliothèques préférées'),
'url' => Class_Url::assemble(['module' => 'opac',
'controller' => 'abonne',
'action' => 'viewable-libraries-json'])]);
'name' => 'library_ids',
'rubrique' => function()
{
$libraries = Class_Profil::getCurrentProfil()->getLibraries();
return (new Class_Entity())
->whenCalledDo('getList', function() use ($libraries)
{
$datas = [];
foreach($libraries as $library)
$datas[$library->getId()] = $library->getLabel();
return $datas;
});
},
'selected_all_means_nothing' => false]);
}
protected function addDomainsElement() {
if (!Class_User_Settings::isBookmarkDomainsReady())
return false;
return $this->addElement('domainSelect',
return $this->addElement('cochesSuggestion',
'domain_ids',
['label' => $this->_('Mes thèmes préférés'),
'url' => Class_Url::assemble(['module' => 'opac',
'controller' => 'abonne',
'action' => 'viewable-domains-json'])]);
['label' => $this->_('Mes thèmes préférées'),
'name' => 'domain_ids',
'rubrique' => function()
{
$domains = Class_Catalogue::findAllCataloguesAIndexer();
return (new Class_Entity())
->whenCalledDo('getList',
function() use ($domains)
{
$datas = [];
foreach($domains as $domain)
$datas[$domain->getId()] = $domain->getLibelle();
return $datas;
});
},
'selected_all_means_nothing' => false]);
}
......
......@@ -39,30 +39,13 @@ class ZendAfi_View_Helper_TagListeCoches extends ZendAfi_View_Helper_BaseHelper
public function tagListeCoches($rubrique, $name, $valeurs='', $id_bib=0) {
$rubriques =
['type_doc' => new ZendAfi_View_Helper_TagListeCochesSourceDocType(),
'section' => $this->_simpleSourceFor('Class_CodifSection'),
'genre' => $this->_simpleSourceFor('Class_CodifGenre'),
'langue' => $this->_simpleSourceFor('Class_CodifLangue'),
'emplacement' => $this->_simpleSourceFor('Class_CodifEmplacement'),
'nature_doc' => $this->_simpleSourceFor('Class_NatureDoc'),
'bibliotheque' => $this->_simpleSourceFor('Class_Bib')->setWhere(['visibilite' => '2']),
'annexe' => (new ZendAfi_View_Helper_TagListeCochesSourceAnnexe())->setWhere(array_filter(['id_bib' => $id_bib,
'invisible' => 0])),
'profile' => new ZendAfi_View_Helper_TagListeCochesSourceProfile()
];
if (!array_key_exists($rubrique, $rubriques))
if(!$datas = $this->_getDatas($rubrique, $id_bib))
return '';
$this->_name = $name;
$this->_type = $rubrique;
Class_ScriptLoader::getInstance()->addAdminScript('tag_selection');
$this->_definition = $rubriques[$rubrique];
$this->_possibles = $this->_definition->getList();
$this->_possibles = $datas->getList();
$this->_cant_select_all = $this->selected_all_means_nothing ? 'true' : 'false';
$this->_handleValues($valeurs);
......@@ -70,7 +53,34 @@ class ZendAfi_View_Helper_TagListeCoches extends ZendAfi_View_Helper_BaseHelper
return $this->_renderValues()
. $this->_renderSelection()
. $this->_renderList();
}
protected function _getDatas($data, $library_id) {
if(is_callable($data))
return call_user_func($data);
$datas =
['type_doc' => new ZendAfi_View_Helper_TagListeCochesSourceDocType(),
'section' => $this->_simpleSourceFor('Class_CodifSection'),
'genre' => $this->_simpleSourceFor('Class_CodifGenre'),
'langue' => $this->_simpleSourceFor('Class_CodifLangue'),
'emplacement' => $this->_simpleSourceFor('Class_CodifEmplacement'),
'nature_doc' => $this->_simpleSourceFor('Class_NatureDoc'),
'bibliotheque' => $this->_simpleSourceFor('Class_Bib')
->setWhere(['visibilite' => '2']),
'annexe' => (new ZendAfi_View_Helper_TagListeCochesSourceAnnexe())
->setWhere(array_filter(['id_bib' => $library_id,
'invisible' => 0])),
'profile' => new ZendAfi_View_Helper_TagListeCochesSourceProfile()
];
return array_key_exists($data, $datas)
? $datas[$data]
: null;
}
......
......@@ -137,7 +137,6 @@ class AbonneControllerSettingsFormTest extends AbonneControllerSettingsTestCase
}
/** @test */
public function libSelectorShouldBePresent() {
$this->assertXPathContentContains('//div', 'Mes bibliothèques préférées');
......
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