Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
volar committed Dec 5, 2023
1 parent 388f88b commit 7f48d57
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ import type { SortableEvent } from 'sortablejs'
import { WIDGET_HTML_ID_PREFIX } from '@/components/sortable/sortableUtils'
import { fetchAuthorListByIds } from '@/components/damImage/uploadQueue/api/authorApi'
import { useI18n } from 'vue-i18n'
import useVuelidate from '@vuelidate/core'
import {
ADamAssetMetadataValidationScopeSymbol,
AImageMetadataValidationScopeSymbol
} from '@/components/damImage/uploadQueue/composables/uploadValidations'
const props = withDefaults(
defineProps<{
Expand Down Expand Up @@ -79,7 +84,7 @@ if (isUndefined(imageWidgetExtSystemConfig)) {
// eslint-disable-next-line vue/no-setup-props-reactivity-loss
const imageOptions = useCommonAdminImageOptions(props.configName)
const { imageClient } = imageOptions
const { showErrorsDefault } = useAlerts()
const { showErrorsDefault, showValidationError } = useAlerts()
const uploadButtonComponent = ref<InstanceType<any> | null>(null)
const { uploadSizes, uploadAccept } = useDamAcceptTypeAndSizeHelper(
Expand Down Expand Up @@ -233,7 +238,14 @@ const actionLibrary = () => {
assetSelectDialog.value = true
}
const v$ = useVuelidate({}, {}, { $scope: AImageMetadataValidationScopeSymbol })
const saveImages = async () => {
v$.value.$touch()
if (v$.value.$invalid) {
showValidationError()
return
}
try {
const resItems = await bulkUpdateImages(imageClient, toRaw(images.value))
const ids: IntegerId[] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import { isNull, isUndefined } from '@/utils/common'
import AActionDeleteButton from '@/components/buttons/action/AActionDeleteButton.vue'
import { HANDLE_CLASS } from '@/components/sortable/sortableActions'
import { useI18n } from 'vue-i18n'
import {
AImageMetadataValidationScopeSymbol,
useImageValidation
} from '@/components/damImage/uploadQueue/composables/uploadValidations'
const props = withDefaults(
defineProps<{
Expand All @@ -27,6 +31,8 @@ const { t } = useI18n()
const image = computed(() => imageStore.images[props.index])
const { v$ } = useImageValidation(image, AImageMetadataValidationScopeSymbol)
const onEditAsset = () => {
if (isNull(image.value) || isUndefined(image.value)) return
emit('editAsset', image.value.dam.damId)
Expand Down Expand Up @@ -88,6 +94,7 @@ const removeItem = () => {
<AFormTextarea
v-model="image.texts.source"
:label="t('common.damImage.image.model.texts.source')"
:v="v$.image.texts.source"
/>
</VCol>
</VRow>
Expand Down

0 comments on commit 7f48d57

Please sign in to comment.