diff --git a/VERSIONS_HOTLINE/122669 b/VERSIONS_HOTLINE/122669 new file mode 100644 index 0000000000000000000000000000000000000000..cd96380f72f2574456c52fac906062326ad90beb --- /dev/null +++ b/VERSIONS_HOTLINE/122669 @@ -0,0 +1 @@ + - ticket #122669 : Magasin de thèmes , page notice : chaque icone d'action de la page a sa classe dédiée \ No newline at end of file diff --git a/library/templates/Intonation/Library/Selection.php b/library/templates/Intonation/Library/Selection.php index c54bce98ab1b5a5bcf7e5dbc99c6f2f294b9219e..1373115519d5f4f41651a3e963ef369a6144bbac 100644 --- a/library/templates/Intonation/Library/Selection.php +++ b/library/templates/Intonation/Library/Selection.php @@ -117,6 +117,7 @@ class Intonation_Library_Selection extends Class_Entity { ->getIco($this->getView(), $this->_getImageForContext(), 'library')), + 'Identifier' => $this->getIdentifier(), 'Title' => $this->_getTitleForContext(), 'Popup' => $popup]); } diff --git a/library/templates/Intonation/Library/UserPatcher.php b/library/templates/Intonation/Library/UserPatcher.php index 841553ffb7e9dd0b12e962fee58b64759ceb6bf6..b10d7ca3bf6b9fe316a073316426d40f21beb29d 100644 --- a/library/templates/Intonation/Library/UserPatcher.php +++ b/library/templates/Intonation/Library/UserPatcher.php @@ -53,15 +53,18 @@ class Intonation_Library_UserPatcher { public function getDefaultSelections() { return [new Intonation_Library_Selection(['Title' => $this->_('Mes préférés'), 'Image' => 'like', - 'RevertImage' => 'dislike']), + 'RevertImage' => 'dislike', + 'Identifier' => 'toggle_like_record']), new Intonation_Library_Selection(['Title' => $this->_('Déjà lu'), 'Image' => 'readed', - 'RevertImage' => 'unread']), + 'RevertImage' => 'unread', + 'Identifier' => 'toggle_read_record']), new Intonation_Library_Selection(['Title' => $this->_('À lire'), 'Image' => 'to_read', - 'RevertImage' => 'to_not_read'])]; + 'RevertImage' => 'to_not_read', + 'Identifier' => 'toggle_to_read_record'])]; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Record.php b/library/templates/Intonation/Library/View/Wrapper/Record.php index 445dc77eafd65a0f3b74164a9ffe6cc6cfe12fe7..3ee104191cc7c642449a4551fd2113fd76bd2ca3 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record.php @@ -82,6 +82,7 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra 'Popup' => 'true', 'Attribs' => ['class' => 'menu_admin_front_anchor'], 'Image' => Class_Template::current()->getIco($this->_view, 'edit', 'utils'), + 'Identifier' => 'record_change_thumbnail', 'Title' => $this->_('Modifier la vignette de %s', $this->_model->getTitrePrincipal(' '))]); } @@ -423,6 +424,7 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra ->getIco($this->_view, 'play', 'utils')), + 'Identifier' => 'view_online_resource', 'Title' => $this->_('Consulter le document %s en ligne', $this->getMainTitle())]); return $actions; @@ -442,7 +444,8 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra 'play', 'utils')), 'Title' => $this->_('Description de %s en ligne', - $this->getMainTitle())]); + $this->getMainTitle()), + 'Identifier' => 'view_online_resource_description']); return $actions; } @@ -455,7 +458,8 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra 'list', 'utils')), 'Title' => $this->_('Le document %s fait partie du lot %s', - $bundle->getTitrePrincipal())]); + $bundle->getTitrePrincipal()), + 'Identifier' => 'view_record_bundle']); return $actions; } @@ -469,6 +473,7 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra 'library')), 'Title' => $this->_('Réserver le document %s', $this->getMainTitle()), + 'Identifier' => 'hold_record', 'Popup' => true]); return $actions; @@ -486,6 +491,7 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra 'Attribs' => ['class' => 'more_action'], 'Title' => $this->_('Voir plus d\'actions pour le document %s', $this->_model->getTitrePrincipal(' ')), + 'Identifier' => 'view_more_record_actions', 'Image' => Class_Template::current()->getIco($this->_view, 'more', 'utils')]); @@ -503,6 +509,7 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra 'utils'), 'Text' => $this->_('Ajouter …'), 'Popup' => 'true', + 'Identifier' => 'add_record_to_selection', 'Title' => $this->_('Ajouter %s dans une sélection', $this->_model->getTitrePrincipal(' '))]); } @@ -525,6 +532,7 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra 'Text' => $this->_('Créer …'), 'Attribs' => ['class' => 'menu_admin_front_anchor'], 'Popup' => 'true', + 'Identifier' => 'record_link_album', 'Title' => $this->_('Créer un album numérique %s', $this->_model->getTitrePrincipal(' '))]); } @@ -545,7 +553,8 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra 'print', 'utils'), 'Title' => $this->_('Imprimer %s', $this->_model->getTitrePrincipal(' ')), - 'Attribs' => ['target' => '_blank']]) + 'Attribs' => ['target' => '_blank'], + 'Identifier' => 'print_record']) : ''); } @@ -568,6 +577,7 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra 'Image' => Class_Template::current()->getIco($this->_view, 'refresh', 'utils'), + 'Identifier' => 'reset_record_thumbnail', 'Text' => $this->_('Générer …'), 'Title' => $this->_('Supprimer et re-générer la vignette de %s', $this->_model->getTitrePrincipal(' '))]); diff --git a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Navigation.php b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Navigation.php index f65686e4ece4c5a2522b44a17d5c171d55e70d1d..157e310cd858a127afd34343ee3a9cf90c6f87d2 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Navigation.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Navigation.php @@ -111,9 +111,10 @@ class Intonation_Library_View_Wrapper_Record_RichContent_Navigation { ->setUrl($this->_getNavigation()->getBackToListUrl()) ->setText($this->_('Recherche')) ->setTitle($this->_('Retourner aux résultats de la recherche')) + ->setIdentifier('back_to_search_result') ->setImage($this->getIco('previous', 'utils')); - return $this->_view->tagAction($link); + return $link; } diff --git a/library/templates/Intonation/View/Permalink.php b/library/templates/Intonation/View/Permalink.php index 46109c427c4f84eda567d238abb2300b8e216ee1..3c076089d1a3b61c78b3745747e2fc0640cd23f1 100644 --- a/library/templates/Intonation/View/Permalink.php +++ b/library/templates/Intonation/View/Permalink.php @@ -25,12 +25,13 @@ class Intonation_View_Permalink extends ZendAfi_View_Helper_BaseHelper { 'permalink', 'utils'); - return $this->view->tagAction(new Intonation_Library_Link(['Text' => $this->_('Lien …'), - 'Image' => $image, - 'Title' => $this->view->_('Voir le lien permanent suivant: %s', $url), - 'Class' => 'permalink py-1 my-1', - 'Attribs' => ['data-url' => $url, - 'data-helptext' => $this->view->_('Copiez le lien suivant'), - 'onclick' => 'popupPermalink(this);']])); + return new Intonation_Library_Link(['Text' => $this->_('Lien …'), + 'Image' => $image, + 'Title' => $this->view->_('Voir le lien permanent suivant: %s', $url), + 'Class' => 'permalink py-1 my-1', + 'Identifier' => 'view_permalink', + 'Attribs' => ['data-url' => $url, + 'data-helptext' => $this->view->_('Copiez le lien suivant'), + 'onclick' => 'popupPermalink(this);']]); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderActions.php b/library/templates/Intonation/View/RenderActions.php index aeadd00202cdf67a09e85c60555778aa5cf0f110..40aa0047ed6bb154e8ee2e0ffab1c976e2232b75 100644 --- a/library/templates/Intonation/View/RenderActions.php +++ b/library/templates/Intonation/View/RenderActions.php @@ -27,7 +27,14 @@ class Intonation_View_RenderActions extends ZendAfi_View_Helper_BaseHelper { if (!$html = $this->view->tagAction($action)) continue; - $links [] = $this->view->div($items_attribs, $html); + + $action_attribs = $items_attribs; + + if ($tag_class = (is_scalar($action) ? '' : $action->getIdentifier())) + $action_attribs['class'] = $action_attribs['class'] . ' ' . $tag_class; + + + $links [] = $this->view->div($action_attribs, $html); } return $this->view->grid(implode($links)); diff --git a/library/templates/Intonation/View/SocialNetworksActions.php b/library/templates/Intonation/View/SocialNetworksActions.php index c828d30f534e8ce0a79a26bf0c1a0ab5273b3f3c..56f96ae13571502576dc8eee0aa9ccc25a0c800b 100644 --- a/library/templates/Intonation/View/SocialNetworksActions.php +++ b/library/templates/Intonation/View/SocialNetworksActions.php @@ -41,6 +41,7 @@ class Intonation_View_SocialNetworksActions extends ZendAfi_View_Helper_ReseauxS 'Text' => $clef, 'Title' => $label, 'Url' => '#', + 'Identifier' => 'share_record_on_' . $clef, 'Attribs' => ['onclick' => sprintf('$.getScript(\'%s\')', $this->getScriptFromController($url_table))]]); return ''; diff --git a/tests/scenarios/Templates/TemplatesSearchTest.php b/tests/scenarios/Templates/TemplatesSearchTest.php index 2477591684bd0b1a9e09f16cb54dfb3e8d6d72a5..fd0fbf403635b5e8a35fcb2e00572e80da11dcc5 100644 --- a/tests/scenarios/Templates/TemplatesSearchTest.php +++ b/tests/scenarios/Templates/TemplatesSearchTest.php @@ -177,6 +177,7 @@ class TemplatesSearchViewRecordTest extends TemplatesIntonationTestCase { Class_Profil::clearCache(); + $this->fixture('Class_CodifGenre', ['id' => 13, 'libelle' => 'Roman']); @@ -192,7 +193,9 @@ class TemplatesSearchViewRecordTest extends TemplatesIntonationTestCase { 'titre_principal' => 'Psycho', 'clef_oeuvre' => 'PSYKO', 'clef_alpha' => 'PSYKO', - 'facettes' => 'G13 M12']); + 'facettes' => 'G13 M12', + 'exemplaires' => [Class_Exemplaire::newInstanceWithIdAssertSave(3, + ['code_barres' => '123PS'])]]); $this->fixture('Class_TypeDoc', ['id' => 1, @@ -210,7 +213,12 @@ class TemplatesSearchViewRecordTest extends TemplatesIntonationTestCase { 'id_notice' => 456, 'source_author' => null]); - $this->dispatch('/opac/recherche/viewnotice/id/456/id_profil/72'); + ZendAfi_Auth::getInstance() + ->logUser(Class_Users::newInstanceWithIdAssertSave(332, + ['login' => 'bob', + 'password' => 'eponge'])); + + $this->dispatch('/opac/recherche/viewnotice/expressionRecherche/Lost/id/456/id_profil/72'); } @@ -266,6 +274,34 @@ class TemplatesSearchViewRecordTest extends TemplatesIntonationTestCase { public function recordNavHomeLinkShouldContainsIcoMaSuperIcoAndToutSavoirSurLaNoticeTitle() { $this->assertXPath('//ul[contains(@class, "nav")]//li//a[contains(@class, "active")][contains(@href, "recherche/viewnotice")][@title="Tout savoir sur la notice"]//img[@src= "https://ma.super-ico.afi-sa.fr"]'); } + + + public function recordActionLinks() { + return [ + ['add_record_to_selection', 'href', '/panier/add-record-ajax'], + ['hold_record', 'href', '/abonne/reserver'], + ['share_record_on_facebook', 'onclick', '/social-network/share/on/facebook'], + ['share_record_on_twitter', 'onclick', '/social-network/share/on/twitter'], + ['view_permalink', 'onclick', 'popupPermalink'], + ['print_record', 'href', '/recherche/print'], + ['toggle_like_record', 'href', '/abonne/ajouter-le-document-a-la-selection/selection_label/'. urlencode('Mes préférés')], + ['toggle_read_record', 'href', '/abonne/ajouter-le-document-a-la-selection/selection_label/' . urlencode('Déjà lu')], + ['toggle_to_read_record', 'href', '/abonne/ajouter-le-document-a-la-selection/selection_label/' . urlencode('À lire')], + ['back_to_search_result', 'href', '/recherche/simple'] + ]; + } + + + /** + * @dataProvider recordActionLinks + * @test + */ + public function actionsShouldContainsAddRecordAjaxWithClassAddRecordToSelection($identifier, $link_attribute, $url) { + $this->assertXPath(sprintf('//div[contains(@class, "jumbotron_actions")]//div[contains(@class, "%s")]//a[contains(@%s, "%s")]', + $identifier, + $link_attribute, + $url)); + } }