fix: wait before routing after creating new/duplicating view

This commit is contained in:
Shariq Ansari 2024-01-03 18:21:17 +05:30
parent df6fd590cb
commit 4bf58e5b8c
3 changed files with 15 additions and 18 deletions

View File

@ -74,7 +74,7 @@ async function create() {
{ view: view.value }
)
show.value = false
props.options.afterCreate?.(v, view.value)
props.options.afterCreate?.(v)
}
async function update() {

View File

@ -51,7 +51,8 @@
<ViewModal
:doctype="doctype"
:options="{
afterCreate: (v) => {
afterCreate: async (v) => {
await reloadView()
viewUpdated = false
router.push({ name: route.name, query: { view: v.name } })
},
@ -171,7 +172,16 @@ list.value = createResource({
params: getParams(),
cache: [props.doctype, route.query.view],
onSuccess(data) {
setupDefaults(data)
let cv = getView(route.query.view)
defaultParams.value = {
doctype: props.doctype,
filters: list.value.params.filters,
order_by: list.value.params.order_by,
columns: data.columns,
rows: data.rows,
custom_view_name: cv?.name || '',
}
},
})
@ -234,19 +244,6 @@ const viewsDropdownOptions = computed(() => {
return _views
})
function setupDefaults(data) {
let cv = getView(route.query.view)
defaultParams.value = {
doctype: props.doctype,
filters: list.value.params.filters,
order_by: list.value.params.order_by,
columns: data.columns,
rows: data.rows,
custom_view_name: cv?.name || '',
}
}
function updateFilter(filters) {
viewUpdated.value = true
if (!defaultParams.value) {

View File

@ -37,8 +37,8 @@ export const viewsStore = defineStore('crm-views', () => {
return pinnedViews.value
}
function reload() {
views.reload()
async function reload(wait = false) {
await views.reload()
}
return {