Skip to content
Snippets Groups Projects
Commit ba11dcb1 authored by Laurent's avatar Laurent
Browse files

dev #80538 search reset button tracks wich form tab to display

parent 20390b4d
Branches
Tags
3 merge requests!2871Wip,!2869Master,!2862Dev#80538 recherche avancee ajouter un bouton reinitialiser formulaire
Pipeline #5171 passed with stage
in 29 minutes and 56 seconds
......@@ -284,7 +284,7 @@ class RechercheController extends ZendAfi_Controller_Action {
public function avanceeAction() {
$this->view->annexes = Class_CodifAnnexe::getMultiOptions();
$this->view->criteres_recherche = $this->newCriteresRecherches($this->_request->getParams());
$this->view->active_tab = $this->_getParam('form_id', 0);
$this->view->search_forms =
Class_SearchForm::findAllByPrefs(isset($this->preferences['forms'])
? $this->preferences['forms']
......
<?php
echo
$this->openBoite($this->_current_module['preferences']['titre'])
. $this->advancedSearch($this->search_forms)
. $this->advancedSearch($this->search_forms, $this->active_tab)
. $this->closeBoite()
. $this->tag('div', $this->historiqueRecherche(), ['class' => 'conteneur_simple']);
\ No newline at end of file
. $this->tag('div', $this->historiqueRecherche(), ['class' => 'conteneur_simple']);
......@@ -22,7 +22,7 @@
class ZendAfi_View_Helper_AdvancedSearch extends ZendAfi_View_Helper_BaseHelper {
public function advancedSearch($search_forms = []) {
public function advancedSearch($search_forms = [], $active_tab = 0) {
if(!Class_AdminVar::isCustomSearchFormEnabled())
return $this->view->legacyAdvancedSearch();
......@@ -32,14 +32,14 @@ class ZendAfi_View_Helper_AdvancedSearch extends ZendAfi_View_Helper_BaseHelper
return empty($html)
? $this->_renderDefaultAdvancedSearch()
: $this->_renderSearchForms($html);
: $this->_renderSearchForms($html, $active_tab);
}
protected function _renderSearchForms($html_array) {
protected function _renderSearchForms($html_array, $active_tab) {
$html = [];
foreach($html_array as $form)
$html [] = $this->_tag('div', $form, ['id' => md5($form),
foreach($html_array as $id => $form)
$html [] = $this->_tag('div', $form, ['id' => $id,
'class' => 'tabify_me']);
$content = implode($html);
......@@ -48,8 +48,9 @@ class ZendAfi_View_Helper_AdvancedSearch extends ZendAfi_View_Helper_BaseHelper
Class_ScriptLoader::getInstance()
->addOPACScript('tabify')
->addJQueryReady(sprintf('$("#%s").tabify();',
$forms_container_id));
->addJQueryReady(sprintf('$("#%s").tabify({active:%d});',
$forms_container_id,
$active_tab));
return $this->_tag('div',
$content,
......@@ -63,12 +64,13 @@ class ZendAfi_View_Helper_AdvancedSearch extends ZendAfi_View_Helper_BaseHelper
}
protected function _clearFormButton() {
protected function _clearFormButton($form_id) {
return $this->view->button((new Class_Entity())
->setUrl($this->view->url(['module' => 'opac',
'controller' => 'recherche' ,
'action' => 'avancee',
'statut' => 'reset'], null,true))
'statut' => 'reset',
'form_id' => $form_id], null,true))
->setAttribs(['class' => 'bouton init',
'title' => $this->_('Réinitialiser le formulaire')])
->setText($this->_('Réinitialiser')));
......@@ -108,7 +110,7 @@ class ZendAfi_View_Helper_AdvancedSearch extends ZendAfi_View_Helper_BaseHelper
$html = $this->_tag('p', $this->_('Ce formulaire n\'est pas visible.'), ['class' => 'error']) . $html;
$html .= $this->view->renderForm($this->_populateForm($form_wrapper->getForm()),
['append' => [$this->_clearFormButton()]]);
['append' => [$this->_clearFormButton(count($content))]]);
$content[] = $html;
return $content;
......
......@@ -19,7 +19,7 @@
*/
(function ( $ ) {
$.fn.tabify = function() {
$.fn.tabify = function(options) {
var html = $(this);
var html_content = html.find('.tabify_me');
......@@ -48,7 +48,7 @@
legend.remove();
});
html.prepend(tabs).tabs();
html.prepend(tabs).tabs(options);
html.prepend(no_legend);
html.find('a.errors.ui-tabs-anchor').first().click();
}
......
......@@ -468,11 +468,8 @@ $form
class AdvancedSearchValidCustomFormsSelectedAndPublishedTest
extends AdvancedSearchCustomFormSelectedTestCase {
protected function _prepareFixtures() {
abstract class AdvancedSearchValidCustomFormsSelectedAndPublishedTestCase extends AdvancedSearchCustomFormSelectedTestCase {
protected function _prepareFixtures() {
parent::_prepareFixtures();
$author_search_form = 'userfiles/forms/author_search_form.php';
......@@ -534,8 +531,13 @@ class AdvancedSearchValidCustomFormsSelectedAndPublishedTest
->setCfgModules(['recherche' => ['avancee' => ['forms' => '3;9']]]);
ZendAfi_Auth::getInstance()->clearIdentity();
}
}
class AdvancedSearchValidCustomFormsSelectedAndPublishedTest extends AdvancedSearchValidCustomFormsSelectedAndPublishedTestCase {
/** @test */
public function authorFieldShouldBePresent() {
$this->assertXPath('//input[@name="author_field"]', $this->_response->getBody());
......@@ -568,7 +570,30 @@ class AdvancedSearchValidCustomFormsSelectedAndPublishedTest
/** @test */
public function formShouldContainsResetButton() {
$this->assertXPathContentContains('//button[contains(@data-url,"/recherche/avancee/statut/reset")]', 'Réinitialiser');
$this->assertXPathContentContains('//button[contains(@data-url,"/recherche/avancee/statut/reset/form_id/1")]', 'Réinitialiser');
}
}
class AdvancedSearchResetSecondFormTest extends AdvancedSearchValidCustomFormsSelectedAndPublishedTestCase {
public function setUp() {
AbstractControllerTestCase::setUp();
$this->_prepareFixtures();
}
/** @test */
public function resetFormIdOneShouldActivateFormIdOne() {
$this->dispatch('/recherche/avancee/statut/reset/form_id/1', true);
$this->assertXPathContentContains('//script', '.tabify({active:1})');
}
/** @test */
public function resetFormEmptyShouldActivateFormIdZero() {
$this->dispatch('/recherche/avancee/statut/reset', true);
$this->assertXPathContentContains('//script', '.tabify({active:0})');
}
}
......
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