fix: added CRM View Settings store
This commit is contained in:
parent
95f16759dd
commit
01beb61f0c
34
frontend/src/stores/views.js
Normal file
34
frontend/src/stores/views.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import { createListResource } from 'frappe-ui'
|
||||||
|
import { reactive } from 'vue'
|
||||||
|
|
||||||
|
export const viewsStore = defineStore('crm-views', () => {
|
||||||
|
let viewsByName = reactive({})
|
||||||
|
|
||||||
|
const views = createListResource({
|
||||||
|
doctype: 'CRM View Settings',
|
||||||
|
fields: ['*'],
|
||||||
|
cache: 'crm-views',
|
||||||
|
initialData: [],
|
||||||
|
auto: true,
|
||||||
|
transform(views) {
|
||||||
|
for (let view of views) {
|
||||||
|
viewsByName[view.name] = view
|
||||||
|
}
|
||||||
|
return views
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
function getView(view) {
|
||||||
|
if (!view) return null
|
||||||
|
if (!viewsByName[view]) {
|
||||||
|
views.reload()
|
||||||
|
}
|
||||||
|
return viewsByName[view]
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
views,
|
||||||
|
getView,
|
||||||
|
}
|
||||||
|
})
|
||||||
Loading…
x
Reference in New Issue
Block a user