Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: upload an image to an album #2192

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/photos-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-main.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-public.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-src_views_AlbumContent_vue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-src_views_AlbumContent_vue.js.map

Large diffs are not rendered by default.

38 changes: 31 additions & 7 deletions src/components/FilesPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@
<div class="file-picker__actions">
<UploadPicker :accept="allowedMimes"
:context="uploadContext"
:destination="photosLocation"
:destination="album.basename"
:root="uploadContext.root"
:multiple="true"
@uploaded="refreshFiles" />
@uploaded="emitUploadedEvent" />
<NcButton type="primary" :disabled="loading || selectedFileIds.length === 0" @click="emitPickedEvent">
<template #icon>
<ImagePlus v-if="!loading" />
Expand Down Expand Up @@ -95,6 +96,7 @@
import FilesByMonthMixin from '../mixins/FilesByMonthMixin.js'
import UserConfig from '../mixins/UserConfig.js'
import allowedMimes from '../services/AllowedMimes.js'
import { getCurrentUser } from '@nextcloud/auth'

export default {
name: 'FilesPicker',
Expand Down Expand Up @@ -124,6 +126,10 @@
],

props: {
album: {
type: Object,
required: true,
},
// Label to show in the submit button.
destination: {
type: String,
Expand All @@ -143,20 +149,38 @@
},
},

emits: [
'files-uploaded',
'files-picked',
],

data() {
return {
allowedMimes,
targetMonth: null,
uploadContext: {
route: 'albumpicker',
},
}
},

computed: {
...mapGetters([
'files',
]),

/**
* The upload picker context
* We're uploading to the album folder, and the backend handle
* the writing to the default location as well as the album update.
* The context is also used for the NewFileMenu.
*
* @return {Album&{route: string, root: string}}

Check warning on line 175 in src/components/FilesPicker.vue

View workflow job for this annotation

GitHub Actions / eslint

The type 'Album' is undefined
*/
uploadContext() {
return {
...this.album,
route: 'albumpicker',
root: `dav/photos/${getCurrentUser()?.uid}/albums`,
}
},
},

watch: {
Expand All @@ -172,8 +196,8 @@
this.fetchFiles('', {}, this.blacklistIds)
},

refreshFiles() {
this.fetchFiles('', { firstResult: 0 }, [...this.blacklistIds, ...this.fetchedFileIds], true)
emitUploadedEvent() {
this.$emit('files-uploaded')
},

emitPickedEvent() {
Expand Down
7 changes: 7 additions & 0 deletions src/views/AlbumContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@
:name="t('photos', 'Add photos to {albumName}', {albumName: albumName})"
@close="showAddPhotosModal = false">
<FilesPicker v-if="album !== undefined"
:album="album"
:destination="album.basename"
:blacklist-ids="albumFileIds"
@files-uploaded="handleFilesUploaded"
@files-picked="handleFilesPicked" />
</NcModal>

Expand Down Expand Up @@ -351,6 +353,11 @@ export default {
}
},

handleFilesUploaded() {
this.showAddPhotosModal = false
this.onUpload()
},

async handleFilesPicked(fileIds) {
this.showAddPhotosModal = false
await this.addFilesToCollection({ collectionFileName: this.album.filename, fileIdsToAdd: fileIds })
Expand Down
1 change: 1 addition & 0 deletions src/views/SharedAlbumContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
:name="t('photos', 'Add photos to {albumName}', {albumName: albumOriginalName})"
@close="showAddPhotosModal = false">
<FilesPicker v-if="album !== undefined"
:album="album"
:destination="album.basename"
:blacklist-ids="albumFileIds"
:loading="loadingAddFilesToAlbum"
Expand Down
Loading