From 945dee68364f690dd0e75c1f139060ca784177de Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 4 Dec 2019 22:56:17 +0530 Subject: [PATCH] fix: Replace route if same doctype --- src/pages/ListView/List.vue | 12 ++++-------- src/utils.js | 9 ++++++++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/pages/ListView/List.vue b/src/pages/ListView/List.vue index e329cfd5..1ee58726 100644 --- a/src/pages/ListView/List.vue +++ b/src/pages/ListView/List.vue @@ -54,6 +54,7 @@ import Row from '@/components/Row'; import ListCell from './ListCell'; import Button from '@/components/Button'; import Avatar from '@/components/Avatar'; +import { openQuickEdit } from '@/utils'; export default { name: 'List', @@ -103,14 +104,9 @@ export default { this.$router.push(this.listConfig.formRoute(doc.name)); return; } - let method = this.$route.query.edit ? 'replace' : 'push'; - this.$router[method]({ - path: `/list/${this.doctype}`, - query: { - edit: 1, - doctype: this.doctype, - name: doc.name - } + openQuickEdit({ + doctype: this.doctype, + name: doc.name }); }, async updateData(filters) { diff --git a/src/utils.js b/src/utils.js index 396c2937..d65d1deb 100644 --- a/src/utils.js +++ b/src/utils.js @@ -128,7 +128,14 @@ export function partyWithAvatar(party) { export function openQuickEdit({ doctype, name, hideFields, defaults = {} }) { let currentRoute = router.currentRoute; - router.push({ + let query = currentRoute.query; + let method = 'push'; + if (query.edit && query.doctype === doctype) { + // replace the current route if we are + // editing another document of the same doctype + method = 'replace'; + } + router[method]({ query: { edit: 1, doctype,