From 89e19502d37f545e899d7ee2110f86ac1ddee8fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 16 Nov 2023 11:53:57 +0100 Subject: [PATCH] Export: in filter "Filter accompanying period work (social action) by type, goal and result", order the items alphabetically or with the defined order --- .../unreleased/Feature-20231116-115315.yaml | 6 +++++ .../vuejs/ExportFormActionGoalResult/App.vue | 27 +++++++++++++++++-- .../Normalizer/SocialIssueNormalizer.php | 1 + 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 .changes/unreleased/Feature-20231116-115315.yaml diff --git a/.changes/unreleased/Feature-20231116-115315.yaml b/.changes/unreleased/Feature-20231116-115315.yaml new file mode 100644 index 000000000..c63dec5f8 --- /dev/null +++ b/.changes/unreleased/Feature-20231116-115315.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: 'Export: in filter "Filter accompanying period work (social action) by type, + goal and result", order the items alphabetically or with the defined order' +time: 2023-11-16T11:53:15.32989153+01:00 +custom: + Issue: "161" diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/ExportFormActionGoalResult/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/ExportFormActionGoalResult/App.vue index 322ee3750..235fae90b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/ExportFormActionGoalResult/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/ExportFormActionGoalResult/App.vue @@ -14,7 +14,7 @@ :multiple="true" :close-on-select="false" :placeholder="$t('action.placeholder')" - label="text" + :custom-label="formatSocialAction" track-by="id" :searchable="true" > @@ -161,9 +161,31 @@ export default { }, methods: { async getSocialActionsList() { - this.actions.options = await getSocialActions(); + let actions = await getSocialActions(); + this.actions.options = actions.toSorted(function (a, b) { + console.log(a, b); + if (a.issue.ordering === b.issue.ordering) { + if (a.ordering === b.ordering) { + return 0; + } + if (a.ordering < b.ordering) { + return -1; + } + return 1; + } + + if (a.issue.ordering < b.issue.ordering) { + return -1; + } + + return 1; + }) }, + formatSocialAction({text, issue}) { + return text + ' (' + issue.text + ')'; + }, + /** * Select/unselect in Action Multiselect * @param value @@ -263,6 +285,7 @@ export default { if (dump.length > 0) { //console.log('push ' + dump.length + ' elems in', target, dump); } + data.sort(); }, /** diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php index a2f69624d..778336d2b 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/SocialIssueNormalizer.php @@ -35,6 +35,7 @@ class SocialIssueNormalizer implements ContextAwareNormalizerInterface, Normaliz 'children_ids' => $socialIssue->getChildren()->map(static fn (SocialIssue $si) => $si->getId()), 'title' => $socialIssue->getTitle(), 'text' => $this->render->renderString($socialIssue, []), + 'ordering' => $socialIssue->getOrdering(), ]; case 'docgen':