From 10fa8cadc63e7430a588fa5cd3a513d1b819c360 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timoth=C3=A9e=20Poussard?= <tpoussard@neogeo.fr>
Date: Mon, 11 Oct 2021 11:03:14 +0200
Subject: [PATCH] order custom fields by position

---
 src/views/feature/Feature_edit.vue             | 8 +++++++-
 src/views/feature_type/Feature_type_detail.vue | 8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/views/feature/Feature_edit.vue b/src/views/feature/Feature_edit.vue
index 8ea11a37..07fbc1f4 100644
--- a/src/views/feature/Feature_edit.vue
+++ b/src/views/feature/Feature_edit.vue
@@ -173,7 +173,7 @@
         <!-- Extra Fields -->
         <div class="ui horizontal divider">DONNÉES MÉTIER</div>
         <div
-          v-for="(field, index) in extra_form"
+          v-for="(field, index) in orderedCustomFields"
           :key="field.field_type + index"
           class="field"
         >
@@ -367,6 +367,12 @@ export default {
       );
     },
 
+    orderedCustomFields() {
+      return [...this.extra_form].sort(
+        (a, b) => a.position - b.position
+      );
+    },
+
     geoRefFileLabel() {
       if (this.file) {
         return this.file.name;
diff --git a/src/views/feature_type/Feature_type_detail.vue b/src/views/feature_type/Feature_type_detail.vue
index 37a732a0..d849be91 100644
--- a/src/views/feature_type/Feature_type_detail.vue
+++ b/src/views/feature_type/Feature_type_detail.vue
@@ -35,7 +35,7 @@
           <h3 class="ui header">Champs</h3>
           <div class="ui divided list">
             <div
-              v-for="(field, index) in structure.customfield_set"
+              v-for="(field, index) in orderedCustomFields"
               :key="field.name + index"
               class="item"
             >
@@ -226,6 +226,12 @@ export default {
     lastFeatures: function () {
       return this.feature_type_features.slice(0, 5);
     },
+
+    orderedCustomFields() {
+      return [...this.structure.customfield_set].sort(
+        (a, b) => a.position - b.position
+      );
+    },
   },
 
   methods: {
-- 
GitLab