2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

fix: Replace route if same doctype

This commit is contained in:
Faris Ansari 2019-12-04 22:56:17 +05:30
parent 7916619754
commit 945dee6836
2 changed files with 12 additions and 9 deletions

View File

@ -54,6 +54,7 @@ import Row from '@/components/Row';
import ListCell from './ListCell'; import ListCell from './ListCell';
import Button from '@/components/Button'; import Button from '@/components/Button';
import Avatar from '@/components/Avatar'; import Avatar from '@/components/Avatar';
import { openQuickEdit } from '@/utils';
export default { export default {
name: 'List', name: 'List',
@ -103,14 +104,9 @@ export default {
this.$router.push(this.listConfig.formRoute(doc.name)); this.$router.push(this.listConfig.formRoute(doc.name));
return; return;
} }
let method = this.$route.query.edit ? 'replace' : 'push'; openQuickEdit({
this.$router[method]({ doctype: this.doctype,
path: `/list/${this.doctype}`, name: doc.name
query: {
edit: 1,
doctype: this.doctype,
name: doc.name
}
}); });
}, },
async updateData(filters) { async updateData(filters) {

View File

@ -128,7 +128,14 @@ export function partyWithAvatar(party) {
export function openQuickEdit({ doctype, name, hideFields, defaults = {} }) { export function openQuickEdit({ doctype, name, hideFields, defaults = {} }) {
let currentRoute = router.currentRoute; 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: { query: {
edit: 1, edit: 1,
doctype, doctype,