{"version":3,"file":"TagContent-CH9RaPUa.chunk.mjs","sources":["../src/views/TagContent.vue"],"sourcesContent":["<!--\n  - SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<!-- Errors handlers-->\n\t<NcEmptyContent v-if=\"error\" :name=\"t('photos', 'An error occurred')\" />\n\n\t<NcLoadingIcon v-else-if=\"loading\" class=\"loader\" />\n\n\t<!-- Folder content -->\n\t<div v-else>\n\t\t<div class=\"photos-navigation\">\n\t\t\t<NcActions class=\"photos-navigation__back\">\n\t\t\t\t<NcActionButton @click=\"$router.push({ name: 'tags' })\">\n\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t<ArrowLeft />\n\t\t\t\t\t</template>\n\t\t\t\t\t{{ t('photos', 'Back to tags overview') }}\n\t\t\t\t</NcActionButton>\n\t\t\t</NcActions>\n\t\t\t<h2 class=\"photos-navigation__title\">\n\t\t\t\t{{ path }}\n\t\t\t</h2>\n\t\t</div>\n\t\t<div class=\"heading-subline\">\n\t\t\t{{ n('photos', '%n photo', '%n photos', fileIds.length) }}\n\t\t</div>\n\t\t<NcEmptyContent v-if=\"isEmpty\" :name=\"t('photos', 'No photos with this tag yet')\" />\n\n\t\t<FilesListViewer\n\t\t\tclass=\"tag__photos\"\n\t\t\t:container-element=\"appContent\"\n\t\t\t:file-ids=\"fileIds\"\n\t\t\t:base-height=\"isMobile ? 120 : 200\"\n\t\t\t:loading=\"loading\">\n\t\t\t<FileComponent\n\t\t\t\tslot-scope=\"{ file }\"\n\t\t\t\t:file=\"files[file.id]\"\n\t\t\t\t:allow-selection=\"true\"\n\t\t\t\t:selected=\"selection[file.id] === true\"\n\t\t\t\t@click=\"openViewer\"\n\t\t\t\t@select-toggled=\"onFileSelectToggle\" />\n\t\t</FilesListViewer>\n\t</div>\n</template>\n\n<script lang='ts'>\nimport { translatePlural as n, translate as t } from '@nextcloud/l10n'\nimport { useIsMobile } from '@nextcloud/vue/composables/useIsMobile'\nimport NcActionButton from '@nextcloud/vue/components/NcActionButton'\nimport NcActions from '@nextcloud/vue/components/NcActions'\nimport NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent'\nimport NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'\nimport ArrowLeft from 'vue-material-design-icons/ArrowLeft.vue'\nimport FileComponent from '../components/FileComponent.vue'\nimport FilesListViewer from '../components/FilesListViewer.vue'\nimport AbortControllerMixin from '../mixins/AbortControllerMixin.js'\nimport FilesSelectionMixin from '../mixins/FilesSelectionMixin.js'\nimport logger from '../services/logger.js'\nimport { toViewerFileInfo } from '../utils/fileUtils.js'\n\nexport default {\n\tname: 'TagContent',\n\tcomponents: {\n\t\tFileComponent,\n\t\tFilesListViewer,\n\t\tNcEmptyContent,\n\t\tNcActions,\n\t\tNcActionButton,\n\t\tNcLoadingIcon,\n\t\tArrowLeft,\n\t},\n\n\tmixins: [\n\t\tFilesSelectionMixin,\n\t\tAbortControllerMixin,\n\t],\n\n\tprops: {\n\t\tpath: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\t},\n\n\tsetup() {\n\t\treturn {\n\t\t\tisMobile: useIsMobile(),\n\t\t}\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\terror: null as boolean | null,\n\t\t\tloading: false,\n\t\t\tappContent: document.getElementById('app-content-vue'),\n\t\t}\n\t},\n\n\tcomputed: {\n\t\tfiles() {\n\t\t\treturn this.$store.state.files.files\n\t\t},\n\n\t\ttags() {\n\t\t\treturn this.$store.state.systemtags.tags\n\t\t},\n\n\t\t// current tag id from current path\n\t\ttagId() {\n\t\t\treturn this.$store.getters.tagId(this.path)\n\t\t},\n\n\t\t// current tag\n\t\ttag() {\n\t\t\treturn this.tags[this.tagId]\n\t\t},\n\n\t\t// files list of the current tag\n\t\tfileIds() {\n\t\t\treturn this.$store.state.systemtags.tagsFiles[this.tagId]\n\t\t},\n\n\t\tisEmpty() {\n\t\t\treturn this.fileIds.length === 0\n\t\t},\n\t},\n\n\twatch: {\n\t\tasync path() {\n\t\t\tthis.fetchContent()\n\t\t},\n\t},\n\n\tasync beforeMount() {\n\t\tthis.fetchContent()\n\t},\n\n\tmethods: {\n\t\tasync fetchContent() {\n\t\t\t// close any potential opened viewer\n\t\t\twindow.OCA.Viewer.close()\n\n\t\t\tthis.loading = true\n\t\t\tthis.error = null\n\n\t\t\ttry {\n\t\t\t\t// if we don't already have some cached data let's show a loader\n\t\t\t\tif (!this.tags[this.tagId]) {\n\t\t\t\t\tawait this.$store.dispatch('fetchAllTags', { signal: this.abortController.signal })\n\t\t\t\t}\n\n\t\t\t\tif (this.tag && !this.fileIds) {\n\t\t\t\t\tawait this.$store.dispatch('fetchTagFiles', { id: this.tagId, signal: this.abortController.signal })\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error('Failed to fetch tags', { error })\n\t\t\t\tthis.error = true\n\t\t\t} finally {\n\t\t\t\t// done loading\n\t\t\t\tthis.loading = false\n\t\t\t}\n\t\t},\n\n\t\topenViewer(fileId: number) {\n\t\t\twindow.OCA.Viewer.open({\n\t\t\t\tfileInfo: toViewerFileInfo(this.files[fileId]),\n\t\t\t\tlist: this.fileIds.map((fileId) => toViewerFileInfo(this.files[fileId])),\n\t\t\t})\n\t\t},\n\n\t\tt,\n\t\tn,\n\t},\n}\n</script>\n\n<style scoped lang=\"scss\">\n.loader {\n\tmargin-top: 30vh;\n}\n\n.photos-navigation {\n\tdisplay: flex;\n\theight: 44px;\n\tpadding: 0 40px;\n\talign-items: center;\n\tmax-width: 100%;\n\n\th2 {\n\t\tpadding: 0;\n\t\tmargin: 0;\n\t}\n}\n\n.heading-subline {\n\tmargin-inline-start: 85px;\n\tmargin-top: -11px;\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.tag__photos {\n\tpadding: 0 64px;\n}\n</style>\n"],"names":["_sfc_main","FileComponent","FilesListViewer","NcEmptyContent","NcActions","NcActionButton","NcLoadingIcon","ArrowLeft","FilesSelectionMixin","AbortControllerMixin","useIsMobile","error","logger","fileId","toViewerFileInfo","t","translatePlural"],"mappings":"muBA+DA,MAAAA,EAAA,CACA,KAAA,aACA,WAAA,CACA,cAAAC,EACA,gBAAAC,EACA,eAAAC,EACA,UAAAC,EACA,eAAAC,EACA,cAAAC,EACA,UAAAC,CAAA,EAGA,OAAA,CACAC,EACAC,CAAA,EAGA,MAAA,CACA,KAAA,CACA,KAAA,OACA,QAAA,EAAA,CACA,EAGA,OAAA,CACA,MAAA,CACA,SAAAC,EAAA,CAAA,CAEA,EAEA,MAAA,CACA,MAAA,CACA,MAAA,KACA,QAAA,GACA,WAAA,SAAA,eAAA,iBAAA,CAAA,CAEA,EAEA,SAAA,CACA,OAAA,CACA,OAAA,KAAA,OAAA,MAAA,MAAA,KACA,EAEA,MAAA,CACA,OAAA,KAAA,OAAA,MAAA,WAAA,IACA,EAGA,OAAA,CACA,OAAA,KAAA,OAAA,QAAA,MAAA,KAAA,IAAA,CACA,EAGA,KAAA,CACA,OAAA,KAAA,KAAA,KAAA,KAAA,CACA,EAGA,SAAA,CACA,OAAA,KAAA,OAAA,MAAA,WAAA,UAAA,KAAA,KAAA,CACA,EAEA,SAAA,CACA,OAAA,KAAA,QAAA,SAAA,CACA,CAAA,EAGA,MAAA,CACA,MAAA,MAAA,CACA,KAAA,aAAA,CACA,CAAA,EAGA,MAAA,aAAA,CACA,KAAA,aAAA,CACA,EAEA,QAAA,CACA,MAAA,cAAA,CAEA,OAAA,IAAA,OAAA,MAAA,EAEA,KAAA,QAAA,GACA,KAAA,MAAA,KAEA,GAAA,CAEA,KAAA,KAAA,KAAA,KAAA,GACA,MAAA,KAAA,OAAA,SAAA,eAAA,CAAA,OAAA,KAAA,gBAAA,OAAA,EAGA,KAAA,KAAA,CAAA,KAAA,SACA,MAAA,KAAA,OAAA,SAAA,gBAAA,CAAA,GAAA,KAAA,MAAA,OAAA,KAAA,gBAAA,MAAA,CAAA,CAEA,OAAAC,EAAA,CACAC,EAAA,MAAA,uBAAA,CAAA,MAAAD,CAAA,CAAA,EACA,KAAA,MAAA,EACA,QAAA,CAEA,KAAA,QAAA,EACA,CACA,EAEA,WAAAE,EAAA,CACA,OAAA,IAAA,OAAA,KAAA,CACA,SAAAC,EAAA,KAAA,MAAAD,CAAA,CAAA,EACA,KAAA,KAAA,QAAA,IAAAA,GAAAC,EAAA,KAAA,MAAAD,CAAA,CAAA,CAAA,CAAA,CACA,CACA,EAAA,EAEAE,EAAAC,EAAAA,CACA,CAEA"}