Skip to content

Commit

Permalink
Restrict source folder selection to 1
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed Feb 15, 2024
1 parent e3c3926 commit 8f16b06
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/Service/UserConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class UserConfigService {
public const DEFAULT_CONFIGS = [
'croppedLayout' => 'false',
'photosLocation' => '/Photos',
'photosSourceFolders' => '["/Photos"]',
'photosSourceFolder' => '/Photos',
];

private IConfig $config;
Expand Down
42 changes: 23 additions & 19 deletions src/components/Settings/PhotosSourceLocationsSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,24 @@
<template>
<div class="photos-locations">
<ul>
<li v-for="(source, index) in photosSourceFolders"
<PhotosFolder :path="photosSourceFolder" :root-folder-label="t('photos', 'All folders')" />
<!-- TODO: uncomment when SEARCH on multiple folders is implemented. -->
<!-- <li v-for="(source, index) in photosSourceFolder"
:key="index">
<PhotosFolder :path="source" :can-delete="photosSourceFolders.length !== 1" @remove-folder="removeSourceFolder(index)" :root-folder-label="t('photos', 'All folders')"/>
</li>
<PhotosFolder :path="source"
:can-delete="photosSourceFolder.length !== 1"
:root-folder-label="t('photos', 'All folders')"
@remove-folder="removeSourceFolder(index)" />
</li> -->
</ul>

<NcButton :aria-label="t('photos', 'Add source directory')"
<NcButton :aria-label="t('photos', 'Choose a source Photos for the timelines')"
@click="debounceAddSourceFolder">
<template #icon>
<!-- TODO: uncomment when SEARCH on multiple folders is implemented. -->
<!-- <template #icon>
<Plus :size="20" />
</template>
{{ t('photos', 'Add folder') }}
</template> -->
{{ t('photos', 'Choose a different folder') }}
</NcButton>
</div>
</template>
Expand All @@ -43,8 +49,6 @@
import debounce from 'debounce'
import { defineComponent } from 'vue'
import Plus from 'vue-material-design-icons/Plus.vue'
import { NcButton } from '@nextcloud/vue'
import { getFilePickerBuilder } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n'
Expand All @@ -56,14 +60,13 @@ export default defineComponent({
components: {
NcButton,
Plus,
PhotosFolder,
},
computed: {
/** @return {string[]} */
photosSourceFolders() {
return this.$store.state.userConfig.photosSourceFolders
/** @return {string} */
photosSourceFolder() {
return this.$store.state.userConfig.photosSourceFolder
},
},
Expand All @@ -86,16 +89,17 @@ export default defineComponent({
async addSourceFolder() {
const pickedFolder = await this.openFilePicker(t('photos', 'Select a source folder for your media'))
if (this.photosSourceFolders.includes(pickedFolder)) {
return
}
this.$store.dispatch('updateUserConfig', { key: 'photosSourceFolders', value: [...this.photosSourceFolders, pickedFolder] })
// TODO: uncomment when SEARCH on multiple folders is implemented.
// if (this.photosSourceFolder.includes(pickedFolder)) {
// return
// }
this.$store.dispatch('updateUserConfig', { key: 'photosSourceFolder', value: pickedFolder })
},
removeSourceFolder(index) {
const folders = [...this.photosSourceFolders]
const folders = [...this.photosSourceFolder]
folders.splice(index, 1)
this.$store.dispatch('updateUserConfig', { key: 'photosSourceFolders', value: folders })
this.$store.dispatch('updateUserConfig', { key: 'photosSourceFolder', value: folders })
},
t,
Expand Down

0 comments on commit 8f16b06

Please sign in to comment.