-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'move_to_folder' of https://github.com/ahaltindis/memories…
… into ahaltindis-move_to_folder
- Loading branch information
Showing
3 changed files
with
214 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<template> | ||
<Modal @close="close" size="normal" v-if="processing"> | ||
<template #title> | ||
{{ t("memories", "Move to folder") }} | ||
</template> | ||
|
||
<div class="outer"> | ||
{{ | ||
t("memories", "Processing … {n}/{m}", { | ||
n: photosDone, | ||
m: photos.length, | ||
}) | ||
}} | ||
</div> | ||
</Modal> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from "vue"; | ||
import * as dav from "../../services/DavRequests"; | ||
import { getFilePickerBuilder, FilePickerType } from "@nextcloud/dialogs"; | ||
import { showInfo } from "@nextcloud/dialogs"; | ||
import { IPhoto } from "../../types"; | ||
import Modal from "./Modal.vue"; | ||
export default defineComponent({ | ||
name: "MoveToFolderModal", | ||
components: { | ||
Modal, | ||
}, | ||
data: () => ({ | ||
photos: [] as IPhoto[], | ||
photosDone: 0, | ||
processing: false, | ||
}), | ||
methods: { | ||
open(photos: IPhoto[]) { | ||
this.photosDone = 0; | ||
this.processing = false; | ||
this.photos = photos; | ||
this.chooseFolderPath(); | ||
}, | ||
moved(photos: IPhoto[]) { | ||
this.$emit("moved", photos); | ||
}, | ||
close() { | ||
this.photos = []; | ||
this.processing = false; | ||
this.$emit("close"); | ||
}, | ||
async chooseFolderModal(title: string, initial: string) { | ||
const picker = getFilePickerBuilder(title) | ||
.setMultiSelect(false) | ||
.setModal(false) | ||
.setType(FilePickerType.Move) | ||
.addMimeTypeFilter("httpd/unix-directory") | ||
.allowDirectories() | ||
.startAt(initial) | ||
.build(); | ||
return await picker.pick(); | ||
}, | ||
async chooseFolderPath() { | ||
let destination = await this.chooseFolderModal( | ||
this.t("memories", "Choose a folder"), | ||
this.config_foldersPath | ||
); | ||
// Fails if the target exists, same behavior with Nextcloud files implementation. | ||
const gen = dav.movePhotos(this.photos, destination, false); | ||
this.processing = true; | ||
for await (const fids of gen) { | ||
this.photosDone += fids.filter((f) => f).length; | ||
this.moved(this.photos.filter((p) => fids.includes(p.fileid))); | ||
} | ||
const n = this.photosDone; | ||
showInfo( | ||
this.n( | ||
"memories", | ||
"{n} item moved to folder", | ||
"{n} items moved to folder", | ||
n, | ||
{ n } | ||
) | ||
); | ||
this.close(); | ||
}, | ||
}, | ||
}); | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.outer { | ||
margin-top: 15px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters