From e29ab062f66fe1262394da61dc430b91f7f46217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poussard?= <tpoussard@neogeo.fr> Date: Thu, 23 Sep 2021 11:20:13 +0200 Subject: [PATCH] fix project_type title instead of slug in route params & get project infos and modify new project fields --- src/views/feature_type/Feature_type_edit.vue | 4 ++-- src/views/project/Project_edit.vue | 16 ++++++++++++---- src/views/project/Project_type_list.vue | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/views/feature_type/Feature_type_edit.vue b/src/views/feature_type/Feature_type_edit.vue index bfe55b1a..9ee84d79 100644 --- a/src/views/feature_type/Feature_type_edit.vue +++ b/src/views/feature_type/Feature_type_edit.vue @@ -501,10 +501,10 @@ export default { } if (this.action === "duplicate") { //* replace original name with new default title - this.form.title.value += ` (Copie ${new Date() + this.form.title.value += ` (Copie-${new Date() .toLocaleString() .slice(0, -3) - .replace(",", "")} )`; + .replace(",", "")})`; this.updateStore(); // * initialize form in store in case this.form would not be modified } } diff --git a/src/views/project/Project_edit.vue b/src/views/project/Project_edit.vue index 070e88a2..b20ef247 100644 --- a/src/views/project/Project_edit.vue +++ b/src/views/project/Project_edit.vue @@ -382,15 +382,23 @@ export default { created() { this.definePageType(); + console.log(this.action); if (this.action === "create") { this.thumbnailFileSrc = require("@/assets/img/default.png"); - } else if (this.action === "edit") { + } else if (this.action === "edit" || this.action === "create_from") { if (!this.project) { this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug); } - this.form = this.project; - /* this.form.thumbnail = //* add api base to display image src - configuration.VUE_APP_DJANGO_BASE + this.form.thumbnail; */ + this.form = { ...this.project }; //* create a new object to avoid modifying original one + if (this.action === "create_from") { + this.form.title = + this.project.title + + ` (Copie-${new Date() + .toLocaleString() + .slice(0, -3) + .replace(",", "")})`; + this.form.is_project_type = false; + } //* transform string values to objects for dropdowns display (could be in a computed) this.form.access_level_pub_feature = { name: this.project.access_level_pub_feature, diff --git a/src/views/project/Project_type_list.vue b/src/views/project/Project_type_list.vue index 3909eab7..1af8b5d5 100644 --- a/src/views/project/Project_type_list.vue +++ b/src/views/project/Project_type_list.vue @@ -21,7 +21,7 @@ :to="{ name: 'project_create_from', params: { - slug: project.title, + slug: project.slug, }, }" >{{ project.title }}</router-link -- GitLab