fix: watching query param changes to reload lead list

This commit is contained in:
Shariq Ansari 2023-08-09 20:42:35 +05:30
parent df84aa01c9
commit 7a9d22cbe1
3 changed files with 23 additions and 12 deletions

View File

@ -144,6 +144,15 @@ watch(
} }
) )
watch(
() => getOrderBy(),
(value) => {
if (!value) {
sortValues.value = []
}
}
)
function setSort(data) { function setSort(data) {
sortValues.value = [ sortValues.value = [
...sortValues.value, ...sortValues.value,

View File

@ -3,19 +3,18 @@ import './index.css'
import { createApp } from 'vue' import { createApp } from 'vue'
import router from './router' import router from './router'
import App from './App.vue' import App from './App.vue'
import { createPinia } from "pinia"; import { createPinia } from 'pinia'
import { FrappeUI, Button, setConfig, frappeRequest, resourcesPlugin } from 'frappe-ui' import { FrappeUI, Button, setConfig, frappeRequest } from 'frappe-ui'
// create a pinia instance // create a pinia instance
let pinia = createPinia(); let pinia = createPinia()
let app = createApp(App) let app = createApp(App)
setConfig('resourceFetcher', frappeRequest) setConfig('resourceFetcher', frappeRequest)
app.use(FrappeUI) app.use(FrappeUI)
app.use(pinia); app.use(pinia)
app.use(router) app.use(router)
app.component('Button', Button) app.component('Button', Button)

View File

@ -70,7 +70,7 @@ import {
createResource, createResource,
} from 'frappe-ui' } from 'frappe-ui'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { ref, computed, reactive, onBeforeUpdate } from 'vue' import { ref, computed, reactive, watch } from 'vue'
const list = { const list = {
title: 'Leads', title: 'Leads',
@ -101,12 +101,20 @@ const leads = createListResource({
'lead_owner', 'lead_owner',
'modified', 'modified',
], ],
orderBy: getOrderBy() || 'modified desc', orderBy: 'modified desc',
cache: 'Leads', cache: 'Leads',
pageLength: 20, pageLength: 20,
auto: true, auto: true,
}) })
watch(
() => getOrderBy(),
(value) => {
leads.orderBy = value || 'modified desc'
leads.reload()
}
)
const columns = [ const columns = [
{ {
label: 'Name', label: 'Name',
@ -268,9 +276,4 @@ function createNewLead(close) {
}) })
.then(close) .then(close)
} }
onBeforeUpdate(() => {
leads.orderBy = getOrderBy() || 'modified desc'
leads.reload()
})
</script> </script>