{"version":3,"file":"stylesheets/8053.css?h=25e6cec6ea29f1793625","mappings":"AA4BA,yCACA,0EACA,iBACA,CACA,6CACA,iBACA,cACA,eACA,CAEA,qBACA,cACA,YACA,eACA,UACA,CC6DA,mCACA,YACA,gBACA,SACA,CAEA,yCACA,YACA,gBAEA,kBACA,CAEA,iFAJA,oDASA,CALA,wCACA,+CAEA,2DAFA,mBAEA,0CACA,QACA,CAEA,uDACA,mBACA,wBADA,kBACA,sBACA,CAEA,wCACA,qBACA,CAEA,wEAEA,eACA,WACA,CACA,mCACA,qDACA,SACA,iBACA,CACA,kCACA,mCACA,YACA,mBACA,eACA,kBACA,CACA,sCAIA,wBAHA,qDAEA,aACA,uBAFA,UAGA,CAEA,yCAEA,mBADA,eACA,iBACA,CCaA,+BACA,WACA,CAEA,wCACA,qDACA,QACA,CAEA,gCACA,iBACA,CAEA,sCACA,SACA","sources":["webpack://@studip/core/./resources/vue/components/stock-images/Thumbnail.vue","webpack://@studip/core/./resources/vue/components/stock-images/ImagesListItem.vue","webpack://@studip/core/./resources/vue/components/stock-images/ImagesList.vue"],"sourcesContent":["<template>\n    <div class=\"stock-images-thumbnail\" v-if=\"url\">\n        <div :style=\"{ width }\">\n            <img :src=\"url\" :style=\"{ 'object-fit': contain ? 'contain' : 'cover' }\" role=\"presentation\" />\n        </div>\n    </div>\n</template>\n\n<script>\nexport default {\n    props: {\n        url: {\n            type: String,\n            required: true,\n        },\n        width: {\n            type: String,\n            default: '6rem',\n        },\n        contain: {\n            type: Boolean,\n            default: false\n        }\n    },\n};\n</script>\n\n<style scoped>\n.stock-images-thumbnail {\n    display: inline-flex;\n    position: relative;\n}\n.stock-images-thumbnail > div {\n    aspect-ratio: 1/1;\n    display: block;\n    overflow: hidden;\n}\n\nimg {\n    display: block;\n    height: 100%;\n    max-width: 100%;\n    width: 100%;\n}\n</style>\n","<template>\n    <tr @click=\"onSelect\">\n        <td>\n            <label>\n                <input type=\"checkbox\" :checked=\"isChecked\" @change=\"onCheckboxChange\" />\n                <span class=\"sr-only\">{{\n                    $gettextInterpolate($gettext('%{context} auswählen'), { context: stockImage.attributes.title })\n                }}</span>\n            </label>\n        </td>\n        <td>\n            <div>\n                <Thumbnail\n                    v-if=\"thumbnailUrl\"\n                    :url=\"thumbnailUrl\"\n                    width=\"6rem\"\n                    style=\"background: var(--light-gray-color-40)\"\n                    contain\n                />\n                <div>\n                    <div>{{ stockImage.attributes.title }}</div>\n                    <div>\n                        <span class=\"stock-image-author\">{{ stockImage.attributes.author }}</span>\n                        <span class=\"stock-image-tags\">\n                            <button\n                                type=\"button\"\n                                class=\"stock-image-tag\"\n                                v-for=\"tag in stockImage.attributes.tags\"\n                                :key=\"tag\"\n                                @click=\"onTagClick(tag)\"\n                            >\n                                {{ tag }}\n                            </button>\n                        </span>\n                    </div>\n\n                    <ul class=\"stock-image-palette\" :title=\"$gettext('Bildfarben')\" role=\"presentation\">\n                        <li\n                            v-for=\"(color, index) in palette\"\n                            :key=\"index\"\n                            :style=\"`background-color: rgb(${color[0]} ${color[1]} ${color[2]});`\"\n                            :alt=\"color.join(',')\"\n                        ></li>\n                    </ul>\n                </div>\n            </div>\n        </td>\n        <td>\n            <studip-icon shape=\"file-pic\" alt=\"\" />\n            {{ imageFormat(stockImage) }}\n        </td>\n        <td><studip-file-size :size=\"stockImage.attributes.size\" /></td>\n        <td>{{ stockImage.attributes.width }} × {{ stockImage.attributes.height }}</td>\n    </tr>\n</template>\n<script>\nimport Thumbnail from './Thumbnail.vue';\nimport { getFormat } from './format.js';\n\nexport default {\n    props: {\n        stockImage: {\n            type: Object,\n            required: true,\n        },\n        isChecked: {\n            type: Boolean,\n            default: false,\n        },\n    },\n    components: {\n        Thumbnail,\n    },\n    computed: {\n        palette() {\n            return this.stockImage.attributes.palette ?? [];\n        },\n        thumbnailUrl() {\n            return (\n                this.stockImage.attributes['download-urls'].small ??\n                this.stockImage.attributes['download-urls'].original\n            );\n        },\n    },\n    methods: {\n        imageFormat(image) {\n            return getFormat(image.attributes['mime-type']);\n        },\n        onCheckboxChange() {\n            this.$emit('checked');\n        },\n        onSelect({ target }) {\n            if (!['INPUT', 'LABEL', 'BUTTON'].includes(target.tagName)) {\n                this.$emit('select');\n            }\n        },\n        onTagClick(tag) {\n            this.$emit('search', tag);\n        },\n    },\n};\n</script>\n\n<style scoped>\ntr > td:nth-child(1) {\n    height: 100%;\n    min-height: 100%;\n    padding: 0;\n}\n\ntr > td:nth-child(1) > label {\n    height: 100%;\n    min-height: 100%;\n    display: flex;\n    padding-inline: 1em;\n}\n\ntr > td:nth-child(2) > div {\n    align-items: center;\n    display: flex;\n    flex-direction: row;\n    gap: 1rem;\n}\n\ntr > td:nth-child(2) > div div:last-child {\n    flex: 1;\n    margin-inline-end: 1rem;\n}\n\ntr > td:nth-child(3) img {\n    vertical-align: middle;\n}\n\n.stock-image-author,\n.stock-image-tags {\n    font-size: 0.8em;\n    opacity: 0.75;\n}\n.stock-image-tags {\n    display: flex;\n    gap: 0.5em;\n    margin-block: 0.5em;\n}\n.stock-image-tag {\n    background-color: var(--base-color);\n    border: none;\n    color: var(--white);\n    cursor: pointer;\n    padding: 0.25em 0.5em;\n}\n.stock-image-palette {\n    display: flex;\n    width: 100%;\n    height: 0.25em;\n    padding-inline-start: 0;\n}\n\n.stock-image-palette li {\n    display: inline;\n    flex: 1;\n}\n</style>\n","<template>\n    <div>\n        <table class=\"default\">\n            <caption>\n                <div class=\"caption-container\">\n                    <div>\n                        <studip-icon shape=\"folder-public-full\" :size=\"30\" alt=\"\" />\n                        <span>{{ caption }}</span>\n                    </div>\n                </div>\n            </caption>\n            <thead>\n                <tr>\n                    <th>\n                        <label>\n                            <input type=\"checkbox\" ref=\"checkAll\" :checked=\"allChecked\" @change=\"onCheckedAllChange\" />\n                            <span class=\"sr-only\">{{ $gettext('Alle Bilder auswählen') }}</span>\n                        </label>\n                    </th>\n                    <th>{{ $gettext('Name') }}</th>\n                    <th>{{ $gettext('Format') }}</th>\n                    <th>{{ $gettext('Größe') }}</th>\n                    <th>{{ $gettext('Abmessungen') }}</th>\n                </tr>\n            </thead>\n            <tbody v-if=\"paged.length\">\n                <ImagesListItem\n                    :stock-image=\"stockImage\"\n                    v-for=\"stockImage in paged\"\n                    :key=\"stockImage.id\"\n                    :is-checked=\"checkedImages.includes(stockImage.id)\"\n                    @checked=\"$emit('checked', stockImage)\"\n                    @search=\"(query) => $emit('search', query)\"\n                    @select=\"$emit('select', stockImage)\"\n                />\n            </tbody>\n            <tbody v-else>\n                <tr>\n                    <td colspan=\"5\">\n                        <span v-if=\"query.length\">{{\n                            $gettext('Zu diesem Suchbegriff konnten keine Bilder gefunden werden.')\n                        }}</span>\n                        <span v-else>{{ $gettext('Es konnten keine Bilder gefunden werden.') }}</span>\n                    </td>\n                </tr>\n            </tbody>\n            <tfoot v-if=\"paged.length\">\n                <tr>\n                    <td colspan=\"5\">\n                        <button\n                            type=\"button\"\n                            class=\"button\"\n                            @click=\"showConfirmDelete = true\"\n                            :disabled=\"!checkedImages.length\"\n                        >\n                            {{ $gettext('Löschen') }}\n                        </button>\n                    </td>\n                </tr>\n            </tfoot>\n        </table>\n\n        <studip-dialog\n            v-if=\"showConfirmDelete\"\n            :title=\"\n                this.$ngettext(\n                    'Ausgewähltes Bild unwideruflich löschen?',\n                    'Ausgewählte Bilder unwideruflich löschen?',\n                    checkedImages.length\n                )\n            \"\n            :question=\"\n                $ngettext(\n                    'Möchten Sie das ausgewählte Bild wirklich löschen?',\n                    'Möchten Sie die ausgewählten Bilder wirklich löschen?',\n                    checkedImages.length\n                )\n            \"\n            height=\"200\"\n            width=\"450\"\n            @confirm=\"onDelete\"\n            @close=\"showConfirmDelete = false\"\n        ></studip-dialog>\n    </div>\n</template>\n\n<script>\nimport ImagesListItem from './ImagesListItem.vue';\nimport { mapActions } from 'vuex';\n\nexport default {\n    props: {\n        checkedImages: {\n            type: Array,\n            required: true,\n        },\n        perPage: {\n            type: Number,\n            default: 10,\n        },\n        page: {\n            type: Number,\n            default: 1,\n        },\n        query: {\n            type: String,\n            default: '',\n        },\n        stockImages: {\n            type: Array,\n            required: true,\n        },\n    },\n    components: {\n        ImagesListItem,\n    },\n    data: () => ({\n        latestMkdate: null,\n        showConfirmDelete: false,\n    }),\n    computed: {\n        allChecked() {\n            return this.paged.length && this.paged.every(({ id }) => this.checkedImages.includes(id));\n        },\n        caption() {\n            const n = this.stockImages.length;\n            return this.$gettextInterpolate(this.$ngettext('%{ n } Bild gefunden', '%{ n } Bilder gefunden', n), { n });\n        },\n        paged() {\n            return this.stockImages.slice((this.page - 1) * this.perPage, this.page * this.perPage);\n        },\n        totalItems() {\n            return this.stockImages.length;\n        },\n    },\n    methods: {\n        ...mapActions({ deleteStockImage: 'studip/stockImages/delete' }),\n        checkAll() {\n            this.paged\n                .filter(({ id }) => !this.checkedImages.includes(id))\n                .forEach((image) => this.$emit('checked', image));\n        },\n        checkNone() {\n            this.paged\n                .filter(({ id }) => this.checkedImages.includes(id))\n                .forEach((image) => this.$emit('checked', image));\n        },\n        onCheckedAllChange() {\n            this.allChecked ? this.checkNone() : this.checkAll();\n        },\n        onDelete() {\n            const checkedImages = [...this.checkedImages];\n            this.showConfirmDelete = false;\n            this.checkNone();\n            Promise.allSettled(checkedImages.map((id) => this.deleteStockImage(id))).then(() => {\n                this.revalidatePage();\n            });\n        },\n        revalidatePage() {\n            if (this.totalItems < this.page * this.perPage) {\n                this.$emit('open-page', Math.ceil(this.totalItems / this.perPage));\n            }\n        },\n    },\n    watch: {\n        checkedImages({ length }) {\n            this.$refs.checkAll.indeterminate = 0 < length && length < this.paged.length;\n        },\n    },\n};\n</script>\n\n<style scoped>\ntable.default {\n    height: 100%;\n}\n\n.caption-container div {\n    display: flex;\n    gap: 0.5em;\n}\n\nthead th input {\n    margin-inline: 1em;\n}\n\nthead th:first-child {\n    width: 3em;\n}\n</style>\n"],"names":[],"sourceRoot":""}