forked from mirrors/homebox
frontend: cleanup
* dummy commit * cleanup workflows * setup and run eslint * add linter to CI * use eslint for formatting * reorder rules * drop editor config
This commit is contained in:
parent
78fa714297
commit
75c633dcb5
65 changed files with 2048 additions and 641 deletions
|
@ -1,8 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import ActionsDivider from '../../components/Base/ActionsDivider.vue';
|
||||
import ActionsDivider from "../../components/Base/ActionsDivider.vue";
|
||||
|
||||
definePageMeta({
|
||||
layout: 'home',
|
||||
layout: "home",
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
|
@ -16,8 +16,8 @@
|
|||
const { data: location } = useAsyncData(locationId.value, async () => {
|
||||
const { data, error } = await api.locations.get(locationId.value);
|
||||
if (error) {
|
||||
toast.error('Failed to load location');
|
||||
navigateTo('/home');
|
||||
toast.error("Failed to load location");
|
||||
navigateTo("/home");
|
||||
return;
|
||||
}
|
||||
return data;
|
||||
|
@ -25,25 +25,25 @@
|
|||
|
||||
function maybeTimeAgo(date?: string): string {
|
||||
if (!date) {
|
||||
return '??';
|
||||
return "??";
|
||||
}
|
||||
|
||||
const time = new Date(date);
|
||||
|
||||
return `${useTimeAgo(time).value} (${useDateFormat(time, 'MM-DD-YYYY').value})`;
|
||||
return `${useTimeAgo(time).value} (${useDateFormat(time, "MM-DD-YYYY").value})`;
|
||||
}
|
||||
|
||||
const details = computed(() => {
|
||||
const dt = {
|
||||
Name: location.value?.name || '',
|
||||
Description: location.value?.description || '',
|
||||
Name: location.value?.name || "",
|
||||
Description: location.value?.description || "",
|
||||
};
|
||||
|
||||
if (preferences.value.showDetails) {
|
||||
dt['Created At'] = maybeTimeAgo(location.value?.createdAt);
|
||||
dt['Updated At'] = maybeTimeAgo(location.value?.updatedAt);
|
||||
dt['Database ID'] = location.value?.id || '';
|
||||
dt['Group Id'] = location.value?.groupId || '';
|
||||
dt["Created At"] = maybeTimeAgo(location.value?.createdAt);
|
||||
dt["Updated At"] = maybeTimeAgo(location.value?.updatedAt);
|
||||
dt["Database ID"] = location.value?.id || "";
|
||||
dt["Group Id"] = location.value?.groupId || "";
|
||||
}
|
||||
|
||||
return dt;
|
||||
|
@ -52,7 +52,7 @@
|
|||
const { reveal } = useConfirm();
|
||||
|
||||
async function confirmDelete() {
|
||||
const { isCanceled } = await reveal('Are you sure you want to delete this location? This action cannot be undone.');
|
||||
const { isCanceled } = await reveal("Are you sure you want to delete this location? This action cannot be undone.");
|
||||
|
||||
if (isCanceled) {
|
||||
return;
|
||||
|
@ -61,23 +61,23 @@
|
|||
const { error } = await api.locations.delete(locationId.value);
|
||||
|
||||
if (error) {
|
||||
toast.error('Failed to delete location');
|
||||
toast.error("Failed to delete location");
|
||||
return;
|
||||
}
|
||||
toast.success('Location deleted');
|
||||
navigateTo('/home');
|
||||
toast.success("Location deleted");
|
||||
navigateTo("/home");
|
||||
}
|
||||
|
||||
const updateModal = ref(false);
|
||||
const updating = ref(false);
|
||||
const updateData = reactive({
|
||||
name: '',
|
||||
description: '',
|
||||
name: "",
|
||||
description: "",
|
||||
});
|
||||
|
||||
function openUpdate() {
|
||||
updateData.name = location.value?.name || '';
|
||||
updateData.description = location.value?.description || '';
|
||||
updateData.name = location.value?.name || "";
|
||||
updateData.description = location.value?.description || "";
|
||||
updateModal.value = true;
|
||||
}
|
||||
|
||||
|
@ -86,11 +86,11 @@
|
|||
const { error, data } = await api.locations.update(locationId.value, updateData);
|
||||
|
||||
if (error) {
|
||||
toast.error('Failed to update location');
|
||||
toast.error("Failed to update location");
|
||||
return;
|
||||
}
|
||||
|
||||
toast.success('Location updated');
|
||||
toast.success("Location updated");
|
||||
location.value = data;
|
||||
updateModal.value = false;
|
||||
updating.value = false;
|
||||
|
@ -102,8 +102,8 @@
|
|||
<BaseModal v-model="updateModal">
|
||||
<template #title> Update Location </template>
|
||||
<form v-if="location" @submit.prevent="update">
|
||||
<FormTextField :autofocus="true" label="Location Name" v-model="updateData.name" />
|
||||
<FormTextField label="Location Description" v-model="updateData.description" />
|
||||
<FormTextField v-model="updateData.name" :autofocus="true" label="Location Name" />
|
||||
<FormTextField v-model="updateData.description" label="Location Description" />
|
||||
<div class="modal-action">
|
||||
<BaseButton type="submit" :loading="updating"> Update </BaseButton>
|
||||
</div>
|
||||
|
@ -111,14 +111,14 @@
|
|||
</BaseModal>
|
||||
<section>
|
||||
<BaseSectionHeader class="mb-5" dark>
|
||||
{{ location ? location.name : '' }}
|
||||
{{ location ? location.name : "" }}
|
||||
</BaseSectionHeader>
|
||||
<BaseDetails class="mb-2" :details="details">
|
||||
<template #title> Location Details </template>
|
||||
</BaseDetails>
|
||||
<div class="form-control ml-auto mr-2 max-w-[130px]">
|
||||
<label class="label cursor-pointer">
|
||||
<input type="checkbox" v-model.checked="preferences.showDetails" class="checkbox" />
|
||||
<input v-model="preferences.showDetails" type="checkbox" class="toggle" />
|
||||
<span class="label-text"> Detailed View </span>
|
||||
</label>
|
||||
</div>
|
||||
|
@ -128,7 +128,7 @@
|
|||
<section v-if="location">
|
||||
<BaseSectionHeader class="mb-5"> Items </BaseSectionHeader>
|
||||
<div class="grid gap-2 grid-cols-2">
|
||||
<ItemCard v-for="item in location.items" :item="item" :key="item.id" />
|
||||
<ItemCard v-for="item in location.items" :key="item.id" :item="item" />
|
||||
</div>
|
||||
</section>
|
||||
</BaseContainer>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue