Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { computed } from "vue";
- import { defineStore } from "pinia";
- import { createListResource } from "frappe-ui";
- export let usePwCategoryStore = defineStore("pw_category", () => {
- console.log("usePwCategoryStore called");
- let filters = {}
- let pw_category = localStorage.getItem("pw_category") || 0;
- if (pw_category) {
- filters = { 'pw_category': pw_category }
- }
- let pw_categories = createListResource({
- doctype: "PW Category",
- fields: ["*"],
- auto: true,
- pageLength: 99999,
- });
- let dropdown = computed(() =>
- pw_categories.data?.map((o) => ({
- label: o.pw_category,
- value: o.name,
- }))
- );
- return {
- dropdown,
- pw_categories,
- };
- });
- export let usePwSubCategoryStore = defineStore("pw_sub_category", () => {
- console.log("usePwSubCategoryStore called");
- let filters = {}
- let pw_category = localStorage.getItem("pw_category") || 0;
- if (pw_category) {
- filters = { 'pw_category': pw_category }
- }
- let pw_sub_categories = createListResource({
- doctype: "PW Sub Category",
- fields: ["*"],
- filters: filters,
- auto: true,
- pageLength: 99999,
- });
- let dropdown = computed(() =>
- pw_sub_categories.data?.map((o) => ({
- label: o.pw_sub_category,
- value: o.name,
- }))
- );
- return {
- dropdown,
- pw_sub_categories,
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement