-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from simonsobs/dev
Enable Reordering of Queue Items
- Loading branch information
Showing
9 changed files
with
390 additions
and
51 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
File renamed without changes.
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,148 @@ | ||
<template> | ||
<div class="d-flex"> | ||
<VBtn v-if="mobile" variant="text" icon="mdi-close" @click="show = false"></VBtn> | ||
<VSpacer></VSpacer> | ||
<VBtn | ||
variant="text" | ||
icon="mdi-trash-can-outline" | ||
@click="dialogConfirmDelete = true" | ||
></VBtn> | ||
<VMenu :close-on-content-click="false"> | ||
<template v-slot:activator="{ props }"> | ||
<VBtn v-bind="props" variant="text" icon="mdi-dots-horizontal"></VBtn> | ||
</template> | ||
<VList> | ||
<VListSubheader>Move (Reorder)</VListSubheader> | ||
<VListItem :disabled="atTop" @click="moveToTop"> | ||
<template v-slot:prepend> | ||
<v-icon> mdi-arrow-up </v-icon> | ||
</template> | ||
To Top | ||
</VListItem> | ||
<VListItem :disabled="atTop" @click="moveOneUp"> | ||
<template v-slot:prepend> | ||
<v-icon> mdi-arrow-up-thin </v-icon> | ||
</template> | ||
One Up | ||
</VListItem> | ||
<VListItem :disabled="atBottom" @click="moveOneDown"> | ||
<template v-slot:prepend> | ||
<v-icon> mdi-arrow-down-thin </v-icon> | ||
</template> | ||
One Down | ||
</VListItem> | ||
<VListItem :disabled="atBottom" @click="moveToBottom"> | ||
<template v-slot:prepend> | ||
<v-icon> mdi-arrow-down</v-icon> | ||
</template> | ||
To Bottom | ||
</VListItem> | ||
</VList> | ||
</VMenu> | ||
<DeleteConfirmationDialog | ||
v-model="dialogConfirmDelete" | ||
:item="item" | ||
@confirm="onDeleteConfirmed" | ||
> | ||
</DeleteConfirmationDialog> | ||
<LoadingIndicator v-model="loading"> </LoadingIndicator> | ||
<ErrorDialog v-model="dialogError" :error="error"> </ErrorDialog> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, computed, toRefs } from "vue"; | ||
import { useDisplay } from "vuetify"; | ||
import type { CombinedError } from "@urql/vue"; | ||
import { useItems } from "../items"; | ||
import type { Item } from "../items"; | ||
import DeleteConfirmationDialog from "./DeleteConfirmationDialog.vue"; | ||
import LoadingIndicator from "../LoadingIndicator.vue"; | ||
import ErrorDialog from "../ErrorDialog.vue"; | ||
const { mobile } = useDisplay(); | ||
interface Props { | ||
item: Item; | ||
nItems: number; | ||
} | ||
const props = defineProps<Props>(); | ||
const { item } = toRefs(props); | ||
const show = defineModel<boolean>(); | ||
const dialogConfirmDelete = ref(false); | ||
const loading = ref<boolean>(false); | ||
const dialogError = ref<boolean>(false); | ||
const error = ref<CombinedError>(); | ||
const { | ||
items, | ||
deleteItem, | ||
moveItemToTop, | ||
moveItemOneUp, | ||
moveItemOneDown, | ||
moveItemToBottom, | ||
} = useItems(); | ||
const nItems = computed(() => items.value?.length ?? 0); | ||
const atTop = computed(() => item.value.order === 1); | ||
const atBottom = computed(() => item.value.order === nItems.value); | ||
async function onDeleteConfirmed() { | ||
loading.value = true; | ||
const result = await deleteItem(item.value); | ||
loading.value = false; | ||
if (result.error) { | ||
error.value = result.error; | ||
dialogError.value = true; | ||
return; | ||
} | ||
show.value = false; | ||
} | ||
async function moveToTop() { | ||
loading.value = true; | ||
const result = await moveItemToTop(item.value); | ||
loading.value = false; | ||
if (result.error) { | ||
error.value = result.error; | ||
dialogError.value = true; | ||
return; | ||
} | ||
} | ||
async function moveOneUp() { | ||
loading.value = true; | ||
const result = await moveItemOneUp(item.value); | ||
loading.value = false; | ||
if (result.error) { | ||
error.value = result.error; | ||
dialogError.value = true; | ||
return; | ||
} | ||
} | ||
async function moveOneDown() { | ||
loading.value = true; | ||
const result = await moveItemOneDown(item.value); | ||
loading.value = false; | ||
if (result.error) { | ||
error.value = result.error; | ||
dialogError.value = true; | ||
return; | ||
} | ||
} | ||
async function moveToBottom() { | ||
loading.value = true; | ||
const result = await moveItemToBottom(item.value); | ||
loading.value = false; | ||
if (result.error) { | ||
error.value = result.error; | ||
dialogError.value = true; | ||
return; | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped></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
Oops, something went wrong.