@anzusystems/common-admin 2.0.0-rc.30 → 2.0.0-rc.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/domains/anzuUser/components/AAnzuUserDatatable.vue.d.ts +4 -2
- package/dist/domains/anzuUser/components/AAnzuUserDatatable.vue.js +4 -4
- package/dist/domains/anzuUser/components/AAnzuUserDatatable.vue.js.map +1 -1
- package/dist/domains/anzuUser/components/AAnzuUserForm.vue.d.ts +3 -2
- package/dist/domains/anzuUser/components/AAnzuUserForm.vue.js +1 -1
- package/dist/domains/anzuUser/components/AAnzuUserForm.vue.js.map +1 -1
- package/dist/domains/anzuUser/components/AUserMetadataForm.vue.d.ts +5 -4
- package/dist/domains/anzuUser/components/AUserMetadataForm.vue.js +113 -108
- package/dist/domains/anzuUser/components/AUserMetadataForm.vue.js.map +1 -1
- package/dist/domains/anzuUser/composables/anzuUserValidations.d.ts +3 -2
- package/dist/domains/anzuUser/composables/anzuUserValidations.js +1 -1
- package/dist/domains/anzuUser/composables/anzuUserValidations.js.map +1 -1
- package/dist/domains/anzuUser/composables/userSystemDescriptor.d.ts +4 -3
- package/dist/domains/anzuUser/composables/userSystemDescriptor.js.map +1 -1
- package/dist/domains/anzuUser/filter/anzuUserFilter.d.ts +1 -2
- package/dist/domains/anzuUser/filter/anzuUserFilter.js.map +1 -1
- package/dist/domains/dam/uploadQueue/components/UploadQueueDialog.vue.js +84 -84
- package/dist/domains/dam/uploadQueue/components/UploadQueueDialog.vue.js.map +1 -1
- package/dist/domains/filters/composables/filterFactory.js +53 -52
- package/dist/domains/filters/composables/filterFactory.js.map +1 -1
- package/dist/domains/listEditor/composables/useKeyboardNav.js +3 -3
- package/dist/domains/listEditor/composables/useKeyboardNav.js.map +1 -1
- package/dist/domains/unsavedGuard/composables/useUnsavedChangesGuard.js +25 -21
- package/dist/domains/unsavedGuard/composables/useUnsavedChangesGuard.js.map +1 -1
- package/dist/lib.d.ts +2 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AUserMetadataForm.vue.js","names":["_useModel","_openBlock","_createBlock","ASystemEntityScope","_withCtx","_createVNode","_component_VRow","_component_VCol","_component_VAlert","_createTextVNode","_toDisplayString","AFormTextField","_unref","ARow","ACopyText","AAvatarColorPicker","_createElementBlock","createBlock","createCommentVNode","createElementBlock","createTextVNode","createVNode","defineComponent","mergeModels","onMounted","openBlock","ref","toDisplayString","unref","useModel","watch","withCtx","useI18n","AAvatarColorPicker_default","ACopyText_default","ARow_default","AFormTextField_default","ASystemEntityScope_default","ANZU_USER_ENTITY","useUserMetadataValidation","VAlert","VCol","VRow","_hoisted_1","AUserMetadataForm_vue_vue_type_script_setup_true_lang_default","\"user\"","\"userModifiers\"","__props","props","user","t","v$","derivedFullName","firstName","lastName","derivedAvatarText","fullNameTouched","avatarTextTouched","seedTouchedFlags","next","previous","_ctx","_cache","$event"],"sources":["../../../../src/domains/anzuUser/components/AUserMetadataForm.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { onMounted, ref, watch } from 'vue'\nimport { useI18n } from 'vue-i18n'\nimport AAvatarColorPicker from '@/domains/ui/components/AAvatarColorPicker.vue'\nimport ACopyText from '@/domains/ui/components/ACopyText.vue'\nimport ARow from '@/domains/ui/components/ARow.vue'\nimport AFormTextField from '@/domains/form/components/AFormTextField.vue'\nimport ASystemEntityScope from '@/domains/form/components/ASystemEntityScope.vue'\nimport { ANZU_USER_ENTITY } from '@/domains/anzuUser/api/anzuUserApi'\nimport { useUserMetadataValidation } from '@/domains/anzuUser/composables/anzuUserValidations'\nimport type { BaseUser } from '@/shared/types/AnzuUser'\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The system's validation profile (`requiredMetadata`).\n * The cross-system repair form always passes `true`. It writes to many systems, and a loose\n * form could put an empty name into cms, which cms's own form would then refuse to save.\n */\n required?: boolean\n /**\n * Whether the id is entered at all. False only in cms, whose backend resolves it from SSO.\n * With `isEdit` this gives three states that `readonly` alone cannot: not drawn, editable, or read-only.\n */\n idInput?: boolean\n isEdit?: boolean\n readonly?: boolean\n /**\n * Random colour on an empty value, as all four admins do.\n * Deliberately not passed by the cross-system repair form. It is strict, so\n * it would invent a colour on open and mark it as a change in every system.\n */\n randomColor?: boolean\n /** The system's `metadataNote` -- the same sentence the cross-system dialog shows. */\n note?: string | undefined\n /** i18n namespace for the field labels; the backend identity does not belong here. */\n scopeSystem?: string\n scopeSubject?: string\n /** Vuelidate scope. Omitted means the page's own collector picks these rules up. */\n validationScope?: string | symbol | false | undefined\n }>(),\n {\n required: false,\n idInput: true,\n isEdit: false,\n readonly: false,\n randomColor: false,\n note: undefined,\n scopeSystem: 'common',\n scopeSubject: ANZU_USER_ENTITY,\n validationScope: undefined,\n }\n)\n\nconst user = defineModel<BaseUser>('user', { required: true })\n\nconst { t } = useI18n()\n\n/* eslint-disable vue/no-setup-props-reactivity-loss */\nconst { v$ } = useUserMetadataValidation(user, {\n required: () => props.required,\n idInput: () => props.idInput,\n isEdit: () => props.isEdit,\n scope: props.validationScope,\n})\n/* eslint-enable vue/no-setup-props-reactivity-loss */\n\nconst derivedFullName = () => {\n const { firstName, lastName } = user.value.person\n if (firstName.length === 0 || lastName.length === 0) return ''\n return firstName + ' ' + lastName\n}\n\nconst derivedAvatarText = () => {\n const { firstName, lastName } = user.value.person\n if (firstName.length === 0 || lastName.length === 0) return ''\n return firstName.slice(0, 1) + lastName.slice(0, 1)\n}\n\n/**\n * Dirty flags: the derived fields recompute until someone edits them, then stop.\n * Flags are seeded from the data. A stored value that differs from the derived one was set on purpose\n * (cms fixtures have `Anzu` + `User 1` with full name `Anzu User1`), and renaming must not overwrite it.\n */\nconst fullNameTouched = ref(false)\nconst avatarTextTouched = ref(false)\n\nconst seedTouchedFlags = () => {\n fullNameTouched.value = user.value.person.fullName.length > 0 && user.value.person.fullName !== derivedFullName()\n avatarTextTouched.value = user.value.avatar.text.length > 0 && user.value.avatar.text !== derivedAvatarText()\n}\n\nonMounted(seedTouchedFlags)\n\n/**\n * Re-seeded whenever the record is replaced, not only when its id changes.\n * The metadata repair dialog swaps between two systems' records for the same person, so the\n * id stays the same. Stale flags would overwrite the chosen source's deliberate full name.\n * Declared before the derive watcher so the flags are updated first.\n */\nwatch(\n () => user.value,\n () => seedTouchedFlags()\n)\n\n// Keyed on the names as a string, not an array. A new array on every read\n// would fire on any object replacement, even one that changed nothing.\nwatch(\n () => `${user.value.person.firstName}\\u0000${user.value.person.lastName}`,\n (next, previous) => {\n if (props.readonly || next === previous) return\n if (!fullNameTouched.value) user.value.person.fullName = derivedFullName()\n if (!avatarTextTouched.value) user.value.avatar.text = derivedAvatarText()\n }\n)\n</script>\n\n<template>\n <ASystemEntityScope\n :system=\"scopeSystem\"\n :subject=\"scopeSubject\"\n >\n <VRow>\n <VCol cols=\"12\">\n <VAlert\n v-if=\"note\"\n type=\"info\"\n variant=\"tonal\"\n density=\"compact\"\n class=\"mb-4\"\n >\n {{ note }}\n </VAlert>\n <VRow>\n <VCol\n cols=\"12\"\n sm=\"3\"\n >\n <!--\n Three states: not drawn where the backend resolves the id; editable while creating; read-only\n once the record exists, because every other system looks the person up by this key.\n -->\n <!--\n `.number` is required. Vue applies model modifiers inside `emit`, so without it the field\n returns the string \"42\" for an `IntegerIdNullable`, and the create body carries that string.\n -->\n <AFormTextField\n v-if=\"idInput && !isEdit && !readonly\"\n v-model.number=\"user.id\"\n type=\"number\"\n :v=\"v$.user.id\"\n :label=\"t('common.anzuUser.model.id')\"\n :hint=\"t('common.anzuUser.hint.idReadonlyOnEdit')\"\n persistent-hint\n />\n <ARow\n v-else-if=\"user.id\"\n :title=\"t('common.anzuUser.model.id')\"\n >\n <ACopyText :value=\"user.id\" />\n </ARow>\n </VCol>\n <VCol\n cols=\"12\"\n sm=\"9\"\n >\n <ARow\n v-if=\"readonly\"\n :title=\"t('common.anzuUser.model.email')\"\n :value=\"user.email\"\n />\n <AFormTextField\n v-else\n v-model=\"user.email\"\n :v=\"v$.user.email\"\n data-cy=\"user-email\"\n />\n </VCol>\n </VRow>\n <VRow>\n <VCol\n cols=\"12\"\n sm=\"3\"\n >\n <ARow\n v-if=\"readonly\"\n :title=\"t('common.anzuUser.model.person.firstName')\"\n :value=\"user.person.firstName\"\n />\n <AFormTextField\n v-else\n v-model=\"user.person.firstName\"\n :v=\"v$.user.person.firstName\"\n data-cy=\"user-firstName\"\n />\n </VCol>\n <VCol\n cols=\"12\"\n sm=\"3\"\n >\n <ARow\n v-if=\"readonly\"\n :title=\"t('common.anzuUser.model.person.lastName')\"\n :value=\"user.person.lastName\"\n />\n <AFormTextField\n v-else\n v-model=\"user.person.lastName\"\n :v=\"v$.user.person.lastName\"\n data-cy=\"user-lastName\"\n />\n </VCol>\n <VCol\n cols=\"12\"\n sm=\"6\"\n >\n <ARow\n v-if=\"readonly\"\n :title=\"t('common.anzuUser.model.person.fullName')\"\n :value=\"user.person.fullName\"\n />\n <!--\n `@update:model-value` fires only on a real edit. The watcher assigns\n through the model, so recomputing never marks the field touched.\n -->\n <AFormTextField\n v-else\n v-model=\"user.person.fullName\"\n :v=\"v$.user.person.fullName\"\n :hint=\"fullNameTouched ? undefined : t('common.anzuUser.hint.derivedFromName')\"\n :persistent-hint=\"!fullNameTouched\"\n data-cy=\"user-fullName\"\n @update:model-value=\"fullNameTouched = true\"\n />\n </VCol>\n </VRow>\n <VRow>\n <VCol\n cols=\"12\"\n sm=\"3\"\n >\n <AAvatarColorPicker\n v-model=\"user.avatar.color\"\n :label=\"t('common.anzuUser.model.avatar.color')\"\n :readonly=\"readonly\"\n :required=\"required\"\n :random-color=\"randomColor\"\n />\n <div\n v-if=\"v$.user.avatar.color.$error\"\n class=\"text-error text-body-small\"\n >\n {{ v$.user.avatar.color.$errors[0]?.$message }}\n </div>\n </VCol>\n <VCol\n cols=\"12\"\n sm=\"3\"\n >\n <ARow\n v-if=\"readonly\"\n :title=\"t('common.anzuUser.model.avatar.text')\"\n :value=\"user.avatar.text\"\n />\n <AFormTextField\n v-else\n v-model=\"user.avatar.text\"\n :v=\"v$.user.avatar.text\"\n :maxlength=\"3\"\n :hint=\"avatarTextTouched ? undefined : t('common.anzuUser.hint.derivedFromName')\"\n :persistent-hint=\"!avatarTextTouched\"\n data-cy=\"user-avatarText\"\n @update:model-value=\"avatarTextTouched = true\"\n />\n </VCol>\n </VRow>\n </VCol>\n </VRow>\n </ASystemEntityScope>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYA,IAAMgD,IAAQD,GA0CRE,IAAOjD,EAAqB+C,GAAC,MAA0B,GAEvD,EAAEG,SAAMlB,EAAQ,GAGhB,EAAEmB,UAAOZ,EAA0BU,GAAM;GAC7C,gBAAgBD,EAAM;GACtB,eAAeA,EAAM;GACrB,cAAcA,EAAM;GACpB,OAAOA,EAAM;EACf,CAAC,GAGKI,UAAwB;GAC5B,IAAM,EAAEC,cAAWC,gBAAaL,EAAK,MAAM;GAE3C,OADII,EAAU,WAAW,KAAKC,EAAS,WAAW,IAAU,KACrDD,IAAY,MAAMC;EAC3B,GAEMC,UAA0B;GAC9B,IAAM,EAAEF,cAAWC,gBAAaL,EAAK,MAAM;GAE3C,OADII,EAAU,WAAW,KAAKC,EAAS,WAAW,IAAU,KACrDD,EAAU,MAAM,GAAG,CAAC,IAAIC,EAAS,MAAM,GAAG,CAAC;EACpD,GAOME,IAAkB9B,EAAI,EAAK,GAC3B+B,IAAoB/B,EAAI,EAAK,GAE7BgC,UAAyB;GAC7BF,EAAgB,QAAQP,EAAK,MAAM,OAAO,SAAS,SAAS,KAAKA,EAAK,MAAM,OAAO,aAAaG,EAAgB,GAChHK,EAAkB,QAAQR,EAAK,MAAM,OAAO,KAAK,SAAS,KAAKA,EAAK,MAAM,OAAO,SAASM,EAAkB;EAC9G;E,OAEA/B,EAAUkC,CAAgB,GAQ1B5B,QACQmB,EAAK,aACLS,EAAiB,CACzB,GAIA5B,QACQ,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AA;;SAFC,OAAOD,EAAAsC,CAAA,CAAC,CAAA,mCAAA;SACR,OAAOD,EAAA,MAAK,OAAO;Q,oCAEtBhD,EAAA,GAAAC,EASES,GAAA;;SAPS,YAAAsC,EAAA,MAAK,OAAO;S,wBAAZa,EAAA,QAAAC,MAAAd,EAAA,MAAK,OAAO,OAAIc,GAMJD,EAAA,QAAAC,MAAAN,EAAA,QAAiB,E;SALrC,GAAG7C,EAAAuC,CAAA,CAAE,CAAC,KAAK,OAAO;SAClB,WAAW;SACX,MAAMM,EAAA,QAAoB,KAAA,IAAY7C,EAAAsC,CAAA,CAAC,CAAA,sCAAA;SACvC,mBAAe,CAAGO,EAAA;SACnB,WAAQ"}
|
|
1
|
+
{"version":3,"file":"AUserMetadataForm.vue.js","names":["_useModel","_openBlock","_createBlock","ASystemEntityScope","_withCtx","_createVNode","_component_VRow","_component_VCol","_component_VAlert","_createTextVNode","_toDisplayString","AFormTextField","_unref","ARow","ACopyText","AAvatarColorPicker","_createElementBlock","computed","createBlock","createCommentVNode","createElementBlock","createTextVNode","createVNode","defineComponent","mergeModels","onMounted","openBlock","ref","toDisplayString","unref","useModel","watch","withCtx","useI18n","AAvatarColorPicker_default","ACopyText_default","ARow_default","AFormTextField_default","ASystemEntityScope_default","ANZU_USER_ENTITY","useUserMetadataValidation","VAlert","VCol","VRow","_hoisted_1","AUserMetadataForm_vue_vue_type_script_setup_true_lang_default","\"user\"","\"userModifiers\"","__props","props","user","id","value","t","v$","derivedFullName","firstName","lastName","derivedAvatarText","fullNameTouched","avatarTextTouched","seedTouchedFlags","next","previous","_ctx","_cache","$event"],"sources":["../../../../src/domains/anzuUser/components/AUserMetadataForm.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { computed, onMounted, ref, watch } from 'vue'\nimport { useI18n } from 'vue-i18n'\nimport AAvatarColorPicker from '@/domains/ui/components/AAvatarColorPicker.vue'\nimport ACopyText from '@/domains/ui/components/ACopyText.vue'\nimport ARow from '@/domains/ui/components/ARow.vue'\nimport AFormTextField from '@/domains/form/components/AFormTextField.vue'\nimport ASystemEntityScope from '@/domains/form/components/ASystemEntityScope.vue'\nimport { ANZU_USER_ENTITY } from '@/domains/anzuUser/api/anzuUserApi'\nimport { useUserMetadataValidation } from '@/domains/anzuUser/composables/anzuUserValidations'\nimport type { BaseUser } from '@/shared/types/AnzuUser'\nimport type { IntegerIdNullable } from '@/shared/types/common'\nimport type { UserIdInput } from '@/domains/anzuUser/composables/userSystemDescriptor'\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The system's validation profile (`requiredMetadata`).\n * The cross-system repair form always passes `true`. It writes to many systems, and a loose\n * form could put an empty name into cms, which cms's own form would then refuse to save.\n */\n required?: boolean\n /**\n * Whether the id is entered at all; see `UserIdInput`. With `isEdit` this gives states that `readonly` alone\n * cannot: not drawn, editable, or read-only.\n */\n idInput?: UserIdInput\n isEdit?: boolean\n readonly?: boolean\n /**\n * Random colour on an empty value, as all four admins do.\n * Deliberately not passed by the cross-system repair form. It is strict, so\n * it would invent a colour on open and mark it as a change in every system.\n */\n randomColor?: boolean\n /** The system's `metadataNote` -- the same sentence the cross-system dialog shows. */\n note?: string | undefined\n /** i18n namespace for the field labels; the backend identity does not belong here. */\n scopeSystem?: string\n scopeSubject?: string\n /** Vuelidate scope. Omitted means the page's own collector picks these rules up. */\n validationScope?: string | symbol | false | undefined\n }>(),\n {\n required: false,\n idInput: true,\n isEdit: false,\n readonly: false,\n randomColor: false,\n note: undefined,\n scopeSystem: 'common',\n scopeSubject: ANZU_USER_ENTITY,\n validationScope: undefined,\n }\n)\n\nconst user = defineModel<BaseUser>('user', { required: true })\n\n// An emptied field gives '' even with `.number`; an optional id must be null to be looked up in SSO.\nconst id = computed({\n get: () => user.value.id,\n set: (value: IntegerIdNullable | '' | undefined) => {\n user.value.id = value === '' ? null : value\n },\n})\n\nconst { t } = useI18n()\n\n/* eslint-disable vue/no-setup-props-reactivity-loss */\nconst { v$ } = useUserMetadataValidation(user, {\n required: () => props.required,\n idInput: () => props.idInput,\n isEdit: () => props.isEdit,\n scope: props.validationScope,\n})\n/* eslint-enable vue/no-setup-props-reactivity-loss */\n\nconst derivedFullName = () => {\n const { firstName, lastName } = user.value.person\n if (firstName.length === 0 || lastName.length === 0) return ''\n return firstName + ' ' + lastName\n}\n\nconst derivedAvatarText = () => {\n const { firstName, lastName } = user.value.person\n if (firstName.length === 0 || lastName.length === 0) return ''\n return firstName.slice(0, 1) + lastName.slice(0, 1)\n}\n\n/**\n * Dirty flags: the derived fields recompute until someone edits them, then stop.\n * Flags are seeded from the data. A stored value that differs from the derived one was set on purpose\n * (cms fixtures have `Anzu` + `User 1` with full name `Anzu User1`), and renaming must not overwrite it.\n */\nconst fullNameTouched = ref(false)\nconst avatarTextTouched = ref(false)\n\nconst seedTouchedFlags = () => {\n fullNameTouched.value = user.value.person.fullName.length > 0 && user.value.person.fullName !== derivedFullName()\n avatarTextTouched.value = user.value.avatar.text.length > 0 && user.value.avatar.text !== derivedAvatarText()\n}\n\nonMounted(seedTouchedFlags)\n\n/**\n * Re-seeded whenever the record is replaced, not only when its id changes.\n * The metadata repair dialog swaps between two systems' records for the same person, so the\n * id stays the same. Stale flags would overwrite the chosen source's deliberate full name.\n * Declared before the derive watcher so the flags are updated first.\n */\nwatch(\n () => user.value,\n () => seedTouchedFlags()\n)\n\n// Keyed on the names as a string, not an array. A new array on every read\n// would fire on any object replacement, even one that changed nothing.\nwatch(\n () => `${user.value.person.firstName}\\u0000${user.value.person.lastName}`,\n (next, previous) => {\n if (props.readonly || next === previous) return\n if (!fullNameTouched.value) user.value.person.fullName = derivedFullName()\n if (!avatarTextTouched.value) user.value.avatar.text = derivedAvatarText()\n }\n)\n</script>\n\n<template>\n <ASystemEntityScope\n :system=\"scopeSystem\"\n :subject=\"scopeSubject\"\n >\n <VRow>\n <VCol cols=\"12\">\n <VAlert\n v-if=\"note\"\n type=\"info\"\n variant=\"tonal\"\n density=\"compact\"\n class=\"mb-4\"\n >\n {{ note }}\n </VAlert>\n <VRow>\n <VCol\n cols=\"12\"\n sm=\"3\"\n >\n <!--\n Three states: not drawn where the backend resolves the id; editable while creating; read-only\n once the record exists, because every other system looks the person up by this key.\n -->\n <!--\n `.number` is required. Vue applies model modifiers inside `emit`, so without it the field\n returns the string \"42\" for an `IntegerIdNullable`, and the create body carries that string.\n -->\n <AFormTextField\n v-if=\"idInput && !isEdit && !readonly\"\n v-model.number=\"id\"\n type=\"number\"\n :v=\"v$.user.id\"\n :label=\"t('common.anzuUser.model.id')\"\n :hint=\"t('common.anzuUser.hint.idReadonlyOnEdit')\"\n persistent-hint\n />\n <ARow\n v-else-if=\"user.id\"\n :title=\"t('common.anzuUser.model.id')\"\n >\n <ACopyText :value=\"user.id\" />\n </ARow>\n </VCol>\n <VCol\n cols=\"12\"\n sm=\"9\"\n >\n <ARow\n v-if=\"readonly\"\n :title=\"t('common.anzuUser.model.email')\"\n :value=\"user.email\"\n />\n <AFormTextField\n v-else\n v-model=\"user.email\"\n :v=\"v$.user.email\"\n data-cy=\"user-email\"\n />\n </VCol>\n </VRow>\n <VRow>\n <VCol\n cols=\"12\"\n sm=\"3\"\n >\n <ARow\n v-if=\"readonly\"\n :title=\"t('common.anzuUser.model.person.firstName')\"\n :value=\"user.person.firstName\"\n />\n <AFormTextField\n v-else\n v-model=\"user.person.firstName\"\n :v=\"v$.user.person.firstName\"\n data-cy=\"user-firstName\"\n />\n </VCol>\n <VCol\n cols=\"12\"\n sm=\"3\"\n >\n <ARow\n v-if=\"readonly\"\n :title=\"t('common.anzuUser.model.person.lastName')\"\n :value=\"user.person.lastName\"\n />\n <AFormTextField\n v-else\n v-model=\"user.person.lastName\"\n :v=\"v$.user.person.lastName\"\n data-cy=\"user-lastName\"\n />\n </VCol>\n <VCol\n cols=\"12\"\n sm=\"6\"\n >\n <ARow\n v-if=\"readonly\"\n :title=\"t('common.anzuUser.model.person.fullName')\"\n :value=\"user.person.fullName\"\n />\n <!--\n `@update:model-value` fires only on a real edit. The watcher assigns\n through the model, so recomputing never marks the field touched.\n -->\n <AFormTextField\n v-else\n v-model=\"user.person.fullName\"\n :v=\"v$.user.person.fullName\"\n :hint=\"fullNameTouched ? undefined : t('common.anzuUser.hint.derivedFromName')\"\n :persistent-hint=\"!fullNameTouched\"\n data-cy=\"user-fullName\"\n @update:model-value=\"fullNameTouched = true\"\n />\n </VCol>\n </VRow>\n <VRow>\n <VCol\n cols=\"12\"\n sm=\"3\"\n >\n <AAvatarColorPicker\n v-model=\"user.avatar.color\"\n :label=\"t('common.anzuUser.model.avatar.color')\"\n :readonly=\"readonly\"\n :required=\"required\"\n :random-color=\"randomColor\"\n />\n <div\n v-if=\"v$.user.avatar.color.$error\"\n class=\"text-error text-body-small\"\n >\n {{ v$.user.avatar.color.$errors[0]?.$message }}\n </div>\n </VCol>\n <VCol\n cols=\"12\"\n sm=\"3\"\n >\n <ARow\n v-if=\"readonly\"\n :title=\"t('common.anzuUser.model.avatar.text')\"\n :value=\"user.avatar.text\"\n />\n <AFormTextField\n v-else\n v-model=\"user.avatar.text\"\n :v=\"v$.user.avatar.text\"\n :maxlength=\"3\"\n :hint=\"avatarTextTouched ? undefined : t('common.anzuUser.hint.derivedFromName')\"\n :persistent-hint=\"!avatarTextTouched\"\n data-cy=\"user-avatarText\"\n @update:model-value=\"avatarTextTouched = true\"\n />\n </VCol>\n </VRow>\n </VCol>\n </VRow>\n </ASystemEntityScope>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcA,IAAMiD,IAAQD,GA0CRE,IAAOlD,EAAqBgD,GAAC,MAA0B,GAGvDG,IAAKlC,EAAS;GAClB,WAAWiC,EAAK,MAAM;GACtB,MAAME,MAA8C;IAClDF,EAAK,MAAM,KAAKE,MAAU,KAAK,OAAOA;GACxC;EACF,CAAC,GAEK,EAAEC,SAAMpB,EAAQ,GAGhB,EAAEqB,UAAOd,EAA0BU,GAAM;GAC7C,gBAAgBD,EAAM;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, Ref } from 'vue';
|
|
2
2
|
import { BaseUser } from '../../../shared/types/AnzuUser';
|
|
3
|
+
import { UserIdInput } from './userSystemDescriptor';
|
|
3
4
|
export interface UserMetadataValidationOptions {
|
|
4
5
|
/**
|
|
5
6
|
* The system's profile (`requiredMetadata` on its descriptor). `false` requires only the
|
|
@@ -7,8 +8,8 @@ export interface UserMetadataValidationOptions {
|
|
|
7
8
|
* It applies equally to create and edit.
|
|
8
9
|
*/
|
|
9
10
|
required: MaybeRefOrGetter<boolean>;
|
|
10
|
-
/** Whether the id is a field at all. When it is
|
|
11
|
-
idInput: MaybeRefOrGetter<
|
|
11
|
+
/** Whether the id is a field at all. When it is `true`, and this is a create, it is required. */
|
|
12
|
+
idInput: MaybeRefOrGetter<UserIdInput>;
|
|
12
13
|
isEdit: MaybeRefOrGetter<boolean>;
|
|
13
14
|
/** Scope key, so an owning form can validate its own fields alongside the app's system fields. */
|
|
14
15
|
scope?: string | symbol | false;
|
|
@@ -6,7 +6,7 @@ function i(i, a) {
|
|
|
6
6
|
let { email: o, hexColor: s, maxLength: c, minLength: l, required: u } = r(), d = t(() => {
|
|
7
7
|
let e = n(a.required) ? { required: u } : {};
|
|
8
8
|
return { user: {
|
|
9
|
-
id: n(a.idInput) && !n(a.isEdit) ? { required: u } : {},
|
|
9
|
+
id: n(a.idInput) === !0 && !n(a.isEdit) ? { required: u } : {},
|
|
10
10
|
email: {
|
|
11
11
|
required: u,
|
|
12
12
|
email: o,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anzuUserValidations.js","names":["useVuelidate","computed","toValue","useValidate","useUserMetadataValidation","user","options","email","hexColor","maxLength","minLength","required","rules","requiredWhenProfileSays"],"sources":["../../../../src/domains/anzuUser/composables/anzuUserValidations.ts"],"sourcesContent":["import useVuelidate from '@vuelidate/core'\nimport { computed, toValue, type MaybeRefOrGetter, type Ref } from 'vue'\nimport { useValidate } from '@/shared/validators/vuelidate/useValidate'\nimport type { BaseUser } from '@/shared/types/AnzuUser'\n\nexport interface UserMetadataValidationOptions {\n /**\n * The system's profile (`requiredMetadata` on its descriptor). `false` requires only the\n * e-mail. `true` also requires first, last and full name, avatar text and avatar colour.\n * It applies equally to create and edit.\n */\n required: MaybeRefOrGetter<boolean>\n /** Whether the id is a field at all. When it is
|
|
1
|
+
{"version":3,"file":"anzuUserValidations.js","names":["useVuelidate","computed","toValue","useValidate","useUserMetadataValidation","user","options","email","hexColor","maxLength","minLength","required","rules","requiredWhenProfileSays"],"sources":["../../../../src/domains/anzuUser/composables/anzuUserValidations.ts"],"sourcesContent":["import useVuelidate from '@vuelidate/core'\nimport { computed, toValue, type MaybeRefOrGetter, type Ref } from 'vue'\nimport { useValidate } from '@/shared/validators/vuelidate/useValidate'\nimport type { BaseUser } from '@/shared/types/AnzuUser'\nimport type { UserIdInput } from '@/domains/anzuUser/composables/userSystemDescriptor'\n\nexport interface UserMetadataValidationOptions {\n /**\n * The system's profile (`requiredMetadata` on its descriptor). `false` requires only the\n * e-mail. `true` also requires first, last and full name, avatar text and avatar colour.\n * It applies equally to create and edit.\n */\n required: MaybeRefOrGetter<boolean>\n /** Whether the id is a field at all. When it is `true`, and this is a create, it is required. */\n idInput: MaybeRefOrGetter<UserIdInput>\n isEdit: MaybeRefOrGetter<boolean>\n /** Scope key, so an owning form can validate its own fields alongside the app's system fields. */\n scope?: string | symbol | false\n}\n\n/**\n * The `BaseUserDto` rules, per profile.\n * Lengths follow backend constraints (`email` 256, first/last 120, full 242, avatar text 2-3). The\n * backend requires only the e-mail. The front end is deliberately stricter, as set by `requiredMetadata`.\n */\nexport function useUserMetadataValidation(user: Ref<BaseUser>, options: UserMetadataValidationOptions) {\n const { email, hexColor, maxLength, minLength, required } = useValidate()\n\n const rules = computed(() => {\n // Read inside the computed, not at setup. The \"not found anywhere\" dialog switches the target\n // system under a mounted form, and a profile captured at mount would keep the first system's rules.\n const requiredWhenProfileSays = toValue(options.required) ? { required } : {}\n\n return {\n user: {\n // Required only on create where the id is typed. On edit it is a\n // displayed primary key, and in cms the backend resolves it from SSO.\n id: toValue(options.idInput) === true && !toValue(options.isEdit) ? { required } : {},\n email: {\n required,\n email,\n maxLength: maxLength(256),\n },\n person: {\n firstName: { ...requiredWhenProfileSays, minLength: minLength(2), maxLength: maxLength(120) },\n lastName: { ...requiredWhenProfileSays, minLength: minLength(2), maxLength: maxLength(120) },\n fullName: { ...requiredWhenProfileSays, minLength: minLength(3), maxLength: maxLength(242) },\n },\n avatar: {\n // Check the shape, not the length: `minLength(7)` accepts `#GGGGGG`, which the server rejects.\n // `hexColor` passes an empty value, so a profile without a required colour still saves.\n color: { ...requiredWhenProfileSays, hexColor },\n text: { ...requiredWhenProfileSays, minLength: minLength(2), maxLength: maxLength(3) },\n },\n },\n }\n })\n\n const v$ = useVuelidate(rules, { user }, options.scope === undefined ? undefined : { $scope: options.scope })\n\n return {\n v$,\n }\n}\n"],"mappings":";;;;AAyBA,SAAgBI,EAA0BC,GAAqBC,GAAwC;CACrG,IAAM,EAAEC,UAAOC,aAAUC,cAAWC,cAAWC,gBAAaR,EAAY,GAElES,IAAQX,QAAe;EAG3B,IAAMY,IAA0BX,EAAQI,EAAQ,QAAQ,IAAI,EAAEK,YAAS,IAAI,CAAC;EAE5E,OAAO,EACL,MAAM;GAGJ,IAAIT,EAAQI,EAAQ,OAAO,MAAM,MAAQ,CAACJ,EAAQI,EAAQ,MAAM,IAAI,EAAEK,YAAS,IAAI,CAAC;GACpF,OAAO;IACLA;IACAJ;IACA,WAAWE,EAAU,GAAG;GAC1B;GACA,QAAQ;IACN,WAAW;KAAE,GAAGI;KAAyB,WAAWH,EAAU,CAAC;KAAG,WAAWD,EAAU,GAAG;IAAE;IAC5F,UAAU;KAAE,GAAGI;KAAyB,WAAWH,EAAU,CAAC;KAAG,WAAWD,EAAU,GAAG;IAAE;IAC3F,UAAU;KAAE,GAAGI;KAAyB,WAAWH,EAAU,CAAC;KAAG,WAAWD,EAAU,GAAG;IAAE;GAC7F;GACA,QAAQ;IAGN,OAAO;KAAE,GAAGI;KAAyBL;IAAS;IAC9C,MAAM;KAAE,GAAGK;KAAyB,WAAWH,EAAU,CAAC;KAAG,WAAWD,EAAU,CAAC;IAAE;GACvF;EACF,EACF;CACF,CAAC;CAID,OAAO,EACL,IAHST,EAAaY,GAAO,EAAEP,QAAK,GAAGC,EAAQ,UAAU,KAAA,IAAY,KAAA,IAAY,EAAE,QAAQA,EAAQ,MAAM,CAGzG,EACF;AACF"}
|
|
@@ -18,6 +18,8 @@ export interface AnzuUserEndpointPair {
|
|
|
18
18
|
put: string;
|
|
19
19
|
post: string;
|
|
20
20
|
}
|
|
21
|
+
/** The id field on create: required, optional (an empty one is looked up in SSO by e-mail), or not drawn. */
|
|
22
|
+
export type UserIdInput = boolean | 'optional';
|
|
21
23
|
/** `/adm/users`. Only cms, dam and contentHub have it; it is the only path with a `PATCH`. */
|
|
22
24
|
export interface BaseUserEndpointPair extends AnzuUserEndpointPair {
|
|
23
25
|
patch: string;
|
|
@@ -70,10 +72,9 @@ export interface UserSystemDescriptor<TSystem extends string = string, TUser ext
|
|
|
70
72
|
*/
|
|
71
73
|
requiredMetadata: boolean;
|
|
72
74
|
/**
|
|
73
|
-
* Whether the id is typed in
|
|
74
|
-
* Read-only on edit regardless.
|
|
75
|
+
* Whether the id is typed in on create; `false` in cms, `'optional'` in Content Hub. Read-only on edit regardless.
|
|
75
76
|
*/
|
|
76
|
-
idInput:
|
|
77
|
+
idInput: UserIdInput;
|
|
77
78
|
extraState?: (user: TUser) => UserSystemExtraState | null;
|
|
78
79
|
/** Above the `enabled` switch and in the row of a bulk action. */
|
|
79
80
|
enabledNote?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userSystemDescriptor.js","names":["defineUserSystemDescriptor","descriptor","descriptorMayWrite","action","resolveProbeEndpoint","pair","resolveMetadataWrite","base","anzuUser","resolveEnabledWrite","resolveCreateEndpoint"],"sources":["../../../../src/domains/anzuUser/composables/userSystemDescriptor.ts"],"sourcesContent":["import type { RouteLocationRaw } from 'vue-router'\nimport type { AxiosClientFn } from '@/domains/api/utils/client'\nimport type { AnzuUser } from '@/shared/types/AnzuUser'\n\n/**\n * A system state shown next to `enabled`. Today: blog's `status` and forum's `settings.banned`.\n * Both are serialized on the entity, so rendering costs no extra call.\n */\nexport interface UserSystemExtraState {\n /** \"blogger\", \"commenter\". The app translates it; the library only prints it. */\n label: string\n /** \"active\", \"banned\". */\n value: string\n tone: 'ok' | 'warn' | 'error'\n}\n\n/** `/adm/v1/anzu-user`. Absent in contentHub, which has only `/adm/users`. */\nexport interface AnzuUserEndpointPair {\n get: string\n put: string\n post: string\n}\n\n/** `/adm/users`. Only cms, dam and contentHub have it; it is the only path with a `PATCH`. */\nexport interface BaseUserEndpointPair extends AnzuUserEndpointPair {\n patch: string\n}\n\n/**\n * Paired GET and write paths. A write body is always the whole object the GET on the same path returned.\n * The two paths return different DTOs. A GET from one and a PUT to the other\n * silently drops fields, e.g. cms `CmsUserDto` with `updateRelations()`.\n */\nexport interface UserSystemEndpoints {\n anzuUser: AnzuUserEndpointPair | null\n base: BaseUserEndpointPair | null\n permissionGroup: string\n /** Per system. contentHub uses `/adm/users/current`. */\n currentUser: string\n list: string\n /**\n * Which pair the probe reads through. The probe follows the write path.\n * In dam `GET /adm/v1/anzu-user/{id}` is ungated while `GET /adm/users/{id}`\n * needs `DAM_USER_READ`, so only the second can show \"no access\".\n */\n probe: 'anzuUser' | 'base'\n}\n\n/**\n * Where \"manage in X\" leads. A callback because the descriptor does not know which row is drawn.\n * Internal targets go through the router. External ones open in a new tab.\n * `href: null` means a missing url and renders disabled with a reason.\n */\nexport type UserSystemManageTarget =\n | { kind: 'internal'; to: RouteLocationRaw }\n | { kind: 'external'; href: string | null }\n\nexport interface UserSystemDescriptor<TSystem extends string = string, TUser extends AnzuUser = AnzuUser> {\n system: TSystem\n client: AxiosClientFn\n /** Reaches every `useApiRequest` built for this system; see `permissionGroupApi`. */\n entity: string\n /**\n * Whether the system is enabled in this admin's config (`envConfig[system].enabled`).\n * Mandatory because the disabled state must be shown. Omitting the system from the array is not the same.\n */\n isEnabled: () => boolean\n /**\n * Validation profile. `false`: only e-mail is required. `true`: also\n * first name, last name, full name, avatar text and avatar colour.\n * Same for create and edit.\n */\n requiredMetadata: boolean\n /**\n * Whether the id is typed in
|
|
1
|
+
{"version":3,"file":"userSystemDescriptor.js","names":["defineUserSystemDescriptor","descriptor","descriptorMayWrite","action","resolveProbeEndpoint","pair","resolveMetadataWrite","base","anzuUser","resolveEnabledWrite","resolveCreateEndpoint"],"sources":["../../../../src/domains/anzuUser/composables/userSystemDescriptor.ts"],"sourcesContent":["import type { RouteLocationRaw } from 'vue-router'\nimport type { AxiosClientFn } from '@/domains/api/utils/client'\nimport type { AnzuUser } from '@/shared/types/AnzuUser'\n\n/**\n * A system state shown next to `enabled`. Today: blog's `status` and forum's `settings.banned`.\n * Both are serialized on the entity, so rendering costs no extra call.\n */\nexport interface UserSystemExtraState {\n /** \"blogger\", \"commenter\". The app translates it; the library only prints it. */\n label: string\n /** \"active\", \"banned\". */\n value: string\n tone: 'ok' | 'warn' | 'error'\n}\n\n/** `/adm/v1/anzu-user`. Absent in contentHub, which has only `/adm/users`. */\nexport interface AnzuUserEndpointPair {\n get: string\n put: string\n post: string\n}\n\n/** The id field on create: required, optional (an empty one is looked up in SSO by e-mail), or not drawn. */\nexport type UserIdInput = boolean | 'optional'\n\n/** `/adm/users`. Only cms, dam and contentHub have it; it is the only path with a `PATCH`. */\nexport interface BaseUserEndpointPair extends AnzuUserEndpointPair {\n patch: string\n}\n\n/**\n * Paired GET and write paths. A write body is always the whole object the GET on the same path returned.\n * The two paths return different DTOs. A GET from one and a PUT to the other\n * silently drops fields, e.g. cms `CmsUserDto` with `updateRelations()`.\n */\nexport interface UserSystemEndpoints {\n anzuUser: AnzuUserEndpointPair | null\n base: BaseUserEndpointPair | null\n permissionGroup: string\n /** Per system. contentHub uses `/adm/users/current`. */\n currentUser: string\n list: string\n /**\n * Which pair the probe reads through. The probe follows the write path.\n * In dam `GET /adm/v1/anzu-user/{id}` is ungated while `GET /adm/users/{id}`\n * needs `DAM_USER_READ`, so only the second can show \"no access\".\n */\n probe: 'anzuUser' | 'base'\n}\n\n/**\n * Where \"manage in X\" leads. A callback because the descriptor does not know which row is drawn.\n * Internal targets go through the router. External ones open in a new tab.\n * `href: null` means a missing url and renders disabled with a reason.\n */\nexport type UserSystemManageTarget =\n | { kind: 'internal'; to: RouteLocationRaw }\n | { kind: 'external'; href: string | null }\n\nexport interface UserSystemDescriptor<TSystem extends string = string, TUser extends AnzuUser = AnzuUser> {\n system: TSystem\n client: AxiosClientFn\n /** Reaches every `useApiRequest` built for this system; see `permissionGroupApi`. */\n entity: string\n /**\n * Whether the system is enabled in this admin's config (`envConfig[system].enabled`).\n * Mandatory because the disabled state must be shown. Omitting the system from the array is not the same.\n */\n isEnabled: () => boolean\n /**\n * Validation profile. `false`: only e-mail is required. `true`: also\n * first name, last name, full name, avatar text and avatar colour.\n * Same for create and edit.\n */\n requiredMetadata: boolean\n /**\n * Whether the id is typed in on create; `false` in cms, `'optional'` in Content Hub. Read-only on edit regardless.\n */\n idInput: UserIdInput\n extraState?: (user: TUser) => UserSystemExtraState | null\n /** Above the `enabled` switch and in the row of a bulk action. */\n enabledNote?: string\n /** In the metadata repair dialog and in the owning form. */\n metadataNote?: string\n /** In the confirmation dialog when an account is created here. */\n createNote?: string\n endpoints: UserSystemEndpoints\n /** The system's name as the app translates it. */\n label?: string\n manage?: (user: TUser) => UserSystemManageTarget\n /**\n * Whether the current user may write this system's accounts. `false`\n * removes create, enable/disable, manage and the bulk action part.\n * `undefined` or no function leaves it to the probe and the\n * backend. Only the admin knows the other systems' current users.\n */\n canWrite?: (action: UserSystemWriteAction) => boolean | undefined\n}\n\nexport type UserSystemWriteAction = 'create' | 'update'\n\n/**\n * Type erasure point for the heterogeneous descriptor array.\n * Descriptors differ in `TUser`. Erasing here avoids a cast at every call site under `strict: true`.\n */\nexport type AnyUserSystemDescriptor = UserSystemDescriptor<string, AnzuUser>\n\nexport const defineUserSystemDescriptor = <TSystem extends string, TUser extends AnzuUser>(\n descriptor: UserSystemDescriptor<TSystem, TUser>\n): AnyUserSystemDescriptor => descriptor as unknown as AnyUserSystemDescriptor\n\n/** False only when the descriptor says no. Not knowing is not a no. */\nexport const descriptorMayWrite = (descriptor: AnyUserSystemDescriptor, action: UserSystemWriteAction): boolean =>\n descriptor.canWrite?.(action) !== false\n\n/**\n * Both `endpoints` branches are nullable, so `probe: 'base'` may name a system without `/adm/users`.\n * Each admin's descriptor test asserts this resolves for every system.\n */\nexport const resolveProbeEndpoint = (descriptor: AnyUserSystemDescriptor): AnzuUserEndpointPair => {\n const pair = descriptor.endpoints[descriptor.endpoints.probe]\n if (pair === null) {\n throw new Error(\n `[userSystemDescriptor] '${descriptor.system}' names probe '${descriptor.endpoints.probe}', which it does not have.`\n )\n }\n return pair\n}\n\n/**\n * Metadata goes through `PATCH /adm/users/{id}` where it exists.\n * Its method has no setters for roles, permissions, groups or `enabled`.\n */\nexport const resolveMetadataWrite = (\n descriptor: AnyUserSystemDescriptor\n): { method: 'PATCH'; get: string; url: string } | { method: 'PUT'; get: string; url: string } => {\n const base = descriptor.endpoints.base\n if (base !== null) return { method: 'PATCH', get: base.get, url: base.patch }\n const anzuUser = descriptor.endpoints.anzuUser\n if (anzuUser === null) {\n throw new Error(`[userSystemDescriptor] '${descriptor.system}' has neither write path.`)\n }\n return { method: 'PUT', get: anzuUser.get, url: anzuUser.put }\n}\n\n/**\n * `enabled` has no PATCH. Only the full update calls `setEnabled`.\n * So it is GET then PUT on the same path with the whole DTO from the GET.\n */\nexport const resolveEnabledWrite = (descriptor: AnyUserSystemDescriptor): { get: string; url: string } => {\n const base = descriptor.endpoints.base\n if (base !== null) return { get: base.get, url: base.put }\n const anzuUser = descriptor.endpoints.anzuUser\n if (anzuUser === null) {\n throw new Error(`[userSystemDescriptor] '${descriptor.system}' has neither write path.`)\n }\n return { get: anzuUser.get, url: anzuUser.put }\n}\n\n/** Creating an account goes the same way a write does. */\nexport const resolveCreateEndpoint = (descriptor: AnyUserSystemDescriptor): string => {\n const base = descriptor.endpoints.base\n if (base !== null) return base.post\n const anzuUser = descriptor.endpoints.anzuUser\n if (anzuUser === null) {\n throw new Error(`[userSystemDescriptor] '${descriptor.system}' has no create path.`)\n }\n return anzuUser.post\n}\n"],"mappings":";AA4GA,IAAaA,KACXC,MAC4BA,GAGjBC,KAAsBD,GAAqCE,MACtEF,EAAW,WAAWE,CAAM,MAAM,IAMvBC,KAAwBH,MAA8D;CACjG,IAAMI,IAAOJ,EAAW,UAAUA,EAAW,UAAU;CACvD,IAAII,MAAS,MACX,MAAU,MACR,2BAA2BJ,EAAW,OAAO,iBAAiBA,EAAW,UAAU,MAAM,2BAC3F;CAEF,OAAOI;AACT,GAMaC,KACXL,MACgG;CAChG,IAAMM,IAAON,EAAW,UAAU;CAClC,IAAIM,MAAS,MAAM,OAAO;EAAE,QAAQ;EAAS,KAAKA,EAAK;EAAK,KAAKA,EAAK;CAAM;CAC5E,IAAMC,IAAWP,EAAW,UAAU;CACtC,IAAIO,MAAa,MACf,MAAU,MAAM,2BAA2BP,EAAW,OAAO,0BAA0B;CAEzF,OAAO;EAAE,QAAQ;EAAO,KAAKO,EAAS;EAAK,KAAKA,EAAS;CAAI;AAC/D,GAMaC,KAAuBR,MAAsE;CACxG,IAAMM,IAAON,EAAW,UAAU;CAClC,IAAIM,MAAS,MAAM,OAAO;EAAE,KAAKA,EAAK;EAAK,KAAKA,EAAK;CAAI;CACzD,IAAMC,IAAWP,EAAW,UAAU;CACtC,IAAIO,MAAa,MACf,MAAU,MAAM,2BAA2BP,EAAW,OAAO,0BAA0B;CAEzF,OAAO;EAAE,KAAKO,EAAS;EAAK,KAAKA,EAAS;CAAI;AAChD,GAGaE,KAAyBT,MAAgD;CACpF,IAAMM,IAAON,EAAW,UAAU;CAClC,IAAIM,MAAS,MAAM,OAAOA,EAAK;CAC/B,IAAMC,IAAWP,EAAW,UAAU;CACtC,IAAIO,MAAa,MACf,MAAU,MAAM,2BAA2BP,EAAW,OAAO,sBAAsB;CAErF,OAAOO,EAAS;AAClB"}
|
|
@@ -24,8 +24,7 @@ type ListFields = typeof anzuUserListFields;
|
|
|
24
24
|
export declare const anzuUserFilterStorageKey: (system: string) => string;
|
|
25
25
|
/**
|
|
26
26
|
* Common fields plus per-system extras.
|
|
27
|
-
* Extras are a parameter because
|
|
28
|
-
* with `memberOf`, dam with `custom`, and only cms has `allowedSites`.
|
|
27
|
+
* Extras are a parameter because each system adds its own and picks its groups from its own backend.
|
|
29
28
|
* Extra fields render automatically; a custom widget goes through the matching slot.
|
|
30
29
|
*/
|
|
31
30
|
export declare function useAnzuUserListFilter<E extends readonly MakeFilterOption[] = []>(system: string, extraFields?: E): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anzuUserFilter.js","names":["createFilter","createFilterStore","ANZU_USER_ENTITY","anzuUserListFields","listStores","anzuUserFilterStorageKey","system","useAnzuUserListFilter","extraFields","extras","fields","key","field","store","filterConfig","filterData","useAnzuUserEmailLookupFilter"],"sources":["../../../../src/domains/anzuUser/filter/anzuUserFilter.ts"],"sourcesContent":["import {\n createFilter,\n createFilterStore,\n type FilterConfig,\n type FilterData,\n type MakeFilterOption,\n} from '@/domains/filters/composables/filterFactory'\nimport { ANZU_USER_ENTITY } from '@/domains/anzuUser/api/anzuUserApi'\n\nconst anzuUserListFields = [\n { name: 'id' as const, default: null, type: 'integer' },\n { name: 'email' as const, variant: 'startsWith', default: null, type: 'string', render: { skip: true } },\n { name: 'enabled' as const, default: null, type: 'boolean' },\n] satisfies readonly MakeFilterOption[]\n\ntype ListFields = typeof anzuUserListFields\n\n/** One store per system; see the note in `permissionGroupFilter`. */\nconst listStores = new Map<string, FilterData<readonly MakeFilterOption[]>>()\n\nexport const anzuUserFilterStorageKey = (system: string) => `commonAnzuUser_${system}`\n\n/**\n * Common fields plus per-system extras.\n * Extras are a parameter because
|
|
1
|
+
{"version":3,"file":"anzuUserFilter.js","names":["createFilter","createFilterStore","ANZU_USER_ENTITY","anzuUserListFields","listStores","anzuUserFilterStorageKey","system","useAnzuUserListFilter","extraFields","extras","fields","key","field","store","filterConfig","filterData","useAnzuUserEmailLookupFilter"],"sources":["../../../../src/domains/anzuUser/filter/anzuUserFilter.ts"],"sourcesContent":["import {\n createFilter,\n createFilterStore,\n type FilterConfig,\n type FilterData,\n type MakeFilterOption,\n} from '@/domains/filters/composables/filterFactory'\nimport { ANZU_USER_ENTITY } from '@/domains/anzuUser/api/anzuUserApi'\n\nconst anzuUserListFields = [\n { name: 'id' as const, default: null, type: 'integer' },\n { name: 'email' as const, variant: 'startsWith', default: null, type: 'string', render: { skip: true } },\n { name: 'enabled' as const, default: null, type: 'boolean' },\n] satisfies readonly MakeFilterOption[]\n\ntype ListFields = typeof anzuUserListFields\n\n/** One store per system; see the note in `permissionGroupFilter`. */\nconst listStores = new Map<string, FilterData<readonly MakeFilterOption[]>>()\n\nexport const anzuUserFilterStorageKey = (system: string) => `commonAnzuUser_${system}`\n\n/**\n * Common fields plus per-system extras.\n * Extras are a parameter because each system adds its own and picks its groups from its own backend.\n * Extra fields render automatically; a custom widget goes through the matching slot.\n */\nexport function useAnzuUserListFilter<E extends readonly MakeFilterOption[] = []>(\n system: string,\n extraFields?: E\n): {\n filterConfig: FilterConfig<readonly [...ListFields, ...E]>\n filterData: FilterData<readonly [...ListFields, ...E]>\n} {\n const extras = (extraFields ?? []) as readonly MakeFilterOption[]\n const fields = [...anzuUserListFields, ...extras] as unknown as readonly [...ListFields, ...E]\n // Extras are part of the store key. A shared store would carry a value the other list cannot clear.\n const key = [system, ...extras.map((field) => field.name)].join('|')\n\n let store = listStores.get(key)\n if (!store) {\n store = createFilterStore(fields) as FilterData<readonly MakeFilterOption[]>\n listStores.set(key, store)\n }\n\n const { filterConfig, filterData } = createFilter(fields, store as FilterData<readonly [...ListFields, ...E]>, {\n system: 'common',\n subject: ANZU_USER_ENTITY,\n })\n\n return { filterConfig, filterData }\n}\n\n/**\n * Exact e-mail match for cross-system search.\n * `startsWith` would match `jozko@sme.sk` to `jozko.mrkvicka@sme.sk` and report the wrong identity.\n */\nexport function useAnzuUserEmailLookupFilter() {\n const fields = [\n { name: 'email' as const, variant: 'eq', default: null, type: 'string' },\n ] satisfies readonly MakeFilterOption[]\n\n const { filterConfig, filterData } = createFilter(fields, createFilterStore(fields), {\n system: 'common',\n subject: ANZU_USER_ENTITY,\n })\n\n return { filterConfig, filterData }\n}\n\n/** Test seam; the list stores are module state. */\nexport const resetAnzuUserListFilters = () => {\n listStores.clear()\n}\n"],"mappings":";;;AASA,IAAMG,IAAqB;CACzB;EAAE,MAAM;EAAe,SAAS;EAAM,MAAM;CAAU;CACtD;EAAE,MAAM;EAAkB,SAAS;EAAc,SAAS;EAAM,MAAM;EAAU,QAAQ,EAAE,MAAM,GAAK;CAAE;CACvG;EAAE,MAAM;EAAoB,SAAS;EAAM,MAAM;CAAU;AAC7D,GAKMC,oBAAa,IAAI,IAAqD,GAE/DC,KAA4BC,MAAmB,kBAAkBA;AAO9E,SAAgBC,EACdD,GACAE,GAIA;CACA,IAAMC,IAAUD,KAAe,CAAC,GAC1BE,IAAS,CAAC,GAAGP,GAAoB,GAAGM,CAAM,GAE1CE,IAAM,CAACL,GAAQ,GAAGG,EAAO,KAAKG,MAAUA,EAAM,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,GAE/DC,IAAQT,EAAW,IAAIO,CAAG;CACzBE,MACHA,IAAQZ,EAAkBS,CAAM,GAChCN,EAAW,IAAIO,GAAKE,CAAK;CAG3B,IAAM,EAAEC,iBAAcC,kBAAef,EAAaU,GAAQG,GAAqD;EAC7G,QAAQ;EACR,SAASX;CACX,CAAC;CAED,OAAO;EAAEY;EAAcC;CAAW;AACpC;AAMA,SAAgBC,IAA+B;CAC7C,IAAMN,IAAS,CACb;EAAE,MAAM;EAAkB,SAAS;EAAM,SAAS;EAAM,MAAM;CAAS,CACzE,GAEM,EAAEI,iBAAcC,kBAAef,EAAaU,GAAQT,EAAkBS,CAAM,GAAG;EACnF,QAAQ;EACR,SAASR;CACX,CAAC;CAED,OAAO;EAAEY;EAAcC;CAAW;AACpC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { computed as e, createBlock as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createTextVNode as a, createVNode as o, defineComponent as s, mergeProps as ee, onBeforeUnmount as
|
|
1
|
+
import { computed as e, createBlock as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createTextVNode as a, createVNode as o, defineComponent as s, mergeProps as c, normalizeClass as ee, onBeforeUnmount as l, openBlock as u, ref as d, resolveComponent as te, toDisplayString as f, toRaw as p, unref as m, vShow as ne, watch as re, withCtx as h, withDirectives as ie, withModifiers as g } from "vue";
|
|
2
2
|
import { useUploadQueueDialog as ae, useUploadQueueDialogDrawn as oe } from "../composables/useUploadQueueDialog.js";
|
|
3
3
|
import { useI18n as se } from "vue-i18n";
|
|
4
4
|
import ce from "./UploadQueueEditable2.vue.js";
|
|
5
|
-
import { useUploadQueuesStore as
|
|
6
|
-
import { useDisplay as
|
|
7
|
-
import { useTheme as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { useAlerts as
|
|
11
|
-
import { bulkUpdateAssetsMetadata as v, fetchAsset as
|
|
12
|
-
import { useCommonAdminCoreDamOptions as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { UploadQueueItemStatus as
|
|
5
|
+
import { useUploadQueuesStore as _ } from "../store/uploadQueuesStore.js";
|
|
6
|
+
import { useDisplay as le } from "vuetify";
|
|
7
|
+
import { useTheme as ue } from "../../../system/composables/themeSettings.js";
|
|
8
|
+
import de from "./UploadQueueButtonStop2.vue.js";
|
|
9
|
+
import fe from "@vuelidate/core";
|
|
10
|
+
import { useAlerts as pe } from "../../../system/composables/alerts.js";
|
|
11
|
+
import { bulkUpdateAssetsMetadata as v, fetchAsset as me, hasMetadataToSave as he, showMetadataSaveError as y } from "../../api/damAssetApi.js";
|
|
12
|
+
import { useCommonAdminCoreDamOptions as ge } from "../../composables/commonAdminCoreDamOptions.js";
|
|
13
|
+
import _e from "../../../ui/file/components/AFileInput2.vue.js";
|
|
14
|
+
import ve from "../../../ui/file/components/AFileDropzone3.vue.js";
|
|
15
|
+
import { UploadQueueItemStatus as b } from "../../types/UploadQueue.js";
|
|
16
16
|
import { generateUUIDv1 as ye } from "../../../../shared/utils/generator.js";
|
|
17
17
|
import { mapUploadMetadataToImages as be } from "../../imageWidget/utils/metadataToImageMap.js";
|
|
18
18
|
import { hasNoDamCredit as xe, useDamCreditConfig as Se } from "../../author/composables/damCredit.js";
|
|
@@ -20,22 +20,19 @@ import { storeToRefs as Ce } from "pinia";
|
|
|
20
20
|
import { useAssetDetailStore as we } from "../../assetDetail/store/assetDetailStore.js";
|
|
21
21
|
import { useDamConfigName as Te } from "../../composables/damConfigName.js";
|
|
22
22
|
import { isNull as Ee } from "../../../../shared/utils/common.js";
|
|
23
|
-
import { VBtn as
|
|
23
|
+
import { VBtn as x } from "vuetify/components/VBtn";
|
|
24
24
|
import { VCard as De } from "vuetify/components/VCard";
|
|
25
25
|
import { VDialog as Oe } from "vuetify/components/VDialog";
|
|
26
|
-
import { VDivider as
|
|
27
|
-
import { VSpacer as
|
|
28
|
-
import { VIcon as
|
|
29
|
-
import { VProgressCircular as
|
|
30
|
-
import { VToolbar as
|
|
26
|
+
import { VDivider as S } from "vuetify/components/VDivider";
|
|
27
|
+
import { VSpacer as C } from "vuetify/components/VGrid";
|
|
28
|
+
import { VIcon as w } from "vuetify/components/VIcon";
|
|
29
|
+
import { VProgressCircular as T } from "vuetify/components/VProgressCircular";
|
|
30
|
+
import { VToolbar as ke } from "vuetify/components/VToolbar";
|
|
31
31
|
import { VTooltip as E } from "vuetify/components/VTooltip";
|
|
32
32
|
// src/domains/dam/uploadQueue/components/UploadQueueDialog.vue?vue&type=script&setup=true&lang.ts
|
|
33
|
-
var
|
|
33
|
+
var Ae = { class: "asset-footer__upload asset-footer--full asset-footer__upload--full pa-0" }, je = { class: "d-flex w-100 h-100 flex-column" }, Me = { class: "d-flex align-center px-2" }, Ne = {
|
|
34
34
|
key: 0,
|
|
35
35
|
class: "text-label-large d-flex align-center"
|
|
36
|
-
}, Ne = {
|
|
37
|
-
key: 1,
|
|
38
|
-
class: "text-label-large d-flex align-center text-green-darken-3 font-weight-bold"
|
|
39
36
|
}, Pe = {
|
|
40
37
|
key: 0,
|
|
41
38
|
class: "text-body-small d-flex align-center"
|
|
@@ -56,42 +53,42 @@ var ke = { class: "asset-footer__upload asset-footer--full asset-footer__upload-
|
|
|
56
53
|
"apply"
|
|
57
54
|
],
|
|
58
55
|
setup(s, { emit: D }) {
|
|
59
|
-
let O = s, k = D, A = Te(O.configName), Ie = Se(A), { uploadQueueDialog: j, uploadQueueDialogSaving: M, uploadQueueSidebar: N, toggleUploadQueueSidebar:
|
|
56
|
+
let O = s, k = D, A = Te(O.configName), Ie = Se(A), { uploadQueueDialog: j, uploadQueueDialogSaving: M, uploadQueueSidebar: N, toggleUploadQueueSidebar: Le } = ae(), P = _(), F = e(() => P.getQueueTotalCount(O.queueKey)), I = e(() => P.getQueueItems(O.queueKey)), L = e(() => P.getQueueProcessedCount(O.queueKey)), R = e(() => F.value > L.value), Re = e(() => F.value === L.value), z = e(() => I.value.filter((e) => e.status === b.Failed).length), ze = e(() => z.value === 0 ? "text-green-darken-3" : z.value === I.value.length ? "text-error" : "text-deep-orange-darken-4"), Be = e(() => !I.value.some(he)), B = (e) => e.status === b.Uploaded, Ve = e(() => !I.value.some(B)), He = (e) => B(e) && !e.canEditMetadata && !Ee(e.assetId), { t: V } = se(), { toolbarColor: Ue } = ue(), { mdAndDown: We } = le(), H = fe({ $stopPropagation: !0 }), { showRecordWas: Ge, showValidationError: U, showErrorsDefault: W, showWarningT: G } = pe(), { damClient: K, endPointAsset: q, endPointAuthor: Ke, customUploadMetadataToImageMap: J } = ge(A), Y = d(!1), X = d(!1);
|
|
60
57
|
re(() => Y.value || X.value, (e) => {
|
|
61
58
|
M.value = e ? O.queueKey : null;
|
|
62
59
|
}, { flush: "sync" });
|
|
63
60
|
let Z = !1;
|
|
64
|
-
|
|
61
|
+
l(() => {
|
|
65
62
|
Z = !0, M.value === O.queueKey && (M.value = null);
|
|
66
63
|
}), oe(O.queueKey);
|
|
67
|
-
let
|
|
68
|
-
|
|
69
|
-
}, Q = (e) => Promise.all(e.map((e) => e.assetId ? $.savingOf(e.assetId, A) : null)),
|
|
64
|
+
let qe = async () => {
|
|
65
|
+
P.stopUpload(O.queueKey), j.value = null;
|
|
66
|
+
}, Q = (e) => Promise.all(e.map((e) => e.assetId ? $.savingOf(e.assetId, A) : null)), Je = async () => {
|
|
70
67
|
if (Y.value || X.value) return;
|
|
71
|
-
let e =
|
|
68
|
+
let e = p(I.value);
|
|
72
69
|
if (e.length !== 0) {
|
|
73
70
|
if (Y.value = !0, H.value.$touch(), H.value.$invalid) U(), Y.value = !1;
|
|
74
71
|
else try {
|
|
75
|
-
await Q(e), await v(K, q, e, void 0, O.extSystem, A),
|
|
72
|
+
await Q(e), await v(K, q, e, void 0, O.extSystem, A), Ge("updated");
|
|
76
73
|
} catch (e) {
|
|
77
74
|
y(e, O.extSystem, A);
|
|
78
75
|
} finally {
|
|
79
76
|
Y.value = !1;
|
|
80
77
|
}
|
|
81
78
|
}
|
|
82
|
-
},
|
|
79
|
+
}, Ye = async () => {
|
|
83
80
|
if (Y.value || X.value) return;
|
|
84
|
-
let e =
|
|
81
|
+
let e = p(I.value);
|
|
85
82
|
if (e.length === 0) return;
|
|
86
83
|
X.value = !0;
|
|
87
|
-
let t = e.filter(
|
|
84
|
+
let t = e.filter(He);
|
|
88
85
|
if (t.length > 0) {
|
|
89
86
|
let e = j.value;
|
|
90
|
-
if (await Promise.all(t.map((e) =>
|
|
87
|
+
if (await Promise.all(t.map((e) => P.refreshAsset(e.assetId, { queueKey: O.queueKey }))), Z || j.value !== e) {
|
|
91
88
|
X.value = !1;
|
|
92
89
|
return;
|
|
93
90
|
}
|
|
94
|
-
if (t.some((e) =>
|
|
91
|
+
if (t.some((e) => P.isGivenUpMissing(e)) && G("common.damImage.queueItem.assetGone"), t.some((e) => e.canEditMetadata)) {
|
|
95
92
|
G("common.damImage.upload.metadataJustLoaded"), X.value = !1;
|
|
96
93
|
return;
|
|
97
94
|
}
|
|
@@ -105,7 +102,7 @@ var ke = { class: "asset-footer__upload asset-footer--full asset-footer__upload-
|
|
|
105
102
|
y(e, O.extSystem, A);
|
|
106
103
|
return;
|
|
107
104
|
}
|
|
108
|
-
let n = e.filter(B), r = J ? await J(n, t, K, O.extSystem, O.licenceId) : await be(n, t, K, O.extSystem, O.licenceId,
|
|
105
|
+
let n = e.filter(B), r = J ? await J(n, t, K, O.extSystem, O.licenceId) : await be(n, t, K, O.extSystem, O.licenceId, Ke, Ie(O.extSystem)), i = new Set(t.map((e) => e.id)), a = r.map((e) => ({
|
|
109
106
|
key: ye(),
|
|
110
107
|
...e,
|
|
111
108
|
damAuthors: e.authorIds ?? [],
|
|
@@ -119,73 +116,76 @@ var ke = { class: "asset-footer__upload asset-footer--full asset-footer__upload-
|
|
|
119
116
|
} finally {
|
|
120
117
|
X.value = !1;
|
|
121
118
|
}
|
|
122
|
-
}, $ = we(), { updateUploadStore:
|
|
123
|
-
|
|
119
|
+
}, $ = we(), { updateUploadStore: Xe } = Ce($), Ze = async (e) => {
|
|
120
|
+
Xe.value = !0;
|
|
124
121
|
try {
|
|
125
|
-
await $.open(O.queueKey, () =>
|
|
122
|
+
await $.open(O.queueKey, () => me(K, q, e));
|
|
126
123
|
} catch (e) {
|
|
127
124
|
W(e);
|
|
128
125
|
}
|
|
129
126
|
};
|
|
130
|
-
return (e,
|
|
131
|
-
let
|
|
132
|
-
return
|
|
127
|
+
return (e, l) => {
|
|
128
|
+
let d = te("ABtnPrimary");
|
|
129
|
+
return u(), t(Oe, {
|
|
133
130
|
"model-value": !0,
|
|
134
131
|
fullscreen: "",
|
|
135
132
|
scrollable: "",
|
|
136
133
|
class: "overlay--sidebar"
|
|
137
134
|
}, {
|
|
138
|
-
default:
|
|
139
|
-
default:
|
|
135
|
+
default: h(() => [o(De, null, {
|
|
136
|
+
default: h(() => [i("div", Ae, [i("div", je, [o(ke, {
|
|
140
137
|
class: "w-100 border-b pr-1",
|
|
141
|
-
color:
|
|
138
|
+
color: m(Ue),
|
|
142
139
|
density: "compact",
|
|
143
140
|
height: 64,
|
|
144
141
|
style: { "overflow-x": "auto" }
|
|
145
142
|
}, {
|
|
146
|
-
default:
|
|
147
|
-
i("div",
|
|
148
|
-
|
|
149
|
-
|
|
143
|
+
default: h(() => [
|
|
144
|
+
i("div", Me, [i("div", null, [R.value ? (u(), r("div", Ne, f(m(V)("common.damImage.upload.title")), 1)) : (u(), r("div", {
|
|
145
|
+
key: 1,
|
|
146
|
+
class: ee(["text-label-large d-flex align-center font-weight-bold", ze.value])
|
|
147
|
+
}, f(m(V)("common.damImage.upload.titleDone")), 3))])]),
|
|
148
|
+
o(C),
|
|
149
|
+
R.value ? (u(), r("div", Pe, [o(T, {
|
|
150
150
|
indeterminate: "",
|
|
151
151
|
color: "primary",
|
|
152
152
|
size: "16",
|
|
153
153
|
width: "2",
|
|
154
154
|
class: "mr-1"
|
|
155
|
-
}), i("div", null,
|
|
155
|
+
}), i("div", null, f(m(V)("common.damImage.upload.uploading")) + " " + f(L.value + 1) + "/" + f(F.value), 1)])) : n("", !0),
|
|
156
156
|
i("div", Fe, [
|
|
157
|
-
ie(o(
|
|
157
|
+
ie(o(S, {
|
|
158
158
|
vertical: "",
|
|
159
159
|
class: "mx-4 my-2"
|
|
160
|
-
}, null, 512), [[ne,
|
|
161
|
-
|
|
160
|
+
}, null, 512), [[ne, R.value]]),
|
|
161
|
+
Re.value ? (u(), t(d, {
|
|
162
162
|
key: 0,
|
|
163
163
|
height: 36,
|
|
164
164
|
class: "mr-2",
|
|
165
165
|
rounded: "pill",
|
|
166
166
|
loading: X.value,
|
|
167
|
-
disabled: Y.value ||
|
|
168
|
-
onClick:
|
|
167
|
+
disabled: Y.value || Ve.value,
|
|
168
|
+
onClick: g(Ye, ["stop"])
|
|
169
169
|
}, {
|
|
170
|
-
default:
|
|
170
|
+
default: h(() => [a(f(m(We) ? m(V)("common.damImage.upload.apply") : m(V)("common.damImage.upload.saveAndApply")), 1)]),
|
|
171
171
|
_: 1
|
|
172
172
|
}, 8, ["loading", "disabled"])) : n("", !0),
|
|
173
|
-
o(
|
|
174
|
-
"aria-label":
|
|
173
|
+
o(x, {
|
|
174
|
+
"aria-label": m(V)("common.damImage.upload.save"),
|
|
175
175
|
variant: "text",
|
|
176
176
|
height: 36,
|
|
177
177
|
width: 36,
|
|
178
178
|
class: "mr-2 text-medium-emphasis",
|
|
179
179
|
icon: "",
|
|
180
180
|
loading: Y.value,
|
|
181
|
-
disabled: X.value ||
|
|
182
|
-
onClick:
|
|
181
|
+
disabled: X.value || Be.value,
|
|
182
|
+
onClick: g(Je, ["stop"])
|
|
183
183
|
}, {
|
|
184
|
-
default:
|
|
184
|
+
default: h(() => [o(w, { icon: "mdi-content-save" }), o(E, {
|
|
185
185
|
activator: "parent",
|
|
186
186
|
location: "bottom"
|
|
187
187
|
}, {
|
|
188
|
-
default:
|
|
188
|
+
default: h(() => [a(f(m(V)("common.damImage.upload.save")), 1)]),
|
|
189
189
|
_: 1
|
|
190
190
|
})]),
|
|
191
191
|
_: 1
|
|
@@ -194,15 +194,15 @@ var ke = { class: "asset-footer__upload asset-footer--full asset-footer__upload-
|
|
|
194
194
|
"loading",
|
|
195
195
|
"disabled"
|
|
196
196
|
]),
|
|
197
|
-
o(
|
|
197
|
+
o(_e, {
|
|
198
198
|
"file-input-key": s.fileInputKey,
|
|
199
199
|
accept: s.accept,
|
|
200
200
|
"max-sizes": s.maxSizes,
|
|
201
201
|
multiple: "",
|
|
202
|
-
onFilesInput:
|
|
202
|
+
onFilesInput: l[0] ||= (e) => k("filesInput", e)
|
|
203
203
|
}, {
|
|
204
|
-
activator:
|
|
205
|
-
"aria-label":
|
|
204
|
+
activator: h(({ props: e }) => [o(x, c({
|
|
205
|
+
"aria-label": m(V)("common.damImage.upload.add"),
|
|
206
206
|
icon: "",
|
|
207
207
|
variant: "text",
|
|
208
208
|
height: 34,
|
|
@@ -210,11 +210,11 @@ var ke = { class: "asset-footer__upload asset-footer--full asset-footer__upload-
|
|
|
210
210
|
class: "text-medium-emphasis",
|
|
211
211
|
disabled: Y.value || X.value
|
|
212
212
|
}, e), {
|
|
213
|
-
default:
|
|
213
|
+
default: h(() => [o(w, { icon: "mdi-plus" }), o(E, {
|
|
214
214
|
activator: "parent",
|
|
215
215
|
location: "bottom"
|
|
216
216
|
}, {
|
|
217
|
-
default:
|
|
217
|
+
default: h(() => [a(f(m(V)("common.damImage.upload.add")), 1)]),
|
|
218
218
|
_: 1
|
|
219
219
|
})]),
|
|
220
220
|
_: 1
|
|
@@ -225,26 +225,26 @@ var ke = { class: "asset-footer__upload asset-footer--full asset-footer__upload-
|
|
|
225
225
|
"accept",
|
|
226
226
|
"max-sizes"
|
|
227
227
|
]),
|
|
228
|
-
o(
|
|
228
|
+
o(S, {
|
|
229
229
|
vertical: "",
|
|
230
230
|
class: "mx-4 my-2"
|
|
231
231
|
}),
|
|
232
|
-
o(
|
|
233
|
-
"aria-label":
|
|
232
|
+
o(x, {
|
|
233
|
+
"aria-label": m(V)("common.damImage.asset.massOperations.title"),
|
|
234
234
|
height: 36,
|
|
235
235
|
width: 36,
|
|
236
|
-
active:
|
|
237
|
-
variant:
|
|
238
|
-
color:
|
|
236
|
+
active: m(N),
|
|
237
|
+
variant: m(N) ? "flat" : "text",
|
|
238
|
+
color: m(N) ? "secondary" : "",
|
|
239
239
|
class: "mr-2 text-medium-emphasis",
|
|
240
240
|
icon: "",
|
|
241
|
-
onClick:
|
|
241
|
+
onClick: g(m(Le), ["stop"])
|
|
242
242
|
}, {
|
|
243
|
-
default:
|
|
243
|
+
default: h(() => [o(w, { icon: "mdi-tag-text-outline" }), o(E, {
|
|
244
244
|
activator: "parent",
|
|
245
245
|
location: "bottom"
|
|
246
246
|
}, {
|
|
247
|
-
default:
|
|
247
|
+
default: h(() => [a(f(m(V)("common.damImage.asset.massOperations.title")), 1)]),
|
|
248
248
|
_: 1
|
|
249
249
|
})]),
|
|
250
250
|
_: 1
|
|
@@ -255,11 +255,11 @@ var ke = { class: "asset-footer__upload asset-footer--full asset-footer__upload-
|
|
|
255
255
|
"color",
|
|
256
256
|
"onClick"
|
|
257
257
|
]),
|
|
258
|
-
o(
|
|
258
|
+
o(de, {
|
|
259
259
|
"data-cy": "button-close",
|
|
260
260
|
"button-size": 36,
|
|
261
|
-
"is-uploading":
|
|
262
|
-
onConfirm:
|
|
261
|
+
"is-uploading": R.value,
|
|
262
|
+
onConfirm: qe
|
|
263
263
|
}, null, 8, ["is-uploading"])
|
|
264
264
|
])
|
|
265
265
|
]),
|
|
@@ -267,22 +267,22 @@ var ke = { class: "asset-footer__upload asset-footer--full asset-footer__upload-
|
|
|
267
267
|
}, 8, ["color"]), o(ce, {
|
|
268
268
|
"queue-key": s.queueKey,
|
|
269
269
|
"ext-system": s.extSystem,
|
|
270
|
-
"config-name":
|
|
271
|
-
"mass-operations":
|
|
272
|
-
onShowDetail:
|
|
270
|
+
"config-name": m(A),
|
|
271
|
+
"mass-operations": m(N),
|
|
272
|
+
onShowDetail: Ze
|
|
273
273
|
}, null, 8, [
|
|
274
274
|
"queue-key",
|
|
275
275
|
"ext-system",
|
|
276
276
|
"config-name",
|
|
277
277
|
"mass-operations"
|
|
278
|
-
])]), o(
|
|
278
|
+
])]), o(ve, {
|
|
279
279
|
variant: "fill",
|
|
280
280
|
transparent: "",
|
|
281
281
|
"hover-only": "",
|
|
282
282
|
accept: s.accept,
|
|
283
283
|
"max-sizes": s.maxSizes,
|
|
284
284
|
disabled: Y.value || X.value,
|
|
285
|
-
onDrop:
|
|
285
|
+
onDrop: l[1] ||= (e) => k("drop", e)
|
|
286
286
|
}, null, 8, [
|
|
287
287
|
"accept",
|
|
288
288
|
"max-sizes",
|