@anzusystems/common-admin 2.0.0-rc.22 → 2.0.0-rc.24
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/AnzuSystemsCommonAdmin.d.ts +2 -0
- package/dist/AnzuSystemsCommonAdmin.js.map +1 -1
- package/dist/common-admin.css +1 -1
- package/dist/common-admin.js +33 -29
- package/dist/domains/dam/api/damAssetApi.d.ts +12 -5
- package/dist/domains/dam/api/damAssetApi.js +66 -55
- package/dist/domains/dam/api/damAssetApi.js.map +1 -1
- package/dist/domains/dam/assetDetail/components/AssetDetailSidebarMetadata.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/domains/dam/assetDetail/components/AssetDetailSidebarMetadata.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/assetDetail/components/AssetMetadata.vue_vue_type_script_setup_true_lang.js +100 -108
- package/dist/domains/dam/assetDetail/components/AssetMetadata.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/assetDetail/store/assetDetailStore.d.ts +2 -0
- package/dist/domains/dam/assetSelect/components/AAssetListInner.vue.d.ts +2 -0
- package/dist/domains/dam/assetSelect/components/AAssetSelect.vue.d.ts +1 -0
- package/dist/domains/dam/assetSelect/composables/assetSelectListActions.js +1 -1
- package/dist/domains/dam/assetSelect/composables/assetSelectListActions.js.map +1 -1
- package/dist/domains/dam/assetSelect/store/assetSelectStore.d.ts +112 -0
- package/dist/domains/dam/author/components/AuthorCreateButton.vue.d.ts +6 -0
- package/dist/domains/dam/author/components/AuthorCreateButton.vue_vue_type_script_setup_true_lang.js +13 -5
- package/dist/domains/dam/author/components/AuthorCreateButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/author/components/AuthorRemoteAutocompleteCachedAuthorChip.js +4 -2
- package/dist/domains/dam/author/components/AuthorRemoteAutocompleteCachedAuthorChip.js.map +1 -1
- package/dist/domains/dam/author/components/AuthorRemoteAutocompleteCachedAuthorChip.vue_vue_type_script_setup_true_lang.js +45 -39
- package/dist/domains/dam/author/components/AuthorRemoteAutocompleteCachedAuthorChip.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/author/components/AuthorRemoteAutocompleteWithCached.js +1 -1
- package/dist/domains/dam/author/components/AuthorRemoteAutocompleteWithCached.vue.d.ts +15 -2
- package/dist/domains/dam/author/components/AuthorRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js +118 -96
- package/dist/domains/dam/author/components/AuthorRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/author/components/DamAuthorFilterRemoteAutocomplete.vue.d.ts +3 -0
- package/dist/domains/dam/author/components/DamAuthorFilterRemoteAutocomplete.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/domains/dam/author/components/DamAuthorFilterRemoteAutocomplete.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/author/components/DamSourcesAuthorsFields.js +8 -0
- package/dist/domains/dam/author/components/DamSourcesAuthorsFields.js.map +1 -0
- package/dist/domains/dam/author/components/DamSourcesAuthorsFields.vue.d.ts +67 -0
- package/dist/domains/dam/author/components/DamSourcesAuthorsFields.vue_vue_type_script_setup_true_lang.js +144 -0
- package/dist/domains/dam/author/components/DamSourcesAuthorsFields.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/domains/dam/author/components/DamSourcesAuthorsRow.js +8 -0
- package/dist/domains/dam/author/components/DamSourcesAuthorsRow.js.map +1 -0
- package/dist/domains/dam/author/components/DamSourcesAuthorsRow.vue.d.ts +27 -0
- package/dist/domains/dam/author/components/DamSourcesAuthorsRow.vue_vue_type_script_setup_true_lang.js +47 -0
- package/dist/domains/dam/author/components/DamSourcesAuthorsRow.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/domains/dam/author/composables/authorActions.js +2 -1
- package/dist/domains/dam/author/composables/authorActions.js.map +1 -1
- package/dist/domains/dam/author/composables/authorFieldRouting.d.ts +15 -0
- package/dist/domains/dam/author/composables/authorFieldRouting.js +18 -0
- package/dist/domains/dam/author/composables/authorFieldRouting.js.map +1 -0
- package/dist/domains/dam/author/composables/authorValidation.js +1 -1
- package/dist/domains/dam/author/composables/authorValidation.js.map +1 -1
- package/dist/domains/dam/author/composables/cachedAuthors.js +4 -2
- package/dist/domains/dam/author/composables/cachedAuthors.js.map +1 -1
- package/dist/domains/dam/author/composables/damAuthorConfig.d.ts +5 -0
- package/dist/domains/dam/author/composables/damAuthorConfig.js +5 -2
- package/dist/domains/dam/author/composables/damAuthorConfig.js.map +1 -1
- package/dist/domains/dam/author/composables/damCredit.d.ts +35 -0
- package/dist/domains/dam/author/composables/damCredit.js +44 -0
- package/dist/domains/dam/author/composables/damCredit.js.map +1 -0
- package/dist/domains/dam/author/composables/damSourceConfig.d.ts +15 -0
- package/dist/domains/dam/author/composables/damSourceConfig.js +19 -0
- package/dist/domains/dam/author/composables/damSourceConfig.js.map +1 -0
- package/dist/domains/dam/author/factory/AuthorFactory.js +3 -1
- package/dist/domains/dam/author/factory/AuthorFactory.js.map +1 -1
- package/dist/domains/dam/author/filter/AuthorFilter.d.ts +38 -4
- package/dist/domains/dam/author/filter/AuthorFilter.js +20 -6
- package/dist/domains/dam/author/filter/AuthorFilter.js.map +1 -1
- package/dist/domains/dam/author/types/DamAuthor.d.ts +4 -0
- package/dist/domains/dam/composables/commonAdminCoreDamOptions.d.ts +1 -0
- package/dist/domains/dam/composables/commonAdminCoreDamOptions.js +1 -0
- package/dist/domains/dam/composables/commonAdminCoreDamOptions.js.map +1 -1
- package/dist/domains/dam/imageWidget/components/ImageDetailDialogMetadata.vue.d.ts +9 -1
- package/dist/domains/dam/imageWidget/components/ImageDetailDialogMetadata.vue_vue_type_script_setup_true_lang.js +206 -204
- package/dist/domains/dam/imageWidget/components/ImageDetailDialogMetadata.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/imageWidget/components/ImageMassOperations.vue_vue_type_script_setup_true_lang.js +165 -131
- package/dist/domains/dam/imageWidget/components/ImageMassOperations.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/imageWidget/components/ImageMediaWidgetInner.vue_vue_type_script_setup_true_lang.js +344 -335
- package/dist/domains/dam/imageWidget/components/ImageMediaWidgetInner.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/imageWidget/components/ImageWidgetInner.vue.d.ts +1 -0
- package/dist/domains/dam/imageWidget/components/ImageWidgetInner.vue_vue_type_script_setup_true_lang.js +251 -242
- package/dist/domains/dam/imageWidget/components/ImageWidgetInner.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleInner.vue.d.ts +1 -0
- package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleInner.vue_vue_type_script_setup_true_lang.js +308 -303
- package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleInner.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleItem.vue.d.ts +1 -0
- package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleItem.vue_vue_type_script_setup_true_lang.js +84 -87
- package/dist/domains/dam/imageWidget/components/ImageWidgetMultipleItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/imageWidget/composables/imageDialogDamAuthors.d.ts +6 -3
- package/dist/domains/dam/imageWidget/composables/imageDialogDamAuthors.js +82 -77
- package/dist/domains/dam/imageWidget/composables/imageDialogDamAuthors.js.map +1 -1
- package/dist/domains/dam/imageWidget/composables/useImageMassOperations.d.ts +2 -0
- package/dist/domains/dam/imageWidget/composables/useImageMassOperations.js +59 -37
- package/dist/domains/dam/imageWidget/composables/useImageMassOperations.js.map +1 -1
- package/dist/domains/dam/imageWidget/store/imageStore.d.ts +2 -0
- package/dist/domains/dam/imageWidget/utils/metadataToImageMap.d.ts +3 -1
- package/dist/domains/dam/imageWidget/utils/metadataToImageMap.js +13 -22
- package/dist/domains/dam/imageWidget/utils/metadataToImageMap.js.map +1 -1
- package/dist/domains/dam/keyword/components/KeywordRemoteAutocompleteWithCached.js +1 -1
- package/dist/domains/dam/keyword/components/KeywordRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/domains/dam/keyword/components/KeywordRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/types/Asset.d.ts +1 -0
- package/dist/domains/dam/types/Asset.js.map +1 -1
- package/dist/domains/dam/types/DamConfig.d.ts +6 -0
- package/dist/domains/dam/types/DamConfig.js.map +1 -1
- package/dist/domains/dam/types/ImageAware.d.ts +1 -0
- package/dist/domains/dam/types/UploadQueue.d.ts +1 -0
- package/dist/domains/dam/types/UploadQueue.js.map +1 -1
- package/dist/domains/dam/uploadQueue/components/AssetQueueSelectedSidebar.vue_vue_type_script_setup_true_lang.js +204 -175
- package/dist/domains/dam/uploadQueue/components/AssetQueueSelectedSidebar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/uploadQueue/components/UploadQueueDialog.vue_vue_type_script_setup_true_lang.js +67 -65
- package/dist/domains/dam/uploadQueue/components/UploadQueueDialog.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/uploadQueue/components/UploadQueueDialogSingle.vue_vue_type_script_setup_true_lang.js +71 -70
- package/dist/domains/dam/uploadQueue/components/UploadQueueDialogSingle.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/uploadQueue/components/UploadQueueDialogSingleSidebarMetadataContent.vue_vue_type_script_setup_true_lang.js +83 -91
- package/dist/domains/dam/uploadQueue/components/UploadQueueDialogSingleSidebarMetadataContent.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/uploadQueue/components/UploadQueueEditable.vue_vue_type_script_setup_true_lang.js +4 -0
- package/dist/domains/dam/uploadQueue/components/UploadQueueEditable.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/uploadQueue/components/UploadQueueItemEditable.vue.d.ts +10 -2
- package/dist/domains/dam/uploadQueue/components/UploadQueueItemEditable.vue_vue_type_script_setup_true_lang.js +178 -177
- package/dist/domains/dam/uploadQueue/components/UploadQueueItemEditable.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/dam/uploadQueue/components/uploadQueueBindings.d.ts +2 -0
- package/dist/domains/dam/uploadQueue/components/uploadQueueBindings.js +4 -3
- package/dist/domains/dam/uploadQueue/components/uploadQueueBindings.js.map +1 -1
- package/dist/domains/dam/uploadQueue/composables/uploadQueueMassOperations.d.ts +1 -0
- package/dist/domains/dam/uploadQueue/composables/uploadQueueMassOperations.js +11 -8
- package/dist/domains/dam/uploadQueue/composables/uploadQueueMassOperations.js.map +1 -1
- package/dist/domains/dam/uploadQueue/core/uploadQueueFill.d.ts +2 -0
- package/dist/domains/dam/uploadQueue/core/uploadQueueFill.js +4 -1
- package/dist/domains/dam/uploadQueue/core/uploadQueueFill.js.map +1 -1
- package/dist/domains/dam/uploadQueue/factory/UploadQueueItemFactory.js +1 -0
- package/dist/domains/dam/uploadQueue/factory/UploadQueueItemFactory.js.map +1 -1
- package/dist/domains/dam/uploadQueue/settlement/uploadSettle.js +4 -4
- package/dist/domains/dam/uploadQueue/settlement/uploadSettle.js.map +1 -1
- package/dist/domains/dam/uploadQueue/store/uploadQueuesStore.d.ts +1 -0
- package/dist/domains/dam/uploadQueue/store/uploadQueuesStore.js +7 -4
- package/dist/domains/dam/uploadQueue/store/uploadQueuesStore.js.map +1 -1
- package/dist/domains/filters/datatable/components/ADatatableSidePanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/filters/datatable/components/ALiveListingPill.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/remoteAutocomplete/components/AFormRemoteAutocompleteWithCached.vue.d.ts +3 -0
- package/dist/domains/remoteAutocomplete/components/AFormRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js +6 -2
- package/dist/domains/remoteAutocomplete/components/AFormRemoteAutocompleteWithCached.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/lib.d.ts +5 -1
- package/dist/locales/cs/common/assetSelect.js +1 -1
- package/dist/locales/cs/common/damImage.js +84 -10
- package/dist/locales/cs/common/damImage.js.map +1 -1
- package/dist/locales/cs.d.ts +6 -0
- package/dist/locales/en/common/assetSelect.js +1 -1
- package/dist/locales/en/common/damImage.js +84 -10
- package/dist/locales/en/common/damImage.js.map +1 -1
- package/dist/locales/en.d.ts +6 -0
- package/dist/locales/sk/common/assetSelect.js +1 -1
- package/dist/locales/sk/common/damImage.js +84 -10
- package/dist/locales/sk/common/damImage.js.map +1 -1
- package/dist/locales/sk.d.ts +6 -0
- package/dist/plugins/i18n.d.ts +6 -0
- package/package.json +26 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageWidgetMultipleItem.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_createVNode","AImageWidgetSimple","_unref","_component_VRow","_withCtx","_component_VCol","_createBlock","_component_VBtn","_withModifiers","_createTextVNode","_toDisplayString","AActionDeleteButton","AFormTextarea","ASystemEntityScope","AuthorRemoteAutocompleteWithCached","_component_VSwitch","AImageWidgetSimple_default","AFormTextarea_default","AActionDeleteButton_default","AuthorRemoteAutocompleteWithCached_default","ASystemEntityScope_default","_hoisted_1","_hoisted_2","_hoisted_3","ImageWidgetMultipleItem_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","damConfigName","useDamConfigName","imageStore","useImageStore","useI18n","useExtSystemIdForCached","authorConflicts","ref","image","computed","imageSourceRequired","isNull","isUndefined","useImageValidation","onEditAsset","removeItem","onSourceTyped","openBlock","createElementBlock","createElementVNode","createVNode","unref","VRow","withCtx","VCol","createCommentVNode","createBlock","VBtn","withModifiers","createTextVNode","toDisplayString","_cache","$event","t","v$","cachedExtSystemId","AImageMetadataValidationScopeSymbol","VSwitch"],"sources":["../../../../../src/domains/dam/imageWidget/components/ImageWidgetMultipleItem.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport AImageWidgetSimple from '@/domains/dam/imageWidget/components/AImageWidgetSimple.vue'\nimport { useImageStore } from '@/domains/dam/imageWidget/store/imageStore'\nimport { computed, ref } from 'vue'\nimport AFormTextarea from '@/domains/form/components/AFormTextarea.vue'\nimport type { DocId } from '@/shared/types/common'\nimport { isNull, isUndefined } from '@/shared/utils/common'\nimport AActionDeleteButton from '@/domains/ui/buttons/action/components/AActionDeleteButton.vue'\nimport { useI18n } from 'vue-i18n'\nimport { AImageMetadataValidationScopeSymbol, useImageValidation } from '@/domains/dam/composables/uploadValidations'\nimport AuthorRemoteAutocompleteWithCached from '@/domains/dam/author/components/AuthorRemoteAutocompleteWithCached.vue'\nimport ASystemEntityScope from '@/domains/form/components/ASystemEntityScope.vue'\nimport { useExtSystemIdForCached } from '@/domains/dam/composables/extSystemIdForCached'\nimport { useDamConfigName } from '@/domains/dam/composables/damConfigName'\n\nconst props = withDefaults(\n defineProps<{\n index: number\n authorEnabled: boolean\n showSourceEnabled?: boolean\n sourceLabel?: string\n editAssetLabel?: string\n readonly?: boolean\n configName?: string\n }>(),\n {\n readonly: false,\n configName: undefined,\n showSourceEnabled: true,\n sourceLabel: undefined,\n editAssetLabel: undefined,\n }\n)\n\nconst emit = defineEmits<{\n (e: 'editAsset', data: DocId): void\n (e: 'removeItem', index: number): void\n}>()\n// eslint-disable-next-line vue/no-setup-props-reactivity-loss\nconst damConfigName = useDamConfigName(props.configName)\n\nconst imageStore = useImageStore()\nconst { t } = useI18n()\n\nconst { cachedExtSystemId } = useExtSystemIdForCached(damConfigName)\nconst authorConflicts = ref<DocId[]>([])\n// `index` comes from the parent's v-for over these same images.\nconst image = computed(() => imageStore.images[props.index]!)\n\nconst imageSourceRequired = computed(() => {\n if (isNull(image.value) || isUndefined(image.value)) return true\n return !(image.value.showDamAuthors && props.authorEnabled)\n})\n\nconst { v$ } = useImageValidation(image, imageSourceRequired, damConfigName)\n\nconst onEditAsset = () => {\n if (isNull(image.value) || isUndefined(image.value)) return\n emit('editAsset', image.value.dam.damId)\n}\n\nconst removeItem = () => {\n emit('removeItem', props.index)\n}\n\n// A typed source belongs to the user, not to a pick. This holds even when the text equals the names a pick wrote.\nconst onSourceTyped = () => {\n if (isNull(image.value) || isUndefined(image.value)) return\n imageStore.forgetSourceOfPick(image.value)\n}\n</script>\n\n<template>\n <div class=\"asset-list-tiles__item\">\n <div class=\"asset-list-tiles__item-card\">\n <div class=\"ma-2\">\n <!-- No reorder controls here: the grid is `#view-body`, which SortableJS never binds to.\n Reordering lives in reorder mode. -->\n <AImageWidgetSimple\n :model-value=\"image.id\"\n :image=\"image\"\n :config-name=\"damConfigName\"\n />\n <VRow density=\"compact\">\n <VCol class=\"d-flex justify-space-between mt-1\">\n <VBtn\n v-if=\"!readonly\"\n variant=\"text\"\n size=\"small\"\n class=\"mb-2\"\n @click.stop=\"onEditAsset\"\n >\n {{ editAssetLabel }}\n </VBtn>\n <AActionDeleteButton\n v-if=\"!readonly\"\n variant=\"icon\"\n :size=\"30\"\n button-class=\"\"\n @delete-record=\"removeItem\"\n />\n </VCol>\n </VRow>\n <!-- `undefined`, not `false`, when editable: the fields then still follow a parent form's readonly and disabled. -->\n <VRow density=\"compact\">\n <VCol>\n <AFormTextarea\n v-model=\"image.texts.description\"\n :readonly=\"readonly || undefined\"\n :label=\"t('common.damImage.image.model.texts.description')\"\n :help=\"t('common.damImage.image.help.texts.description')\"\n :v=\"v$.image?.texts.description\"\n />\n </VCol>\n </VRow>\n <VRow\n v-if=\"image.showDamAuthors && authorEnabled\"\n density=\"compact\"\n >\n <VCol>\n <ASystemEntityScope\n subject=\"author\"\n system=\"dam\"\n >\n <AuthorRemoteAutocompleteWithCached\n v-model=\"image.damAuthors\"\n :disabled=\"readonly || undefined\"\n :ext-system=\"cachedExtSystemId\"\n :label=\"t('common.damImage.asset.model.authors')\"\n :author-conflicts=\"authorConflicts\"\n data-cy=\"custom-field-authors\"\n clearable\n multiple\n :validation-scope=\"AImageMetadataValidationScopeSymbol\"\n />\n </ASystemEntityScope>\n </VCol>\n </VRow>\n <VRow\n v-else\n density=\"compact\"\n >\n <VCol>\n <AFormTextarea\n v-model=\"image.texts.source\"\n :readonly=\"readonly || undefined\"\n :label=\"sourceLabel\"\n :v=\"v$.image?.texts.source\"\n @update:model-value=\"onSourceTyped\"\n />\n </VCol>\n </VRow>\n <VRow v-if=\"showSourceEnabled\">\n <VCol>\n <VSwitch\n v-model=\"image.flags.showSource\"\n :disabled=\"readonly || undefined\"\n :label=\"t('common.damImage.image.model.flags.showSource')\"\n density=\"compact\"\n hide-details\n />\n </VCol>\n </VRow>\n </div>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n.asset-list-tiles--thumbnail.a-sortable-widget__group {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n\n .asset-list-tiles__item {\n flex: 1 1 260px;\n min-width: 260px;\n max-width: 400px;\n\n img:not(.img-svg) {\n padding: 0;\n }\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAeA,IAAM6B,IAAQC,GAmBRC,IAAOH,GAKPI,IAAgBC,EAAiBJ,EAAM,UAAU,GAEjDK,IAAaC,EAAc,GAC3B,EAAE,SAAMC,EAAQ,GAEhB,EAAE,yBAAsBC,EAAwBL,CAAa,GAC7DM,IAAkBC,EAAa,CAAC,CAAC,GAEjCC,IAAQC,QAAeP,EAAW,OAAOL,EAAM,MAAO,GAEtDa,IAAsBD,QACtBE,EAAOH,EAAM,KAAK,KAAKI,EAAYJ,EAAM,KAAK,IAAU,KACrD,EAAEA,EAAM,MAAM,kBAAkBX,EAAM,cAC9C,GAEK,EAAE,UAAOgB,EAAmBL,GAAOE,GAAqBV,CAAa,GAErEc,UAAoB;GACxB,AAAIH,EAAOH,EAAM,KAAK,KAAKI,EAAYJ,EAAM,KA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,MAAM,MAAM,aAAUC;MAC9B,UAAUlC,EAAA,YAAY,KAAA;MACtB,OAAOzB,EAAA4D,CAAA,CAAC,CAAA,8CAAA;MACT,SAAQ;MACR,gBAAA"}
|
|
1
|
+
{"version":3,"file":"ImageWidgetMultipleItem.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_createVNode","AImageWidgetSimple","_unref","_component_VRow","_withCtx","_component_VCol","_createBlock","_component_VBtn","_withModifiers","_createTextVNode","_toDisplayString","AActionDeleteButton","AFormTextarea","DamSourcesAuthorsFields","_component_VSwitch","AImageWidgetSimple_default","AFormTextarea_default","AActionDeleteButton_default","DamSourcesAuthorsFields_default","_hoisted_1","_hoisted_2","_hoisted_3","ImageWidgetMultipleItem_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","damConfigName","useDamConfigName","imageStore","useImageStore","useI18n","useExtSystemIdForCached","authorConflicts","ref","image","computed","useDamConfigState","imageConfig","getDamConfigExtSystem","cachedExtSystemId","DamAssetType","showDamSelection","isNull","isUndefined","imageSourceRequired","useImageValidation","onEditAsset","removeItem","onSourceTyped","openBlock","createElementBlock","createElementVNode","createVNode","unref","VRow","withCtx","VCol","createCommentVNode","createBlock","VBtn","withModifiers","createTextVNode","toDisplayString","_cache","$event","t","v$","AImageMetadataValidationScopeSymbol","VSwitch"],"sources":["../../../../../src/domains/dam/imageWidget/components/ImageWidgetMultipleItem.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport AImageWidgetSimple from '@/domains/dam/imageWidget/components/AImageWidgetSimple.vue'\nimport { useImageStore } from '@/domains/dam/imageWidget/store/imageStore'\nimport { computed, ref } from 'vue'\nimport AFormTextarea from '@/domains/form/components/AFormTextarea.vue'\nimport type { DocId } from '@/shared/types/common'\nimport { isNull, isUndefined } from '@/shared/utils/common'\nimport AActionDeleteButton from '@/domains/ui/buttons/action/components/AActionDeleteButton.vue'\nimport { useI18n } from 'vue-i18n'\nimport { AImageMetadataValidationScopeSymbol, useImageValidation } from '@/domains/dam/composables/uploadValidations'\nimport DamSourcesAuthorsFields from '@/domains/dam/author/components/DamSourcesAuthorsFields.vue'\nimport { useDamConfigState } from '@/domains/dam/config/composables/damConfigState'\nimport { DamAssetType } from '@/domains/dam/types/Asset'\nimport { useExtSystemIdForCached } from '@/domains/dam/composables/extSystemIdForCached'\nimport { useDamConfigName } from '@/domains/dam/composables/damConfigName'\n\nconst props = withDefaults(\n defineProps<{\n index: number\n authorEnabled: boolean\n sourceEnabled: boolean\n showSourceEnabled?: boolean\n sourceLabel?: string\n editAssetLabel?: string\n readonly?: boolean\n configName?: string\n }>(),\n {\n readonly: false,\n configName: undefined,\n showSourceEnabled: true,\n sourceLabel: undefined,\n editAssetLabel: undefined,\n }\n)\n\nconst emit = defineEmits<{\n (e: 'editAsset', data: DocId): void\n (e: 'removeItem', index: number): void\n}>()\n// eslint-disable-next-line vue/no-setup-props-reactivity-loss\nconst damConfigName = useDamConfigName(props.configName)\n\nconst imageStore = useImageStore()\nconst { t } = useI18n()\n\nconst { cachedExtSystemId } = useExtSystemIdForCached(damConfigName)\nconst authorConflicts = ref<DocId[]>([])\n// `index` comes from the parent's v-for over these same images.\nconst image = computed(() => imageStore.images[props.index]!)\n\nconst { getDamConfigExtSystem } = useDamConfigState(undefined, damConfigName)\nconst imageConfig = computed(() => getDamConfigExtSystem(cachedExtSystemId.value)?.[DamAssetType.Image])\n\nconst showDamSelection = computed(() => {\n if (isNull(image.value) || isUndefined(image.value)) return false\n return image.value.showDamAuthors && (props.sourceEnabled || props.authorEnabled)\n})\n\nconst imageSourceRequired = computed(() => !showDamSelection.value)\n\nconst { v$ } = useImageValidation(image, imageSourceRequired, damConfigName)\n\nconst onEditAsset = () => {\n if (isNull(image.value) || isUndefined(image.value)) return\n emit('editAsset', image.value.dam.damId)\n}\n\nconst removeItem = () => {\n emit('removeItem', props.index)\n}\n\n// A typed source belongs to the user, not to a pick. This holds even when the text equals the names a pick wrote.\nconst onSourceTyped = () => {\n if (isNull(image.value) || isUndefined(image.value)) return\n imageStore.forgetSourceOfPick(image.value)\n}\n</script>\n\n<template>\n <div class=\"asset-list-tiles__item\">\n <div class=\"asset-list-tiles__item-card\">\n <div class=\"ma-2\">\n <!-- No reorder controls here: the grid is `#view-body`, which SortableJS never binds to.\n Reordering lives in reorder mode. -->\n <AImageWidgetSimple\n :model-value=\"image.id\"\n :image=\"image\"\n :config-name=\"damConfigName\"\n />\n <VRow density=\"compact\">\n <VCol class=\"d-flex justify-space-between mt-1\">\n <VBtn\n v-if=\"!readonly\"\n variant=\"text\"\n size=\"small\"\n class=\"mb-2\"\n @click.stop=\"onEditAsset\"\n >\n {{ editAssetLabel }}\n </VBtn>\n <AActionDeleteButton\n v-if=\"!readonly\"\n variant=\"icon\"\n :size=\"30\"\n button-class=\"\"\n @delete-record=\"removeItem\"\n />\n </VCol>\n </VRow>\n <!-- `undefined`, not `false`, when editable: the fields then still follow a parent form's readonly and disabled. -->\n <VRow density=\"compact\">\n <VCol>\n <AFormTextarea\n v-model=\"image.texts.description\"\n :readonly=\"readonly || undefined\"\n :label=\"t('common.damImage.image.model.texts.description')\"\n :help=\"t('common.damImage.image.help.texts.description')\"\n :v=\"v$.image?.texts.description\"\n />\n </VCol>\n </VRow>\n <DamSourcesAuthorsFields\n v-if=\"showDamSelection\"\n v-model:sources=\"image.damSources\"\n v-model:authors=\"image.damAuthors\"\n :disabled=\"readonly\"\n :ext-system=\"cachedExtSystemId\"\n :source-enabled=\"sourceEnabled\"\n :author-enabled=\"authorEnabled\"\n :source-required=\"!!imageConfig?.sources?.required\"\n :author-required=\"!!imageConfig?.authors?.required\"\n :validation-scope=\"AImageMetadataValidationScopeSymbol\"\n :author-conflicts=\"authorConflicts\"\n show-credit\n :credit-label=\"sourceLabel\"\n />\n <VRow\n v-else\n density=\"compact\"\n >\n <VCol>\n <AFormTextarea\n v-model=\"image.texts.source\"\n :readonly=\"readonly || undefined\"\n :label=\"sourceLabel\"\n :v=\"v$.image?.texts.source\"\n @update:model-value=\"onSourceTyped\"\n />\n </VCol>\n </VRow>\n <VRow v-if=\"showSourceEnabled\">\n <VCol>\n <VSwitch\n v-model=\"image.flags.showSource\"\n :disabled=\"readonly || undefined\"\n :label=\"t('common.damImage.image.model.flags.showSource')\"\n density=\"compact\"\n hide-details\n />\n </VCol>\n </VRow>\n </div>\n </div>\n </div>\n</template>\n\n<style lang=\"scss\">\n.asset-list-tiles--thumbnail.a-sortable-widget__group {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n\n .asset-list-tiles__item {\n flex: 1 1 260px;\n min-width: 260px;\n max-width: 400px;\n\n img:not(.img-svg) {\n padding: 0;\n }\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBA,IAAM2B,IAAQC,GAoBRC,IAAOH,GAKPI,IAAgBC,EAAiBJ,EAAM,UAAU,GAEjDK,IAAaC,EAAc,GAC3B,EAAE,SAAMC,EAAQ,GAEhB,EAAE,yBAAsBC,EAAwBL,CAAa,GAC7DM,IAAkBC,EAAa,CAAC,CAAC,GAEjCC,IAAQC,QAAeP,EAAW,OAAOL,EAAM,MAAO,GAEtD,EAAE,6BAA0Ba,EAAkB,KAAA,GAAWV,CAAa,GACtEW,IAAcF,QAAeG,EAAsBC,EAAkB,KAAK,CAAC,GAAGC,EAAa,MAAM,GAEjGC,IAAmBN,QACnBO,EAAOR,EAAM,KAAK,KAAKS,EAAYT,EAAM,KAAK,IAAU,KACrDA,EAAM,MAAM,mBAAmBX,EAAM,iBAAiBA,EAAM,cACpE,GAEKqB,IAAsBT,QAAe,CAACM,EAAiB,KAAK,GAE5D,EAAE,UAAOI,EAAmBX,GAAOU,GAAqBlB,CAAa,GAErEoB,UAAoB;GACxB,AAAIJ,EAAOR,EAAM,KAAK,KAAKS,EAAYT,EAAM,KAAK,KAClDT,EAAK,aAAaS,EAAM,MAAM,IAAI,KAAK;EACzC,GAEMa,UAAmB;GACvB,EAAK,cAAcxB,E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6,7 +6,7 @@ interface HeldAsset {
|
|
|
6
6
|
/** The file the asset was read for, i.e. the file of the image made from that pick. */
|
|
7
7
|
file: DocId;
|
|
8
8
|
}
|
|
9
|
-
/** Result of re-reading the held asset: the asset with its
|
|
9
|
+
/** Result of re-reading the held asset: the asset with its credit, or the failure. */
|
|
10
10
|
export type HeldAssetAnew = {
|
|
11
11
|
of: HeldAsset;
|
|
12
12
|
asset: AssetDetailItemDto;
|
|
@@ -16,13 +16,14 @@ export type HeldAssetAnew = {
|
|
|
16
16
|
failure: unknown;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
* Fills an empty source with the
|
|
19
|
+
* Fills an empty source with the credit once the held asset turns out to have sources or authors.
|
|
20
20
|
* The pick creates the image with an empty source, and the dialog hides the source while it offers the pick.
|
|
21
21
|
* So an empty or whitespace-only source belongs to the pick. A non-empty source came from a save elsewhere and stays.
|
|
22
22
|
*/
|
|
23
23
|
export declare const giveNamesToEmptySource: (image: ImageCreateUpdateAware, names: string) => void;
|
|
24
24
|
/**
|
|
25
|
-
* DAM authors the single-image widget dialog offers in place of a source,
|
|
25
|
+
* DAM sources and authors the single-image widget dialog offers in place of a source,
|
|
26
|
+
* for a library-picked asset that has neither.
|
|
26
27
|
* The widget holds the asset and the file it was read for, and offers its authors only in that file's image dialog.
|
|
27
28
|
* Do not use the asset detail store: it is shared per page by the picker,
|
|
28
29
|
* detail and other widgets, which caused wrong authors to be saved.
|
|
@@ -391,6 +392,7 @@ export declare function useImageDialogDamAuthors(configName: string, shownImage:
|
|
|
391
392
|
} | null;
|
|
392
393
|
keywords: DocId[];
|
|
393
394
|
authors: DocId[];
|
|
395
|
+
sources: DocId[];
|
|
394
396
|
podcasts: DocId[];
|
|
395
397
|
metadata: {
|
|
396
398
|
authorSuggestions: import('../../types/Asset').AssetMetadataSuggestions;
|
|
@@ -421,6 +423,7 @@ export declare function useImageDialogDamAuthors(configName: string, shownImage:
|
|
|
421
423
|
offerDamAuthorsOf: (asset: AssetDetailItemDto, file: DocId) => void;
|
|
422
424
|
offerNoDamAuthors: () => void;
|
|
423
425
|
pickDamAuthors: (authors: DocId[]) => void;
|
|
426
|
+
pickDamSources: (sources: DocId[]) => void;
|
|
424
427
|
onAssetDetailClose: (shown: AssetDetailItemDto | null) => void;
|
|
425
428
|
holdConfirmForDetailAssetRead: (saving: boolean, again: () => void) => boolean;
|
|
426
429
|
readHeldAnew: (file: DocId | undefined) => Promise<HeldAssetAnew> | null;
|
|
@@ -1,102 +1,107 @@
|
|
|
1
1
|
import { fetchAsset as e } from "../../api/damAssetApi.js";
|
|
2
2
|
import { useAssetDetailStore as t } from "../../assetDetail/store/assetDetailStore.js";
|
|
3
|
-
import {
|
|
4
|
-
import { useCommonAdminCoreDamOptions as
|
|
5
|
-
import { useExtSystemIdForCached as
|
|
6
|
-
import { useDamConfigState as
|
|
7
|
-
import { useAlerts as
|
|
8
|
-
import { isNull as
|
|
9
|
-
import { WAIT_RAN_OUT as
|
|
10
|
-
import { computed as
|
|
3
|
+
import { fetchDamCredit as n, hasNoDamCredit as r, useDamCreditConfig as i } from "../../author/composables/damCredit.js";
|
|
4
|
+
import { useCommonAdminCoreDamOptions as a } from "../../composables/commonAdminCoreDamOptions.js";
|
|
5
|
+
import { useExtSystemIdForCached as o } from "../../composables/extSystemIdForCached.js";
|
|
6
|
+
import { useDamConfigState as s } from "../../config/composables/damConfigState.js";
|
|
7
|
+
import { useAlerts as c } from "../../../system/composables/alerts.js";
|
|
8
|
+
import { isNull as l } from "../../../../shared/utils/common.js";
|
|
9
|
+
import { WAIT_RAN_OUT as u, withinWaitLimit as d } from "../utils/waitLimit.js";
|
|
10
|
+
import { computed as f, onBeforeUnmount as p, ref as m, shallowRef as h, watch as g } from "vue";
|
|
11
11
|
// src/domains/dam/imageWidget/composables/imageDialogDamAuthors.ts
|
|
12
|
-
var
|
|
12
|
+
var _ = 4, v = (e, t) => {
|
|
13
13
|
e.texts.source.trim().length === 0 && (e.texts.source = t);
|
|
14
14
|
};
|
|
15
|
-
function
|
|
16
|
-
let { damClient:
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
function y(y, b, x) {
|
|
16
|
+
let { damClient: S, endPointAsset: C, endPointAuthor: w } = a(y), { getExtSystemByLicence: T } = s(S, y), E = i(y), { cachedExtSystemId: D } = o(y), O = t(), { showErrorsDefault: k, showErrorT: A, showUnknownError: j } = c(), M = m(null), N = !1;
|
|
17
|
+
p(() => {
|
|
18
|
+
N = !0;
|
|
19
19
|
});
|
|
20
|
-
let
|
|
21
|
-
let e =
|
|
22
|
-
return !
|
|
23
|
-
},
|
|
24
|
-
if (
|
|
25
|
-
let e =
|
|
26
|
-
return
|
|
27
|
-
}),
|
|
28
|
-
|
|
20
|
+
let P = () => {
|
|
21
|
+
let e = b();
|
|
22
|
+
return !l(M.value) && !l(e) && e.dam.damId === M.value.file ? e : null;
|
|
23
|
+
}, F = h(null), I = f(() => {
|
|
24
|
+
if (l(M.value)) return null;
|
|
25
|
+
let e = P();
|
|
26
|
+
return l(e) || e === F.value ? null : M.value.asset;
|
|
27
|
+
}), L = (e, t) => {
|
|
28
|
+
M.value = {
|
|
29
29
|
asset: e,
|
|
30
30
|
file: t
|
|
31
31
|
};
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
let t =
|
|
32
|
+
}, R = () => {
|
|
33
|
+
M.value = null;
|
|
34
|
+
}, z = (e) => {
|
|
35
|
+
let t = I.value;
|
|
36
36
|
t && (t.authors = e);
|
|
37
|
-
},
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
},
|
|
37
|
+
}, B = (e) => {
|
|
38
|
+
let t = I.value;
|
|
39
|
+
t && (t.sources = e);
|
|
40
|
+
}, V = async (e, t) => {
|
|
41
|
+
let r = await T(e.licence) ?? t;
|
|
42
|
+
return n(S, w, r, e.sources, e.authors, E(r, t));
|
|
43
|
+
}, H = async (t, n, i) => {
|
|
41
44
|
try {
|
|
42
45
|
await n;
|
|
43
|
-
let
|
|
46
|
+
let a = await e(S, C, t.asset.id), o = r(a.authors, a.sources) ? "" : await V(a, i), s = {
|
|
44
47
|
of: t,
|
|
45
|
-
asset:
|
|
46
|
-
names:
|
|
48
|
+
asset: a,
|
|
49
|
+
names: o
|
|
47
50
|
};
|
|
48
|
-
if (
|
|
49
|
-
if (
|
|
50
|
-
...
|
|
51
|
-
authors: t.asset.authors
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
if (N || x() || M.value !== t) return s;
|
|
52
|
+
if (r(a.authors, a.sources)) return t.asset = {
|
|
53
|
+
...a,
|
|
54
|
+
authors: t.asset.authors,
|
|
55
|
+
sources: t.asset.sources
|
|
56
|
+
}, s;
|
|
57
|
+
let c = P();
|
|
58
|
+
return l(c) || (M.value = null, v(c, o)), s;
|
|
55
59
|
} catch (e) {
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
let n =
|
|
59
|
-
return n && (
|
|
60
|
+
if (N) return null;
|
|
61
|
+
k(e);
|
|
62
|
+
let n = M.value === t ? P() : null;
|
|
63
|
+
return n && (F.value = n), null;
|
|
60
64
|
}
|
|
61
|
-
},
|
|
62
|
-
|
|
65
|
+
}, U = null, W = /* @__PURE__ */ new Map(), G = null, K = m(!1), q = () => {
|
|
66
|
+
G = null, K.value = !1;
|
|
63
67
|
};
|
|
64
|
-
return
|
|
65
|
-
|
|
68
|
+
return g(b, (e) => {
|
|
69
|
+
q(), e !== F.value && (F.value = null);
|
|
66
70
|
}, { flush: "sync" }), {
|
|
67
|
-
damAuthorsAsset:
|
|
68
|
-
offerDamAuthorsOf:
|
|
69
|
-
offerNoDamAuthors:
|
|
70
|
-
pickDamAuthors:
|
|
71
|
+
damAuthorsAsset: I,
|
|
72
|
+
offerDamAuthorsOf: L,
|
|
73
|
+
offerNoDamAuthors: R,
|
|
74
|
+
pickDamAuthors: z,
|
|
75
|
+
pickDamSources: B,
|
|
71
76
|
onAssetDetailClose: (e) => {
|
|
72
|
-
let t =
|
|
73
|
-
if (
|
|
74
|
-
let n = t.asset.id, r =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
let t = M.value;
|
|
78
|
+
if (l(e) || l(t) || l(P()) || x()) return;
|
|
79
|
+
let n = t.asset.id, r = O.savingOf(n, y), i = D.value, a = (W.get(n) ?? Promise.resolve()).then(() => H(t, r, i));
|
|
80
|
+
W.set(n, a), U = a, a.then(() => {
|
|
81
|
+
W.get(n) === a && W.delete(n), U === a && (U = null);
|
|
77
82
|
});
|
|
78
83
|
},
|
|
79
84
|
holdConfirmForDetailAssetRead: (e, t) => {
|
|
80
|
-
let n =
|
|
81
|
-
if (
|
|
82
|
-
if (e || !
|
|
83
|
-
let r =
|
|
84
|
-
return
|
|
85
|
-
|
|
85
|
+
let n = U;
|
|
86
|
+
if (l(n)) return !1;
|
|
87
|
+
if (e || !l(G)) return !0;
|
|
88
|
+
let r = G = Symbol("confirm");
|
|
89
|
+
return K.value = !0, d(n, _, y).then((e) => {
|
|
90
|
+
G === r && (q(), e === u ? N || A("error.apiTimedOut.message") : l(e) || t());
|
|
86
91
|
}), !0;
|
|
87
92
|
},
|
|
88
93
|
readHeldAnew: (t) => {
|
|
89
|
-
let n =
|
|
90
|
-
if (
|
|
91
|
-
let
|
|
92
|
-
return (
|
|
94
|
+
let n = M.value;
|
|
95
|
+
if (l(n) || n.file !== t || x()) return null;
|
|
96
|
+
let i = D.value;
|
|
97
|
+
return (U ?? Promise.resolve(null)).then(async (t) => {
|
|
93
98
|
if (t?.of === n) return t;
|
|
94
99
|
try {
|
|
95
|
-
let t = await e(
|
|
100
|
+
let t = await e(S, C, n.asset.id);
|
|
96
101
|
return {
|
|
97
102
|
of: n,
|
|
98
103
|
asset: t,
|
|
99
|
-
names: t.authors.
|
|
104
|
+
names: r(t.authors, t.sources) ? "" : await V(t, i)
|
|
100
105
|
};
|
|
101
106
|
} catch (e) {
|
|
102
107
|
return {
|
|
@@ -107,21 +112,21 @@ function _(_, v, y) {
|
|
|
107
112
|
});
|
|
108
113
|
},
|
|
109
114
|
takeHeldAnew: (e, t) => {
|
|
110
|
-
|
|
115
|
+
l(e) || N || x() || l(t) || t.dam.damId !== e.of.file || ("failure" in e ? (k(e.failure) || j(), M.value === e.of && (F.value = t)) : r(e.asset.authors, e.asset.sources) ? M.value === e.of && (e.of.asset = e.asset) : (M.value === e.of && (M.value = null), v(t, e.names)));
|
|
111
116
|
},
|
|
112
117
|
letGoOnceSavedWithSource: (e) => {
|
|
113
|
-
let t =
|
|
114
|
-
return
|
|
115
|
-
|
|
118
|
+
let t = M.value;
|
|
119
|
+
return l(t) || t.file !== e.dam.damId || !l(I.value) ? () => void 0 : () => {
|
|
120
|
+
M.value === t && (M.value = null);
|
|
116
121
|
};
|
|
117
122
|
},
|
|
118
123
|
authorsGivenMeanwhile: async (t) => {
|
|
119
|
-
let n =
|
|
120
|
-
return r.authors.
|
|
124
|
+
let n = D.value, i = await e(S, C, t.id);
|
|
125
|
+
return r(i.authors, i.sources) ? null : V(i, n);
|
|
121
126
|
},
|
|
122
|
-
confirmWaits:
|
|
127
|
+
confirmWaits: K
|
|
123
128
|
};
|
|
124
129
|
}
|
|
125
|
-
export {
|
|
130
|
+
export { v as giveNamesToEmptySource, y as useImageDialogDamAuthors };
|
|
126
131
|
|
|
127
132
|
//# sourceMappingURL=imageDialogDamAuthors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageDialogDamAuthors.js","names":["REQUESTS_OF_A_DETAIL_ASSET_READ","giveNamesToEmptySource","image","names","useImageDialogDamAuthors","useCommonAdminCoreDamOptions","configName","useDamConfigState","damClient","useExtSystemIdForCached","assetDetailStore","useAssetDetailStore","useAlerts","held","ref","unmounted","imageOfHeld","shownImage","isNull","staleIn","shallowRef","damAuthorsAsset","computed","offerDamAuthorsOf","offerNoDamAuthors","pickDamAuthors","asset","authors","namesOf","extSystem","getExtSystemByLicence","pageExtSystem","fetchAuthorListByIds","endPointAuthor","author","takeAuthorsOfDetailAsset","detailSave","fetchAsset","endPointAsset","of","source","read","readonly","detailAssetRead","detailAssetReads","waitingConfirm","confirmWaits","dropWaitingConfirm","watch","shown","assetId","cachedExtSystemId","saving","waiting","withinWaitLimit","answer","WAIT_RAN_OUT","showErrorT","again","file","afterDetail","failure","anew","showErrorsDefault","showUnknownError"],"sources":["../../../../../src/domains/dam/imageWidget/composables/imageDialogDamAuthors.ts"],"sourcesContent":["import { computed, onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport { fetchAsset } from '@/domains/dam/api/damAssetApi'\nimport { useAssetDetailStore } from '@/domains/dam/assetDetail/store/assetDetailStore'\nimport { fetchAuthorListByIds } from '@/domains/dam/author/api/authorApi'\nimport { useCommonAdminCoreDamOptions } from '@/domains/dam/composables/commonAdminCoreDamOptions'\nimport { useExtSystemIdForCached } from '@/domains/dam/composables/extSystemIdForCached'\nimport { useDamConfigState } from '@/domains/dam/config/composables/damConfigState'\nimport type { AssetDetailItemDto } from '@/domains/dam/types/Asset'\nimport type { ImageCreateUpdateAware } from '@/domains/dam/types/ImageAware'\nimport { useAlerts } from '@/domains/system/composables/alerts'\nimport type { DocId, IntegerId } from '@/shared/types/common'\nimport { isNull } from '@/shared/utils/common'\nimport { WAIT_RAN_OUT, withinWaitLimit } from '@/domains/dam/imageWidget/utils/waitLimit'\n\ninterface HeldAsset {\n asset: AssetDetailItemDto\n /** The file the asset was read for, i.e. the file of the image made from that pick. */\n file: DocId\n}\n\n/** Result of re-reading the held asset: the asset with its author names, or the failure. */\nexport type HeldAssetAnew =\n | { of: HeldAsset; asset: AssetDetailItemDto; names: string }\n | { of: HeldAsset; failure: unknown }\n\n/** Result of reading a held asset after its detail closed. */\ntype DetailAssetRead = { of: HeldAsset; asset: AssetDetailItemDto; names: string }\n\n// Sequential requests of a read after a detail closes: the rest of the detail save, the asset,\n// the asset licence (once per page), and the author names.\nconst REQUESTS_OF_A_DETAIL_ASSET_READ = 4\n\n/**\n * Fills an empty source with the authors' names once the held asset turns out to have authors.\n * The pick creates the image with an empty source, and the dialog hides the source while it offers the pick.\n * So an empty or whitespace-only source belongs to the pick. A non-empty source came from a save elsewhere and stays.\n */\nexport const giveNamesToEmptySource = (image: ImageCreateUpdateAware, names: string) => {\n if (image.texts.source.trim().length === 0) image.texts.source = names\n}\n\n/**\n * DAM authors the single-image widget dialog offers in place of a source, for a library-picked asset that has none.\n * The widget holds the asset and the file it was read for, and offers its authors only in that file's image dialog.\n * Do not use the asset detail store: it is shared per page by the picker,\n * detail and other widgets, which caused wrong authors to be saved.\n * `shownImage`: the image the widget dialog shows, or none.\n */\nexport function useImageDialogDamAuthors(\n configName: string,\n shownImage: () => ImageCreateUpdateAware | null,\n readonly: () => boolean\n) {\n const { damClient, endPointAsset, endPointAuthor } = useCommonAdminCoreDamOptions(configName)\n const { getExtSystemByLicence } = useDamConfigState(damClient, configName)\n const { cachedExtSystemId } = useExtSystemIdForCached(configName)\n const assetDetailStore = useAssetDetailStore()\n const { showErrorsDefault, showErrorT, showUnknownError } = useAlerts()\n\n const held = ref<HeldAsset | null>(null)\n // A read may end once the widget is gone.\n let unmounted = false\n onBeforeUnmount(() => {\n unmounted = true\n })\n\n /** The image the dialog shows, when it is the one the held asset was read for. */\n const imageOfHeld = () => {\n const image = shownImage()\n return !isNull(held.value) && !isNull(image) && image.dam.damId === held.value.file ? image : null\n }\n\n // The shown image after a read of the held asset for it failed. The held asset may then be stale.\n // The dialog shows the image source instead of the pick until it shows an image again.\n // Otherwise it kept offering the stale pick, and its confirm wrote nothing only after the user had picked.\n const staleIn = shallowRef<ImageCreateUpdateAware | null>(null)\n\n /**\n * The asset whose authors the dialog offers.\n * Null unless the dialog shows the image the asset was read for and the last read for that image has not failed.\n */\n const damAuthorsAsset = computed(() => {\n if (isNull(held.value)) return null\n const image = imageOfHeld()\n return isNull(image) || image === staleIn.value ? null : held.value.asset\n })\n\n const offerDamAuthorsOf = (asset: AssetDetailItemDto, file: DocId) => {\n held.value = { asset, file }\n }\n\n const offerNoDamAuthors = () => {\n held.value = null\n }\n\n const pickDamAuthors = (authors: DocId[]) => {\n const asset = damAuthorsAsset.value\n if (asset) asset.authors = authors\n }\n\n /**\n * Author names resolve under the ext system of the asset licence.\n * Falls back to `pageExtSystem` when the licence has none.\n */\n const namesOf = async (asset: AssetDetailItemDto, pageExtSystem: IntegerId) => {\n const extSystem = (await getExtSystemByLicence(asset.licence)) ?? pageExtSystem\n const authorsRes = await fetchAuthorListByIds(damClient, endPointAuthor, extSystem, asset.authors)\n return authorsRes.map((author) => author.name).join(', ')\n }\n\n /**\n * The \"edit asset\" detail may have added authors, so the asset is read again.\n * The read waits for the detail save that was pending on close. An earlier read returns the old asset.\n * If the asset now has authors, the author pick is dropped and an\n * empty image source takes their names. An existing source stays.\n * `pageExtSystem` is the ext system configured when the detail closed. It is used when the licence gives none.\n */\n const takeAuthorsOfDetailAsset = async (\n of: HeldAsset,\n detailSave: Promise<void> | null,\n pageExtSystem: IntegerId\n ): Promise<DetailAssetRead | null> => {\n try {\n await detailSave\n const asset = await fetchAsset(damClient, endPointAsset, of.asset.id)\n const source = asset.authors.length > 0 ? await namesOf(asset, pageExtSystem) : ''\n const read = { of, asset, names: source }\n // Unmounted, turned read-only, or now holding another pick's asset: write nothing.\n if (unmounted || readonly() || held.value !== of) return read\n if (asset.authors.length === 0) {\n of.asset = { ...asset, authors: of.asset.authors }\n return read\n }\n // Write only into the image the asset was read for. The dialog may have closed or show another image.\n // The widget keeps holding the asset, so \"edit image\" of that file re-reads\n // it and fills the empty source. Dropping it here left that source empty.\n const image = imageOfHeld()\n if (isNull(image)) return read\n held.value = null\n giveNamesToEmptySource(image, source)\n return read\n } catch (e) {\n if (unmounted) return null\n showErrorsDefault(e)\n const image = held.value === of ? imageOfHeld() : null\n if (image) staleIn.value = image\n return null\n }\n }\n\n // The latest pending read of an asset whose detail closed. \"Confirm\" waits for it, and \"edit image\" uses its result.\n let detailAssetRead: Promise<DetailAssetRead | null> | null = null\n // Pending detail-close reads, chained per asset. A read of another asset does not wait for them.\n const detailAssetReads = new Map<DocId, Promise<DetailAssetRead | null>>()\n // The confirm currently waiting for that read, if any.\n let waitingConfirm: symbol | null = null\n const confirmWaits = ref(false)\n const dropWaitingConfirm = () => {\n waitingConfirm = null\n confirmWaits.value = false\n }\n // A confirm belongs to the dialog opening it was pressed in. Drop it when the dialog closes or shows a new image.\n // Otherwise the read could answer after a reopen and confirm and save that opening without a press.\n watch(\n shownImage,\n (image) => {\n dropWaitingConfirm()\n if (image !== staleIn.value) staleIn.value = null\n },\n { flush: 'sync' }\n )\n\n /**\n * \"Confirm\" pressed while a just-closed detail's asset is still read. The read may change what\n * the form asks for, so the confirm waits (`true`) and `again` re-runs it after the read.\n * Repeated presses, or presses while `saving`, are ignored.\n * The wait is limited by `withinWaitLimit` over the read's sequential requests, so a slow\n * but answering DAM does not time out. On timeout the press is dropped and the user is told.\n * A failed read also drops the press. Otherwise it saved the image with the shown source, without the picked authors.\n */\n const holdConfirmForDetailAssetRead = (saving: boolean, again: () => void) => {\n const read = detailAssetRead\n if (isNull(read)) return false\n if (saving || !isNull(waitingConfirm)) return true\n const waiting = (waitingConfirm = Symbol('confirm'))\n confirmWaits.value = true\n void withinWaitLimit(read, REQUESTS_OF_A_DETAIL_ASSET_READ, configName).then((answer) => {\n if (waitingConfirm !== waiting) return\n dropWaitingConfirm()\n if (answer === WAIT_RAN_OUT) {\n if (!unmounted) showErrorT('error.apiTimedOut.message')\n return\n }\n if (isNull(answer)) return\n again()\n })\n return true\n }\n\n /**\n * `shown`: the asset the detail showed; none if it closed from its loader or after a failed read.\n * Reads only if the dialog offers this asset's authors. The read's inputs are captured before any await.\n */\n const onAssetDetailClose = (shown: AssetDetailItemDto | null) => {\n const of = held.value\n if (isNull(shown) || isNull(of) || isNull(imageOfHeld()) || readonly()) return\n const assetId = of.asset.id\n const detailSave = assetDetailStore.savingOf(assetId, configName)\n const pageExtSystem = cachedExtSystemId.value\n const read = (detailAssetReads.get(assetId) ?? Promise.resolve()).then(() =>\n takeAuthorsOfDetailAsset(of, detailSave, pageExtSystem)\n )\n detailAssetReads.set(assetId, read)\n detailAssetRead = read\n void read.then(() => {\n if (detailAssetReads.get(assetId) === read) detailAssetReads.delete(assetId)\n if (detailAssetRead === read) detailAssetRead = null\n })\n }\n\n /**\n * \"Edit image\" of `file`. The held asset is as it was at pick time and may have\n * gained authors since; confirming would overwrite them, so it is re-read first.\n * A pending detail-close read is newer and is reused. A failed one is retried.\n * Inputs are captured at the press because the read may drop the held asset.\n * Returns `null` if no asset is held for that file or the widget is read-only.\n */\n const readHeldAnew = (file: DocId | undefined): Promise<HeldAssetAnew> | null => {\n const of = held.value\n if (isNull(of) || of.file !== file || readonly()) return null\n const pageExtSystem = cachedExtSystemId.value\n return (detailAssetRead ?? Promise.resolve(null)).then(async (afterDetail) => {\n if (afterDetail?.of === of) return afterDetail\n try {\n const asset = await fetchAsset(damClient, endPointAsset, of.asset.id)\n return { of, asset, names: asset.authors.length > 0 ? await namesOf(asset, pageExtSystem) : '' }\n } catch (failure) {\n return { of, failure }\n }\n })\n }\n\n /**\n * Applies a `readHeldAnew` result to the shown image of that file.\n * Without authors the fresh asset becomes the held one, so picks from a dialog closed without confirm do not return.\n * With authors the pick goes and an empty source takes their names (`giveNamesToEmptySource`).\n * A failed read is reported once and the dialog shows the source until\n * a new image is shown. The asset stays held for the next \"edit image\".\n */\n const takeHeldAnew = (anew: HeldAssetAnew | null, image: ImageCreateUpdateAware | null) => {\n if (isNull(anew) || unmounted || readonly()) return\n if (isNull(image) || image.dam.damId !== anew.of.file) return\n if ('failure' in anew) {\n if (!showErrorsDefault(anew.failure)) showUnknownError()\n if (held.value === anew.of) staleIn.value = image\n return\n }\n if (anew.asset.authors.length === 0) {\n if (held.value === anew.of) anew.of.asset = anew.asset\n return\n }\n if (held.value === anew.of) held.value = null\n giveNamesToEmptySource(image, anew.names)\n }\n\n /**\n * On confirm of `image`: release the held asset after save if the dialog showed the source because a read failed.\n * Otherwise the next \"edit image\" re-read the asset, showed the pick again, and a confirm replaced the user's source.\n */\n const letGoOnceSavedWithSource = (image: ImageCreateUpdateAware) => {\n const of = held.value\n if (isNull(of) || of.file !== image.dam.damId || !isNull(damAuthorsAsset.value)) return () => undefined\n return () => {\n if (held.value === of) held.value = null\n }\n }\n\n /**\n * Read right before picked authors are written into `asset`. Returns names of authors\n * given elsewhere meanwhile, or `null` if none. Throws if they cannot be read.\n * Not atomic: an author added between this read and the write is still overwritten.\n */\n const authorsGivenMeanwhile = async (asset: AssetDetailItemDto) => {\n const pageExtSystem = cachedExtSystemId.value\n const read = await fetchAsset(damClient, endPointAsset, asset.id)\n return read.authors.length > 0 ? namesOf(read, pageExtSystem) : null\n }\n\n return {\n damAuthorsAsset,\n offerDamAuthorsOf,\n offerNoDamAuthors,\n pickDamAuthors,\n onAssetDetailClose,\n holdConfirmForDetailAssetRead,\n readHeldAnew,\n takeHeldAnew,\n letGoOnceSavedWithSource,\n authorsGivenMeanwhile,\n /** A confirm waits for the read of a just-closed detail's asset. Its button spins. */\n confirmWaits,\n }\n}\n"],"mappings":";;;;;;;;;;;AA8BA,IAAMA,IAAkC,GAO3BC,KAA0B,GAA+B,MAAkB;CACtF,AAAIC,EAAM,MAAM,OAAO,KAAK,CAAC,CAAC,WAAW,MAAG,EAAM,MAAM,SAASC;AACnE;AASA,SAAgBC,EACd,GACA,GACA,GACA;CACA,IAAM,EAAE,cAAW,kBAAe,sBAAmBC,EAA6BC,CAAU,GACtF,EAAE,6BAA0BC,EAAkBC,GAAWF,CAAU,GACnE,EAAE,yBAAsBG,EAAwBH,CAAU,GAC1DI,IAAmBC,EAAoB,GACvC,EAAE,sBAAmB,eAAY,wBAAqBC,EAAU,GAEhEC,IAAOC,EAAsB,IAAI,GAEnCC,IAAY;CAChB,QAAsB;EACpB,IAAY;CACd,CAAC;CAGD,IAAMC,UAAoB;EACxB,IAAMd,IAAQe,EAAW;EACzB,OAAO,CAACC,EAAOL,EAAK,KAAK,KAAK,CAACK,EAAOhB,CAAK,KAAKA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GAEhB,OADIK,EAAOqB,CAAE,KAAKA,EAAG,SAASrC,EAAM,IAAI,SAAS,CAACgB,EAAOG,EAAgB,KAAK,UAAgB,KAAA,UACjF;IACX,AAAIR,EAAK,UAAU0B,MAAI,EAAK,QAAQ;GACtC;EACF;EAuBE,8BAhBmC,MAA8B;GACjE,IAAMR,IAAgBoB,EAAkB,OAClCV,IAAO,MAAMJ,EAAW7B,GAAW8B,GAAeZ,EAAM,EAAE;GAChE,OAAOe,EAAK,QAAQ,SAAS,IAAIb,EAAQa,GAAMV,CAAa,IAAI;EAClE;EAcE;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"imageDialogDamAuthors.js","names":["REQUESTS_OF_A_DETAIL_ASSET_READ","giveNamesToEmptySource","image","names","useImageDialogDamAuthors","useCommonAdminCoreDamOptions","configName","useDamConfigState","damClient","creditConfigOf","useDamCreditConfig","useExtSystemIdForCached","assetDetailStore","useAssetDetailStore","useAlerts","held","ref","unmounted","imageOfHeld","shownImage","isNull","staleIn","shallowRef","damAuthorsAsset","computed","offerDamAuthorsOf","offerNoDamAuthors","pickDamAuthors","asset","authors","pickDamSources","sources","namesOf","extSystem","getExtSystemByLicence","pageExtSystem","fetchDamCredit","endPointAuthor","takeAuthorsOfDetailAsset","detailSave","fetchAsset","endPointAsset","of","source","hasNoDamCredit","read","readonly","detailAssetRead","detailAssetReads","waitingConfirm","confirmWaits","dropWaitingConfirm","watch","shown","assetId","cachedExtSystemId","saving","waiting","withinWaitLimit","answer","WAIT_RAN_OUT","showErrorT","again","file","afterDetail","failure","anew","showErrorsDefault","showUnknownError"],"sources":["../../../../../src/domains/dam/imageWidget/composables/imageDialogDamAuthors.ts"],"sourcesContent":["import { computed, onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport { fetchAsset } from '@/domains/dam/api/damAssetApi'\nimport { useAssetDetailStore } from '@/domains/dam/assetDetail/store/assetDetailStore'\nimport { fetchDamCredit, hasNoDamCredit, useDamCreditConfig } from '@/domains/dam/author/composables/damCredit'\nimport { useCommonAdminCoreDamOptions } from '@/domains/dam/composables/commonAdminCoreDamOptions'\nimport { useExtSystemIdForCached } from '@/domains/dam/composables/extSystemIdForCached'\nimport { useDamConfigState } from '@/domains/dam/config/composables/damConfigState'\nimport type { AssetDetailItemDto } from '@/domains/dam/types/Asset'\nimport type { ImageCreateUpdateAware } from '@/domains/dam/types/ImageAware'\nimport { useAlerts } from '@/domains/system/composables/alerts'\nimport type { DocId, IntegerId } from '@/shared/types/common'\nimport { isNull } from '@/shared/utils/common'\nimport { WAIT_RAN_OUT, withinWaitLimit } from '@/domains/dam/imageWidget/utils/waitLimit'\n\ninterface HeldAsset {\n asset: AssetDetailItemDto\n /** The file the asset was read for, i.e. the file of the image made from that pick. */\n file: DocId\n}\n\n/** Result of re-reading the held asset: the asset with its credit, or the failure. */\nexport type HeldAssetAnew =\n | { of: HeldAsset; asset: AssetDetailItemDto; names: string }\n | { of: HeldAsset; failure: unknown }\n\n/** Result of reading a held asset after its detail closed. */\ntype DetailAssetRead = { of: HeldAsset; asset: AssetDetailItemDto; names: string }\n\n// Sequential requests of a read after a detail closes: the rest of the detail save, the asset,\n// the asset licence (once per page), and the names of its sources and authors.\nconst REQUESTS_OF_A_DETAIL_ASSET_READ = 4\n\n/**\n * Fills an empty source with the credit once the held asset turns out to have sources or authors.\n * The pick creates the image with an empty source, and the dialog hides the source while it offers the pick.\n * So an empty or whitespace-only source belongs to the pick. A non-empty source came from a save elsewhere and stays.\n */\nexport const giveNamesToEmptySource = (image: ImageCreateUpdateAware, names: string) => {\n if (image.texts.source.trim().length === 0) image.texts.source = names\n}\n\n/**\n * DAM sources and authors the single-image widget dialog offers in place of a source,\n * for a library-picked asset that has neither.\n * The widget holds the asset and the file it was read for, and offers its authors only in that file's image dialog.\n * Do not use the asset detail store: it is shared per page by the picker,\n * detail and other widgets, which caused wrong authors to be saved.\n * `shownImage`: the image the widget dialog shows, or none.\n */\nexport function useImageDialogDamAuthors(\n configName: string,\n shownImage: () => ImageCreateUpdateAware | null,\n readonly: () => boolean\n) {\n const { damClient, endPointAsset, endPointAuthor } = useCommonAdminCoreDamOptions(configName)\n const { getExtSystemByLicence } = useDamConfigState(damClient, configName)\n const creditConfigOf = useDamCreditConfig(configName)\n const { cachedExtSystemId } = useExtSystemIdForCached(configName)\n const assetDetailStore = useAssetDetailStore()\n const { showErrorsDefault, showErrorT, showUnknownError } = useAlerts()\n\n const held = ref<HeldAsset | null>(null)\n // A read may end once the widget is gone.\n let unmounted = false\n onBeforeUnmount(() => {\n unmounted = true\n })\n\n /** The image the dialog shows, when it is the one the held asset was read for. */\n const imageOfHeld = () => {\n const image = shownImage()\n return !isNull(held.value) && !isNull(image) && image.dam.damId === held.value.file ? image : null\n }\n\n // The shown image after a read of the held asset for it failed. The held asset may then be stale.\n // The dialog shows the image source instead of the pick until it shows an image again.\n // Otherwise it kept offering the stale pick, and its confirm wrote nothing only after the user had picked.\n const staleIn = shallowRef<ImageCreateUpdateAware | null>(null)\n\n /**\n * The asset whose authors the dialog offers.\n * Null unless the dialog shows the image the asset was read for and the last read for that image has not failed.\n */\n const damAuthorsAsset = computed(() => {\n if (isNull(held.value)) return null\n const image = imageOfHeld()\n return isNull(image) || image === staleIn.value ? null : held.value.asset\n })\n\n const offerDamAuthorsOf = (asset: AssetDetailItemDto, file: DocId) => {\n held.value = { asset, file }\n }\n\n const offerNoDamAuthors = () => {\n held.value = null\n }\n\n const pickDamAuthors = (authors: DocId[]) => {\n const asset = damAuthorsAsset.value\n if (asset) asset.authors = authors\n }\n\n const pickDamSources = (sources: DocId[]) => {\n const asset = damAuthorsAsset.value\n if (asset) asset.sources = sources\n }\n\n /**\n * The credit resolves under the ext system of the asset licence: its names, and its format once loaded.\n * Falls back to `pageExtSystem` when the licence has none.\n */\n const namesOf = async (asset: AssetDetailItemDto, pageExtSystem: IntegerId) => {\n const extSystem = (await getExtSystemByLicence(asset.licence)) ?? pageExtSystem\n return fetchDamCredit(\n damClient,\n endPointAuthor,\n extSystem,\n asset.sources,\n asset.authors,\n creditConfigOf(extSystem, pageExtSystem)\n )\n }\n\n /**\n * The \"edit asset\" detail may have added sources or authors, so the asset is read again.\n * The read waits for the detail save that was pending on close. An earlier read returns the old asset.\n * If the asset now has either, the pick is dropped and an\n * empty image source takes their credit. An existing source stays.\n * `pageExtSystem` is the ext system configured when the detail closed. It is used when the licence gives none.\n */\n const takeAuthorsOfDetailAsset = async (\n of: HeldAsset,\n detailSave: Promise<void> | null,\n pageExtSystem: IntegerId\n ): Promise<DetailAssetRead | null> => {\n try {\n await detailSave\n const asset = await fetchAsset(damClient, endPointAsset, of.asset.id)\n const source = hasNoDamCredit(asset.authors, asset.sources) ? '' : await namesOf(asset, pageExtSystem)\n const read = { of, asset, names: source }\n // Unmounted, turned read-only, or now holding another pick's asset: write nothing.\n if (unmounted || readonly() || held.value !== of) return read\n if (hasNoDamCredit(asset.authors, asset.sources)) {\n of.asset = { ...asset, authors: of.asset.authors, sources: of.asset.sources }\n return read\n }\n // Write only into the image the asset was read for. The dialog may have closed or show another image.\n // The widget keeps holding the asset, so \"edit image\" of that file re-reads\n // it and fills the empty source. Dropping it here left that source empty.\n const image = imageOfHeld()\n if (isNull(image)) return read\n held.value = null\n giveNamesToEmptySource(image, source)\n return read\n } catch (e) {\n if (unmounted) return null\n showErrorsDefault(e)\n const image = held.value === of ? imageOfHeld() : null\n if (image) staleIn.value = image\n return null\n }\n }\n\n // The latest pending read of an asset whose detail closed. \"Confirm\" waits for it, and \"edit image\" uses its result.\n let detailAssetRead: Promise<DetailAssetRead | null> | null = null\n // Pending detail-close reads, chained per asset. A read of another asset does not wait for them.\n const detailAssetReads = new Map<DocId, Promise<DetailAssetRead | null>>()\n // The confirm currently waiting for that read, if any.\n let waitingConfirm: symbol | null = null\n const confirmWaits = ref(false)\n const dropWaitingConfirm = () => {\n waitingConfirm = null\n confirmWaits.value = false\n }\n // A confirm belongs to the dialog opening it was pressed in. Drop it when the dialog closes or shows a new image.\n // Otherwise the read could answer after a reopen and confirm and save that opening without a press.\n watch(\n shownImage,\n (image) => {\n dropWaitingConfirm()\n if (image !== staleIn.value) staleIn.value = null\n },\n { flush: 'sync' }\n )\n\n /**\n * \"Confirm\" pressed while a just-closed detail's asset is still read. The read may change what\n * the form asks for, so the confirm waits (`true`) and `again` re-runs it after the read.\n * Repeated presses, or presses while `saving`, are ignored.\n * The wait is limited by `withinWaitLimit` over the read's sequential requests, so a slow\n * but answering DAM does not time out. On timeout the press is dropped and the user is told.\n * A failed read also drops the press. Otherwise it saved the image with the shown source, without the picked authors.\n */\n const holdConfirmForDetailAssetRead = (saving: boolean, again: () => void) => {\n const read = detailAssetRead\n if (isNull(read)) return false\n if (saving || !isNull(waitingConfirm)) return true\n const waiting = (waitingConfirm = Symbol('confirm'))\n confirmWaits.value = true\n void withinWaitLimit(read, REQUESTS_OF_A_DETAIL_ASSET_READ, configName).then((answer) => {\n if (waitingConfirm !== waiting) return\n dropWaitingConfirm()\n if (answer === WAIT_RAN_OUT) {\n if (!unmounted) showErrorT('error.apiTimedOut.message')\n return\n }\n if (isNull(answer)) return\n again()\n })\n return true\n }\n\n /**\n * `shown`: the asset the detail showed; none if it closed from its loader or after a failed read.\n * Reads only if the dialog offers this asset's authors. The read's inputs are captured before any await.\n */\n const onAssetDetailClose = (shown: AssetDetailItemDto | null) => {\n const of = held.value\n if (isNull(shown) || isNull(of) || isNull(imageOfHeld()) || readonly()) return\n const assetId = of.asset.id\n const detailSave = assetDetailStore.savingOf(assetId, configName)\n const pageExtSystem = cachedExtSystemId.value\n const read = (detailAssetReads.get(assetId) ?? Promise.resolve()).then(() =>\n takeAuthorsOfDetailAsset(of, detailSave, pageExtSystem)\n )\n detailAssetReads.set(assetId, read)\n detailAssetRead = read\n void read.then(() => {\n if (detailAssetReads.get(assetId) === read) detailAssetReads.delete(assetId)\n if (detailAssetRead === read) detailAssetRead = null\n })\n }\n\n /**\n * \"Edit image\" of `file`. The held asset is as it was at pick time and may have\n * gained authors since; confirming would overwrite them, so it is re-read first.\n * A pending detail-close read is newer and is reused. A failed one is retried.\n * Inputs are captured at the press because the read may drop the held asset.\n * Returns `null` if no asset is held for that file or the widget is read-only.\n */\n const readHeldAnew = (file: DocId | undefined): Promise<HeldAssetAnew> | null => {\n const of = held.value\n if (isNull(of) || of.file !== file || readonly()) return null\n const pageExtSystem = cachedExtSystemId.value\n return (detailAssetRead ?? Promise.resolve(null)).then(async (afterDetail) => {\n if (afterDetail?.of === of) return afterDetail\n try {\n const asset = await fetchAsset(damClient, endPointAsset, of.asset.id)\n return {\n of,\n asset,\n names: hasNoDamCredit(asset.authors, asset.sources) ? '' : await namesOf(asset, pageExtSystem),\n }\n } catch (failure) {\n return { of, failure }\n }\n })\n }\n\n /**\n * Applies a `readHeldAnew` result to the shown image of that file.\n * Without sources and authors the fresh asset becomes the held one, so picks from a dialog closed without\n * confirm do not return. With either the pick goes and an empty source takes their credit (`giveNamesToEmptySource`).\n * A failed read is reported once and the dialog shows the source until\n * a new image is shown. The asset stays held for the next \"edit image\".\n */\n const takeHeldAnew = (anew: HeldAssetAnew | null, image: ImageCreateUpdateAware | null) => {\n if (isNull(anew) || unmounted || readonly()) return\n if (isNull(image) || image.dam.damId !== anew.of.file) return\n if ('failure' in anew) {\n if (!showErrorsDefault(anew.failure)) showUnknownError()\n if (held.value === anew.of) staleIn.value = image\n return\n }\n if (hasNoDamCredit(anew.asset.authors, anew.asset.sources)) {\n if (held.value === anew.of) anew.of.asset = anew.asset\n return\n }\n if (held.value === anew.of) held.value = null\n giveNamesToEmptySource(image, anew.names)\n }\n\n /**\n * On confirm of `image`: release the held asset after save if the dialog showed the source because a read failed.\n * Otherwise the next \"edit image\" re-read the asset, showed the pick again, and a confirm replaced the user's source.\n */\n const letGoOnceSavedWithSource = (image: ImageCreateUpdateAware) => {\n const of = held.value\n if (isNull(of) || of.file !== image.dam.damId || !isNull(damAuthorsAsset.value)) return () => undefined\n return () => {\n if (held.value === of) held.value = null\n }\n }\n\n /**\n * Read right before picked sources and authors are written into `asset`. Returns the credit of those\n * given elsewhere meanwhile, or `null` if none. Throws if they cannot be read.\n * Not atomic: one added between this read and the write is still overwritten.\n */\n const authorsGivenMeanwhile = async (asset: AssetDetailItemDto) => {\n const pageExtSystem = cachedExtSystemId.value\n const read = await fetchAsset(damClient, endPointAsset, asset.id)\n return hasNoDamCredit(read.authors, read.sources) ? null : namesOf(read, pageExtSystem)\n }\n\n return {\n damAuthorsAsset,\n offerDamAuthorsOf,\n offerNoDamAuthors,\n pickDamAuthors,\n pickDamSources,\n onAssetDetailClose,\n holdConfirmForDetailAssetRead,\n readHeldAnew,\n takeHeldAnew,\n letGoOnceSavedWithSource,\n authorsGivenMeanwhile,\n /** A confirm waits for the read of a just-closed detail's asset. Its button spins. */\n confirmWaits,\n }\n}\n"],"mappings":";;;;;;;;;;;AA8BA,IAAMA,IAAkC,GAO3BC,KAA0B,GAA+B,MAAkB;CACtF,AAAIC,EAAM,MAAM,OAAO,KAAK,CAAC,CAAC,WAAW,MAAG,EAAM,MAAM,SAASC;AACnE;AAUA,SAAgBC,EACd,GACA,GACA,GACA;CACA,IAAM,EAAE,cAAW,kBAAe,sBAAmBC,EAA6BC,CAAU,GACtF,EAAE,6BAA0BC,EAAkBC,GAAWF,CAAU,GACnEG,IAAiBC,EAAmBJ,CAAU,GAC9C,EAAE,yBAAsBK,EAAwBL,CAAU,GAC1DM,IAAmBC,EAAoB,GACvC,EAAE,sBAAmB,eAAY,wBAAqBC,EAAU,GAEhEC,IAAOC,EAAsB,IAAI,GAEnCC,IAAY;CAChB,QAAsB;EACpB,IAAY;CACd,CAAC;CAGD,IAAMC,UAAoB;EACxB,IAAMhB,IAAQiB,EAAW;EACzB,OAAO,CAACC,EAAOL,EAAK,KAAK,KAAK,CAACK,EAAOlB,CAAK,KAAKA,EAAM,IAAI,UAAUa,EAAK,MAAM,OAAOb,IAAQ;CAChG,GAKMmB,IAAUC,EAA0C,IAAI,GAMxDC,IAAkBC,QAAe;EACrC,IAAIJ,E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MxB,IAAK3B,EAAK;GAEhB,OADIK,EAAOsB,CAAE,KAAKA,EAAG,SAASxC,EAAM,IAAI,SAAS,CAACkB,EAAOG,EAAgB,KAAK,UAAgB,KAAA,UACjF;IACX,AAAIR,EAAK,UAAU2B,MAAI,EAAK,QAAQ;GACtC;EACF;EAwBE,8BAjBmC,MAA8B;GACjE,IAAMP,IAAgBoB,EAAkB,OAClCV,IAAO,MAAML,EAAWhC,GAAWiC,GAAeb,EAAM,EAAE;GAChE,OAAOgB,EAAeC,EAAK,SAASA,EAAK,OAAO,IAAI,OAAOb,EAAQa,GAAMV,CAAa;EACxF;EAeE;CACF;AACF"}
|
|
@@ -3,4 +3,6 @@ export declare function useImageMassOperations(configName: string): {
|
|
|
3
3
|
replaceEmptyDescription: (value: string, forceReplace?: boolean) => void;
|
|
4
4
|
replaceEmptySource: (value: string, forceReplace?: boolean) => void;
|
|
5
5
|
replaceEmptyAuthors: (value: DocId[], forceReplace?: boolean) => Promise<void>;
|
|
6
|
+
replaceEmptySources: (value: DocId[], forceReplace?: boolean) => Promise<void>;
|
|
7
|
+
replaceEmptySelections: (picks: Partial<Record<"damAuthors" | "damSources", string[]>>, forceReplace?: boolean) => Promise<void>;
|
|
6
8
|
};
|
|
@@ -1,52 +1,74 @@
|
|
|
1
1
|
import { isUndefined as e } from "../../../../shared/utils/common.js";
|
|
2
2
|
import { useImageStore as t } from "../store/imageStore.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { damCreditConfigOf as n, damCreditFromMap as r, fetchDamAuthorsMap as i } from "../../author/composables/damCredit.js";
|
|
4
|
+
import { useDamConfigState as a } from "../../config/composables/damConfigState.js";
|
|
5
|
+
import { useCommonAdminCoreDamOptions as o } from "../../composables/commonAdminCoreDamOptions.js";
|
|
6
|
+
import { useExtSystemIdForCached as s } from "../../composables/extSystemIdForCached.js";
|
|
7
|
+
import { useDamConfigStoreOf as c } from "../../config/store/damConfigStore.js";
|
|
7
8
|
// src/domains/dam/imageWidget/composables/useImageMassOperations.ts
|
|
8
|
-
function
|
|
9
|
-
let
|
|
10
|
-
if (
|
|
11
|
-
let r =
|
|
9
|
+
function l(l) {
|
|
10
|
+
let u = t(), d = (t, n = !1) => {
|
|
11
|
+
if (u.readonly) return;
|
|
12
|
+
let r = u.images;
|
|
12
13
|
for (let i = 0; i < r.length; i++) {
|
|
13
14
|
let a = r[i];
|
|
14
15
|
(n || e(a.texts.description) || a.texts.description.length === 0) && (a.texts.description = t);
|
|
15
16
|
}
|
|
16
|
-
},
|
|
17
|
-
if (
|
|
18
|
-
let r =
|
|
17
|
+
}, f = (t, n = !1) => {
|
|
18
|
+
if (u.readonly) return;
|
|
19
|
+
let r = u.images;
|
|
19
20
|
for (let i = 0; i < r.length; i++) {
|
|
20
21
|
let a = r[i];
|
|
21
|
-
(n || e(a.texts.source) || a.texts.source.length === 0) && (a.texts.source = t,
|
|
22
|
+
(n || e(a.texts.source) || a.texts.source.length === 0) && (a.texts.source = t, u.forgetSourceOfPick(a));
|
|
22
23
|
}
|
|
23
|
-
}, { damClient:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
}, { damClient: p, endPointAuthor: m } = o(l), { cachedExtSystemId: h } = s(l), g = c(l), { getDamConfigExtSystem: _ } = a(void 0, l), v = async (t, a) => {
|
|
25
|
+
if (u.readonly) return;
|
|
26
|
+
let o = Object.keys(t).filter((e) => a || t[e].length > 0);
|
|
27
|
+
if (o.length === 0) return;
|
|
28
|
+
let s = h.value, c = (e) => g.damConfigLicenceExtSystem.get(e.dam.licenceId)?.extSystem ?? s, l = (t) => {
|
|
29
|
+
let n = e(t.texts.source) || t.texts.source.trim().length === 0;
|
|
30
|
+
return o.filter((r) => a || (e(t[r]) || t[r].length === 0) && (t.showDamAuthors || n));
|
|
31
|
+
}, d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
32
|
+
u.images.forEach((e) => {
|
|
33
|
+
let n = l(e);
|
|
34
|
+
if (n.length === 0) return;
|
|
35
|
+
let r = c(e);
|
|
36
|
+
d.set(e, {
|
|
37
|
+
fields: n,
|
|
38
|
+
extSystem: r
|
|
39
|
+
}), f.set(r, [
|
|
40
|
+
...f.get(r) ?? [],
|
|
41
|
+
...e.damSources ?? [],
|
|
42
|
+
...e.damAuthors ?? [],
|
|
43
|
+
...n.flatMap((e) => t[e])
|
|
44
|
+
]);
|
|
45
|
+
});
|
|
46
|
+
let v = /* @__PURE__ */ new Map();
|
|
47
|
+
await Promise.all([...f].map(async ([e, t]) => {
|
|
48
|
+
v.set(e, await i(p, m, e, t));
|
|
49
|
+
})), u.readonly || u.images.forEach((i) => {
|
|
50
|
+
let a = d.get(i);
|
|
51
|
+
if (e(a)) return;
|
|
52
|
+
let o = l(i).filter((e) => a.fields.includes(e)), c = v.get(a.extSystem);
|
|
53
|
+
if (o.length === 0 || e(c)) return;
|
|
54
|
+
o.forEach((e) => {
|
|
55
|
+
i[e] = [...t[e]];
|
|
33
56
|
});
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
57
|
+
let f = a.extSystem;
|
|
58
|
+
i.texts.source = r(c, i.damSources, i.damAuthors, n(_(f) ?? _(s))), u.noteSourceOfPick(i);
|
|
59
|
+
});
|
|
60
|
+
}, y = Promise.resolve(), b = (e, t = !1) => {
|
|
61
|
+
let n = y.then(() => v(e, t));
|
|
62
|
+
return y = n.catch(() => void 0), n;
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
replaceEmptyDescription: d,
|
|
66
|
+
replaceEmptySource: f,
|
|
67
|
+
replaceEmptyAuthors: (e, t = !1) => b({ damAuthors: e }, t),
|
|
68
|
+
replaceEmptySources: (e, t = !1) => b({ damSources: e }, t),
|
|
69
|
+
replaceEmptySelections: b
|
|
48
70
|
};
|
|
49
71
|
}
|
|
50
|
-
export {
|
|
72
|
+
export { l as useImageMassOperations };
|
|
51
73
|
|
|
52
74
|
//# sourceMappingURL=useImageMassOperations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useImageMassOperations.js","names":["useImageMassOperations","imageStore","useImageStore","replaceEmptyDescription","items","item","forceReplace","isUndefined","value","replaceEmptySource","useCommonAdminCoreDamOptions","configName","useExtSystemIdForCached","damConfigStore","useDamConfigStoreOf","pageExtSystem","cachedExtSystemId","extSystemOf","licence","namesUnder","authorsRes","fetchAuthorListByIds","damClient","endPointAuthor","extSystem","authorNames","name","author","authorId","i","noAuthors","noSource"],"sources":["../../../../../src/domains/dam/imageWidget/composables/useImageMassOperations.ts"],"sourcesContent":["import { isUndefined } from '@/shared/utils/common'\nimport { useImageStore } from '@/domains/dam/imageWidget/store/imageStore'\nimport type { DocId, IntegerId } from '@/shared/types/common'\nimport { fetchAuthorListByIds } from '@/domains/dam/author/api/authorApi'\nimport { useCommonAdminCoreDamOptions } from '@/domains/dam/composables/commonAdminCoreDamOptions'\nimport { useExtSystemIdForCached } from '@/domains/dam/composables/extSystemIdForCached'\nimport { useDamConfigStoreOf } from '@/domains/dam/config/store/damConfigStore'\n\nexport function useImageMassOperations(configName: string) {\n const imageStore = useImageStore()\n\n const replaceEmptyDescription = (value: string, forceReplace = false) => {\n if (imageStore.readonly) return\n const items = imageStore.images\n for (let i = 0; i < items.length; i++) {\n const item = items[i]!\n if (forceReplace || isUndefined(item.texts.description) || item.texts.description.length === 0) {\n item.texts.description = value\n }\n }\n }\n\n const replaceEmptySource = (value: string, forceReplace = false) => {\n if (imageStore.readonly) return\n const items = imageStore.images\n for (let i = 0; i < items.length; i++) {\n const item = items[i]!\n if (forceReplace || isUndefined(item.texts.source) || item.texts.source.length === 0) {\n item.texts.source = value\n // The source is user-given text, not names from an author pick.\n imageStore.forgetSourceOfPick(item)\n }\n }\n }\n\n const { damClient, endPointAuthor } = useCommonAdminCoreDamOptions(configName)\n const { cachedExtSystemId } = useExtSystemIdForCached(configName)\n const damConfigStore = useDamConfigStoreOf(configName)\n\n const replaceEmptyAuthors = async (value: DocId[], forceReplace = false) => {\n if (imageStore.readonly) return\n // Empty picks fill nothing. Writing them would only clear the rows' sources.\n if (!forceReplace && value.length === 0) return\n // Names under the ext system of each row's asset licence, as everywhere else in the widgets.\n // Falls back to the configured ext system when the licence is unknown. One\n // lookup per ext system; the fallback was previously used for every row.\n const pageExtSystem = cachedExtSystemId.value\n const extSystemOf = new Map<IntegerId, IntegerId>()\n imageStore.images.forEach((item) => {\n const licence = item.dam.licenceId\n extSystemOf.set(licence, damConfigStore.damConfigLicenceExtSystem.get(licence)?.extSystem ?? pageExtSystem)\n })\n const namesUnder = new Map<IntegerId, string>()\n await Promise.all(\n [...new Set([...extSystemOf.values(), pageExtSystem])].map(async (extSystem) => {\n const authorsRes = await fetchAuthorListByIds(damClient, endPointAuthor, extSystem, [...value])\n const authorNames: string[] = []\n value.forEach((authorId) => {\n const name = authorsRes.find((author) => author.id === authorId)?.name\n if (!isUndefined(name) && name.trim().length > 0) authorNames.push(name)\n })\n namesUnder.set(extSystem, authorNames.join(', '))\n })\n )\n // The widget may have turned read-only while the authors loaded.\n if (imageStore.readonly) return\n const items = imageStore.images\n for (let i = 0; i < items.length; i++) {\n const item = items[i]!\n const noAuthors = isUndefined(item.damAuthors) || item.damAuthors.length === 0\n // Whitespace counts as empty, as in the required-source check.\n const noSource = isUndefined(item.texts.source) || item.texts.source.trim().length === 0\n // A row not offering the authors shows its source. A filled source is the user's and is not overwritten.\n if (forceReplace || (noAuthors && (item.showDamAuthors || noSource))) {\n item.damAuthors = value\n item.texts.source = namesUnder.get(extSystemOf.get(item.dam.licenceId) ?? pageExtSystem) ?? ''\n imageStore.noteSourceOfPick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AM,QAAQ,IACZ,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAGF,EAAY,OAAO,GAAGF,CAAa,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,MAAc;IAC9E,IAAMK,IAAa,MAAMC,EAAqBC,GAAWC,GAAgBC,GAAW,CAAC,GAAGhB,CAAK,CAAC,GACxFiB,IAAwB,CAAC;IAK/B,AAJAjB,EAAM,SAAS,MAAa;KAC1B,IAAMkB,IAAON,EAAW,MAAM,MAAWO,EAAO,OAAOC,CAAQ,CAAC,EAAE;KAClE,AAAI,CAACrB,EAAYmB,CAAI,KAAKA,EAAK,KAAK,CAAC,CAAC,SAAS,KAAGD,EAAY,KAAKC,CAAI;IACzE,CAAC,GACDP,EAAW,IAAIK,GAAWC,EAAY,KAAK,IAAI,CAAC;GAClD,CAAC,CACH,GAEIxB,EAAW,UAAU;GACzB,IAAMG,IAAQH,EAAW;GACzB,KAAK,IAAI4B,IAAI,GAAGA,IAAIzB,EAAM,QAAQ,KAAK;IACrC,IAAMC,IAAOD,EAAMyB,IACbC,IAAYvB,EAAYF,EAAK,UAAU,KAAKA,EAAK,WAAW,WAAW,GAEvE0B,IAAWxB,EAAYF,EAAK,MAAM,MAAM,KAAKA,EAAK,MAAM,OAAO,KAAK,CAAC,CAAC,WAAW;IAEvF,CAAIC,KAAiBwB,MAAczB,EAAK,kBAAkB0B,QACxD,EAAK,aAAavB,GAClB,EAAK,MAAM,SAASW,EAAW,IAAIF,EAAY,IAAIZ,EAAK,IAAI,SAAS,KAAKU,CAAa,KAAK,IAC5Fd,EAAW,iBAAiBI,CAAI;GAEpC;EACF;CAMA;AACF"}
|
|
1
|
+
{"version":3,"file":"useImageMassOperations.js","names":["useImageMassOperations","imageStore","useImageStore","replaceEmptyDescription","items","item","forceReplace","isUndefined","value","replaceEmptySource","useCommonAdminCoreDamOptions","configName","useExtSystemIdForCached","damConfigStore","useDamConfigStoreOf","useDamConfigState","fillSelections","fields","picks","field","pageExtSystem","cachedExtSystemId","extSystemOf","fieldsTakenBy","noSource","taken","idsUnder","itemFields","extSystem","namesUnder","ids","fetchDamAuthorsMap","damClient","endPointAuthor","before","names","damCreditFromMap","damCreditConfigOf","getDamConfigExtSystem","lastFill","replaceEmptySelections","fill"],"sources":["../../../../../src/domains/dam/imageWidget/composables/useImageMassOperations.ts"],"sourcesContent":["import { isUndefined } from '@/shared/utils/common'\nimport { useImageStore } from '@/domains/dam/imageWidget/store/imageStore'\nimport type { DocId, IntegerId } from '@/shared/types/common'\nimport type { ImageStoreItem } from '@/domains/dam/types/ImageAware'\nimport type { DamAuthor } from '@/domains/dam/author/types/DamAuthor'\nimport { damCreditConfigOf, damCreditFromMap, fetchDamAuthorsMap } from '@/domains/dam/author/composables/damCredit'\nimport { useDamConfigState } from '@/domains/dam/config/composables/damConfigState'\nimport { useCommonAdminCoreDamOptions } from '@/domains/dam/composables/commonAdminCoreDamOptions'\nimport { useExtSystemIdForCached } from '@/domains/dam/composables/extSystemIdForCached'\nimport { useDamConfigStoreOf } from '@/domains/dam/config/store/damConfigStore'\n\nexport function useImageMassOperations(configName: string) {\n const imageStore = useImageStore()\n\n const replaceEmptyDescription = (value: string, forceReplace = false) => {\n if (imageStore.readonly) return\n const items = imageStore.images\n for (let i = 0; i < items.length; i++) {\n const item = items[i]!\n if (forceReplace || isUndefined(item.texts.description) || item.texts.description.length === 0) {\n item.texts.description = value\n }\n }\n }\n\n const replaceEmptySource = (value: string, forceReplace = false) => {\n if (imageStore.readonly) return\n const items = imageStore.images\n for (let i = 0; i < items.length; i++) {\n const item = items[i]!\n if (forceReplace || isUndefined(item.texts.source) || item.texts.source.length === 0) {\n item.texts.source = value\n // The source is user-given text, not names from an author pick.\n imageStore.forgetSourceOfPick(item)\n }\n }\n }\n\n const { damClient, endPointAuthor } = useCommonAdminCoreDamOptions(configName)\n const { cachedExtSystemId } = useExtSystemIdForCached(configName)\n const damConfigStore = useDamConfigStoreOf(configName)\n const { getDamConfigExtSystem } = useDamConfigState(undefined, configName)\n\n type DamSelectionField = 'damAuthors' | 'damSources'\n type DamSelectionPicks = Partial<Record<DamSelectionField, DocId[]>>\n\n /**\n * Fills the sources or authors of the rows, or both, and a row's source with the credit of its sources and authors.\n * Each field is decided on a row as it was before the fill, so both at once fill the rows either alone would.\n * Names and format under the ext system of each row's asset licence, as everywhere else in the widgets.\n * Falls back to the configured ext system when the licence is unknown (or, for the format, not loaded).\n * One lookup per ext system; the fallback was previously used for every row.\n */\n const fillSelections = async (picks: DamSelectionPicks, forceReplace: boolean) => {\n if (imageStore.readonly) return\n // Empty picks fill nothing. Writing them would only clear the rows' sources.\n const fields = (Object.keys(picks) as DamSelectionField[]).filter(\n (field) => forceReplace || picks[field]!.length > 0\n )\n if (fields.length === 0) return\n const pageExtSystem = cachedExtSystemId.value\n const extSystemOf = (item: ImageStoreItem) =>\n damConfigStore.damConfigLicenceExtSystem.get(item.dam.licenceId)?.extSystem ?? pageExtSystem\n const fieldsTakenBy = (item: ImageStoreItem) => {\n // Whitespace counts as empty, as in the required-source check.\n const noSource = isUndefined(item.texts.source) || item.texts.source.trim().length === 0\n // A row not offering the pick shows its source. A filled source is the user's and is not overwritten.\n return fields.filter(\n (field) =>\n forceReplace || ((isUndefined(item[field]) || item[field].length === 0) && (item.showDamAuthors || noSource))\n )\n }\n // The fields a row takes and its ext system, as they were before the names loaded.\n const taken = new Map<ImageStoreItem, { fields: DamSelectionField[]; extSystem: IntegerId }>()\n const idsUnder = new Map<IntegerId, DocId[]>()\n imageStore.images.forEach((item) => {\n const itemFields = fieldsTakenBy(item)\n if (itemFields.length === 0) return\n const extSystem = extSystemOf(item)\n taken.set(item, { fields: itemFields, extSystem })\n idsUnder.set(extSystem, [\n ...(idsUnder.get(extSystem) ?? []),\n ...(item.damSources ?? []),\n ...(item.damAuthors ?? []),\n ...itemFields.flatMap((field) => picks[field]!),\n ])\n })\n const namesUnder = new Map<IntegerId, Map<DocId, DamAuthor>>()\n await Promise.all(\n [...idsUnder].map(async ([extSystem, ids]) => {\n namesUnder.set(extSystem, await fetchDamAuthorsMap(damClient, endPointAuthor, extSystem, ids))\n })\n )\n // The widget may have turned read-only while the names loaded.\n if (imageStore.readonly) return\n imageStore.images.forEach((item) => {\n // Only rows and fields that took the pick before and still do. A source typed meanwhile stays.\n const before = taken.get(item)\n if (isUndefined(before)) return\n const itemFields = fieldsTakenBy(item).filter((field) => before.fields.includes(field))\n const names = namesUnder.get(before.extSystem)\n if (itemFields.length === 0 || isUndefined(names)) return\n itemFields.forEach((field) => {\n item[field] = [...picks[field]!]\n })\n const extSystem = before.extSystem\n item.texts.source = damCreditFromMap(\n names,\n item.damSources,\n item.damAuthors,\n damCreditConfigOf(getDamConfigExtSystem(extSystem) ?? getDamConfigExtSystem(pageExtSystem))\n )\n imageStore.noteSourceOfPick(item)\n })\n }\n\n // Fills run one after the other. One pressed while another still loads names waits for it, so it starts from\n // the lists the first wrote and the credit keeps the names of both. Run at once, the later write left the\n // names of the earlier fill out of the credit.\n let lastFill: Promise<void> = Promise.resolve()\n const replaceEmptySelections = (picks: DamSelectionPicks, forceReplace = false) => {\n const fill = lastFill.then(() => fillSelections(picks, forceReplace))\n lastFill = fill.catch(() => undefined)\n return fill\n }\n\n const replaceEmptyAuthors = (value: DocId[], forceReplace = false) =>\n replaceEmptySelections({ damAuthors: value }, forceReplace)\n\n const replaceEmptySources = (value: DocId[], forceReplace = false) =>\n replaceEmptySelections({ damSources: value }, forceReplace)\n\n return {\n replaceEmptyDescription,\n replaceEmptySource,\n replaceEmptyAuthors,\n replaceEmptySources,\n replaceEmptySelections,\n }\n}\n"],"mappings":";;;;;;;;AAWA,SAAgBA,EAAuB,GAAoB;CACzD,IAAMC,IAAaC,EAAc,GAE3BC,KAA2B,GAAe,IAAe,OAAU;EACvE,IAAIF,EAAW,UAAU;EACzB,IAAMG,IAAQH,EAAW;EACzB,KAAK,IAAI,IAAI,GAAG,IAAIG,EAAM,QAAQ,KAAK;GACrC,IAAMC,IAAOD,EAAM;GACnB,CAAIE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e,OAAU;EACjF,IAAMC,IAAOF,EAAS,WAAWvB,EAAeE,GAAOZ,CAAY,CAAC;EAEpE,OADA,IAAWmC,EAAK,YAAY,KAAA,CAAS,GAC9BA;CACT;CAQA,OAAO;EACL;EACA;EACA,sBAT2B,GAAgB,IAAe,OAC1DD,EAAuB,EAAE,YAAYhC,EAAM,GAAGF,CAAY;EAS1D,sBAP2B,GAAgB,IAAe,OAC1DkC,EAAuB,EAAE,YAAYhC,EAAM,GAAGF,CAAY;EAO1D;CACF;AACF"}
|
|
@@ -3,6 +3,7 @@ export declare const useImageStore: import('pinia').SetupStoreDefinition<"common
|
|
|
3
3
|
images: import('vue').Ref<{
|
|
4
4
|
damAuthors: import('../../../../lib').DocId[];
|
|
5
5
|
showDamAuthors: boolean;
|
|
6
|
+
damSources: import('../../../../lib').DocId[];
|
|
6
7
|
assetId: undefined | import('../../../../lib').DocId;
|
|
7
8
|
key: string;
|
|
8
9
|
id?: import('../../../../lib').IntegerId | undefined;
|
|
@@ -25,6 +26,7 @@ export declare const useImageStore: import('pinia').SetupStoreDefinition<"common
|
|
|
25
26
|
}[], ImageStoreItem[] | {
|
|
26
27
|
damAuthors: import('../../../../lib').DocId[];
|
|
27
28
|
showDamAuthors: boolean;
|
|
29
|
+
damSources: import('../../../../lib').DocId[];
|
|
28
30
|
assetId: undefined | import('../../../../lib').DocId;
|
|
29
31
|
key: string;
|
|
30
32
|
id?: import('../../../../lib').IntegerId | undefined;
|