2026-01-27 12:19:49 -05:00
|
|
|
(()=>{var e,t,n,i={15914(e,t,n){"use strict";n.d(t,{A:()=>o});var i=n(71354),r=n.n(i),s=n(76314),a=n.n(s)()(r());a.push([e.id,"\n._fileListFilterAccount_ZW91g {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: var(--default-grid-baseline);\n}\n._fileListFilterAccount__avatar_V0YuN {\n\t/* 24px is the avatar size */\n\tmargin: calc((var(--default-clickable-area) - 24px) / 2);\n}\n._fileListFilterAccount__currentUser_PqQfx {\n\tfont-weight: normal !important;\n}\n","",{version:3,sources:["webpack://./apps/files_sharing/src/components/FileListFilterAccount.vue"],names:[],mappings:";AA4JA;CACA,aAAA;CACA,sBAAA;CACA,iCAAA;AACA;AAEA;CACA,4BAAA;CACA,wDAAA;AACA;AAEA;CACA,8BAAA;AACA",sourcesContent:["\x3c!--\n - SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors\n - SPDX-License-Identifier: AGPL-3.0-or-later\n--\x3e\n<template>\n\t<div :class=\"$style.fileListFilterAccount\">\n\t\t<NcTextField\n\t\t\tv-if=\"availableAccounts.length > 1\"\n\t\t\tv-model=\"accountFilter\"\n\t\t\ttype=\"search\"\n\t\t\t:label=\"t('files_sharing', 'Filter accounts')\" />\n\t\t<NcButton\n\t\t\tv-for=\"account of shownAccounts\"\n\t\t\t:key=\"account.id\"\n\t\t\talignment=\"start\"\n\t\t\t:pressed=\"selectedAccounts.includes(account)\"\n\t\t\tvariant=\"tertiary\"\n\t\t\twide\n\t\t\t@update:pressed=\"toggleAccount(account.id, $event)\">\n\t\t\t<template #icon>\n\t\t\t\t<NcAvatar\n\t\t\t\t\t:class=\"$style.fileListFilterAccount__avatar\"\n\t\t\t\t\tv-bind=\"account\"\n\t\t\t\t\t:size=\"24\"\n\t\t\t\t\tdisable-menu\n\t\t\t\t\thide-status />\n\t\t\t</template>\n\t\t\t{{ account.displayName }}\n\t\t\t<span v-if=\"account.id === currentUserId\" :class=\"$style.fileListFilterAccount__currentUser\">\n\t\t\t\t({{ t('files', 'you') }})\n\t\t\t</span>\n\t\t</NcButton>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport type { AccountFilter, IAccountData } from '../files_filters/AccountFilter.ts'\n\nimport { t } from '@nextcloud/l10n'\nimport { computed, onMounted, onUnmounted, ref, watch } from 'vue'\nimport NcAvatar from '@nextcloud/vue/components/NcAvatar'\nimport NcButton from '@nextcloud/vue/components/NcButton'\nimport NcTextField from '@nextcloud/vue/components/NcTextField'\nimport { getCurrentUser } from '../../../../core/src/OC/currentuser.js'\n\ninterface IUserSelectData {\n\tid: string\n\tuser: string\n\tdisplayName: string\n}\n\nconst props = defineProps<{\n\tfilter: AccountFilter\n}>()\n\nconst currentUserId = getCurrentUser()!.uid\n\nconst accountFilter = ref('')\nconst availableAccounts = ref<IUserSelectData[]>([])\nconst selectedAccounts = ref<IUserSelectData[]>([])\nwatch(selectedAccounts, () => {\n\tconst accounts = selectedAccounts.value.map(({ id: uid, displayName }) => ({ uid, displayName }))\n\tprops.filter.setAccounts(accounts.length > 0 ? accounts : undefined)\n})\n\nonMounted(() => {\n\tsetAvailableAccounts(props.filter.availableAccounts)\n\tselectedAccounts.value = availableAccounts.value.filter(({ id }) => props.filter.filterAccounts?.some(({ uid }) => uid === id)) ?? []\n\tprops.filter.addEventListener('accounts-updated', setAvailableAccounts)\n\tprops.filter.addEventListener('reset', resetFilter)\n\tprops.filter.addEventListener('deselect', deselect)\n})\nonUnmounted(() => {\n\tprops.filter.removeEventListener('accounts-updated', setAvailableAccounts)\n\tprops.filter.removeEventListener('reset', resetFilter)\n\tprops.filter.removeEventListener('deselect', deselect)\n})\n\n/**\n * Currently shown accounts (filtered)\n */\nconst shownAccounts = computed(() => {\n\tif (!accountFilter.value) {\n\t\treturn [...availableAccounts.value].sort(sortAccounts)\n\t}\n\n\tconst queryParts = accountFilter.value.toLocaleLowerCase().trim().split(' ')\n\tconst accounts = availableAccounts.value.filter((account) => queryParts.every((part) => account.user.toLocaleLowerCase().includes(part)\n\t\t|| account.displayName.toLocaleLowerCase().includes(part)))\n\treturn accounts.sort(sortAccounts)\n})\n\n/**\n * Sort accounts, putting the current user at the begin\n *\n * @param a - First account\n * @param b - Second account\n
|