Skip to content

Commit

Permalink
feat: Ease opening photos picker in album content view
Browse files Browse the repository at this point in the history
  • Loading branch information
artonge committed Jan 29, 2025
1 parent 4d46dd8 commit 18a9d53
Showing 1 changed file with 10 additions and 78 deletions.
88 changes: 10 additions & 78 deletions src/views/AlbumContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
:path="'/' + albumName"
:title="albumName"
@refresh="fetchAlbumContent">
<div v-if="album.location !== ''" slot="subtitle" class="album__location">
<div v-if="album.location !== ''"
slot="subtitle"
class="album__location">
<MapMarker />{{ album.location }}
</div>

Expand All @@ -54,13 +56,12 @@
</template>

<template v-if="album !== undefined" slot="right">
<UploadPicker v-if="album.nbItems !== 0"
:accept="allowedMimes"
:context="uploadContext"
:destination="album.basename"
:root="uploadContext.root"
:multiple="true"
@uploaded="onUpload" />
<NcButton @click="showAddPhotosModal = true">
<template #icon>
<Plus :size="20" />
</template>
{{ t('photos', 'Add photos to this album' ) }}
</NcButton>

<NcButton v-if="sharingEnabled"
type="tertiary"
Expand Down Expand Up @@ -166,11 +167,10 @@
</template>

<script>
import { addNewFileMenuEntry, removeNewFileMenuEntry } from '@nextcloud/files'
import { getCurrentUser } from '@nextcloud/auth'
import { mapActions, mapGetters } from 'vuex'
import { NcActions, NcActionButton, NcButton, NcModal, NcEmptyContent, NcActionSeparator, NcLoadingIcon, isMobile } from '@nextcloud/vue'
import { UploadPicker, getUploader } from '@nextcloud/upload'
import { getUploader } from '@nextcloud/upload'
import debounce from 'debounce'

import Close from 'vue-material-design-icons/Close.vue'
Expand All @@ -181,7 +181,6 @@ import ImagePlus from 'vue-material-design-icons/ImagePlus.vue'
import MapMarker from 'vue-material-design-icons/MapMarker.vue'
import Pencil from 'vue-material-design-icons/Pencil.vue'
import Plus from 'vue-material-design-icons/Plus.vue'
import PlusSvg from '@mdi/svg/svg/plus.svg'
import ShareVariant from 'vue-material-design-icons/ShareVariant.vue'

import AbortControllerMixin from '../mixins/AbortControllerMixin.js'
Expand All @@ -198,7 +197,6 @@ import FilesPicker from '../components/FilesPicker.vue'
import HeaderNavigation from '../components/HeaderNavigation.vue'

import { genFileInfo } from '../utils/fileUtils.js'
import allowedMimes from '../services/AllowedMimes.js'
import client from '../services/DavClient.js'
import DavRequest from '../services/DavRequest.js'
import logger from '../services/logger.js'
Expand Down Expand Up @@ -229,7 +227,6 @@ export default {
Pencil,
Plus,
ShareVariant,
UploadPicker,
},

mixins: [
Expand All @@ -249,26 +246,11 @@ export default {

data() {
return {
allowedMimes,

showAddPhotosModal: false,
showManageCollaboratorView: false,
showEditAlbumForm: false,

loadingAddCollaborators: false,

uploader: getUploader(),

newFileMenuEntry: {
id: 'album-add',
displayName: t('photos', 'Add photos to this album'),
templateName: '',
if: (context) => context.route === this.$route.name,
/** Existing icon css class */
iconSvgInline: PlusSvg,
/** Function to be run after creation */
handler: () => { this.showAddPhotosModal = true },
},
}
},

Expand Down Expand Up @@ -297,20 +279,6 @@ export default {
sharingEnabled() {
return OC.Share !== undefined
},

/**
* 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.
*/
uploadContext() {
return {
...this.album,
route: this.$route.name,
root: `dav/photos/${getCurrentUser()?.uid}/albums`,
}
},
},

watch: {
Expand All @@ -323,11 +291,6 @@ export default {

mounted() {
this.fetchAlbumContent()
addNewFileMenuEntry(this.newFileMenuEntry)
},

destroyed() {
removeNewFileMenuEntry(this.newFileMenuEntry)
},

methods: {
Expand Down Expand Up @@ -431,15 +394,6 @@ export default {
this.loadingAddCollaborators = false
}
},

/**
* A new File has been uploaded, let's add it
*
* @param {Upload[]} uploads
*/
onUpload: debounce(function() {
this.fetchAlbumContent()
}, 500),
},
}
</script>
Expand All @@ -461,26 +415,4 @@ export default {
color: var(--color-text-lighter);
}
}

.photos-navigation {
position: relative;
// Add space at the bottom for the progress bar.
&--uploading {
margin-bottom: 30px;
}
}

:deep(.upload-picker) {
.upload-picker__progress {
position: absolute;
bottom: -30px;
left: 64px;
margin: 0;
}
.upload-picker__cancel {
position: absolute;
bottom: -24px;
right: 50px;
}
}
</style>

0 comments on commit 18a9d53

Please sign in to comment.