From 27e60bfb48f6de91fb3e17c26b286b743d8661a0 Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Wed, 15 Mar 2017 11:20:30 +0100 Subject: [PATCH] CIP #57858 improve listeCoches --- .../views/scripts/bib/localisationsmaj.phtml | 4 +- library/Class/ScriptLoader.php | 9 +++++ .../View/Helper/Admin/TagListeSuggestion.php | 38 +++++++++---------- .../ZendAfi/View/Helper/TagListeCoches.php | 6 ++- public/admin/css/global.css | 1 - public/opac/css/global.css | 2 +- .../opac/js/tag_selection/tag_selection.css | 17 +++++++++ .../js/tag_selection}/tag_selection.js | 10 +++-- 8 files changed, 59 insertions(+), 28 deletions(-) create mode 100644 public/opac/js/tag_selection/tag_selection.css rename public/{admin/js => opac/js/tag_selection}/tag_selection.js (95%) diff --git a/application/modules/admin/views/scripts/bib/localisationsmaj.phtml b/application/modules/admin/views/scripts/bib/localisationsmaj.phtml index 734d23d3382..c7692e040a4 100644 --- a/application/modules/admin/views/scripts/bib/localisationsmaj.phtml +++ b/application/modules/admin/views/scripts/bib/localisationsmaj.phtml @@ -1,5 +1,7 @@ <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> +<?php +echo (new Class_ScriptLoader())->addTagSelection()->html(); +?> <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 48e25cd09d9..4fa9ceb6385 100644 --- a/library/Class/ScriptLoader.php +++ b/library/Class/ScriptLoader.php @@ -818,4 +818,13 @@ class Class_ScriptLoader { $label, '.menuGaucheAdmin tr, .titre, img, table, tbody, td'); } + + + public function addTagSelection() { + $this + ->addOPACScript('tag_selection/tag_selection.js') + ->addOPACScriptStyleSheet('tag_selection/tag_selection.css'); + + return $this; + } } diff --git a/library/ZendAfi/View/Helper/Admin/TagListeSuggestion.php b/library/ZendAfi/View/Helper/Admin/TagListeSuggestion.php index 2a6d9d75b10..3dda2473936 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 98b22026bd9..9d770710415 100644 --- a/library/ZendAfi/View/Helper/TagListeCoches.php +++ b/library/ZendAfi/View/Helper/TagListeCoches.php @@ -42,9 +42,11 @@ class ZendAfi_View_Helper_TagListeCoches extends ZendAfi_View_Helper_BaseHelper 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->_possibles = $datas->getList(); $this->_cant_select_all = $this->selected_all_means_nothing ? 'true' : 'false'; @@ -183,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 2cefc44b37f..23e3719510a 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/css/global.css b/public/opac/css/global.css index 1eef47cd7ce..eb4bd7a7a5c 100644 --- a/public/opac/css/global.css +++ b/public/opac/css/global.css @@ -3669,4 +3669,4 @@ th.actions { [data-availability] .record_availability:hover .tooltip ul { padding-left: 1em; -} +} \ No newline at end of file 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 00000000000..ed9827cdceb --- /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 c1eb80bb3b6..7f6fd8d16e3 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); } -- GitLab