diff --git a/.github/config/.finnishwords.txt b/.github/config/.finnishwords.txt index 98b2ffbe0..bc0ecd5c1 100644 --- a/.github/config/.finnishwords.txt +++ b/.github/config/.finnishwords.txt @@ -370,6 +370,7 @@ poistettiin poistettu poistut polku +polkuina postamista poudan profiili diff --git a/CHANGELOG.md b/CHANGELOG.md index 986bf2025..35bc016d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - (GH #944) Create new Taginput component to replace Buefy's taginput component - (GL #944) Replace buefy upload button with a new component: `CUploadButton` - (GL #940) Added TokenModal to replace token page +- (GL #936) Add missing icon for subfolders ### Changed @@ -119,6 +120,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix hiding the pagination of data tables - Fix shared objects functionality: visibility, deleting, editing tags - URL does not strip the path, when that is present. Also small fixes to make it deployable under the same URL. +- (GL #933) Fix for selecting and mass deleting subfolders and files ### Removed diff --git a/swift_browser_ui_frontend/src/common/globalFunctions.js b/swift_browser_ui_frontend/src/common/globalFunctions.js index a8f369215..15ead5bee 100644 --- a/swift_browser_ui_frontend/src/common/globalFunctions.js +++ b/swift_browser_ui_frontend/src/common/globalFunctions.js @@ -88,3 +88,16 @@ export function deleteTag (event, tag, currentTags) { event.preventDefault(); return currentTags.filter(el => el !== tag); } + +export function getPrefix(route) { + // Get current pseudofolder prefix + if (route.query.prefix == undefined) { + return ""; + } + return `${route.query.prefix}/`; +} + +export function isFile(path, route) { + // Return true if path represents a file in the active prefix context + return path.replace(getPrefix(route), "").match("/") ? false : true; +} diff --git a/swift_browser_ui_frontend/src/common/lang.js b/swift_browser_ui_frontend/src/common/lang.js index 86d0ff57c..b708f7442 100644 --- a/swift_browser_ui_frontend/src/common/lang.js +++ b/swift_browser_ui_frontend/src/common/lang.js @@ -107,7 +107,7 @@ let default_translations = { tableOptions: { displayOptions: "Display options", render: "Show as folders", - text: "Show as objects", + text: "Show as paths", hideTags: "Hide tags", showTags: "Display tags", hidePagination: "Hide pagination", @@ -469,7 +469,7 @@ let default_translations = { tableOptions: { displayOptions: "Asetukset", render: "Näytä kansioina", - text: "Näytä tekstinä", + text: "Näytä polkuina", hideTags: "Piilota asiasanat", showTags: "Näytä asiasanat", hidePagination: "Piilota sivutus", diff --git a/swift_browser_ui_frontend/src/components/CObjectTable.vue b/swift_browser_ui_frontend/src/components/CObjectTable.vue index 59312c3b1..f5eef81b7 100644 --- a/swift_browser_ui_frontend/src/components/CObjectTable.vue +++ b/swift_browser_ui_frontend/src/components/CObjectTable.vue @@ -34,9 +34,16 @@ import { import { toggleEditTagsModal, + isFile, + getPrefix, } from "@/common/globalFunctions"; -import { mdiTrayArrowDown, mdiPencilOutline, mdiDeleteOutline } from "@mdi/js"; +import { + mdiTrayArrowDown, + mdiPencilOutline, + mdiDeleteOutline, + mdiFolder , +} from "@mdi/js"; export default { name: "CObjectTable", @@ -57,9 +64,6 @@ export default { type: Boolean, default: true, }, - checkedRows: { - default: [], - }, }, data() { return { @@ -125,13 +129,9 @@ export default { this.setHeaders(); }, methods: { - isFile: function (path) { - // Return true if path represents a file in the active prefix context - return path.replace(this.getPrefix(), "").match("/") ? false : true; - }, changeFolder: function (folder) { this.$router.push( - `${window.location.pathname}?prefix=${this.getPrefix()}${folder}`, + `${window.location.pathname}?prefix=${getPrefix(this.$route)}${folder}`, ); this.componentKey += 1; this.getPage(); @@ -139,7 +139,8 @@ export default { getFolderName: function (path) { // Get the name of the currently displayed pseudofolder let endregex = new RegExp("/.*$"); - return path.replace(this.getPrefix(), "").replace(endregex, ""); + return path.replace(getPrefix(this.$route), "") + .replace(endregex, ""); }, getPage: function () { let offset = 0; @@ -158,10 +159,10 @@ export default { this.objects = this .objs .filter((obj) => { - return obj.name.startsWith(this.getPrefix()); + return obj.name.startsWith(getPrefix(this.$route)); }) .reduce((items, item) => { - if (this.isFile(item.name) || !this.renderFolders) { + if (isFile(item.name, this.$route) || !this.renderFolders) { items.push(item); } else { if (items.find(el => { @@ -188,12 +189,17 @@ export default { items.push({ name: { value: value, - ...(this.renderFolders && !this.isFile(item.name) ? { + ...(this.renderFolders && !isFile(item.name, this.$route) ? { component: { tag: "c-link", params: { href: "javascript:void(0)", color: "dark-grey", + path: mdiFolder, + iconFill: "primary", + iconStyle: { + marginRight: "1rem", + }, onClick: () => this.changeFolder(value), }, }, @@ -321,7 +327,13 @@ export default { }; }, handleSelection(event) { - this.$emit("selected-rows", event.detail); + if (event.detail.length > 0) { + const prefix = getPrefix(this.$route); + const selectedRows = event.detail.map(item => prefix.concat(item)); + this.$emit("selected-rows", selectedRows); + } else { + this.$emit("selected-rows", event.detail); + } }, beginDownload(object) { this.currentDownload = new DecryptedDownloadSession( @@ -337,13 +349,6 @@ export default { navDownload(url) { window.open(url, "_blank"); }, - getPrefix() { - // Get current pseudofolder prefix - if (this.$route.query.prefix == undefined) { - return ""; - } - return `${this.$route.query.prefix}/`; - }, setHeaders() { this.headers = [ { diff --git a/swift_browser_ui_frontend/src/components/ContainerTable.vue b/swift_browser_ui_frontend/src/components/ContainerTable.vue index 6b61fc61c..ee1e5863a 100644 --- a/swift_browser_ui_frontend/src/components/ContainerTable.vue +++ b/swift_browser_ui_frontend/src/components/ContainerTable.vue @@ -389,11 +389,6 @@ export default { message: this.$t("message.container_ops.deleteNote"), }, ); - this.$router.push( - this.$route.params.project - + "/" - + container, - ); } else { toggleDeleteModal(null, container); } diff --git a/swift_browser_ui_frontend/src/components/DeleteModal.vue b/swift_browser_ui_frontend/src/components/DeleteModal.vue index 0735d48c7..ed6ba7df9 100644 --- a/swift_browser_ui_frontend/src/components/DeleteModal.vue +++ b/swift_browser_ui_frontend/src/components/DeleteModal.vue @@ -33,6 +33,8 @@ import { } from "@/common/api"; import { getDB } from "@/common/db"; +import { isFile } from "@/common/globalFunctions"; + export default { name: "DeleteModal", data: function () { @@ -105,18 +107,17 @@ export default { }); }, deleteObjects: function () { - document.querySelector("#objects-toasts").addToast( - { progress: false, - type: "success", - message: this.$t("message.objects.deleteSuccess")}, - ); - let to_remove = new Array; for (let object of this.selectedObjects) { - to_remove.push(object.name); + // Only files are able to delete + if (isFile(object.name, this.$route)) { + to_remove.push(object.name); + } } + if(this.$route.name !== "SharedObjects") { - const objIDs = this.selectedObjects.reduce( + const objIDs = this.selectedObjects.filter( + obj => obj.name && to_remove.includes(obj.name)).reduce( (prev, obj) => [...prev, obj.id], [], ); getDB().objects.bulkDelete(objIDs); @@ -141,6 +142,28 @@ export default { } this.toggleDeleteModal(); + + const dataTable = document.getElementById("objtable"); + dataTable.clearSelections(); + + // Only files can be deleted + // Show warnings when deleting subfolders + if (to_remove.length > 0) { + document.querySelector("#objects-toasts").addToast( + { progress: false, + type: "success", + message: this.$t("message.objects.deleteSuccess")}, + ); + } else { + document.querySelector("#container-error-toasts").addToast( + { + progress: false, + type: "error", + duration: 30000, + message: this.$t("message.container_ops.deleteNote"), + }, + ); + } }); }, }, diff --git a/swift_browser_ui_frontend/src/components/ObjectTable.vue b/swift_browser_ui_frontend/src/components/ObjectTable.vue index 5a1708477..2164612ca 100644 --- a/swift_browser_ui_frontend/src/components/ObjectTable.vue +++ b/swift_browser_ui_frontend/src/components/ObjectTable.vue @@ -42,7 +42,6 @@ -