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

Correction régressions TagListeCoches

parent 1ee22a27
Branches
Tags
No related merge requests found
......@@ -33,7 +33,6 @@ class ZendAfi_View_Helper_TagListeCoches extends ZendAfi_View_Helper_BaseHelper
public function TagListeCoches($rubrique,$name,$valeurs="",$id_bib=0) {
Class_ScriptLoader::getInstance()->addAdminScript('tag_selection');
$rubriques = ['type_doc' => ['model' => 'Class_TypeDoc'],
'section' => ['model' => 'Class_CodifSection'],
......@@ -49,21 +48,26 @@ class ZendAfi_View_Helper_TagListeCoches extends ZendAfi_View_Helper_BaseHelper
'nature_doc' => ['model' => 'Class_NatureDoc'],
'annexe' => ['model' => 'Class_CodifAnnexe',
'where' => array_filter(['id_bib' => $id_bib, 'invisible' => 0])]
];
'annexe' => ['id' => 'code',
'model' => 'Class_CodifAnnexe',
'where' => array_filter(['id_bib' => $id_bib, 'invisible' => 0])]];
$definition = $rubriques[$rubrique];
$loader = call_user_func([$definition['model'], 'getLoader']);
$instances = $loader->findAllBy(isset($definition['where']) ? $definition['where'] : []);
$filter = isset($definition['where']) ? $definition['where'] : [];
$filter['order'] = 'libelle';
$instances = $loader->findAllBy($filter);
$liste = [];
foreach($instances as $instance)
$liste[$instance->getId()] = $instance->getLibelle();
foreach($instances as $instance) {
$key = $instance
->callGetterByAttributeName((isset($definition['id'])) ? $definition['id'] : 'id');
$liste[$key] = $instance->getLibelle();
}
// Texte affichage des libelles
$selection = '';
$coche = array();
if($valeurs) {
if($valeurs) {
$codes=explode(";",$valeurs);
foreach($codes as $code) {
if (array_key_exists($code, $liste)) {
......@@ -72,38 +76,38 @@ class ZendAfi_View_Helper_TagListeCoches extends ZendAfi_View_Helper_BaseHelper
}
}
}
$cant_select_all=$this->selected_all_means_nothing ?'true' : 'false';
$cant_select_all = $this->selected_all_means_nothing ? 'true' : 'false';
// Champs code et libelle
$html='<input id="'.$name.'" type="hidden" name="'.$name.'" value="'.$valeurs.'">';
$html.='<div class="tag_selection">';
$onclick="ouvrirFermer(this,'".$name."_saisie');";
$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>';
$html = '<input id="' . $name . '" type="hidden" name="' . $name . '" value="' . $valeurs . '">';
$html .= '<div class="tag_selection">';
$onclick = "ouvrirFermer(this,'" . $name . "_saisie');";
$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">';
$html .= '<div id="' . $name . '_saisie" class="tag_saisie">';
// Tout cocher/decocher
$html.='<div style="margin-bottom:5px;">';
$html.='<a href="javascript:selectAll(\''.$name.'\',true,';
$html.=$cant_select_all;
$html.=')">&raquo;'.$this->view->_('Tout cocher').'</a>';
$html.='&nbsp;&nbsp;&nbsp;<a href="javascript:selectAll(\''.$name.'\',false,'.$cant_select_all.')">&raquo;'.$this->view->_('Tout décocher').'</a>';
$html.='</div>';
$html .= '<div style="margin-bottom:5px;">';
$html .= '<a href="javascript:selectAll(\'' . $name . '\',true,';
$html .= $cant_select_all;
$html .= ')">&raquo;' . $this->view->_('Tout cocher') . '</a>';
$html .= '&nbsp;&nbsp;&nbsp;<a href="javascript:selectAll(\'' . $name . '\',false,' . $cant_select_all . ')">&raquo;' . $this->view->_('Tout décocher') . '</a>';
$html .='</div>';
// Valeurs
if($liste)
{
foreach($liste as $clef => $libelle)
{
if(array_key_exists($clef, $coche) && $coche[$clef]==true) $checked=' checked="checked"';
else $checked="";
$html.='<input type="checkbox" style="width: inherit;" value="1" clef="'.$clef.'" onclick="getCoches(\''.$name.'\','.$cant_select_all.')"'.$checked.'>'.$libelle.BR;
if ($liste) {
foreach($liste as $clef => $libelle) {
$checked = (array_key_exists($clef, $coche) && $coche[$clef]==true) ?
' checked="checked"' : '';
$html .= '<input type="checkbox" style="width: inherit;" value="1" clef="' . $clef . '" onclick="getCoches(\'' . $name . '\',' . $cant_select_all . ')"' . $checked . '>' . $libelle . BR;
}
}
$html.='</div>';
$html .= '</div>';
return $html;
}
}
\ No newline at end of file
}
?>
\ No newline at end of file
......@@ -840,8 +840,15 @@ class Admin_AlbumControllerEditAlbumMesBDTest extends Admin_AlbumControllerTestC
$this->fixture('Class_Bib', ['id' => '74', 'libelle' => 'Annecy', 'visibilite' => 2]);
$this->fixture('Class_Bib', ['id' => '77', 'libelle' => 'Lognes', 'visibilite' => 0]);
$this->fixture('Class_CodifAnnexe', ['id' => '4', 'libelle' => 'Patrimoine', 'invisible' => 1]);
$this->fixture('Class_CodifAnnexe', ['id' => '5', 'libelle' => 'Archives', 'invisible' => 0]);
$this->fixture('Class_CodifAnnexe', ['id' => '4',
'libelle' => 'Patrimoine',
'invisible' => 1,
'code' => 32]);
$this->fixture('Class_CodifAnnexe', ['id' => '5',
'libelle' =>
'Archives',
'invisible' => 0,
'code' => 33]);
Class_Album::find(43)
->setCatId(2)
......
......@@ -545,6 +545,8 @@ class CatalogueControllerEditUnknownCatalogueTest extends AdminCatalogueControll
class CatalogueControllerEditCatalogueTest extends AdminCatalogueControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_CodifAnnexe', ['id' => 1, 'code' => 12, 'libelle' => 'Annexe 12']);
$this->fixture('Class_CodifAnnexe', ['id' => 2, 'code' => 24, 'libelle' => 'Annexe 24']);
$this->dispatch('/admin/catalogue/edit/id_catalogue/6', true);
}
......@@ -591,6 +593,18 @@ class CatalogueControllerEditCatalogueTest extends AdminCatalogueControllerTestC
}
/** @test */
public function annexe12ChoiceShouldBePresent() {
$this->assertXPath('//div[@id="annexe_saisie"]//input[@type="checkbox"][@clef=12]');
}
/** @test */
public function annexe24ChoiceShouldBePresent() {
$this->assertXPath('//div[@id="annexe_saisie"]//input[@type="checkbox"][@clef=24]');
}
/** @test */
public function thesaurusShouldBeThemes() {
$this->assertXPathContentContains('//td',"Themes");
......
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