move frontend to /web

This commit is contained in:
j3d1 2023-11-18 12:51:24 +01:00
parent 9747c08bab
commit dd75c2b0d6
36 changed files with 0 additions and 0 deletions

114
web/src/views/Items.vue Normal file
View file

@ -0,0 +1,114 @@
<template>
<div class="container-fluid px-xl-5 mt-3">
<Modal title="Edit Item" v-if="editingItem" @close="closeEditingModal()">
<template #body>
<EditItem
:item="editingItem"
badge="uid"
/>
</template>
<template #buttons>
<button type="button" class="btn btn-secondary" @click="closeEditingModal()">Cancel</button>
<button type="button" class="btn btn-success" @click="saveEditingItem()">Save Changes</button>
</template>
</Modal>
<Lightbox v-if="lightboxItem" :file="lightboxItem.file" @close="closeLightboxModal()"/>
<div class="row" v-if="layout === 'table'">
<div class="col-xl-8 offset-xl-2">
<Table
:columns="['uid', 'description', 'box']"
:items="loadedItems"
:keyName="'uid'"
v-slot="{ item }"
@itemActivated="openLightboxModalWith($event)"
>
<div class="btn-group">
<button class="btn btn-success" @click.stop="markItemReturned(item)" title="returned">
<font-awesome-icon icon="check"/>
</button>
<button class="btn btn-secondary" @click.stop="openEditingModalWith(item)" title="edit">
<font-awesome-icon icon="edit"/>
</button>
<button class="btn btn-danger" @click.stop="deleteItem(item)" title="delete">
<font-awesome-icon icon="trash"/>
</button>
</div>
</Table>
</div>
</div>
<Cards
v-if="layout === 'cards'"
:columns="['uid', 'description', 'box']"
:items="loadedItems"
:keyName="'uid'"
v-slot="{ item }"
@itemActivated="openLightboxModalWith($event)"
>
<img
:src="`${baseUrl}/1/thumbs/${item.file}`"
class="card-img-top img-fluid"
>
<div class="card-body">
<h6 class="card-title">{{ item.description }}</h6>
<h6 class="card-subtitle text-secondary">uid: {{ item.uid }} box: {{ item.box }}</h6>
<div class="row mx-auto mt-2">
<div class="btn-group">
<button class="btn btn-outline-success" @click.stop="markItemReturned(item)" title="returned">
<font-awesome-icon icon="check"/>
</button>
<button class="btn btn-outline-secondary" @click.stop="openEditingModalWith(item)" title="edit">
<font-awesome-icon icon="edit"/>
</button>
<button class="btn btn-outline-danger" @click.stop="deleteItem(item)" title="delete">
<font-awesome-icon icon="trash"/>
</button>
</div>
</div>
</div>
</Cards>
</div>
</template>
<script>
import Table from '@/components/Table';
import Cards from '@/components/Cards';
import Modal from '@/components/Modal';
import EditItem from '@/components/EditItem';
import {mapActions, mapState} from 'vuex';
import config from '../config';
import Lightbox from '../components/Lightbox';
export default {
name: 'Items',
data: () => ({
lightboxItem: null,
editingItem: null,
baseUrl: config.service.url,
}),
components: {Lightbox, Table, Cards, Modal, EditItem },
computed: mapState(['loadedItems', 'layout']),
methods: {
...mapActions(['deleteItem','markItemReturned']),
openLightboxModalWith(item) { // Opens the editing modal with a copy of the selected item.
this.lightboxItem = { ...item };
},
closeLightboxModal() { // Closes the editing modal and discards the edited copy of the item.
this.lightboxItem = null;
},
openEditingModalWith(item) {
this.editingItem = item;
},
closeEditingModal() {
this.editingItem = null;
},
saveEditingItem() { // Saves the edited copy of the item.
this.$store.dispatch('updateItem', this.editingItem);
this.closeEditingModal();
}
}
};
</script>
<style scoped>
</style>