-
-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move should be working for both photo and albums
- Loading branch information
Showing
13 changed files
with
380 additions
and
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<template> | ||
<Dialog v-model:visible="visible" pt:root:class="border-none" modal :dismissable-mask="true"> | ||
<template #container="{ closeCallback }"> | ||
<div> | ||
<p class="p-9 text-center text-muted-color max-w-xl text-wrap">{{ confirmation }}</p> | ||
<div class="flex"> | ||
<Button severity="secondary" class="w-full border-none rounded-none rounded-bl-xl font-bold" @click="closeCallback"> | ||
{{ $t("lychee.CANCEL") }} | ||
</Button> | ||
<Button severity="danger" class="w-full border-none rounded-none rounded-br-xl font-bold" @click="execute">{{ | ||
$t("lychee.DELETE") | ||
}}</Button> | ||
</div> | ||
</div> | ||
</template> | ||
</Dialog> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed } from "vue"; | ||
import Button from "primevue/button"; | ||
import AlbumService from "@/services/album-service"; | ||
import { trans } from "laravel-vue-i18n"; | ||
import { sprintf } from "sprintf-js"; | ||
import Dialog from "primevue/dialog"; | ||
const props = defineProps<{ | ||
parentId: string | undefined; | ||
album?: App.Http.Resources.Models.ThumbAlbumResource; | ||
albumIds: string[]; | ||
}>(); | ||
const visible = defineModel<boolean>("visible", { default: false }); | ||
const emit = defineEmits<{ | ||
(e: "deleted"): void; | ||
}>(); | ||
const confirmation = computed(() => { | ||
if (props.album) { | ||
return sprintf(trans("lychee.DELETE_ALBUM_CONFIRMATION"), props.album.title); | ||
} | ||
return sprintf(trans("lychee.DELETE_ALBUMS_CONFIRMATION"), props.albumIds.length); | ||
}); | ||
function execute() { | ||
let albumDeletedIds = []; | ||
if (props.album) { | ||
albumDeletedIds.push(props.album.id); | ||
} else { | ||
albumDeletedIds = props.albumIds as string[]; | ||
} | ||
AlbumService.delete(albumDeletedIds).then(() => { | ||
if (props.parentId === undefined) { | ||
AlbumService.clearAlbums(); | ||
} else { | ||
AlbumService.clearCache(props.parentId); | ||
} | ||
emit("deleted"); | ||
}); | ||
} | ||
</script> |
102 changes: 102 additions & 0 deletions
102
resources/js/components/forms/album/AlbumMoveDialog.vue
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,102 @@ | ||
<template> | ||
<Dialog v-model:visible="visible" pt:root:class="border-none" modal :dismissable-mask="true"> | ||
<template #container="{ closeCallback }"> | ||
<div v-if="titleMovedTo !== undefined"> | ||
<p class="p-9 text-center text-muted-color">{{ confirmation }}</p> | ||
<div class="flex"> | ||
<Button severity="secondary" class="font-bold w-full border-none rounded-none rounded-bl-xl" @click="close"> | ||
{{ $t("lychee.CANCEL") }} | ||
</Button> | ||
<Button severity="contrast" class="font-bold w-full border-none rounded-none rounded-br-xl" @click="execute"> | ||
{{ $t("lychee.MOVE") }} | ||
</Button> | ||
</div> | ||
</div> | ||
<div v-else> | ||
<div class="p-9"> | ||
<span v-if="props.album" class="font-bold"> | ||
{{ sprintf("Move %s to:", props.album.title) }} | ||
</span> | ||
<span v-else class="font-bold"> | ||
{{ sprintf("Move %d albums to:", props.albumIds?.length) }} | ||
</span> | ||
<SearchTargetAlbum :album-id="parentId" @selected="selected" /> | ||
</div> | ||
<Button class="w-full font-bold rounded-none rounded-bl-xl rounded-br-xl border-none" severity="secondary" @click="closeCallback"> | ||
{{ $t("lychee.CANCEL") }} | ||
</Button> | ||
</div> | ||
</template> | ||
</Dialog> | ||
</template> | ||
<script setup lang="ts"> | ||
import { computed, ref } from "vue"; | ||
import Button from "primevue/button"; | ||
import { trans } from "laravel-vue-i18n"; | ||
import { sprintf } from "sprintf-js"; | ||
import SearchTargetAlbum from "@/components/forms/album/SearchTargetAlbum.vue"; | ||
import AlbumService from "@/services/album-service"; | ||
import { useToast } from "primevue/usetoast"; | ||
import Dialog from "primevue/dialog"; | ||
|
||
const props = defineProps<{ | ||
parentId: string | undefined; | ||
album?: App.Http.Resources.Models.ThumbAlbumResource; | ||
albumIds: string[]; | ||
}>(); | ||
|
||
const visible = defineModel<boolean>("visible", { default: false }); | ||
|
||
const emit = defineEmits<{ | ||
(e: "moved"): void; | ||
}>(); | ||
|
||
const toast = useToast(); | ||
const titleMovedTo = ref(undefined as string | undefined); | ||
const destination_id = ref(undefined as string | undefined | null); | ||
const confirmation = computed(() => { | ||
if (props.album) { | ||
return sprintf(trans("lychee.ALBUM_MOVE"), props.album.title, titleMovedTo.value); | ||
} | ||
return sprintf(trans("lychee.ALBUMS_MOVE"), titleMovedTo.value); | ||
}); | ||
|
||
function selected(target: App.Http.Resources.Models.TargetAlbumResource) { | ||
titleMovedTo.value = target.original; | ||
destination_id.value = target.id; | ||
} | ||
|
||
function close() { | ||
titleMovedTo.value = undefined; | ||
destination_id.value = undefined; | ||
visible.value = false; | ||
} | ||
|
||
function execute() { | ||
if (destination_id.value === undefined) { | ||
return; | ||
} | ||
let albumMovedIds = []; | ||
if (props.album) { | ||
albumMovedIds.push(props.album.id); | ||
} else { | ||
albumMovedIds = props.albumIds as string[]; | ||
} | ||
|
||
AlbumService.move(destination_id.value, albumMovedIds).then(() => { | ||
AlbumService.clearCache(destination_id.value); | ||
toast.add({ | ||
severity: "success", | ||
summary: "Album(s) moved to " + titleMovedTo.value, | ||
life: 3000, | ||
}); | ||
AlbumService.clearCache(destination_id.value); | ||
if (props.parentId === undefined) { | ||
AlbumService.clearAlbums(); | ||
} else { | ||
AlbumService.clearCache(props.parentId); | ||
} | ||
emit("moved"); | ||
}); | ||
} | ||
</script> |
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
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,60 @@ | ||
import AlbumService from "@/services/album-service"; | ||
import { AuthStore } from "@/stores/Auth"; | ||
import { LycheeStateStore } from "@/stores/LycheeState"; | ||
import { computed, ref, Ref } from "vue"; | ||
|
||
export function useAlbumsRefresher(auth: AuthStore, lycheeStore: LycheeStateStore, isLoginOpen: Ref<boolean>) { | ||
const user = ref(undefined) as Ref<undefined | App.Http.Resources.Models.UserResource>; | ||
const isKeybindingsHelpOpen = ref(false); | ||
const smartAlbums = ref([]) as Ref<App.Http.Resources.Models.ThumbAlbumResource[]>; | ||
const albums = ref([]) as Ref<App.Http.Resources.Models.ThumbAlbumResource[]>; | ||
const sharedAlbums = ref([]) as Ref<App.Http.Resources.Models.ThumbAlbumResource[]>; | ||
const rootConfig = ref(undefined) as Ref<undefined | App.Http.Resources.GalleryConfigs.RootConfig>; | ||
const rootRights = ref(undefined) as Ref<undefined | App.Http.Resources.Rights.RootAlbumRightsResource>; | ||
const selectableAlbums = computed(() => albums.value.concat(sharedAlbums.value)); | ||
|
||
function refresh() { | ||
auth.getUser().then((data) => { | ||
user.value = data; | ||
|
||
// display popup if logged in and set.. | ||
if (user.value.id && lycheeStore.show_keybinding_help_popup) { | ||
isKeybindingsHelpOpen.value = true; | ||
} | ||
}); | ||
|
||
AlbumService.getAll() | ||
.then((data) => { | ||
smartAlbums.value = (data.data.smart_albums as App.Http.Resources.Models.ThumbAlbumResource[]) ?? []; | ||
albums.value = data.data.albums as App.Http.Resources.Models.ThumbAlbumResource[]; | ||
smartAlbums.value = smartAlbums.value.concat(data.data.tag_albums as App.Http.Resources.Models.ThumbAlbumResource[]); | ||
sharedAlbums.value = (data.data.shared_albums as App.Http.Resources.Models.ThumbAlbumResource[]) ?? []; | ||
rootConfig.value = data.data.config; | ||
rootRights.value = data.data.rights; | ||
|
||
if (albums.value.length === 0 && smartAlbums.value.length === 0 && sharedAlbums.value.length === 0) { | ||
isLoginOpen.value = true; | ||
} | ||
}) | ||
.catch((error) => { | ||
// We are required to login :) | ||
if (error.response.status === 401) { | ||
isLoginOpen.value = true; | ||
} else { | ||
console.error(error); | ||
} | ||
}); | ||
} | ||
|
||
return { | ||
user, | ||
isKeybindingsHelpOpen, | ||
smartAlbums, | ||
albums, | ||
sharedAlbums, | ||
rootConfig, | ||
rootRights, | ||
selectableAlbums, | ||
refresh, | ||
}; | ||
} |
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
14 changes: 14 additions & 0 deletions
14
resources/js/composables/modalsTriggers/deleteAlbumOpen.ts
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,14 @@ | ||
import { ref } from "vue"; | ||
|
||
export function useDeleteAlbumOpen() { | ||
const isDeleteAlbumVisible = ref(false); | ||
|
||
function toggleDeleteAlbum() { | ||
isDeleteAlbumVisible.value = !isDeleteAlbumVisible.value; | ||
} | ||
|
||
return { | ||
isDeleteAlbumVisible, | ||
toggleDeleteAlbum, | ||
}; | ||
} |
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,14 @@ | ||
import { ref } from "vue"; | ||
|
||
export function useMoveAlbumOpen() { | ||
const isMoveAlbumVisible = ref(false); | ||
|
||
function toggleMoveAlbum() { | ||
isMoveAlbumVisible.value = !isMoveAlbumVisible.value; | ||
} | ||
|
||
return { | ||
isMoveAlbumVisible, | ||
toggleMoveAlbum, | ||
}; | ||
} |
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
Oops, something went wrong.