Commit c09e99bf authored by Laurent's avatar Laurent

hotline #114500 Templates / view record config : add thumbnail_fiels param

parent 1246e123
Pipeline #10848 passed with stage
in 55 minutes and 29 seconds
- ticket #114500 : Magasin de thèmes / configuration de l'affichage des notices : ajout du paramètre de la zone de vignettes
\ No newline at end of file
......@@ -25,4 +25,16 @@ class Class_Systeme_ModulesAccueil_Action_Record extends Class_Systeme_ModulesAc
parent::__construct();
$this->_form = 'ZendAfi_Form_Configuration_Widget_Action_Record';
}
public function updateHook($datas) {
$packer = new Class_Profil_ConfigPacker();
foreach($datas['thumbnail_zone'] as $i => $zone)
$packer->add([$zone, $datas['thumbnail_url'][$i]]);
unset($datas['thumbnail_zone']);
unset($datas['thumbnail_url']);
$datas['thumbnail_fields'] = $packer->pack();
return $datas;
}
}
\ No newline at end of file
......@@ -56,7 +56,8 @@ class Class_Systeme_Widget_Action extends Class_Systeme_Widget_Abstract {
protected function _update() {
$datas = array_merge($this->getLocalSettings(),
$this->getNewDatas());
return $this->_save($datas);
$updated_datas = $this->_getWidgetResources()->updateHook($datas);
return $this->_save($updated_datas);
}
......
......@@ -31,12 +31,16 @@ class ZendAfi_Form_Configuration_Widget_Action_Record extends ZendAfi_Form_Confi
['label' => $this->_('Fichier XSL'),
'allowEmpty' => true,
'validators' => [(new Zend_Validate_Regex('/^.*\.xsl$/i'))
->setMessage($this->_('Le fichier doit être de type "xsl"'))]]);
->setMessage($this->_('Le fichier doit être de type "xsl"'))]])
->addElement('unimarc',
'thumbnail_fields',
['label' => $this->_('Zones de vignette')]);
}
public function initDisplayGroups() {
$this->addToDisplaySettingsGroup([Class_Notice_Xsl::KEY]);
$this->addToDisplaySettingsGroup([Class_Notice_Xsl::KEY, 'thumbnail_fields']);
parent::initDisplayGroups();
}
......@@ -45,4 +49,15 @@ class ZendAfi_Form_Configuration_Widget_Action_Record extends ZendAfi_Form_Confi
->setView(new Class_Entity)
->setModel(new Class_Notice);
}
public function populate(array $datas) {
$this->getElement('thumbnail_fields')
->setSettings($datas)
->setMessages(isset($datas['thumbnail_fields_errors'])
? $datas['thumbnail_fields_errors']
: []);
return parent::populate($datas);
}
}
\ No newline at end of file
......@@ -65,11 +65,5 @@ abstract class ZendAfi_Form_Configuration_Widget_Action_Tabs extends ZendAfi_For
}
public function populate($datas) {
parent::populate($datas);
return $this;
}
abstract protected function _getRichContentInstance();
}
\ No newline at end of file
......@@ -1030,33 +1030,6 @@ class TemplatesDispatchAdminWidgetEditActionTest extends TemplatesIntonationTest
}
/** @test */
public function pageTitleShouldBeConfigartionDeLaPageDuDocumentDeTypeBook() {
$this->dispatch('/admin/widget/edit-action/id/recherche_viewnotice_1/id_profil/72');
$this->assertXPathContentContains('//h1', 'Configuration de la page des documents de type livres');
}
/** @test */
public function renameTabTextShouldBePresent() {
$this->dispatch('/admin/widget/edit-action/id/recherche_viewnotice/id_profil/72');
$this->assertXPath('//input[@type="text"][@id="IntonationLabelDocumentItems"]');
}
/** @test */
public function changeTabIcoShouldBePresent() {
$this->dispatch('/admin/widget/edit-action/id/recherche_viewnotice/id_profil/72');
$this->assertXPath('//input[@type="text"][@id="IntonationIcoDocumentItems"]');
}
/** @test */
public function changeTabTitleShouldBePresent() {
$this->dispatch('/admin/widget/edit-action/id/recherche_viewnotice/id_profil/72');
$this->assertXPath('//input[@type="text"][@id="IntonationTitleDocumentItems"]');
}
/** @test */
public function customCssClassesShouldHaveBeenSaved() {
......@@ -1089,3 +1062,85 @@ class TemplatesDispatchAdminWidgetEditActionTest extends TemplatesIntonationTest
$this->assertXPath('//div[contains(@class, "ultra_light_widget")][contains(@data-action, "abonne_fiche")]');
}
}
class TemplatesDispatchAdminWidgetEditActionRechercheViewNoticeTest extends TemplatesIntonationTestCase {
public function setUp() {
parent::setUp();
(new Class_Profil_Preferences())
->setModulePref(Class_Profil::find(72),
(new Class_Profil_ModuleDefinition('recherche',
'viewnotice1')),
['thumbnail_fields' => '959-3;933-3']);
$this->dispatch('/admin/widget/edit-action/id/recherche_viewnotice_1/id_profil/72');
}
/** @test */
public function pageTitleShouldBeConfigartionDeLaPageDuDocumentDeTypeBook() {
$this->assertXPathContentContains('//h1', 'Configuration de la page des documents de type livres');
}
/** @test */
public function renameTabTextShouldBePresent() {
$this->assertXPath('//input[@type="text"][@id="IntonationLabelDocumentItems"]');
}
/** @test */
public function changeTabIcoShouldBePresent() {
$this->assertXPath('//input[@type="text"][@id="IntonationIcoDocumentItems"]');
}
/** @test */
public function changeTabTitleShouldBePresent() {
$this->assertXPath('//input[@type="text"][@id="IntonationTitleDocumentItems"]');
}
/** @test */
public function multiInputsJsShouldBeLoaded() {
$this->assertXPath('//script[contains(@src,"multi_inputs.js")]');
}
/** @test */
public function multiInputThumbnailZonesValuesShouldBeDisplayed() {
$this->assertXPathContentContains('//script',
'"thumbnail_zone":["959","933"],"thumbnail_url":["3","3"]',
$this->_response->getBody());
}
}
class TemplatesDispatchAdminWidgetActionRechercheViewNoticePostTest extends TemplatesIntonationTestCase {
protected $_prefs;
public function setUp() {
parent::setUp();
$this->postDispatch('/admin/widget/edit-action/id/recherche_viewnotice_1/id_profil/72',
[
'thumbnail_zone' => ['959', '933'],
'thumbnail_url' => ['3', '4']]);
$this->_prefs = (new Class_Profil_Preferences())->getModulePref(Class_Profil::find(72),
(new Class_Profil_ModuleDefinition('recherche',
'viewnotice1')));
}
/** @test */
public function preferencesThumbnailFieldsShouldContains959And933() {
$this->assertEquals('959-3;933-4', $this->_prefs['thumbnail_fields']);
}
}
\ No newline at end of file
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