diff --git a/src/store/modules/feature.js b/src/store/modules/feature.js index eb6646b5572a64e0d9522d9d31122dc395d63a71..9b629c72ca3f301918d20e238778fe29739d02e9 100644 --- a/src/store/modules/feature.js +++ b/src/store/modules/feature.js @@ -20,6 +20,24 @@ const feature = { form: null, linkedFormset: [], linked_features: [], + statusChoices: [ + { + name: "Brouillon", + value: "draft", + }, + { + name: "Publié", + value: "published", + }, + { + name: "Archivé", + value: "archived", + }, + { + name: "En attente de publication", + value: "pending", + }, + ], }, mutations: { SET_FEATURES(state, features) { diff --git a/src/views/feature/Feature_detail.vue b/src/views/feature/Feature_detail.vue index e51eb240d8f348028254a963fe48ecc73ecc44b3..fc5562d7eaf9d6bca6c768835466093069db95e2 100644 --- a/src/views/feature/Feature_detail.vue +++ b/src/views/feature/Feature_detail.vue @@ -72,17 +72,11 @@ <td> <b> <i - v-if=" - field.field_type === 'boolean' && field.value === true - " - class="olive check icon" - ></i> - <i - v-else-if=" - field.field_type === 'boolean' && - field.value === false - " - class="red times icon" + v-if="field.field_type === 'boolean'" + :class="[ + 'icon', + field.value ? 'olive check' : 'grey times', + ]" ></i> <span v-else> {{ field.value }} @@ -98,11 +92,8 @@ <tr> <td>Statut</td> <td> - <i - v-if="feature.status" - :class="getIconLabelStatus(feature.status, 'icon')" - ></i> - {{ getIconLabelStatus(feature.status, "label") }} + <i v-if="feature.status" :class="['icon', statusIcon]"></i> + {{ statusLabel }} </td> </tr> <tr> @@ -144,20 +135,6 @@ <a @click="pushNgo(link)">{{ link.feature_to.title }} </a> ({{ link.feature_to.display_creator }} - {{ link.feature_to.created_on }}) - <!-- <router-link - :key="$route.fullPath" - :to="{ - name: 'details-signalement', - params: { - slug_type_signal: link.feature_to.feature_type_slug, - slug_signal: link.feature_to.feature_id, - }, - }" - >{{ link.feature_to.title }}</router-link - > - ({{ link.feature_to.display_creator }} - - {{ link.feature_to.created_on }}) - --> </td> </tr> </tbody> @@ -414,7 +391,7 @@ export default { computed: { ...mapState(["user"]), ...mapGetters(["permissions"]), - ...mapState("feature", ["linked_features"]), + ...mapState("feature", ["linked_features", "statusChoices"]), DJANGO_BASE_URL: function () { return this.$store.state.configuration.VUE_APP_DJANGO_BASE; }, @@ -432,6 +409,28 @@ export default { } return false; }, + + statusIcon() { + switch (this.feature.status) { + case "archived": + return "grey archive"; + case "pending": + return "teal hourglass outline"; + case "published": + return "olive check"; + case "draft": + return "orange pencil alternate"; + default: + return ""; + } + }, + + statusLabel() { + const status = this.statusChoices.find( + (el) => el.value === this.feature.status + ); + return status ? status.name : ""; + }, }, filters: { @@ -443,20 +442,6 @@ export default { }, methods: { - getIconLabelStatus(status, type) { - if (status === "archived") - if (type == "icon") return "grey archive icon"; - else return "Archivé"; - else if (status === "pending") - if (type == "icon") return "teal hourglass outline icon"; - else return "En attente de publication"; - else if (status === "published") - if (type == "icon") return "olive check icon"; - else return "Publié"; - else if (status === "draft") - if (type == "icon") return "orange pencil alternate icon"; - else return "Brouillon"; - }, pushNgo(link) { this.$router.push({ name: "details-signalement", @@ -469,8 +454,6 @@ export default { this.getFeatureAttachments(); this.getLinkedFeatures(); this.addFeatureToMap(); - //this.initMap(); - //this.$router.go(); }, postComment() { @@ -490,7 +473,6 @@ export default { }) .then(() => { this.confirmComment(); - //this.getFeatureAttachments(); //* display new attachment from comment on the page }); } else { this.confirmComment(); @@ -670,9 +652,6 @@ export default { }, created() { - // if (!this.project) { - // this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug); - // } this.$store.commit( "feature_type/SET_CURRENT_FEATURE_TYPE_SLUG", this.$route.params.slug_type_signal diff --git a/src/views/feature/Feature_edit.vue b/src/views/feature/Feature_edit.vue index feea67f50b2775cddff8bade61c25f2a2269ebac..49c6e111cf4ca440b819e290c92e863b9515470b 100644 --- a/src/views/feature/Feature_edit.vue +++ b/src/views/feature/Feature_edit.vue @@ -304,24 +304,6 @@ export default { erreurUploadMessage: null, attachmentDataKey: 0, linkedDataKey: 0, - statusChoices: [ - { - name: "Brouillon", - value: "draft", - }, - { - name: "Publié", - value: "published", - }, - { - name: "Archivé", - value: "archived", - }, - { - name: "En attente de publication", - value: "pending", - }, - ], form: { title: { errors: [], @@ -371,6 +353,7 @@ export default { "features", "extra_form", "linked_features", + "statusChoices" ]), field_title() {