From e30c2e5f1b1fd476c38259b42f72e777b75dcbb9 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Mon, 21 Aug 2023 10:10:15 +0200 Subject: [PATCH] Upload: Pre-select current album in dialog #3644 Signed-off-by: Michael Mayer --- frontend/src/component/album/toolbar.vue | 31 +++++++++++++++--------- frontend/src/component/navigation.vue | 12 +++++++-- frontend/src/dialog/upload.vue | 13 ++++++++++ 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/frontend/src/component/album/toolbar.vue b/frontend/src/component/album/toolbar.vue index 4d0fc168e..3c56ff656 100644 --- a/frontend/src/component/album/toolbar.vue +++ b/frontend/src/component/album/toolbar.vue @@ -33,10 +33,12 @@ get_app - + view_list - + view_comfy @@ -68,7 +70,8 @@ - @@ -77,34 +80,40 @@ import Event from "pubsub-js"; import Notify from "common/notify"; import download from "common/download"; -import { T } from "common/vm"; +import {T} from "common/vm"; export default { name: 'PAlbumToolbar', props: { album: { type: Object, - default: () => {}, + default: () => { + }, }, filter: { type: Object, - default: () => {}, + default: () => { + }, }, updateFilter: { type: Function, - default: () => {}, + default: () => { + }, }, updateQuery: { type: Function, - default: () => {}, + default: () => { + }, }, settings: { type: Object, - default: () => {}, + default: () => { + }, }, refresh: { type: Function, - default: () => {}, + default: () => { + }, }, }, data() { @@ -167,7 +176,7 @@ export default { this.dialog.upload = true; }, showUpload() { - Event.publish("dialog.upload"); + Event.publish("dialog.upload", {albums: [this.album]}); }, expand() { this.searchExpanded = !this.searchExpanded; diff --git a/frontend/src/component/navigation.vue b/frontend/src/component/navigation.vue index ffdf1208c..60bffe2c8 100644 --- a/frontend/src/component/navigation.vue +++ b/frontend/src/component/navigation.vue @@ -664,7 +664,7 @@ {{ config.legalInfo }} - @@ -734,6 +734,7 @@ export default { }, upload: { dialog: false, + data: {}, }, edit: { dialog: false, @@ -777,7 +778,14 @@ export default { this.subscriptions.push(Event.subscribe('index', this.onIndex)); this.subscriptions.push(Event.subscribe('import', this.onIndex)); this.subscriptions.push(Event.subscribe("dialog.reload", () => this.reload.dialog = true)); - this.subscriptions.push(Event.subscribe("dialog.upload", () => this.upload.dialog = true)); + this.subscriptions.push(Event.subscribe("dialog.upload", (ev, data) => { + if(data) { + this.upload.data = data; + } else { + this.upload.data = {}; + } + this.upload.dialog = true; + })); this.subscriptions.push(Event.subscribe("dialog.edit", (ev, data) => { if (!this.edit.dialog) { this.edit.dialog = true; diff --git a/frontend/src/dialog/upload.vue b/frontend/src/dialog/upload.vue index b6326c669..78e185bca 100644 --- a/frontend/src/dialog/upload.vue +++ b/frontend/src/dialog/upload.vue @@ -99,6 +99,10 @@ export default { name: 'PUploadDialog', props: { show: Boolean, + data: { + type: Object, + default: () => {}, + }, }, data() { return { @@ -130,6 +134,15 @@ export default { this.reset(); this.review = this.$config.feature("review"); this.safe = !this.$config.get("uploadNSFW"); + + // Set currently selected albums. + if (this.data && Array.isArray(this.data.albums)) { + this.selectedAlbums = this.data.albums; + } else { + this.selectedAlbums = []; + } + + // Fetch albums from backend. this.findAlbums(""); } },