diff --git a/src/components/damImage/uploadQueue/components/ImageMassOperations.vue b/src/components/damImage/uploadQueue/components/ImageMassOperations.vue new file mode 100644 index 00000000..c9939cf7 --- /dev/null +++ b/src/components/damImage/uploadQueue/components/ImageMassOperations.vue @@ -0,0 +1,149 @@ + + + diff --git a/src/components/damImage/uploadQueue/components/ImageWidgetMultipleItem.vue b/src/components/damImage/uploadQueue/components/ImageWidgetMultipleItem.vue index 5f94e8b4..c1a909b2 100644 --- a/src/components/damImage/uploadQueue/components/ImageWidgetMultipleItem.vue +++ b/src/components/damImage/uploadQueue/components/ImageWidgetMultipleItem.vue @@ -81,6 +81,7 @@ const removeItem = () => { v-model="image.texts.description" :label="t('common.damImage.image.model.texts.description')" :help="t('common.damImage.image.help.texts.description')" + :v="v$.image.texts.description" /> diff --git a/src/components/damImage/uploadQueue/composables/imageMassOperations.ts b/src/components/damImage/uploadQueue/composables/imageMassOperations.ts new file mode 100644 index 00000000..5be2a1ec --- /dev/null +++ b/src/components/damImage/uploadQueue/composables/imageMassOperations.ts @@ -0,0 +1,31 @@ +import { isUndefined } from '@/utils/common' +import { useImageStore } from '@/components/damImage/uploadQueue/composables/imageStore' + +export function useImageMassOperations() { + const imageStore = useImageStore() + + const replaceEmptyDescription = (value: any, forceReplace = false) => { + const items = imageStore.images + for (let i = 0; i < items.length; i++) { + const item = items[i] + if (forceReplace || isUndefined(item.texts.description) || item.texts.description.length === 0) { + item.texts.description = value + } + } + } + + const replaceEmptySource = (value: any, forceReplace = false) => { + const items = imageStore.images + for (let i = 0; i < items.length; i++) { + const item = items[i] + if (forceReplace || isUndefined(item.texts.source) || item.texts.source.length === 0) { + item.texts.source = value + } + } + } + + return { + replaceEmptyDescription, + replaceEmptySource, + } +} diff --git a/src/components/damImage/uploadQueue/composables/uploadValidations.ts b/src/components/damImage/uploadQueue/composables/uploadValidations.ts index d06e3307..271bdc77 100644 --- a/src/components/damImage/uploadQueue/composables/uploadValidations.ts +++ b/src/components/damImage/uploadQueue/composables/uploadValidations.ts @@ -12,14 +12,14 @@ export const ADamKeywordCreateValidationScopeSymbol = Symbol.for('anzu:common:ke export const ADamAuthorCreateValidationScopeSymbol = Symbol.for('anzu:common:author-create-validation-scope') -const { required, maxLength } = useValidate() - -export function useImageValidation( - image: Ref, -) { +export function useImageValidation(image: Ref) { + const { required, maxLength } = useValidate() const rules = computed(() => ({ image: { texts: { + description: { + maxLength: maxLength(2000), + }, source: { required, maxLength: maxLength(255), diff --git a/src/lib.ts b/src/lib.ts index fcd86b60..3b660adf 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -84,6 +84,7 @@ import AImageWidget from '@/components/damImage/AImageWidget.vue' import AImageWidgetSimple from '@/components/damImage/AImageWidgetSimple.vue' import AImageWidgetMultiple from '@/components/damImage/AImageWidgetMultiple.vue' import AImageWidgetMultipleSimple from '@/components/damImage/AImageWidgetMultipleSimple.vue' +import ImageMassOperations from '@/components/damImage/uploadQueue/components/ImageMassOperations.vue' import AImagePublicInput from '@/components/damImage/AImagePublicInput.vue' import ACropperjs from '@/components/ACropperjs.vue' import ADatatable from '@/components/datatable/ADatatable.vue' @@ -591,6 +592,7 @@ export { AImageWidgetSimple, AImageWidgetMultiple, AImageWidgetMultipleSimple, + ImageMassOperations, AImagePublicInput, ACropperjs, ACollabLockedByUser,