useFileUploadProcessing.ts 705 B

1234567891011121314151617181920212223242526272829
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { createMessage } from '@formkit/core'
  3. import { getNodeByName } from '../utils.ts'
  4. export const useFileUploadProcessing = (formId: string, fieldName: string) => {
  5. const fieldNode = getNodeByName(formId, fieldName)
  6. const setFileUploadProcessing = () => {
  7. fieldNode?.root?.store.set(
  8. createMessage({
  9. blocking: true,
  10. key: 'uploadProcessing',
  11. value: true,
  12. visible: false,
  13. }),
  14. )
  15. }
  16. const removeFileUploadProcessing = () => {
  17. fieldNode?.root?.store.remove('uploadProcessing')
  18. }
  19. return {
  20. setFileUploadProcessing,
  21. removeFileUploadProcessing,
  22. }
  23. }