Compare commits

...

9 Commits

Author SHA1 Message Date
ebef3ee901 FIx history date display 2025-06-27 17:56:42 +02:00
d656bb15ff Add recap page 2025-06-27 17:50:22 +02:00
9fe860b526 Renumerate script 2025-06-27 15:49:04 +02:00
a7225eb054 Add shortId handling for QR
Add renumerate script
Add Tasks
2025-06-27 15:35:31 +02:00
6459dbd68c Fix feed date
Fix redirect to new item
2025-06-27 14:01:29 +02:00
361bb0c1ed Many fixes n stuff 2025-04-18 14:42:43 +02:00
892158fc30 Fix style 2025-04-18 13:29:15 +02:00
96899a8477 Fix style 2025-04-16 21:38:56 +02:00
08cf066c88 Fix style 2025-04-16 21:24:49 +02:00
29 changed files with 461 additions and 176 deletions

View File

@ -74,6 +74,7 @@ module.exports = {
'no-unused-vars': 'off',
'no-trailing-spaces' : 'off',
'vue/multi-word-component-names' : 'off',
'vue/no-v-text-v-html-on-component' : 'off',
// allow debugger during development only
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'

1
.gitignore vendored
View File

@ -33,3 +33,4 @@ yarn-error.log*
.env.local*
pocketbase/pb_data/*
pocketbase/pocketbase.exe

View File

@ -8,7 +8,7 @@ HFSPlay stock management
- [ ] editable categories
- [x] qrcode generation
- [x] fix search to be persistent
- [ ] fix comments to be more legible
- [x] fix comments to be more legible
- [ ] fix comments to allow resolution
- [ ] batch print QR codes
- [x] fix tables pagination

View File

@ -13,7 +13,8 @@
"import-categories": "node ./scripts/import_categories.js",
"import-stock": "node ./scripts/import_stock.js",
"import-history": "node ./scripts/import_history.js",
"import-history-files": "node ./scripts/import_history_files.js"
"import-history-files": "node ./scripts/import_history_files.js",
"renumerate-stock": "node ./scripts/renumerate.js"
},
"dependencies": {
"@quasar/extras": "^1.16.4",

BIN
public/font/Geist-Black.otf Normal file

Binary file not shown.

BIN
public/font/Geist-Bold.otf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
public/font/Geist-Light.otf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
public/font/Geist-Thin.otf Normal file

Binary file not shown.

BIN
public/font/Geist-var.ttf Normal file

Binary file not shown.

View File

@ -19,8 +19,6 @@ module.exports = configure(function (/* ctx */) {
// --> boot files are part of "main.js"
// https://v2.quasar.dev/quasar-cli-vite/boot-files
boot: [
'axios',
'pocketbase'
],

View File

@ -6,7 +6,7 @@ const pb = new PocketBase('http://127.0.0.1:8090')
async function main () {
try {
// Authenticate as an admin
await pb.admins.authWithPassword('karkinge@gmail.com', 'PBk4rk1ng3*') // Replace with your admin credentials
await pb.admins.authWithPassword('karkinge@gmail.com', 'XXXXXXX') // Replace with your admin credentials
// Parse JSON file with categories
const data = require('../../gyoza/database_backups/20250320.json')

View File

@ -6,7 +6,7 @@ const pb = new PocketBase('http://127.0.0.1:8090')
async function main () {
try {
// Authenticate as an admin
await pb.admins.authWithPassword('karkinge@gmail.com', 'PBk4rk1ng3*') // Replace with your admin credentials
await pb.admins.authWithPassword('karkinge@gmail.com', 'XXXXXXX') // Replace with your admin credentials
// Parse JSON file with categories
const data = require('../../gyoza/database_backups/20250320.json')

View File

@ -7,7 +7,7 @@ const pb = new PocketBase('http://127.0.0.1:8090')
async function main () {
try {
// Authenticate as an admin
await pb.admins.authWithPassword('karkinge@gmail.com', 'PBk4rk1ng3*') // Replace with your admin credentials
await pb.admins.authWithPassword('karkinge@gmail.com', 'XXXXXXX') // Replace with your admin credentials
// Parse JSON file with categories
const filesPath = '../gyoza/storage/'

View File

@ -6,7 +6,7 @@ const pb = new PocketBase('http://127.0.0.1:8090')
async function main () {
try {
// Authenticate as an admin
await pb.admins.authWithPassword('karkinge@gmail.com', 'PBk4rk1ng3*') // Replace with your admin credentials
await pb.admins.authWithPassword('karkinge@gmail.com', 'XXXXXXX') // Replace with your admin credentials
// Parse JSON file with categories
const data = require('../../gyoza/database_backups/20250320.json')

31
scripts/renumerate.js Normal file
View File

@ -0,0 +1,31 @@
const PocketBase = require('pocketbase').default
// Initialize the PocketBase client
// const pb = new PocketBase('https://stock.hfsplay.fr')
const pb = new PocketBase('http://127.0.0.1:8090')
async function main () {
try {
// Authenticate as an admin
// await pb.admins.authWithPassword('gyoza@hfsplay.fr', 'gyozagyoza') // Replace with your admin credentials
await pb.collection('_superusers').authWithPassword('karkinge@gmail.com', 'XXXXXXX') // Replace with your admin credentials
console.log('connected !')
let stock = await pb.collection('stock').getFullList({
sort: 'created'
})
console.log('Stock items count:', stock.length)
for (let i = 0; i < stock.length; i++) {
const item = stock[i]
if (!item) continue
// Update the item with a new ID
const updatedItem = await pb.collection('stock').update(item.id, {
short_id: i + 1 // Adjust the ID as needed
})
console.log(`Updated item ${item.id} to new ID ${updatedItem.id}`)
}
} catch (error) {
console.error('Error:', error)
}
}
main()

View File

@ -1,6 +1,6 @@
import { boot } from 'quasar/wrappers'
import PocketBase from 'pocketbase'
const pb = new PocketBase('http://127.0.0.1:8090')
const pb = new PocketBase(process.env.DEV ? 'http://127.0.0.1:8090' : 'https://stock.hfsplay.fr')
export default boot(({ app }) => {
pb.collection('_superusers').authWithPassword(

View File

@ -20,7 +20,7 @@
</q-item-section>
<q-item-section side top>
<q-item-label caption>{{timeAgo(history.date)}}</q-item-label>
<q-item-label caption>{{timeAgo(history.date || history.created)}}</q-item-label>
</q-item-section>
</q-item>
</q-list>
@ -63,7 +63,7 @@ export default {
if (hoursDiff < 24) {
return `il y a ${hoursDiff} heure(s)`
} else {
let daysDiff = date.getDateDiff(date2, date1)
let daysDiff = date.getDateDiff(date2, date1, 'days')
return `il y a ${daysDiff} jour(s)`
}
},

View File

@ -1 +1,10 @@
// app global css in SCSS form
@font-face {
font-family: geist;
src: url(./font/Geist-var.ttf) format('truetype');
}
// declare a class which applies it
html, body {
font-family: 'geist';
}

BIN
src/css/font/Geist-var.ttf Normal file

Binary file not shown.

View File

@ -66,7 +66,15 @@
<!-- PRINT STUFF-->
<q-separator/>
<q-item-label header>Utilitaires</q-item-label>
<q-item :to="'/tasks'"
>
<q-item-section>Tâches</q-item-section>
<q-item-section side>
<q-icon name="task"></q-icon>
</q-item-section>
</q-item>
<q-item :to="'/print-settings'"
disable
>
<q-item-section>Impression</q-item-section>
<q-item-section side>
@ -188,6 +196,8 @@ export default {
},
async addItem (category) {
this.$q.loading.show()
// Get next short id
let shortId = await this.$store.dispatch('core/getNextShortId')
let newItem = {
available: true,
comment: '',
@ -196,7 +206,8 @@ export default {
ref: null,
state: null,
type: category.name,
system: null
system: null,
short_id: shortId
}
newItem.ref = `${category.code}-${String(this.counters[category.name] + 1).padStart(4, '0')}`
await this.$store.dispatch('core/addToCollection', {
@ -224,12 +235,9 @@ export default {
ok: 'Oui, STP',
cancel: 'Osef'
})
.then(() => {
.onOk(() => {
this.$router.push(`/item/${newItem.ref}`)
})
.catch(() => {
// Picked "Cancel" or dismissed
})
}
}
}

View File

@ -1,10 +1,13 @@
<template>
<q-page class="q-pa-md">
<q-btn @click="generateQRCode" class="float-right" icon="qr_code"></q-btn>
<q-chip class="float-right text-white" color="secondary">{{item.ref}}</q-chip>
<q-chip v-if="item.deleted" class="float-right q-mr-md" color="red">Supprimé</q-chip>
<h2 class="q-ma-none" :class="{'text-faded': !item.name}">{{item.name || '---- -- ----'}}</h2>
<h4 class="q-ma-none q-pb-md text-grey">{{item.type}}</h4>
<div class="q-ma-none text-h3 text-weight-bolder row" :class="{'text-faded': !item.name}">
<span class="q-mr-md">{{ item.name || '---- -- ----' }}</span>
<q-chip square size="lg" class="text-white q-mr-md" color="secondary">{{item.ref}}</q-chip>
<q-chip square outline size="lg" class="q-mr-md" color="secondary">{{item.short_id}}</q-chip>
<q-chip square size="lg" v-if="item.deleted" color="red">Supprimé</q-chip>
</div>
<h5 class="q-ma-none q-pb-md text-grey">{{item.type}}</h5>
<q-dialog v-model="showQr">
<q-card style="width: 500px">
@ -23,26 +26,36 @@
</q-card>
</q-dialog>
<div class="q-py-md">
<q-input v-model="item.name"
:disable="item.deleted"
type="text"
outlined color="secondary"
stack-label label="Nom" class="q-mb-md"
@update:model-value="changed = true"/>
<q-input v-model="item.owner"
:disable="item.deleted"
outlined color="secondary" stack-label label="Propriétaire" class="q-mb-md"
@input="changed = true"/>
<q-field borderless stack-label label="Etat cosmétique" class="q-mb-md">
<q-btn-toggle
no-caps
:disable="item.deleted"
v-model="item.state"
@update:model-value="changed = true"
toggle-color="secondary"
text-color="black"
:options="[
<div class="row q-col-gutter-xl">
<div class="col-12 col-lg-6">
<div class="row">
<div class="col">
<h4 class="q-ma-none q-pb-md text-light">Informations</h4>
</div>
</div>
<div>
<q-input v-model="item.name"
:disable="item.deleted"
type="text"
label="Nom"
outlined color="secondary"
class="q-mb-md"
@update:model-value="changed = true">
</q-input>
<q-input v-model="item.owner"
:disable="item.deleted"
outlined color="secondary" stack-label label="Propriétaire" class="q-mb-md"
@input="changed = true"/>
<q-field borderless stack-label label="Etat cosmétique" class="q-mb-md">
<q-btn-toggle
class="q-mt-sm"
no-caps
:disable="item.deleted"
v-model="item.state"
@update:model-value="changed = true"
toggle-color="secondary"
text-color="black"
:options="[
{label: 'Neuf', value: 'Neuf'},
{label: 'Excellent', value: 'Excellent'},
{label: 'Bon', value: 'Bon'},
@ -50,150 +63,184 @@
{label: 'Abimé', value: 'Abimé'},
{label: 'Inutilisable', value: 'Inutilisable'}
]"
/>
</q-field>
<q-field borderless stack-label label="Fonctionnel" class="q-mb-md">
<q-btn-toggle
no-caps
:disable="item.deleted"
v-model="item.working"
:toggle-color="item.working ? 'green' : 'red'"
text-color="black"
:options="[
/>
</q-field>
<q-field borderless stack-label label="Fonctionnel" class="q-mb-md">
<q-btn-toggle
class="q-mt-sm"
no-caps
:disable="item.deleted"
v-model="item.working"
:toggle-color="item.working ? 'green' : 'red'"
text-color="black"
:options="[
{label: '✔', value: true},
{label: '?', value: null},
{label: '✘', value: false}
]"
@input="changed = true"
/>
</q-field>
<q-field borderless stack-label label="En stock" class="q-mb-md">
<q-btn-toggle
no-caps
:disable="item.deleted"
v-model="item.available"
:toggle-color="item.available ? 'green' : 'red'"
text-color="black"
:options="[
@input="changed = true"
/>
</q-field>
<q-field borderless stack-label label="En stock" class="q-mb-md">
<q-btn-toggle
class="q-mt-sm"
no-caps
:disable="item.deleted"
v-model="item.available"
:toggle-color="item.available ? 'green' : 'red'"
text-color="black"
:options="[
{label: '✔', value: true},
{label: '✘', value: false}
]"
@input="changed = true"
/>
</q-field>
<q-field borderless stack-label label="Supprimé" class="q-mb-md">
<q-btn-toggle
no-caps
v-model="item.deleted"
:toggle-color="item.deleted ? 'green' : 'red'"
text-color="black"
:options="[
@input="changed = true"
/>
</q-field>
<q-field borderless stack-label label="Supprimé" class="q-mb-md">
<q-btn-toggle
no-caps
v-model="item.deleted"
:toggle-color="item.deleted ? 'green' : 'red'"
text-color="black"
:options="[
{label: 'Oui', value: true},
{label: 'Non', value: false}
]"
@input="changed = true"
/>
</q-field>
<q-input
:disable="item.deleted"
v-model="item.comment"
@update:model-value="changed = true"
type="textarea"
:max-height="100"
rows="4"
outlined color="secondary" stack-label label="Commentaire" class="q-mb-md"
inverted
/>
<q-btn :disabled="!changed || originalItem.deleted"
@click="updateItem()"
color="primary"
:flat="!changed"
>Enregistrer</q-btn>
@input="changed = true"
class="q-mt-sm"
/>
</q-field>
<q-input
:disable="item.deleted"
v-model="item.comment"
@update:model-value="changed = true"
type="textarea"
:max-height="100"
rows="5"
outlined color="secondary" stack-label label="Commentaire" class="q-mb-md"
inverted
/>
<q-btn :disabled="!changed || originalItem.deleted"
@click="updateItem()"
color="primary"
:flat="!changed"
>Enregistrer</q-btn>
</div>
</div>
<div class="col-12 col-lg-6">
<div class="row">
<div class="col">
<h4 class="q-ma-none q-pb-md text-light">Historique</h4>
</div>
<div class="col text-right">
<q-btn outline icon="add" label="ajouter une entrée" color="primary" @click="openHistoryForm()"></q-btn>
</div>
</div>
<q-list bordered separator class="rounded-borders">
<q-item clickable
v-for="event in history"
:key="event.id"
@click="showHistory = true;selectedHistory = event"
>
<q-item-section top thumbnail class="q-ml-none" style="margin:-8px 0 -8px -16px">
<img
:src="getImageUrl(event, event.image_file, true)"
alt="photo"
v-if="event.image_file"
/>
</q-item-section>
<q-item-section>
<q-item-label lines="3" v-html="event.text.split('\n').join('</br>')"></q-item-label>
<q-item-label caption>
<q-icon name="task" class="q-mr-sm" size="xs"
v-if="event.type === 'issue'"
:color="event.solved_at ? 'green' : 'grey'"
/>
<span class="text-capitalize">{{ event.user }}</span>
<template v-if="event.solved_at">
<q-icon name="arrow_right" size="sm"/>
fait par <span class="text-capitalize">{{ event.solved_by }}</span> le {{getDate(event.solved_at)}}
</template>
</q-item-label>
</q-item-section>
<q-item-section side top>
<q-item-label caption>{{ getDate(event.date || event.created) }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</div>
</div>
<br/>
<br/>
<q-dialog v-model="showHistoryForm">
<q-card>
<q-card-section>
<div class="text-h6">Ajouter une entrée</div>
</q-card-section>
<q-card-section>
<q-input
v-model="pendingHistory"
autofocus
type="textarea"
label="Description"
:max-height="100"
rows="3"
invertedd
color="secondary"
/>
<br/>
<q-btn-group outline spread>
<q-btn :outline="pendingHistoryType !== 'comment'" color="secondary" label="Info" icon="info" @click="pendingHistoryType = 'comment'"/>
<q-btn :outline="pendingHistoryType !== 'issue'" color="secondary" label="Tâche" icon="task" @click="pendingHistoryType = 'issue'"/>
</q-btn-group>
<br/>
<q-uploader
:accept="'.jpg,.png'"
:factory="uploadFile"
label="Uploader une photo"
@added="hasFile = true"
ref="uploader"
no-thumbnails
hide-upload-btn
flat
bordered
color="secondary"
/>
<br/>
</q-card-section>
<q-separator></q-separator>
<q-card-actions align="right">
<q-btn flat color="grey" @click.stop="showHistoryForm = false">Annuler</q-btn>
<q-btn flat color="primary" @click.stop="addHistory()">Ok</q-btn>
</q-card-actions>
</q-card>
</q-dialog>
<h4 class="q-ma-none q-pb-md text-light">Historique</h4>
<q-timeline color="secondary">
<!--<q-timeline-entry heading>-->
<!--Historique-->
<!--</q-timeline-entry>-->
<q-timeline-entry
title="Ajouter une entrée"
side="left"
icon="add"
color="primary"
@click="openHistoryForm()"
style="cursor:pointer"
>
<q-slide-transition>
<div v-show="showHistoryForm">
<q-input
v-model="pendingHistory"
type="textarea"
label="Description"
:max-height="100"
rows="3"
invertedd
color="secondary"
/>
<!-- <q-input label="Date"-->
<!-- v-model="pendingHistoryDate"-->
<!-- type="datetime"-->
<!-- format24h />-->
<br/>
<q-uploader
:accept="'.jpg,.png'"
:factory="uploadFile"
label="Uploader une photo"
@added="hasFile = true"
ref="uploader"
no-thumbnails
hide-upload-btn
flat
color="secondary"
/>
<br/>
<q-btn flat color="faded" @click.stop="showHistoryForm = false">Annuler</q-btn>
<q-btn flat color="primary" @click.stop="addHistory()">Ok</q-btn>
<q-dialog v-model="showHistory">
<q-card>
<img :src="getImageUrl(selectedHistory, selectedHistory.image_file)"
alt="photo"
v-if="selectedHistory.image_file"
/>
<q-card-section>
<div v-html="selectedHistory.text.split('\n').join('</br>')"></div>
<div class="text-caption text-grey">
<span class="text-capitalize">{{ selectedHistory.user }}</span>
<q-separator vertical />
<span>{{ getDate(selectedHistory.date || selectedHistory.created) }}</span>
</div>
</q-slide-transition>
</q-timeline-entry>
<q-timeline-entry
v-for="event in history.slice().reverse()"
:key="event.id"
:subtitle="getDate(event.date)"
:title="event.user"
side="left"
>
<div>
<q-icon name="format_quote"
color="light"
size="2rem"
/>
{{ event.text }}
<q-icon name="format_quote"
color="light"
size="2rem"
/>
</div>
<q-img :src="getImageUrl(event, event.image_file)"
alt="photo"
v-if="event.image_file"
class="q-py-md"
style="max-height:300px;max-width:300px"
:fit="'contain'"
/>
<br/>
<q-btn flat
:disable="item.deleted"
icon="delete"
label="Supprimer cette entrée"
@click="removeHistory(event)"
/>
</q-timeline-entry>
</q-timeline>
</q-card-section>
<q-card-section v-if="selectedHistory.type === 'issue' && !selectedHistory.solved_at">
<q-btn outline color="secondary" label="Marquer comme terminé" @click="setTaskDone(selectedHistory)"></q-btn>
</q-card-section>
<q-separator/>
<q-card-actions align="right">
<q-btn flat color="red" @click.stop="removeHistory(selectedHistory)">Supprimer</q-btn>
<q-btn flat color="grey" @click.stop="showHistory = false;selectedHistory = null">Fermer</q-btn>
</q-card-actions>
</q-card>
</q-dialog>
</q-page>
</template>
@ -204,17 +251,20 @@ import QRCode from 'qrcode'
export default {
name: 'StockItem',
props: ['itemRef'],
props: ['itemRef', 'shortId'],
data () {
return {
showHistoryForm: false,
pendingHistory: null,
pendingHistoryType: 'comment',
changed: false,
hasFile: false,
username: null,
qrCodeDataUrl: null,
showQr: false,
item: {}
item: {},
showHistory: false,
selectedHistory: null
}
},
computed: {
@ -243,7 +293,20 @@ export default {
}
},
created: function () {
if (this.shortId) {
let itemRef = this.stock.find(item => {
return item.short_id === parseInt(this.shortId)
})?.ref
console.log('Redirecting to item with ref:', itemRef)
if (itemRef) this.$router.push(`/item/${itemRef}`)
}
this.loadItem()
this.$watch(
() => this.itemRef,
(newId, oldId) => {
this.loadItem()
}
)
},
mounted () {
this.username = this.$q.localStorage.getItem('username')
@ -267,6 +330,7 @@ export default {
data: {
ref: this.itemRef,
text: this.pendingHistory,
type: this.pendingHistoryType,
user: this.$store.state.core.username,
image_file: file,
date: date.toISOString()
@ -322,6 +386,23 @@ export default {
})
})
},
setTaskDone (history) {
this.$store.dispatch('core/updateItem', {
collection: 'history',
itemId: history.id,
data: {
id: history.id,
solved_at: new Date().toISOString(),
solved_by: this.username
}
}).then(_ => {
this.$store.dispatch('core/loadAppData').then(_ => {
this.loadItem()
this.showHistory = false
this.selectedHistory = null
})
})
},
async uploadFile (file) {
// Resize and compress the image before uploading
const options = {
@ -335,8 +416,8 @@ export default {
console.error('Error compressing image:', error)
}
},
getImageUrl (history, image) {
return this.$pb.files.getURL(history, image, { thumb: '300x300f' })
getImageUrl (history, image, thumb = false) {
return this.$pb.files.getURL(history, image, { thumb: thumb ? '300x300f' : null })
},
loadItem () {
let item = this.stock.find(item => {
@ -367,5 +448,8 @@ export default {
}
</script>
<style>
<style scoped>
.q-field__label{
padding-bottom:16px !important;
}
</style>

142
src/pages/TasksPage.vue Normal file
View File

@ -0,0 +1,142 @@
<template>
<q-page padding>
<h4 class="q-mt-none">Tâches</h4>
<q-list bordered separator class="rounded-borders">
<q-item clickable
v-for="issue in issues"
:key="issue.id"
@click="showHistory = true;selectedHistory = issue"
>
<q-item-section top thumbnail class="q-ml-none" style="margin:-8px 0 -8px -16px">
<img
:src="getImageUrl(issue, issue.image_file, true)"
alt="photo"
v-if="issue.image_file"
/>
</q-item-section>
<q-item-section avatar>
<q-icon name="task"
:color="issue.solved_at ? 'green' : 'grey'"
/>
</q-item-section>
<q-item-section>
<q-item-label lines="3" v-html="issue.text.split('\n').join('</br>')"></q-item-label>
<q-item-label caption>
<span class="text-secondary">{{ issue.item.type }} / </span>
<span class="text-secondary q-mr-sm">{{ issue.item.name }}</span>
<span v-if="issue.item.ref">#{{ issue.item.ref }}</span>
</q-item-label>
<q-item-label caption>
<span class="text-capitalize">{{ issue.user }}</span>
<template v-if="issue.solved_at">
<q-icon name="arrow_right" size="sm"/>
fait par <span class="text-capitalize">{{ issue.solved_by }}</span> le {{ getDate(issue.solved_at) }}
</template>
</q-item-label>
</q-item-section>
<q-item-section side top>
<q-item-label caption>{{ getDate(issue.created) }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
<q-dialog v-model="showHistory">
<q-card>
<img :src="getImageUrl(selectedHistory, selectedHistory.image_file)"
alt="photo"
v-if="selectedHistory.image_file"
/>
<q-card-section>
<div v-html="selectedHistory.text.split('\n').join('</br>')"></div>
<div class="text-caption text-grey">
<span class="text-secondary">{{ selectedHistory.item.type }} / </span>
<span class="text-secondary q-mr-sm">{{ selectedHistory.item.name }}</span>
<span v-if="selectedHistory.item.ref">#{{ selectedHistory.item.ref }}</span>
<q-separator class="q-my-md"/>
<span class="text-capitalize q-mr-sm">{{ selectedHistory.user }}</span>
<template v-if="selectedHistory.solved_at">
<q-icon name="arrow_right" size="sm"/>
fait par <span class="text-capitalize">{{ selectedHistory.solved_by }}</span> le {{ getDate(selectedHistory.solved_at) }}
</template>
<!-- <span>{{ getDate(selectedHistory.created) }}</span>-->
</div>
</q-card-section>
<q-card-section v-if="!selectedHistory.solved_at">
<q-btn outline color="secondary" label="Marquer comme terminé" @click="setTaskDone(selectedHistory)"></q-btn>
</q-card-section>
<q-separator/>
<q-card-actions align="right">
<q-btn flat color="red" @click.stop="removeHistory(selectedHistory)">Supprimer</q-btn>
<q-btn flat color="grey" @click.stop="showHistory = false;selectedHistory = null">Fermer</q-btn>
</q-card-actions>
</q-card>
</q-dialog>
<!-- <pre>{{ issues }}</pre>-->
</q-page>
</template>
<script>
import { date, debounce } from 'quasar'
export default {
name: 'TasksPage',
data () {
return {
showHistory: false,
selectedHistory: null
}
},
created () {
},
computed: {
rawIssues () {
return this.$store.state.core.firebase.history.filter(item => {
return item.type === 'issue'
}) || []
},
items () {
return this.$store.state.core.firebase.stock.filter(item => {
let refs = Array.from(new Set(this.rawIssues.map(issue => issue.ref)))
return refs.includes(item.ref)
}) || []
},
issues () {
return this.rawIssues.map(issue => {
let item = this.items.find(item => item.ref === issue.ref) || {}
return {
...issue,
item
}
})
}
},
methods: {
getDate (timestamp) {
return date.formatDate(timestamp, 'DD/MM/YY - HH:mm')
},
setTaskDone (history) {
this.$store.dispatch('core/updateItem', {
collection: 'history',
itemId: history.id,
data: {
id: history.id,
solved_at: new Date().toISOString(),
solved_by: this.$store.state.core.username
}
}).then(_ => {
this.$q.notify('Terminé !')
this.$store.dispatch('core/loadAppData').then(_ => {
this.showHistory = false
this.selectedHistory = null
})
})
}
}
}
</script>
<style>
</style>

View File

@ -13,7 +13,9 @@ const routes = [
{ path: 'dashboard', component: () => import('pages/Dashboard.vue') },
{ path: 'category/:categoryCode', props: true, component: () => import('pages/StockItems.vue') },
{ path: 'item/:itemRef', props: true, component: () => import('pages/StockItem.vue') },
{ path: 'print-settings', props: true, component: () => import('pages/PrintSettings.vue') }
{ path: 'print-settings', props: true, component: () => import('pages/PrintSettings.vue') },
{ path: 'tasks', props: true, component: () => import('pages/TasksPage.vue') },
{ path: ':shortId', props: true, component: () => import('pages/StockItem.vue') }
]
}
]

View File

@ -30,6 +30,14 @@ export function deleteItem (store, data) {
return pb.collection(data.collection).delete(data.data.id)
}
export function getNextShortId (store) {
return pb.collection('stock').getFirstListItem('short_id>0', {
sort: '-short_id'
}).then(item => {
return item.short_id + 1
})
}
// export function uploadFile (store, file) {
// return Firebase.storage().ref().child(Date.now() + file.name).put(file)
// }