Commit f7d4c77c authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #69826 : improve user settings rendering

parent 636365e5
Pipeline #3324 failed with stage
in 14 minutes and 1 second
......@@ -998,24 +998,38 @@ class AbonneController extends ZendAfi_Controller_Action {
}
public function settingsAction() {
public function manageSettingsAction() {
if(!Class_Users::getIdentity())
return $this->_forward('popup-login', 'auth', 'opac', ['redirect' => $this->view->url()]);
$this->view->form = $form = ZendAfi_Form_User_Settings::forUser($this->_user);
$this->view->bookmarked_searches = Class_User_BookmarkedSearch::findAllBy(['id_user' => $this->_user->getId()]);
if ($this->_request->isPost()) {
$data = $this->_request->getPost();
unset($data['id_items']);
$this->_user->setSettings(Class_User_Settings::serializeSettings($data));
$this->_user->save();
$this->_javascriptRedirectToReferrer();
$this->_helper->notify($this->_('Favoris sauvegardés'));
return $this->_redirectClose($this->_getReferer());
}
$this->view->titre = $this->view->_('Gérer mes favoris');
}
public function settingsAction() {
$this->view->titre = $this->view->_('Mes favoris');
$this->view->bookmarked_searches = Class_User_BookmarkedSearch::findAllBy(['id_user' => $this->_user->getId()]);
$form = ZendAfi_Form_User_Settings::forUser($this->_user);
$this->view->form = $form->getElements()
? $form
: null;
if ($this->_request->isPost())
$this->_forward('manage-settings');
}
public function viewableLibrariesJsonAction() {
$this->_helper->json([$this->view->TreeSelect_Json_Libraries(Class_Profil::getCurrentProfil()->getLibraries())]);
}
......@@ -1223,7 +1237,6 @@ class AbonneController extends ZendAfi_Controller_Action {
return;
$criterias = Class_User_BookmarkedSearch::newInstance(['id_user' => $this->_user->getId(),
'email' => $this->_user->getMail(),
'label' => $this->_getParam('label'),
'criterias' => $this->_getCriterias()]);
if(!$criterias->save()) {
......
<?php
echo $this->renderForm($this->form);
if($this->form) {
$this->openBoite($this->titre);
echo $this->renderForm($this->form);
$this->closeBoite();
}
$description = (new Class_TableDescription('bookmarked_searches'))
->addColumn($this->_('Libellé'), function($model) { return $model->getLabel(); })
......@@ -17,4 +22,10 @@ return $this->tagPreview(Class_Url::relative($model->getCriteriasUrl()),
'label' => $this->_('Supprimer la recherche "%s"', $model->getLabel())]]);
});
echo $this->renderTable($description, $this->bookmarked_searches, ['sorter' => true]);
if(!$searches = $this->renderTable($description, $this->bookmarked_searches, ['sorter' => true]))
$searches = $this->_('Vous n\'avez pas enregistré de recherche dans vos favoris');
$this->openBoite($this->_('Mes recherches favorites'));
echo $searches;
$this->closeBoite();
echo $this->abonne_RetourFiche();
......@@ -59,8 +59,7 @@ class Class_User_Settings {
public static function isBookmarkReady() {
return static::isBookmarkDomainsReady()
|| static::isBookmarkLibraryReady()
|| static::isBookmarkSearchesReady();
|| static::isBookmarkLibraryReady();
}
......
......@@ -22,18 +22,16 @@
class ZendAfi_View_Helper_Abonne_Settings extends ZendAfi_View_Helper_Abonne_Abstract {
public function abonne_Settings($user) {
if (!Class_User_Settings::isBookmarkReady())
if ((!Class_User_Settings::isBookmarkReady())
&& (!Class_User_Settings::isBookmarkSearchesReady()))
return '';
$action_url = $this->view->url(['controller' => 'abonne',
'action' => 'settings'], null, true);
return $this->tagFicheAbonne(sprintf('<a data-popup="true" href=\'%s\'>%s</a>',
$action_url,
$this->view->_('Gérer mes favoris')),
return $this->tagFicheAbonne($this->view->tagAnchor($action_url,
$this->_('Mes favoris')),
'settings',
$action_url,
['data-popup' => 'true']);
$action_url);
}
}
?>
\ No newline at end of file
}
\ No newline at end of file
......@@ -55,7 +55,7 @@ class ZendAfi_View_Helper_Bookmarks extends ZendAfi_View_Helper_BaseHelper {
return $this->_tag('p', $this->_('Vous devez être connecté pour gérer vos favoris')).
$this->view->tagAnchor($this->view->url(['module' => 'opac',
'controller' => 'abonne',
'action' => 'settings'], null, true),
'action' => 'manage-settings'], null, true),
$this->_('Me connecter'),
['title' => $this->_('Me connecter'),
'class' => 'bookmarks_edit',
......@@ -81,7 +81,7 @@ class ZendAfi_View_Helper_Bookmarks extends ZendAfi_View_Helper_BaseHelper {
$edit = $this->view->tagAnchor(
$this->view->url(['module' => 'opac',
'controller' => 'abonne' ,
'action' => 'settings'], null, true),
'action' => 'manage-settings'], null, true),
$this->_('Modifier mes favoris'),
['class' => 'bookmarks_edit',
'data-popup' => 'true',
......
......@@ -92,7 +92,7 @@ class AbonneControllerSettingsWithOneLibraryFormTest extends AbonneControllerSet
public function setUp() {
parent::setUp();
$this->dispatch('/abonne/settings/render/popup', true);
$this->dispatch('/abonne/manage-settings/render/popup', true);
}
......@@ -122,7 +122,7 @@ class AbonneControllerSettingsWithNoDomainsFormTest extends AbstractControllerTe
public function setUp() {
parent::setUp();
$this->dispatch('/abonne/settings', true);
$this->dispatch('/abonne/manage-settings', true);
}
......@@ -149,7 +149,7 @@ class AbonneControllerSettingsFormTest extends AbonneControllerSettingsTestCase
['id' => 59,
'libelle' => 'ANNECY']);
$this->dispatch('/abonne/settings', true);
$this->dispatch('/abonne/manage-settings', true);
}
......@@ -196,7 +196,7 @@ class AbonneControllerSettingsFormPostTest extends AbonneControllerSettingsTestC
$post = ['library_ids' => '56',
'domain_ids' => '1-2'];
$this->postDispatch('/abonne/settings', $post);
$this->postDispatch('/abonne/manage-settings', $post);
}
......
Markdown is supported
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