Skip to content

Commit

Permalink
asset metadata user chip wip
Browse files Browse the repository at this point in the history
  • Loading branch information
volar committed Dec 4, 2024
1 parent e72b7d2 commit 712f610
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 10 deletions.
18 changes: 17 additions & 1 deletion src/components/ACachedUserChip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ const props = withDefaults(
defineProps<{
id: null | undefined | IntegerId
routeName?: string | undefined
externalUrl?: string | undefined
cachedUsers?: CollabCachedUsersMap | undefined
}>(),
{
routeName: undefined,
externalUrl: undefined,
cachedUsers: undefined,
}
)
Expand All @@ -38,7 +40,21 @@ const text = computed(() => {
return ''
})
const appendIcon = computed(() => {
if (props.externalUrl) {
return COMMON_CONFIG.CHIP.ICON.LINK
}
if (props.routeName) {
return COMMON_CONFIG.CHIP.ICON.LINK_EXTERNAL
}
return undefined
})
const onClick = () => {
if (props.externalUrl) {
window.open(props.externalUrl, '_blank')
return
}
if (!props.routeName) return
router.push({ name: props.routeName, params: { id: props.id } })
}
Expand Down Expand Up @@ -69,7 +85,7 @@ watch(
v-else
class="pl-1"
size="small"
:append-icon="COMMON_CONFIG.CHIP.ICON.LINK"
:append-icon="appendIcon"
@click.stop="onClick"
>
<AAnzuUserAvatar
Expand Down
6 changes: 1 addition & 5 deletions src/components/dam/assetSelect/AAssetSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import AssetMetadata from '@/components/damImage/uploadQueue/components/AssetMet
import { useAssetSelectStore } from '@/services/stores/coreDam/assetSelectStore'
import { storeToRefs } from 'pinia'
import { useAssetDetailStore } from '@/components/damImage/uploadQueue/composables/assetDetailStore'
import type { CollabCachedUsersMap } from '@/components/collab/composables/collabHelpers'
const props = withDefaults(
defineProps<{
Expand All @@ -36,14 +35,12 @@ const props = withDefaults(
returnType?: AssetSelectReturnTypeType
configName?: string
skipCurrentUserCheck?: boolean
cachedUsers?: CollabCachedUsersMap | undefined
onDetailLoadedCallback?: ((asset: AssetDetailItemDto) => void) | undefined
}>(),
{
returnType: AssetSelectReturnType.MainFileId,
configName: 'default',
skipCurrentUserCheck: false,
cachedUsers: undefined,
onDetailLoadedCallback: undefined,
}
)
Expand All @@ -67,7 +64,7 @@ const {
getSelectedData,
initStoreContext,
detailLoading,
// eslint-disable-next-line vue/no-setup-props-reactivity-loss
// eslint-disable-next-line vue/no-setup-props-reactivity-loss
} = useAssetSelectActions('default', props.onDetailLoadedCallback)
const { loadDamConfigAssetCustomFormElements, getDamConfigAssetCustomFormElements } = useDamConfigState(damClient)
Expand Down Expand Up @@ -275,7 +272,6 @@ defineExpose({
v-if="extId && !customFormConfigLoading"
:ext-system="extId"
readonly
:cached-users="cachedUsers"
/>
</div>
</div>
Expand Down
35 changes: 35 additions & 0 deletions src/components/damImage/uploadQueue/author/cachedUsers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { AnzuUserMinimal } from '@/types/AnzuUser'
import type { DamUser } from '@/components/dam/user/DamUser'
import type { IntegerId } from '@/types/common'
import { defineCached } from '@/composables/system/defineCached'
import { fetchDamUserListByIds } from '@/components/dam/user/userApi'
import { useCommonAdminCoreDamOptions } from '@/components/dam/assetSelect/composables/commonAdminCoreDamOptions'

const mapFullToMinimal = (source: DamUser): AnzuUserMinimal => {
return { id: source.id, email: source.email, avatar: source.avatar, person: source.person }
}

const mapIdToMinimal = (id: IntegerId): AnzuUserMinimal => {
return { id: id, email: '', person: { firstName: '', lastName: '', fullName: '' }, avatar: { color: '', text: '' } }
}

const { cache, fetch, add, addManual, has, get, isLoaded } = defineCached<IntegerId, DamUser, AnzuUserMinimal>(
mapFullToMinimal,
mapIdToMinimal,
(ids: IntegerId[]) => {
const { damClient } = useCommonAdminCoreDamOptions()
return fetchDamUserListByIds(damClient, ids)
}
)

export const useDamCachedUsers = () => {
return {
addManualToCachedUsers: addManual,
addToCachedUsers: add,
fetchCachedUsers: fetch,
cachedUsers: cache,
hasCachedUser: has,
getCachedUser: get,
isLoadedCachedUser: isLoaded,
}
}
11 changes: 7 additions & 4 deletions src/components/damImage/uploadQueue/components/AssetMetadata.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ import { useDamAuthorAssetTypeConfig } from '@/components/damImage/uploadQueue/a
import type { IntegerId } from '@/types/common'
import ABooleanValue from '@/components/ABooleanValue.vue'
import ARow from '@/components/ARow.vue'
import type { CollabCachedUsersMap } from '@/components/collab/composables/collabHelpers'
import ACachedUserChip from '@/components/ACachedUserChip.vue'
import { useDamCachedUsers } from '@/components/damImage/uploadQueue/author/cachedUsers'
const props = withDefaults(
defineProps<{
extSystem: IntegerId
readonly?: boolean
cachedUsers?: CollabCachedUsersMap | undefined
}>(),
{
readonly: false,
cachedUsers: undefined,
}
)
Expand Down Expand Up @@ -61,6 +59,8 @@ const onAnyMetadataChange = () => {
const { keywordRequired, keywordEnabled } = useDamKeywordAssetTypeConfig(assetType.value, props.extSystem)
// eslint-disable-next-line vue/no-setup-props-reactivity-loss,vue/no-ref-object-reactivity-loss
const { authorRequired, authorEnabled } = useDamAuthorAssetTypeConfig(assetType.value, props.extSystem)
const { cachedUsers } = useDamCachedUsers()
</script>

<template>
Expand Down Expand Up @@ -163,7 +163,10 @@ const { authorRequired, authorEnabled } = useDamAuthorAssetTypeConfig(assetType.
:title="t('common.damImage.asset.detail.info.file')"
value="file"
>
<VExpansionPanelText class="text-caption" style="overflow-wrap: normal">
<VExpansionPanelText
class="text-caption"
style="overflow-wrap: normal"
>
<!-- all types -->
<VRow>
<VCol cols="3">
Expand Down
2 changes: 2 additions & 0 deletions src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ import { useDamConfigStore } from '@/components/damImage/uploadQueue/composables
import DamAuthorFilterRemoteAutocomplete from '@/components/damImage/uploadQueue/author/DamAuthorFilterRemoteAutocomplete.vue'
import DamKeywordFilterRemoteAutocomplete from '@/components/damImage/uploadQueue/keyword/DamKeywordFilterRemoteAutocomplete.vue'
import DamUserFilterRemoteAutocomplete from '@/components/dam/user/DamUserFilterRemoteAutocomplete.vue'
import { useDamCachedUsers } from '@/components/damImage/uploadQueue/author/cachedUsers'

export {
// COMPONENTS
Expand Down Expand Up @@ -654,6 +655,7 @@ export {
useCommonAdminImageOptions,
defineAuth,
defineBreadcrumbs,
useDamCachedUsers,

// VALUE OBJECTS
type GrantType,
Expand Down

0 comments on commit 712f610

Please sign in to comment.