objectAttributes.ts 955 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { defineStore } from 'pinia'
  3. import { ref } from 'vue'
  4. import type { EnumObjectManagerObjects } from '#shared/graphql/types.ts'
  5. import log from '#shared/utils/log.ts'
  6. import type { ObjectAttributesObject } from '../types/store.ts'
  7. export const useObjectAttributesStore = defineStore('objectAttributes', () => {
  8. const objectAttributesObjectLookup = ref<
  9. Record<string, ObjectAttributesObject>
  10. >({})
  11. const getObjectAttributesForObject = (object: EnumObjectManagerObjects) => {
  12. const objectAttributesObject = objectAttributesObjectLookup.value[object]
  13. if (!objectAttributesObject) {
  14. log.error(
  15. `Please load the form object attributes first, the object "${object}" does not exists in the store.`,
  16. )
  17. }
  18. return objectAttributesObject
  19. }
  20. return {
  21. objectAttributesObjectLookup,
  22. getObjectAttributesForObject,
  23. }
  24. })