Commit 563ace5d authored by Patrick Barroca's avatar Patrick Barroca 🐧

Merge branch 'hotline#81938_boite_nuage_de_tags_modification_des_types_de_tags_ko' into 'hotline'

hotline #81938 fix widget configuration save

See merge request !2943
parents b70fc572 52ad667d
Pipeline #5840 failed with stage
in 26 minutes and 57 seconds
- ticket #81938 : correction de la sauvegarde du paramétrage des boîtes qui pouvait échouer dans certaines conditions
\ No newline at end of file
......@@ -301,6 +301,4 @@ class Admin_WidgetController extends ZendAfi_Controller_Action {
public function formProvider($widget) {
return call_user_func_array([$widget->getForm(), 'newWith'], [$widget->forForm()]);
}
}
\ No newline at end of file
......@@ -42,7 +42,7 @@ class Class_Systeme_ModulesAccueil_ConteneurDeuxColonnes extends Class_Systeme_M
public function updateHook($datas) {
foreach(['gauche', 'droite'] as $column) {
$key = 'col_' . $column .'_module_id';
$datas [$key] = $datas['preferences'][$key] = static::createModuleForCol($column, $datas, $datas['id_module'], $datas['profile_id']);
$datas [$key] = $datas['preferences'][$key] = static::createModuleForCol($column, $datas['preferences'], $datas['id_module'], $datas['profile_id']);
}
return $datas;
......
......@@ -145,9 +145,9 @@ class Class_Systeme_ModulesAccueil_Library extends Class_Systeme_ModulesAccueil_
public function updateHook($datas) {
if(array_key_exists('default_filters', $datas)
&& (!is_array($datas['default_filters'])))
$datas['default_filters'] = [];
if (array_key_exists('default_filters', $datas['preferences'])
&& (!is_array($datas['preferences']['default_filters'])))
$datas['preferences']['default_filters'] = [];
return $datas;
}
......
......@@ -61,13 +61,13 @@ class Class_Systeme_ModulesAccueil_MenuVertical extends Class_Systeme_ModulesAcc
public function updateHook($datas) {
if(!isset($datas['menu']))
if(!isset($datas['preferences']['menu']))
return $datas;
if(static::NEW_MENU != $datas['menu'])
if(static::NEW_MENU != $datas['preferences']['menu'])
return $datas;
$datas['menu'] = $this->_prefixMenu($this->addMenu());
$datas['preferences']['menu'] = $this->_prefixMenu($this->addMenu());
return $datas;
}
......
......@@ -52,11 +52,11 @@ class Class_Systeme_ModulesAccueil_Sitotheque extends Class_Systeme_ModulesAccue
public function updateHook($datas) {
if(static::DISPLAY_HIERARCHY != $datas['type_aff'])
if(static::DISPLAY_HIERARCHY != $datas['preferences']['type_aff'])
return $datas;
if ($categories = explode('-', $datas['id_categorie']))
$datas['preferences']['id_categorie'] = $datas['id_categorie'] = $categories[0];
if ($categories = explode('-', $datas['preferences']['id_categorie']))
$datas['preferences']['id_categorie'] = $categories[0];
return $datas;
}
......
......@@ -41,4 +41,13 @@ class Class_Systeme_ModulesAccueil_Tags extends Class_Systeme_ModulesAccueil_Nul
'id_panier' => 0,
'id_catalogue' => 0];
}
public function updateHook($datas) {
if (isset($datas['preferences']['type_tags_codes'])) {
$datas['preferences']['type_tags'] = str_replace(';', '', $datas['preferences']['type_tags_codes']);
unset($datas['preferences']['type_tags_codes']);
}
return $datas;
}
}
\ No newline at end of file
......@@ -89,10 +89,10 @@ abstract class Class_Systeme_Widget_Abstract extends Class_Entity {
protected function _getValues($attributes) {
return $this->_getWidgetResources()
->getValues(array_merge(isset($attributes['preferences'])
->getValues(array_merge($attributes,
isset($attributes['preferences'])
? $attributes['preferences']
: [],
$attributes));
: []));
}
......
......@@ -36,16 +36,34 @@ class Class_Systeme_Widget_Widget extends Class_Systeme_Widget_Abstract {
}
protected function _cleanRootAndPreferences($datas) {
$root_properties = ['type_module' => '',
'division' => '',
'id_module' => '',
'preferences' => '',
'parent_id' => '',
'type_menu' => '',
'libelle' => '',
'picto' => '',
'sous_menus' => []];
$cleaned_datas = array_intersect_key($datas, $root_properties);
$cleaned_datas['preferences'] = array_diff_key($datas,
$root_properties);
return $cleaned_datas;
}
protected function _update() {
$datas = array_merge($this->getLocalSettings(),
$this->getNewDatas());
$cleaned_datas = $this->_cleanRootAndPreferences(
array_merge($this->getLocalSettings(),
$this->getNewDatas()));
if(isset($datas['preferences']))
unset($datas['preferences']);
$cleaned_datas['profile_id'] = $this->getProfileId();
$datas = $this->_getWidgetResources()->updateHook($cleaned_datas);
$datas['preferences'] = $datas;
$datas['profile_id'] = $this->getProfileId();
$datas = $this->_getWidgetResources()->updateHook($datas);
$sub_menus = null;
if(isset($datas['children']))
$sub_menus = $this->_convertChildren($datas['children']);
......
......@@ -233,13 +233,13 @@ class WidgetControllerKioquePostTest extends WidgetControllerPostDispatchWidgetC
/** @test */
public function titleShouldBeTitreDuKiosque() {
$this->assertEquals('titre du /kiosque', $this->_saved_settings['titre']);
$this->assertEquals('titre du /kiosque', $this->_saved_settings['preferences']['titre']);
}
/** @test */
public function profilRedirectShouldBeTwelve() {
$this->assertEquals('12', $this->_saved_settings['profil_redirect']);
$this->assertEquals('12', $this->_saved_settings['preferences']['profil_redirect']);
}
}
......@@ -759,21 +759,6 @@ class WidgetControllerVerticalNavDispatchWithMenuFromOtherTest extends WidgetCon
class WidgetControllerTagsDispatchTest extends WidgetControllerDispatchWidgetConfigurationTestCase {
public function setUp() {
$this->_type_module = 'TAGS';
parent::setUp();
}
/** @test */
public function tagSelectionChampsShouldBePresent() {
$this->assertXPathContentContains('//h2', 'Facettes disponibles');
}
}
class WidgetControllerLoginDispatchTest extends WidgetControllerDispatchWidgetConfigurationTestCase {
public function setUp() {
......@@ -959,6 +944,85 @@ class WidgetControllerActivitiesPostDispatchTest extends WidgetControllerPostDis
class WidgetControllerTagsDispatchTest extends WidgetControllerDispatchWidgetConfigurationTestCase {
public function _stormHook() {
$tags = ['modules' => ['6' => ['division' => 3,
'id_module' => '6',
'type_module' => 'TAGS',
'type_tags' => 'AMDPZ',
'nombre' => 40,
'preferences' => ['type_tags' => 'AM',
'titre' => 'Des tags',
'nombre' => 10]]]];
$this
->_profil
->setCfgAccueil($tags)
->assertSave();
}
/** @test */
public function tagSelectionChampsShouldBePresent() {
$this->assertXPathContentContains('//h2', 'Facettes disponibles');
}
/** @test */
public function inputTitreShouldContainsDesTags() {
$this->assertXPath('//input[@name="titre"][@value="Des tags"]');
}
/** @test */
public function inputTypeTagsCodesShouldContainsAandM() {
$this->assertXPath('//input[@name="type_tags_codes"][@value="A;M"]');
}
/** @test */
public function inputNombreShouldHaveValueTen() {
$this->assertXPath('//input[@name="nombre"][@value="10"]');
}
}
class WidgetControllerTagsPostDispatchTest extends WidgetControllerPostDispatchWidgetConfigurationTestCase {
public function setUp() {
$this->_type_module = 'TAGS';
$this->_params = ['type_tags_codes' => 'A;M;S'];
parent::setUp();
}
/** @test */
public function typeTagsAMSShouldHaveBeenSaved() {
$this->assertEquals('AMS', $this->_saved_settings['preferences']['type_tags']);
}
/** @test */
public function typeTagsCodesAMSShouldHaveBeenRemovedFromPreferences() {
$this->assertFalse(isset($this->_saved_settings['preferences']['type_tags_codes']));
}
/** @test */
public function typeTagsCodesAMSShouldHaveBeenRemovedFromParams() {
$this->assertFalse(isset($this->_saved_settings['type_tags']));
}
/** @test */
public function preferencesShouldNotContainsDivision() {
$this->assertFalse(isset($this->_saved_settings['preferences']['division']));
}
}
abstract class WidgetControllerTwoWidgetsTestCase extends WidgetControllerWidgetConfigurationTestCase {
public function setUp() {
......@@ -1552,13 +1616,13 @@ class WidgetControllerLoginPostDispatchTest extends WidgetControllerPostDispatch
/** @test */
public function profilRedirectShouldBe678() {
$this->assertEquals(678, $this->_saved_settings['profil_redirect']);
$this->assertEquals(678, $this->_saved_settings['preferences']['profil_redirect']);
}
/** @test */
public function profilLogoutRedirectShouldBe345() {
$this->assertEquals(345, $this->_saved_settings['profil_logout_redirect']);
$this->assertEquals(345, $this->_saved_settings['preferences']['profil_logout_redirect']);
}
......@@ -1881,23 +1945,18 @@ class WidgetControllerDomainBrowserPostDispatchTest extends WidgetControllerPost
/** @test */
public function paramsShouldHaveBeenSaved() {
$this->assertEquals(array_merge($this->_params,
['boite' => '',
'division' => '3',
'id_module' => '6',
'type_module' => 'DOMAIN_BROWSER',
'preferences' => ['titre' => 'Mes Domaines',
'allow_breadcrumb' => '0',
'root_domain_id' => '10',
'display_mode' => '4',
'boite' => '',
'division' => '3',
'id_module' => '6',
'type_module' => 'DOMAIN_BROWSER',
'profile_id' => '5',
'tri' => 'annee desc'],
'profile_id' => '5',
'tri' => 'annee desc']),
$this->assertEquals(['division' => '3',
'id_module' => '6',
'type_module' => 'DOMAIN_BROWSER',
'preferences' => ['titre' => 'Mes Domaines',
'allow_breadcrumb' => '0',
'root_domain_id' => '10',
'display_mode' => '4',
'profile_id' => '5',
'tri' => 'annee desc',
'boite' => '',
],
'profile_id' => '5'],
$this->_saved_settings);
}
}
......@@ -2318,7 +2377,7 @@ class WidgetControllerWidgetAddWidgetFromTemplateTest extends WidgetControllerWi
/** @test */
public function opTimeoutShouldBeSix() {
$this->assertEquals(6,
$this->_module_config['op_timeout']);
$this->_module_config['preferences']['op_timeout']);
}
}
......
......@@ -483,8 +483,8 @@ class WidgetsPostEditVerticalMenuTest extends WidgetsSimpleTestCase {
/** @test */
public function newMenuIdShouldHaveBeenSetInMenuVerticalSettongs() {
$this->assertEquals('2-0', Class_Profil::getCurrentProfil()->getCfgAccueilAsArray()['modules'][6]['menu']);
public function newMenuIdShouldHaveBeenSetInMenuVerticalSettings() {
$this->assertEquals('2-0', Class_Profil::getCurrentProfil()->getCfgAccueilAsArray()['modules'][6]['preferences']['menu']);
}
......
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