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

hotline #17171 search autocomplete is no longer marked as experimental

parent 805607f7
Branches
Tags
5 merge requests!529Hotline 6.56,!512Master,!484Master,!483Hotline 6.54,!471Hotline#17171 autocomplete
- ticket #17171: L'autocomplétion en recherche simple n'est plus considérée comme expérimentale, il suffit d'activer les batchs associés.
18/10/2014 - v6.54.3 18/10/2014 - v6.54.3
- ticket #16596: Corrige l'ordre de calcul des types de documents (Sous-champ 995 avant le label) - ticket #16596: Corrige l'ordre de calcul des types de documents (Sous-champ 995 avant le label)
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software * along with AFI-OPAC 2.0; 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
*/ */
class ZendAfi_View_Helper_Accueil_RechSimple extends ZendAfi_View_Helper_Accueil_Base { class ZendAfi_View_Helper_Accueil_RechSimple extends ZendAfi_View_Helper_Accueil_Base {
...@@ -24,13 +24,22 @@ class ZendAfi_View_Helper_Accueil_RechSimple extends ZendAfi_View_Helper_Accueil ...@@ -24,13 +24,22 @@ class ZendAfi_View_Helper_Accueil_RechSimple extends ZendAfi_View_Helper_Accueil
$script_loader $script_loader
->addJQueryReady('$("input.expressionRecherche").attr("x-webkit-speech","x-webkit-speech")'); ->addJQueryReady('$("input.expressionRecherche").attr("x-webkit-speech","x-webkit-speech")');
if (!defined('DEVELOPMENT')) if (!$this->_isAutocompleteEnabled())
return; return $this;
$script_loader $script_loader
->addOPACPluginScript('search_autocomplete/search_autocomplete') ->addOPACPluginScript('search_autocomplete/search_autocomplete')
->addJQueryReady('$("input.expressionRecherche").search_autocomplete('. $this->getAutocompleteOptions() .')'); ->addJQueryReady('$("input.expressionRecherche").search_autocomplete('. $this->getAutocompleteOptions() .')');
return $this;
} }
protected function _isAutocompleteEnabled() {
$batch_types = Class_Batch::getActiveTypes();
return in_array('AUTOCOMPLETE_RECORD_TITLE', $batch_types) || in_array('AUTOCOMPLETE_RECORD_AUTHOR', $batch_types);
}
protected function getAutocompleteOptions() { protected function getAutocompleteOptions() {
$options = new stdClass(); $options = new stdClass();
$options->url = $this->view->url(['controller' => 'recherche', $options->url = $this->view->url(['controller' => 'recherche',
...@@ -43,7 +52,7 @@ class ZendAfi_View_Helper_Accueil_RechSimple extends ZendAfi_View_Helper_Accueil ...@@ -43,7 +52,7 @@ class ZendAfi_View_Helper_Accueil_RechSimple extends ZendAfi_View_Helper_Accueil
public function getHtml() { public function getHtml() {
$this->titre = $this->preferences["titre"]; $this->titre = $this->preferences["titre"];
$this->contenu = $this->view->TagRechercheSimple($this->preferences, $this->contenu = $this->view->TagRechercheSimple($this->preferences,
$this->id_module, $this->id_module,
$this->division); $this->division);
return $this->getHtmlArray(); return $this->getHtmlArray();
......
...@@ -16,22 +16,33 @@ ...@@ -16,22 +16,33 @@
* *
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software * along with AFI-OPAC 2.0; 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
*/ */
require_once 'library/ZendAfi/View/Helper/ViewHelperTestCase.php'; require_once 'library/ZendAfi/View/Helper/ViewHelperTestCase.php';
class ZendAfi_View_Helper_Accueil_RechSimpleTest extends ViewHelperTestCase { abstract class ZendAfi_View_Helper_Accueil_RechSimpleTestCase extends ViewHelperTestCase {
public function setup() { public function setup() {
parent::setup(); parent::setup();
$helper = new ZendAfi_View_Helper_Accueil_RechSimple(1, $this->_helper = new ZendAfi_View_Helper_Accueil_RechSimple(1,
['division' => 1, ['division' => 1,
'type_module' => 'RECH_SIMPLE', 'type_module' => 'RECH_SIMPLE',
'preferences' => [ 'preferences' => [
'boite' => '', 'boite' => '',
'titre' => 'Search widget']]); 'titre' => 'Search widget']]);
$helper->setView(new ZendAfi_Controller_Action_Helper_View()); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View());
$this->_html = $helper->getBoite(); }
}
class ZendAfi_View_Helper_Accueil_RechSimpleWithAutocompleteTest extends ZendAfi_View_Helper_Accueil_RechSimpleTestCase {
public function setup() {
parent::setUp();
$this->fixture('Class_Batch', ['id' => 42, 'type' => 'AUTOCOMPLETE_RECORD_TITLE']);
$this->_html = $this->_helper->getBoite();
$this->_head_script = Class_ScriptLoader::getInstance()->html(); $this->_head_script = Class_ScriptLoader::getInstance()->html();
} }
...@@ -49,4 +60,22 @@ class ZendAfi_View_Helper_Accueil_RechSimpleTest extends ViewHelperTestCase { ...@@ -49,4 +60,22 @@ class ZendAfi_View_Helper_Accueil_RechSimpleTest extends ViewHelperTestCase {
$this->assertXPathContentContains($this->_head_script, '//script', $expected_ajax_param); $this->assertXPathContentContains($this->_head_script, '//script', $expected_ajax_param);
} }
} }
class ZendAfi_View_Helper_Accueil_RechSimpleWithoutAutocompleteTest extends ZendAfi_View_Helper_Accueil_RechSimpleTestCase {
public function setup() {
parent::setUp();
Class_Batch::beVolatile();
$this->_html = $this->_helper->getBoite();
$this->_head_script = Class_ScriptLoader::getInstance()->html();
}
/** @test */
public function searchAutocompleteShouldNotBeLodaed() {
$this->assertNotXPath($this->_head_script, '//script[contains(@src,"search_autocomplete.js")]');
}
}
?> ?>
\ No newline at end of file
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