From 0a05dcd753f0bb5c5a9f4e7b7a9ac364f1f197fc Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 21 Apr 2022 20:49:54 +0200 Subject: [PATCH 1/5] add ordering to serialization --- .../Serializer/Normalizer/SocialActionNormalizer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php index e210e1c4f..b7955fc5a 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php @@ -40,6 +40,7 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte 'desactivationDate' => $this->normalizer->normalize($socialAction->getDesactivationDate(), $format, $context), 'title' => $socialAction->getTitle(), 'issue' => $this->normalizer->normalize($socialAction->getIssue(), $format, $context), + 'ordering' => $this->normalizer->normalize($socialAction->getOrdering(), $format, $context) ]; case 'docgen': From a4baf89a6a62e4cb17795e7f2f0b1166d0e562d6 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 21 Apr 2022 21:05:08 +0200 Subject: [PATCH 2/5] social actions ordered in store --- .../Activity/components/SocialIssuesAcc.vue | 24 +++++++++---------- .../Resources/public/vuejs/Activity/store.js | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue index 51957b010..dc092062b 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue @@ -54,19 +54,19 @@ {{ $t('activity.select_first_a_social_issue') }} - + - {{ $t('activity.social_action_list_empty') }} + {{ $t('activity.social_action_list_empty') }} @@ -111,7 +111,7 @@ export default { return this.$store.state.socialIssuesOther; }, socialActionsList() { - return this.$store.state.socialActionsList; + return this.$store.state.socialActionsList }, socialActionsSelected() { return this.$store.state.activity.socialActions; diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js index f94381fc2..9a277a326 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js @@ -131,8 +131,8 @@ const store = createStore({ state.socialActionsList = []; }, addActionInList(state, action) { - //console.log('add action list', action.id); state.socialActionsList.push(action); + state.socialActionsList = state.socialActionsList.sort((a, b) => a.ordering-b.ordering); }, updateActionsSelected(state, actions) { //console.log('update actions selected', actions); From b85e6aae3f73f03b26096258bd5fab00fdc7fa34 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 21 Apr 2022 21:22:18 +0200 Subject: [PATCH 3/5] csfixes --- .../Serializer/Normalizer/SocialActionNormalizer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php index b7955fc5a..da5dcd3cd 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php @@ -40,7 +40,7 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte 'desactivationDate' => $this->normalizer->normalize($socialAction->getDesactivationDate(), $format, $context), 'title' => $socialAction->getTitle(), 'issue' => $this->normalizer->normalize($socialAction->getIssue(), $format, $context), - 'ordering' => $this->normalizer->normalize($socialAction->getOrdering(), $format, $context) + 'ordering' => $this->normalizer->normalize($socialAction->getOrdering(), $format, $context), ]; case 'docgen': From e5209ca6d99da3e41c602d00b1639e120bd1fdbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 25 Apr 2022 22:14:23 +0200 Subject: [PATCH 4/5] do not make a loop to normalizer for a native php object --- .../Serializer/Normalizer/SocialActionNormalizer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php index da5dcd3cd..52ba07a93 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialActionNormalizer.php @@ -40,7 +40,7 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte 'desactivationDate' => $this->normalizer->normalize($socialAction->getDesactivationDate(), $format, $context), 'title' => $socialAction->getTitle(), 'issue' => $this->normalizer->normalize($socialAction->getIssue(), $format, $context), - 'ordering' => $this->normalizer->normalize($socialAction->getOrdering(), $format, $context), + 'ordering' => $socialAction->getOrdering(), ]; case 'docgen': From 75250402c88765d6ab7c78e1b4653f02f483a012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 25 Apr 2022 22:14:36 +0200 Subject: [PATCH 5/5] fix ordering of social actions --- .../public/vuejs/Activity/components/SocialIssuesAcc.vue | 2 +- .../Resources/public/vuejs/Activity/store.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue index dc092062b..4691a860a 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/SocialIssuesAcc.vue @@ -111,7 +111,7 @@ export default { return this.$store.state.socialIssuesOther; }, socialActionsList() { - return this.$store.state.socialActionsList + return this.$store.getters.socialActionsListSorted; }, socialActionsSelected() { return this.$store.state.activity.socialActions; diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js index 9a277a326..ca56a5dae 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js @@ -101,6 +101,9 @@ const store = createStore({ state.activity.activityType.thirdPartiesVisible !== 0) ); }, + socialActionsListSorted(state) { + return [ ...state.socialActionsList].sort((a, b) => a.ordering - b.ordering); + }, }, mutations: { // SocialIssueAcc @@ -132,7 +135,6 @@ const store = createStore({ }, addActionInList(state, action) { state.socialActionsList.push(action); - state.socialActionsList = state.socialActionsList.sort((a, b) => a.ordering-b.ordering); }, updateActionsSelected(state, actions) { //console.log('update actions selected', actions);