diff --git a/VERSIONS_WIP/57858 b/VERSIONS_WIP/57858 new file mode 100644 index 0000000000000000000000000000000000000000..a748ff32573528d54ed4f33a1479d713bb7cadb9 --- /dev/null +++ b/VERSIONS_WIP/57858 @@ -0,0 +1,2 @@ + - ticket #57858 : Compte abonné : amélioration du formulaire de gestion des favoris. + \ No newline at end of file diff --git a/application/modules/admin/views/scripts/bib/localisationsmaj.phtml b/application/modules/admin/views/scripts/bib/localisationsmaj.phtml index 734d23d33822ffbd5681e6943850972c7ed31f86..3d22f48235ea0a7d0ed45ef9f0b5904ae367f15f 100644 --- a/application/modules/admin/views/scripts/bib/localisationsmaj.phtml +++ b/application/modules/admin/views/scripts/bib/localisationsmaj.phtml @@ -1,5 +1,8 @@ +<?php +Class_ScriptLoader::getInstance()->addTagSelection(); +?> + <link rel="stylesheet" type="text/css" media="screen" href="<?php echo URL_ADMIN_JS ?>slimbox/slimbox2.css"> -<script src="<?php echo URL_ADMIN_JS ?>tag_selection.js" type="text/javascript"> </script> <script type="text/javascript" src="<?php echo URL_ADMIN_JS?>slimbox/slimbox2.js"> </script> <script type="text/javascript" src="<?php echo URL_ADMIN_JS?>jquery_ui/jquery.ui.core.min.js"> </script> <script type="text/javascript" src="<?php echo URL_ADMIN_JS?>jquery_ui/jquery.ui.widget.min.js"> </script> diff --git a/library/Class/ScriptLoader.php b/library/Class/ScriptLoader.php index 9cac4f6bde71c0278bde8f275734394f7ed556b7..acfb2ad49a5098076d652a1ce1e49c79ecc34c4c 100644 --- a/library/Class/ScriptLoader.php +++ b/library/Class/ScriptLoader.php @@ -814,7 +814,7 @@ class Class_ScriptLoader { public function addSearchInputToLeftMenu($label) { return $this->_addSearchInput('.main > .left', - 'input_search_menu', + 'input_search_menu', $label, '.menuGaucheAdmin tr, .titre, img, table, tbody, td'); } @@ -834,4 +834,13 @@ class Class_ScriptLoader { $node, json_encode(['callback' => $callback]))); } + + + public function addTagSelection() { + $this + ->addOPACScript('tag_selection/tag_selection.js') + ->addOPACScriptStyleSheet('tag_selection/tag_selection.css'); + + return $this; + } } diff --git a/library/ZendAfi/Form/Element/AbstractSuggest.php b/library/ZendAfi/Form/Element/AbstractSuggest.php index 568ca6eea53d787287061e4d5c6b815c488aab0d..7fca9ee371baeb16354d34f3f39d85f59bf6664e 100644 --- a/library/ZendAfi/Form/Element/AbstractSuggest.php +++ b/library/ZendAfi/Form/Element/AbstractSuggest.php @@ -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; } diff --git a/library/ZendAfi/Form/User/Settings.php b/library/ZendAfi/Form/User/Settings.php index b36e6d6a029264f845b9826ba158cf607da03939..345c7b657559912c1bd364086f985cf4cbb76a91 100644 --- a/library/ZendAfi/Form/User/Settings.php +++ b/library/ZendAfi/Form/User/Settings.php @@ -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'])]); + '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]); } diff --git a/library/ZendAfi/View/Helper/Admin/TagListeSuggestion.php b/library/ZendAfi/View/Helper/Admin/TagListeSuggestion.php index 2a6d9d75b105e661f45783107abb7946934e0c4d..3dda2473936bfb5627622eceae3c9a3d44d7ed63 100644 --- a/library/ZendAfi/View/Helper/Admin/TagListeSuggestion.php +++ b/library/ZendAfi/View/Helper/Admin/TagListeSuggestion.php @@ -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 */ ////////////////////////////////////////////////////////////////////////////////////////// // OPAC3 : Tag liste avec champ suggestion @@ -27,12 +27,12 @@ class ZendAfi_View_Helper_Admin_TagListeSuggestion extends ZendAfi_View_Helper_B // Main routine //---------------------------------------------------------------------------------- public function TagListeSuggestion($rubrique,$name,$valeurs="") { - Class_ScriptLoader::getInstance()->addAdminScript('tag_selection'); + Class_ScriptLoader::getInstance()->addTagSelection(); $selection = $html = ''; // Lire les libelles en fonction de la rubrique $min_cars_recherche=1; - $options=array(1 => $this->translate()->_("commence par"), + $options=array(1 => $this->translate()->_("commence par"), 2 => $this->translate()->_("contient")); $champ_libelle="libelle"; @@ -45,22 +45,22 @@ class ZendAfi_View_Helper_Admin_TagListeSuggestion extends ZendAfi_View_Helper_B break; case "matiere": $table="codif_matiere"; $champ_id="id_matiere"; break; case "interet": $table="codif_interet"; $champ_id="id_interet"; break; - case "dewey": - $table="codif_dewey"; - $champ_id="id_dewey"; - $options=array(1 => $this->translate()->_("indice commence par"), + case "dewey": + $table="codif_dewey"; + $champ_id="id_dewey"; + $options=array(1 => $this->translate()->_("indice commence par"), 2 => $this->translate()->_("libellé commence par"), 3 => $this->translate()->_("libellé contient")); break; - case "pcdm4": - $table="codif_pcdm4"; + case "pcdm4": + $table="codif_pcdm4"; $champ_id="id_pcdm4"; - $options=array(1 => $this->translate()->_("indice commence par"), + $options=array(1 => $this->translate()->_("indice commence par"), 2 => $this->translate()->_("libellé commence par"), 3 => $this->translate()->_("libellé contient")); break; - case "thesaurus": - $table="codif_thesaurus"; + case "thesaurus": + $table="codif_thesaurus"; $champ_id="id_thesaurus"; $options=[ @@ -72,7 +72,7 @@ class ZendAfi_View_Helper_Admin_TagListeSuggestion extends ZendAfi_View_Helper_B case "tag": $table="codif_tags";$champ_id="id_tag"; break; } - + // Texte affichage des libelles if($valeurs) { $codes=explode(";",$valeurs); @@ -86,7 +86,7 @@ class ZendAfi_View_Helper_Admin_TagListeSuggestion extends ZendAfi_View_Helper_B $selection.="«".fetchOne("select ".$champ_libelle." from ".$table." where ".$champ_id."='".$code."'")."» "; } } - + // Champs code et libelle $html.='<input id="'.$name.'" type="hidden" name="'.$name.'" value="'.$valeurs.'">'; $html.='<div class="tag_selection">'; @@ -94,10 +94,10 @@ class ZendAfi_View_Helper_Admin_TagListeSuggestion extends ZendAfi_View_Helper_B $html.='<img onclick="'.$onclick.'" src="'.URL_ADMIN_IMG.'ico/ouvrir.gif" style="margin-top:1px;margin-right:3px;float:left;cursor:pointer">'; $html.='<div id="'.$name.'_aff">'.$selection.'</div>'; $html.='</div>'; - + // Bloc de saisie $html.='<div id="'.$name.'_saisie" class="tag_saisie">'; - + // Champs de sélection $html.='<div style="margin-bottom:5px;padding-top:5px">'; $event="'".$rubrique."','".$name."',getId('".$name."_champ').value".",min_cars=".$min_cars_recherche; @@ -108,13 +108,13 @@ class ZendAfi_View_Helper_Admin_TagListeSuggestion extends ZendAfi_View_Helper_B $event="'".$rubrique."','".$name."',this.value".",min_cars=".$min_cars_recherche; $html.='<input id="'.$name.'_champ" type="text" size="28" max-length="30" onkeyUp="getSuggest('.$event.')" >'; $html.=str_repeat(" ",3).'<a style="color:#D44100;text-decoration:none;" href="javascript:suggestClear(\''.$name.'\',true)">»'.$this->translate()->_('Tout effacer').'</a>'; - + // Liste $html.='<div id="'.$name.'_liste" style="margin-top:10px;padding-top:5px;border-top:1px solid #C8C8C8"></div>'; $html.='</div>'; - + $html.='</div>'; - + return $html; } diff --git a/library/ZendAfi/View/Helper/TagListeCoches.php b/library/ZendAfi/View/Helper/TagListeCoches.php index 1a6eb00e960b18f8f33725d871e384b1c1e26c79..9d770710415f1f2bd9aa4bcab3202f63f97e38d6 100644 --- a/library/ZendAfi/View/Helper/TagListeCoches.php +++ b/library/ZendAfi/View/Helper/TagListeCoches.php @@ -39,30 +39,15 @@ 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 ''; + Class_ScriptLoader::getInstance() + ->addTagSelection(); + $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 +55,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; } @@ -173,7 +185,7 @@ class ZendAfi_View_Helper_TagListeCoches extends ZendAfi_View_Helper_BaseHelper if (!array_key_exists($value, $this->_possibles)) return $this; - $this->_selection .= '«' . $this->_possibles[$value] . '» '; + $this->_selection .= $this->_tag('span', $this->_possibles[$value], ['class' => 'selected']); $this->_filtred_codes[] = $value; $this->_coche[$value] = true; diff --git a/public/admin/css/global.css b/public/admin/css/global.css index 692cb02d02b3455bdbd9687b42038bfc95040410..25c4451b5999a838bac2f8806945280d85051301 100644 --- a/public/admin/css/global.css +++ b/public/admin/css/global.css @@ -121,7 +121,6 @@ option {font-weight:normal; color:#666;} .form ul.errors + input, .form ul.errors + select, .form ul.errors + textarea {border: solid 1px red; } -.form div.tag_selection{width:100%;border:1px solid #C8C8C8;min-height:15px;background-color:#ffffff;padding:2px} .form div.tag_saisie{border:1px solid #C8C8C8;min-height:15px;border-top:none;padding:5px;margin-left:5px;display:none;width:auto;background-color:#ffffff;overflow:auto;max-height:244px} .form div.tag_liste{padding:1px 3px 1px 3px;margin-left:5px;} .form div.tag_liste:hover{background-color:#FFFF99;cursor:pointer} diff --git a/public/opac/js/tag_selection/tag_selection.css b/public/opac/js/tag_selection/tag_selection.css new file mode 100644 index 0000000000000000000000000000000000000000..ed9827cdceb930be4653809835d3801deb7a1100 --- /dev/null +++ b/public/opac/js/tag_selection/tag_selection.css @@ -0,0 +1,17 @@ +.tag_selection{ + padding:0.2em; + margin: 0.2em; + border-bottom: 1px solid #AAA; +} + +span.selected { + cursor: default; + display: inline-block; + white-space: nowrap; + font-size: 1em; + line-height: 1.2em; + padding: 0.2em; + margin: 0 0.1em 0.1em 0.1em; + text-align: center; + border: 1px solid #BBB; +} \ No newline at end of file diff --git a/public/admin/js/tag_selection.js b/public/opac/js/tag_selection/tag_selection.js similarity index 95% rename from public/admin/js/tag_selection.js rename to public/opac/js/tag_selection/tag_selection.js index c1eb80bb3b67efb5849bc6dc173e8b367fcd8f53..7f6fd8d16e3ec88954f70e72d501dafc92611894 100644 --- a/public/admin/js/tag_selection.js +++ b/public/opac/js/tag_selection/tag_selection.js @@ -40,10 +40,12 @@ function getCoches(sIdChamp,allSelectedAsNothingSelected) if(oCheckBox.checked == true) { sLibelle=oCheckBox.nextSibling.data; - if(oChampCodes.value > "") oChampCodes.value += ";"; + if(oChampCodes.value > "") + oChampCodes.value += ";"; oChampCodes.value+=oCheckBox.getAttribute("clef"); - if( sAff > "") sAff +=" "; - sAff+="«" + sLibelle + "»"; + if( sAff > "") + sAff +=" "; + sAff+='<span class="selected">' + sLibelle + '</span>'; } else bToutEstCoche=false; } @@ -141,7 +143,7 @@ function selectSuggest(sIdChamp, oItem) sAff=oChampAff.innerHTML; if( sAff > "") sAff +=" "; - sAff+="«" + oItem.innerHTML + "»" + sAff+='<span class="selected">' + oItem.innerHTML + "</span>" oChampAff.innerHTML=sAff; setFlagMaj(true); } diff --git a/tests/application/modules/opac/controllers/AbonneControllerSettingsTest.php b/tests/application/modules/opac/controllers/AbonneControllerSettingsTest.php index 564d61b561171362574b4224c45650107b8f2a62..4bf8da8d32762deaeadd4d91c31fe80b9fa68869 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerSettingsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerSettingsTest.php @@ -131,13 +131,24 @@ class AbonneControllerSettingsFormTest extends AbonneControllerSettingsTestCase } + /** @test */ + public function listeCocheJsShouldBeLoaded() { + $this->assertXPath('//script[contains(@src,"opac/js/tag_selection/tag_selection.js")]'); + } + + + /** @test */ + public function listeCocheCssShouldBeLoaded() { + $this->assertXPath('//link[contains(@href, "opac/js/tag_selection/tag_selection.css")]'); + } + + /** @test */ public function domainSelectorShouldBePresent() { $this->assertXPathContentContains('//div', 'Mes thèmes préférés'); } - /** @test */ public function libSelectorShouldBePresent() { $this->assertXPathContentContains('//div', 'Mes bibliothèques préférées'); diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index c24969996ef0ada56dfe96c079ca9600cd0f5b76..2b3d2fe30fcd1588dfa61d39fc6e8b23a0036131 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -2678,7 +2678,13 @@ class RechercheControllerAvanceeTest extends AbstractControllerTestCase { /** @test **/ public function scriptTagSlectionShouldBePresent() { - $this->assertXPath('//script[contains(@src,"/admin/js/tag_selection")]'); + $this->assertXPath('//script[contains(@src,"opac/js/tag_selection/tag_selection.js")]'); + } + + + /** @test **/ + public function cssTagSlectionShouldBePresent() { + $this->assertXPath('//link[contains(@href,"opac/js/tag_selection/tag_selection.css")]'); }