Skip to content
Snippets Groups Projects
Commit aa106cc6 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #69826 : add actions to bookmarked searches

parent c26d420c
Branches
Tags
2 merge requests!2523Master,!2516Dev#69826 contractuel minsoc diffusion selective de l information enregistrer modifier ma recherche
Pipeline #3316 failed with stage
in 25 minutes and 10 seconds
......@@ -3,6 +3,18 @@ echo $this->renderForm($this->form);
$description = (new Class_TableDescription('bookmarked_searches'))
->addColumn($this->_('Libellé'), function($model) { return $model->getLabel(); })
->addColumn($this->_('Date création'), function($model) { return $model->getCreationDate(); });
->addColumn($this->_('Date création'), function($model) { return $model->getCreationDate(); })
->addRowAction(function($model) {
return $this->tagPreview(Class_Url::relative($model->getCriteriasUrl()),
$this->_('Voir le résultat de la recherche'));
})
->addRowAction(function ($model) {
return $this->renderModelActions($model, [ ['url' => $this->url(['controller' => 'abonne',
'action' => 'delete-bookmarked-search',
'id' => $model->getId()],null,true),
'icon' => 'delete',
'label' => $this->_('Supprimer la recherche "%s"', $model->getLabel())]]);
});
echo $this->renderTable($description, $this->bookmarked_searches, ['sorter' => true]);
......@@ -46,7 +46,14 @@ class Class_User_BookmarkedSearch extends Storm_Model_Abstract {
'id_user' => ''];
public function getUnserialzedCriterias() {
public function getUnserializedCriterias() {
return unserialize($this->getCriterias());
}
public function getCriteriasUrl() {
if (!$criterias = $this->getUnserializedCriterias())
return '/recherche/simple';
return $criterias->getUrlCriteresWithFacettes();
}
}
\ No newline at end of file
......@@ -123,7 +123,7 @@ class Bookmarks_SearchAbonneBookmarkSearchPostTest extends Bookmarks_SearchWith
/** @test */
public function davisSearchShouldBeBookmarkedInUserSettings() {
$this->assertEquals('Miles Davis', Class_User_BookmarkedSearch::find(1)->getUnserialzedCriterias()->getParam('rech_auteurs'));
$this->assertEquals('Miles Davis', Class_User_BookmarkedSearch::find(1)->getUnserializedCriterias()->getParam('rech_auteurs'));
}
}
......@@ -179,6 +179,10 @@ class Bookmarks_SearchAbonneSettingsTest extends Bookmarks_SearchWithSessionAbst
public function setUp() {
parent::setUp();
$criteres_potter = (new Class_CriteresRecherche)
->setParams(['expressionRecherche' => 'Harry Potter',
'page' => 2]);
$this->fixture('Class_AdminVar',
['id' => 'ENABLE_BOOKMARKABLE_SEARCHES',
'valeur' => 1]);
......@@ -198,4 +202,15 @@ class Bookmarks_SearchAbonneSettingsTest extends Bookmarks_SearchWithSessionAbst
public function tableShouldContainsMilesDavis() {
$this->assertXPathContentContains('//td', 'Miles Davis');
}
/** @test */
public function tableShouldContainsDeleteButton() {
$this->assertXPath('//td//a[contains(@href,"/abonne/delete-bookmarked-search/id/5")]');
}
/** @test */
public function tableShouldContainsLinkToSearch() {
$this->assertXPath('//td//a[contains(@href,"/recherche/simple")]',$this->_response->getBody());
}
}
\ 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