Commit 61fc1bc0 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

wip on theme store

parent d09d74c6
Pipeline #9465 passed with stage
in 41 minutes and 51 seconds
<?php
/**
* Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* 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
*/
class Intonation_View_Abonne_Suggestions extends ZendAfi_View_Helper_BaseHelper {
public function abonne_Suggestions($suggestions) {
if (empty($suggestions))
return $this->_('Aucune suggestion');
$suggestions = array_map(function($suggestion)
{
return (new Intonation_Library_View_Wrapper_Suggestion)
->setModel($suggestion)
->setView($this->view);
}, $suggestions->getArrayCopy());
$callback = function($wrapped) {
return $this->view->cardifyOnlyDescription($wrapped);
};
$collection = new Storm_Collection($suggestions);
$actions = [new Intonation_Library_Link(['Url' => $this->view->url(['controller' => 'abonne',
'action' => 'suggestion-achat-add']),
'Text' => $this->_('Suggérer un achat'),
'InlineText' => 1,
'Class' => 'btn btn-sm btn-success',
'Title' => $this->_('Suggérer un achat à la bibliothèque'),
'Image' => Class_Template::current()->getIco($this->view,
'add',
'utils')])];
return $this->view->renderCollection($collection, $actions, $callback);
}
}
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* 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
*/
class Intonation_View_Abonne_SuggestionsBoard extends Intonation_View_Abonne {
protected $_show_current_section = 'user_suggestions';
public function abonne_SuggestionsBoard($user) {
return $this->_renderSection($user);
}
}
\ No newline at end of file
......@@ -29,7 +29,7 @@ class Intonation_View_CardifyHorizontal extends Intonation_View_CardHelper {
if ($second_link = $element->getSecondaryLink())
$content [] = $this->_tag('div',
$this->view->tagAction($second_link),
$this->view->tagAction($second_link->setInlineText(1)),
['class' => 'card-subtitle']);
if (!$second_link && $secondary_title = $element->getSecondaryTitle())
......
......@@ -29,7 +29,7 @@ class Intonation_View_CardifyOnlyDescription extends Intonation_View_CardHelper
if ($second_link = $element->getSecondaryLink())
$content [] = $this->_tag('div',
$this->view->tagAction($second_link
->setNoButtonText(1)),
->setInlineText(1)),
['class' => 'card-subtitle']);
if ($summary = $element->getDescription())
......
......@@ -52,7 +52,7 @@ class Intonation_View_CardifyWithOverlay extends ZendAfi_View_Helper_BaseHelper
$main_link = $element
->getMainLink()
->setText($content)
->setNoButtonText(true)
->setInlineText(1)
->setImage('');
$link = $this->view->tagAction($main_link);
......
......@@ -102,7 +102,7 @@ class Intonation_View_Jumbotron extends ZendAfi_View_Helper_BaseHelper {
$html = $this->_tag('h1', $this->_element->getMainTitle());
if ($secondary_link = $this->_element->getSecondaryLink())
$html .= $this->view->tagAction($secondary_link->setNoButtonText(1));
$html .= $this->view->tagAction($secondary_link->setInlineText(1));
return $html . $this->_element->getBadges() . $this->_actions();
}
......
......@@ -21,14 +21,22 @@
class Intonation_View_RenderCollection extends ZendAfi_View_Helper_BaseHelper {
public function renderCollection($collection, $actions = []) {
public function renderCollection($collection, $actions = [], $callback = null) {
$callback = $callback
? $callback
: (function($item)
{
return $this->view->cardifyHorizontal($item);
});
foreach ($actions as $action) {
$action->setClass('btn btn-sm btn-success');
}
$html = [$this->view->div(['class' => 'col-12'], $this->view->renderActions($actions)),
$this->view->div(['class' => 'col-12'],
$this->view->renderTruncateList($collection,
(function($item)
{
return $this->view->cardifyHorizontal($item);
})))];
$callback))];
return $this->view->grid(implode($html));
}
......
......@@ -22,6 +22,11 @@
class Intonation_View_RenderTruncateList extends ZendAfi_View_Helper_BaseHelper {
protected
$_container_id,
$_input_id;
public function renderTruncateList($collection, $callback) {
$size = $collection->count();
......@@ -37,40 +42,33 @@ class Intonation_View_RenderTruncateList extends ZendAfi_View_Helper_BaseHelper
'class' => 'list-group-item bg-transparent border-0 px-0']);
});
$id = uniqid();
$this->_container_id = $id = uniqid();
$this->_input_id = 'input_' . $this->_container_id;
return
$this->_renderToolsIn($id, $size)
$this->_renderTools($size)
. $this->_tag('div',
$html,
['id' => $id,
['id' => $this->_container_id,
'class' => 'list-group bg-transparent border-0']);
}
protected function _renderToolsIn($container_id, $size) {
$input_id = 'input_' . $container_id;
protected function _renderTools($size) {
$size_id = uniqid();
$id = uniqid();
Class_ScriptLoader::getInstance()
->addSearchInputToContainer('#' . $container_id,
'#' . $input_id,
'#' . $container_id . ' div.card *, .dropdown, .dropdown-menu')
->addJQueryReady("var container = $('#" . $container_id . "');"
. "container.children().slice(0,3).show();"
. "$('#" . $input_id . "').attr('onkeypress', 'return event.keyCode != 13;');");
$this->renderHeadScriptsOn(Class_ScriptLoader::getInstance());
$onchange =
"var container = $('#" . $container_id . "');"
"var container = $('#" . $this->_container_id . "');"
. "container.children().hide();"
. "var value=$('#" . $id . "').val();"
. "container.children().not('.search_input_not_found').slice(0, value).show();";
$input_keyup =
"$('#" . $id . "').val(10000).change();"
. 'setTimeout(function() {$(\'#' . $size_id . '\').text($(\'#' . $container_id . '\').children(\':visible\').length);}, 10);';
. "setTimeout(function() { $('#" . $size_id . "').text($('#" . $this->_container_id . "').children(':visible').length); var searchText = $('#" . $this->_input_id . "').val(); if (!searchText || searchText == '' || searchText == '*') $('#" . $id . "').val(3).change();}, 10);";
$multi_options = $this->_getTruncateOptions($size);
......@@ -86,7 +84,7 @@ class Intonation_View_RenderTruncateList extends ZendAfi_View_Helper_BaseHelper
'multiOptions' => $multi_options])
->addElement('text',
$input_id,
$this->_input_id,
['label' => $this->_('Filtrer'),
'placeholder' => $this->_('Filtrer avec un nom, un mot, une date'),
'title' => $this->_('Filtrer la liste avec des noms, des mots, des dates'),
......@@ -114,7 +112,7 @@ class Intonation_View_RenderTruncateList extends ZendAfi_View_Helper_BaseHelper
protected function _getTruncateOptions($size) {
if ($size > 100)
if ($size > 50)
return ['3' => $this->_('3'),
'10' => $this->_('10'),
'50' => $this->_('50'),
......@@ -131,4 +129,18 @@ class Intonation_View_RenderTruncateList extends ZendAfi_View_Helper_BaseHelper
return ['10000' => $this->_('Tout')];
}
public function renderHeadScriptsOn($script_loader) {
$script_loader
->addSearchInputToContainer('#' . $this->_container_id,
'#' . $this->_input_id,
'#' . $this->_container_id . ' div.card *, .dropdown, .dropdown-menu')
->addJQueryReady("var container = $('#" . $this->_container_id . "');"
. "container.children().slice(0,3).show();"
. "$('#" . $this->_input_id . "').attr('onkeypress', 'return event.keyCode != 13;');");
return $this;
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* 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
*/
class Intonation_View_Rss_RenderItems extends ZendAfi_View_Helper_BaseHelper {
public function rss_RenderItems($rss) {
$items = $rss->getFeedItems();
$items = array_map(function($element)
{
return (new Intonation_Library_View_Wrapper_RssItem)
->setView($this->view)
->setModel($element);
}, $items);
$items = new Storm_Collection($items);
return $this->view->renderTruncateList($items, function($element)
{
return $this->view->cardifyOnlyDescription($element);
});
}
}
......@@ -57,6 +57,8 @@ class Intonation_View_Search_History extends ZendAfi_View_Helper_BaseHelper {
'action' => 'clear-history']),
'Popup' => true,
'Text' => $this->_('Vider'),
'Class' => 'btn btn-sm btn-warning',
'InlineText' => 1,
'Title' => $this->_('Vider l\'historique de recherches'),
'Image' => Class_Template::current()->getIco($this->view,
'delete',
......
......@@ -87,7 +87,7 @@ class Intonation_View_Search_HtmlCriteria extends ZendAfi_View_Helper_TagCritere
'Image' => Class_Template::current()->getIco($this->view, 'clean', 'utils'),
'Text' => $label,
'Title' => $this->_('Retirer le critère: %s', $label),
'NoButtonText' => 1,
'InlineText' => 1,
'Class' => 'btn btn-warning btn-sm mb-2 mr-2 text-dark text-left']));
}
......
......@@ -111,14 +111,14 @@ class Intonation_View_Search_Result extends ZendAfi_View_Helper_BaseHelper {
'Image' => Class_Template::current()->getIco($this->view, 'list', 'utils'),
'Text' => $this->_tag('span', $this->_('Liste')),
'Title' => $this->_('Afficher le résultat de recherche en mode liste'),
'NoButtonText' => 1,
'InlineText' => 1,
'Attribs' => ['class' => 'btn-sm list_format' . ($wall_active ? '' : ' active')]])),
$this->view->tagAction(new Intonation_Library_Link(['Url' => $this->view->url(['liste_format' => Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR]),
'Image' => Class_Template::current()->getIco($this->view, 'wall', 'utils'),
'Text' => $this->_tag('span', $this->_('Mur')),
'Title' => $this->_('Afficher le résultat de recherche en mode mur'),
'NoButtonText' => 1,
'InlineText' => 1,
'Attribs' => ['class' => 'btn-sm list_format' . ($wall_active ? ' active' : '')]])),
$this->view->search_PageSize($criteria),
......
......@@ -80,7 +80,7 @@ class Intonation_View_TagAction extends ZendAfi_View_Helper_BaseHelper {
if (!$text = $action->getText())
return '';
if ($action->getNoButtonText())
if ($action->getInlineText())
return $this->_tag('div', $text, ['class' => 'd-inline text-left']);
if (!$img)
......
......@@ -51,17 +51,22 @@ class Intonation_View_User_Informations extends ZendAfi_View_Helper_BaseHelper {
$html [] = $this->_tag('dt', $label, ['class' => 'user_info'])
. $this->_tag('dd', $value, ['class' => 'user_info']);
return $this->view->div(['class' => 'card'],
$this->view->div(['class' => 'card-body'],
$this->_tag('dl', implode($html)))
$edit_link =
new Intonation_Library_Link(['Url' => $this->view->url(['controller' => 'abonne',
'action' => 'modifier'], null, true),
'Image' => Class_Template::current()->getIco($this->view, 'edit', 'utils'),
'Text' => $this->_('Modifier mes informations'),
'Title' => $this->_('Modifier les informations me concernant'),
'Class' => 'btn btn-sm btn-success',
'InlineText' => 1,
'Popup' => true]);
. $this->view->div(['class' => 'position-absolute'],
$this->view->tagAnchor($this->view->url(['controller' => 'abonne',
'action' => 'modifier']),
Class_Template::current()->getIco($this->view, 'edit', 'utils'),
['class' => 'ml-1',
'data-popup' => true,
'title' => $this->_('Modifier mes informations')])));
return
$this->view->div(['class' => 'card no_border'],
$this->view->div(['class' => 'card-header pl-2 pb-0'],
$this->view->tagAction($edit_link))
. $this->view->div(['class' => 'card-body pl-0 pt-2'],
$this->_tag('dl', implode($html))));
}
......
.search_input_not_found {
display: none;
display: none !important;
}
......
......@@ -49,45 +49,47 @@
var html = $(this);
var not_found_class = 'search_input_not_found';
var onSearchInputChange = function(searchText) {
var resetAll = function() {
html
.find('*')
.not(default_fixed_display + options.fixed_display)
.removeClass(not_found_class)
.show();
}
var resetAll = function() {
html
.find('*')
.not(default_fixed_display + options.fixed_display)
.removeClass(not_found_class)
.show();
}
var accentsTidy = function(s){
var r = s.toLowerCase();
r = r.replace(new RegExp("[àáâãäå]", 'g'),"a");
r = r.replace(new RegExp("æ", 'g'),"ae");
r = r.replace(new RegExp("ç", 'g'),"c");
r = r.replace(new RegExp("[èéêë]", 'g'),"e");
r = r.replace(new RegExp("[ìíîï]", 'g'),"i");
r = r.replace(new RegExp("ñ", 'g'),"n");
r = r.replace(new RegExp("[òóôõö]", 'g'),"o");
r = r.replace(new RegExp("œ", 'g'),"oe");
r = r.replace(new RegExp("[ùúûü]", 'g'),"u");
r = r.replace(new RegExp("[ýÿ]", 'g'),"y");
return r;
};
var highlightItems = function(elements) {
resetAll();
html.find('*').not(elements).not(default_fixed_display + options.fixed_display).addClass(not_found_class);
html
.find(elements)
.parentsUntil(html)
.not(default_fixed_display + options.fixed_display)
.removeClass(not_found_class)
.show();
}
var onSearchInputChange = function(searchText) {
if (!searchText || searchText == "" || searchText == '*')
return resetAll();
var accentsTidy = function(s){
var r = s.toLowerCase();
r = r.replace(new RegExp("[àáâãäå]", 'g'),"a");
r = r.replace(new RegExp("æ", 'g'),"ae");
r = r.replace(new RegExp("ç", 'g'),"c");
r = r.replace(new RegExp("[èéêë]", 'g'),"e");
r = r.replace(new RegExp("[ìíîï]", 'g'),"i");
r = r.replace(new RegExp("ñ", 'g'),"n");
r = r.replace(new RegExp("[òóôõö]", 'g'),"o");
r = r.replace(new RegExp("œ", 'g'),"oe");
r = r.replace(new RegExp("[ùúûü]", 'g'),"u");
r = r.replace(new RegExp("[ýÿ]", 'g'),"y");
return r;
};
var highlightItems = function(elements) {
resetAll();
html.find('*').not(elements).not(default_fixed_display + options.fixed_display).addClass(not_found_class);
html
.find(elements)
.parentsUntil(html)
.not(default_fixed_display + options.fixed_display)
.removeClass(not_found_class)
.show();
}
searchText = accentsTidy(searchText);
searchText = searchText.split(' ');
searchText = searchText.filter(function(term){return term;});
......@@ -123,7 +125,7 @@
: $(options.input);
search_input
.keyup(function(event){
.on('keyup', function(event){
onSearchInputChange(this.value);
})
.end();
......
......@@ -23,6 +23,9 @@ var ajaxify_calendars = function () {
event.preventDefault();
});
if (undefined != $.fn.masonry)
$(this).closest(".calendar").masonry();
var month_no_event = $('.calendar .month_list a.no_event');
month_no_event.click(function(event) {
event.preventDefault();
......
......@@ -83,7 +83,9 @@
"--ignore-dir" "emacs"
"--ignore-dir" "fichiers"
"--ignore-dir" "jQuery"
"--ignore-dir" "ckeditor"
"--ignore-dir" "ckeditor"
"--ignore-dir" "Bootstrap"
"--ignore-dir" "Font-Awesome"
"--ignore" "jquery.mobile-1.1.0.min.js"
"--ignore" "jquery.mobile-1.2.0.min.js"
"--" ))
......
......@@ -167,7 +167,279 @@ class PolygoneTemplateOpacAdvancedSearchTest extends PolygoneTemplateTestCase {
/** @test */
public function advancedSearchSettingsShouldContainsCustomForm() {
$this->dispatch('/admin/widget/edit-action/id/recherche_avancee/id_profil/24');
$this->dispatch('/admin/widget/edit-action/id/recherche_avancee/id_profil/1');
$this->assertXPath('//input[@id="forms"]');
}
}
\ No newline at end of file
}
class PolygoneTemplateSuggestTest extends PolygoneTemplateTestCase {
/** @test */
public function dispatchSuggestionsWithoutOneShouldRenderEmptyMessage() {
$this->dispatch('/opac/abonne/suggestions');
$this->assertXPathContentContains('//main//div', 'Vous n\'avez pas encore fait de suggestion.');
}
/** @test */
public function dispatchSuggestionsAddShouldRenderForm() {
$this->dispatch('/opac/abonne/suggestion-achat-add');
$this->assertXPath('//main//form');
}
/** @test */
public function dispatchLocalSuggestionsShouldRenderBookDocType() {
$this->fixture('Class_SuggestionAchat',
['id' => 3,
'date_creation' => '2020-02-18',
'type_doc_id' => 1,
'titre' => 'Northlanders',
'auteur' => 'Unknown',
'user' => Class_Users::getIdentity()
]);
$this->dispatch('/opac/abonne/suggestions');
$this->assertXpath('//main//div//i[contains(@class, "fas fa-book")]');
}
}
class PolygoneTemplateKohaSuggestionsTest extends PolygoneTemplateTestCase {
public function setUp() {
parent::setUp();
$sigb_plage =
$this->fixture('Class_IntBib',
[
'id' => 3,
'comm_params' => ['url_serveur' => 'http://plage.com/cgi-bin/koha/ilsdi.pl',
'restful' => '1'],
'comm_sigb' => Class_IntBib::COM_KOHA
]);
$this->fixture('Class_Bib', ['id' => 11,
'libelle' => 'Bib de la plage',
'int_bib' => $sigb_plage]);
$this->fixture('Class_Bib', ['id' => 12,
'libelle' => 'Bib de la plage 2',
'int_bib' => $sigb_plage]);
$this->fixture('Class_Bib', ['id' => 14,
'libelle' => 'Bib de la montagne']);
$istres = $this->fixture('Class_CodifAnnexe',
['id' => 15,
'libelle' => 'Istres',
'id_origine' => 'IST']);
$borrower = new Class_WebService_SIGB_Emprunteur('2341', 'test');