From 9cfb61ee3bfcea24cd0172be41592830467a6303 Mon Sep 17 00:00:00 2001
From: Marc Hanisch <mhanisch@gfz-potsdam.de>
Date: Thu, 11 Mar 2021 11:34:22 +0100
Subject: [PATCH] adds the new CustomTextField to the fields array and sets the
 edit route

---
 pages/devices/_deviceId/customfields.vue | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pages/devices/_deviceId/customfields.vue b/pages/devices/_deviceId/customfields.vue
index fab2e3e08..6f744b8d3 100644
--- a/pages/devices/_deviceId/customfields.vue
+++ b/pages/devices/_deviceId/customfields.vue
@@ -90,9 +90,10 @@ export default class DeviceCustomFieldsPage extends Vue {
   addField (): void {
     const field = new CustomTextField()
     this.isSaving = true
-    this.$api.customfields.add(this.deviceId, field).then(() => {
+    this.$api.customfields.add(this.deviceId, field).then((newField: CustomTextField) => {
       this.isSaving = false
-      this.$router.push('/devices/' + this.deviceId + '/customfields')
+      this.customFields.push(newField)
+      this.$router.push('/devices/' + this.deviceId + '/customfields/' + newField.id + '/edit')
     }).catch(() => {
       this.isSaving = false
       this.$store.commit('snackbar/setError', 'Failed to save custom field')
-- 
GitLab