- ordinamento tabella titoli

- migliorata la lista degli argomenti
This commit is contained in:
Surya Paolo
2025-04-23 01:59:39 +02:00
parent ae4efab0f3
commit fc015404a6
11 changed files with 245 additions and 114 deletions

View File

@@ -257,7 +257,7 @@
</q-item-section> </q-item-section>
</q-item> </q-item>
<q-item <!--<q-item
v-if=" v-if="
tools.isManager() && !optcatalogo.generazionePDFInCorso && (editOn || options.show_edit_book) tools.isManager() && !optcatalogo.generazionePDFInCorso && (editOn || options.show_edit_book)
" "
@@ -276,6 +276,7 @@
<q-item-label>Vedi Numero di Pagine (Da GM)</q-item-label> <q-item-label>Vedi Numero di Pagine (Da GM)</q-item-label>
</q-item-section> </q-item-section>
</q-item> </q-item>
-->
<q-item <q-item
v-if=" v-if="

View File

@@ -1576,6 +1576,15 @@
icon="fas fa-play-circle" icon="fas fa-play-circle"
> >
<div class="column"> <div class="column">
<q-toggle
v-model="myel.catalogo.showListaArgomenti"
color="positive"
icon="fas fa-file-pdf"
label="Mostra Lista Argomenti"
@update:model-value="modifElem"
>
</q-toggle>
<q-toggle <q-toggle
v-model="myel.catalogo.pdf" v-model="myel.catalogo.pdf"
color="positive" color="positive"

View File

@@ -72,6 +72,10 @@ export default defineComponent({
const modifOn = ref(false) const modifOn = ref(false)
const sortAttribute = ref('')
const sortDirection = ref(1)
const optionscatalogo = ref(<any>{maxlength: 0}) const optionscatalogo = ref(<any>{maxlength: 0})
const editOn = computed({ const editOn = computed({
@@ -255,6 +259,37 @@ export default defineComponent({
} }
const sortTable = (sortAttributeToSort: string) => {
if (!props.optcatalogo.showListaArgomenti)
return false
if (sortAttributeToSort) {
if (sortAttribute.value === sortAttributeToSort) {
sortDirection.value = -sortDirection.value
} else {
sortAttribute.value = sortAttributeToSort
sortDirection.value = 1
}
internalProducts.value = internalProducts.value.sort((a: any, b: any) => {
const aVal = a.productInfo?.[sortAttributeToSort] ?? ''
const bVal = b.productInfo?.[sortAttributeToSort] ?? ''
if (aVal instanceof Date && bVal instanceof Date) {
return sortDirection.value === 1 ? aVal.getTime() - bVal.getTime() : bVal.getTime() - aVal.getTime()
}
if (typeof aVal === 'number' && typeof bVal === 'number') {
return sortDirection.value === 1 ? aVal - bVal : bVal - aVal
}
if (typeof aVal === 'string' && typeof bVal === 'string') {
return sortDirection.value === 1 ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal)
}
return sortDirection.value === 1 ? String(aVal).localeCompare(String(bVal)) : String(bVal).localeCompare(String(aVal))
})
}
}
onMounted(mounted) onMounted(mounted)
return { return {
@@ -287,6 +322,9 @@ export default defineComponent({
optionscatalogo, optionscatalogo,
t, t,
products, products,
sortTable,
sortAttribute,
sortDirection,
} }
} }
}) })

View File

@@ -25,8 +25,21 @@
<th <th
v-if="isColumnVisible(col.name)" v-if="isColumnVisible(col.name)"
:key="col.name" :key="col.name"
@click="sortTable(col.name)"
> >
{{ col.label }} {{ col.label }}
<q-icon
v-if="(sortAttribute === col.name) && optcatalogo.showListaArgomenti"
:name="sortDirection === 1 ? 'arrow_drop_up' : 'arrow_drop_down'"
size="16px"
class="q-ml-xs"
/>
<q-icon
v-else-if="optcatalogo.showListaArgomenti"
name="arrow_drop_up"
size="16px"
class="q-ml-xs"
/>
</th> </th>
</template> </template>
</tr> </tr>

View File

@@ -1,5 +1,5 @@
import type { PropType } from 'vue'; import type { PropType } from 'vue';
import { defineComponent, onMounted, ref, watch, computed} from 'vue' import { defineComponent, onMounted, ref, watch, computed } from 'vue'
import { tools } from '@tools' import { tools } from '@tools'
import { useUserStore } from '@store/UserStore' import { useUserStore } from '@store/UserStore'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
@@ -23,6 +23,7 @@ import type {
import { fieldsTable } from '@store/Modules/fieldsTable' import { fieldsTable } from '@store/Modules/fieldsTable'
import Products from 'app/src/rootgen/admin/products/products.vue';
export default defineComponent({ export default defineComponent({
name: 'CSearchProduct', name: 'CSearchProduct',
@@ -37,7 +38,7 @@ export default defineComponent({
idprodtoshow: { idprodtoshow: {
type: String, type: String,
required: false, required: false,
default : '', default: '',
}, },
empty: { empty: {
type: Boolean, type: Boolean,
@@ -47,7 +48,7 @@ export default defineComponent({
nameLinkTemplate: { nameLinkTemplate: {
type: String, type: String,
required: false, required: false,
default : '', default: '',
}, },
visu: { visu: {
type: Number, type: Number,
@@ -245,7 +246,7 @@ export default defineComponent({
router.push(path) router.push(path)
} }
function collabel (rec: any) { function collabel(rec: any) {
// console.log('Record:', rec) // console.log('Record:', rec)
let label = '' let label = ''
if (rec && rec.productInfo) { if (rec && rec.productInfo) {
@@ -254,7 +255,9 @@ export default defineComponent({
if (!productStore.isPubblicatoById(rec.productInfo.idStatoProdotto)) if (!productStore.isPubblicatoById(rec.productInfo.idStatoProdotto))
label += ' (' + productStore.getDescrStatiProdottoByIdStatoProdotto(rec.productInfo.idStatoProdotto || '') + ')' label += ' (' + productStore.getDescrStatiProdottoByIdStatoProdotto(rec.productInfo.idStatoProdotto || '') + ')'
} }
if (productStore.isEsaurito(rec)) {
label += ' (Attualmente non disponibile)'
}
// console.log('Computed label:', label) // console.log('Computed label:', label)
} }
return label return label
@@ -265,18 +268,18 @@ export default defineComponent({
emit('insert', myproduct.value) emit('insert', myproduct.value)
} }
function clickClose() { function clickClose() {
searchList.value[0].value = '' searchList.value[0].value = ''
myproduct.value = null myproduct.value = null
emit('close') emit('close')
} }
function updateproductmodif(element: IProduct) { function updateproductmodif(element: IProduct) {
console.log('CSEARCHPRODUCT: updateproductmodif') console.log('CSEARCHPRODUCT: updateproductmodif')
emit('updateproductmodif', element) emit('updateproductmodif', element)
} }
async function searchOnGM(mystr: string) { async function searchOnGM(mystr: string) {
// refreshSingleBookFromGM({usaDBGMLocale: false}) // refreshSingleBookFromGM({usaDBGMLocale: false})
const options = { const options = {
@@ -293,11 +296,11 @@ export default defineComponent({
// updatefromgm.value = false // updatefromgm.value = false
} }
} }
onMounted(mounted) onMounted(mounted)
return { return {
userStore, userStore,
costanti, costanti,
tools, tools,
@@ -326,7 +329,7 @@ export default defineComponent({
saveSearch, saveSearch,
updateproductmodif, updateproductmodif,
searchOnGM, searchOnGM,
} }
} }
}) })

View File

@@ -861,6 +861,7 @@ export interface IOptCatalogo {
printable?: boolean printable?: boolean
indebug?: boolean indebug?: boolean
maxnumlibri?: number maxnumlibri?: number
showListaArgomenti?: boolean
generazionePDFInCorso?: boolean generazionePDFInCorso?: boolean
first_page?: IDimensioni first_page?: IDimensioni

View File

@@ -190,7 +190,7 @@ export interface IProductsState {
productInfos: IProductInfo[] productInfos: IProductInfo[]
userActive: IUserShort userActive: IUserShort
isPubblicatoById: (idStatoProdotto: number) => boolean; isPubblicatoById?: (idStatoProdotto: number) => boolean;
} }
export interface IProducer { export interface IProducer {

View File

@@ -130,18 +130,18 @@ export const useProducts = defineStore('Products', {
}, },
isDisponibile: (state: IProductsState) => (product: IProduct): boolean => { isDisponibile: (state: IProductsState) => (product: IProduct): boolean => {
return product.arrvariazioni[0].quantita > 100 return product?.arrvariazioni?.[0]?.quantita > 100
}, },
isQtaLimitata: (state: IProductsState) => (product: IProduct): boolean => { isQtaLimitata: (state: IProductsState) => (product: IProduct): boolean => {
return product.arrvariazioni[0].quantita > 50 && product.arrvariazioni[0].quantita < 100 return product?.arrvariazioni?.[0]?.quantita > 50 && product?.arrvariazioni?.[0]?.quantita < 100
}, },
isInEsaurendo: (state: IProductsState) => (product: IProduct): boolean => { isInEsaurendo: (state: IProductsState) => (product: IProduct): boolean => {
return product.arrvariazioni[0].quantita > 0 && product.arrvariazioni[0].quantita < 50 return product?.arrvariazioni?.[0]?.quantita > 0 && product.arrvariazioni?.[0]?.quantita < 50
}, },
isEsaurito: (state: IProductsState) => (product: IProduct): boolean => { isEsaurito: (state: IProductsState) => (product: IProduct): boolean => {
return product.arrvariazioni[0].quantita <= 0 return product?.arrvariazioni?.[0]?.quantita <= 0
}, },
isPubblicatoById: (state: IProductsState) => (idStatoProdotto: number): boolean => { isPubblicatoById: (state: IProductsState) => (idStatoProdotto: number): boolean => {

View File

@@ -32,23 +32,7 @@ body {
} }
// Underline like a href .category-title {
.category {
color: darkblue;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 19px;
cursor: pointer;
}
.category_sel {
color: white !important;
background: #5c8ef4 !important;
padding: 2px;
}
.category-title{
font-weight: bold; font-weight: bold;
font-size: 1.1rem; font-size: 1.1rem;
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
@@ -59,10 +43,13 @@ body {
} }
.fixed-width { .fixed-width {
width: var(--width) !important; /* Usa una variabile CSS */ width: var(--width) !important;
/* Usa una variabile CSS */
} }
.fixed-height { .fixed-height {
height: var(--height) !important; /* Usa una variabile CSS */ height: var(--height) !important;
/* Usa una variabile CSS */
} }
.break { .break {
@@ -96,6 +83,7 @@ body {
margin-bottom: calc(5 * var(--scalecatalog) * 1px); margin-bottom: calc(5 * var(--scalecatalog) * 1px);
font-size: calc(16 * var(--scalecatalog) * 1px); font-size: calc(16 * var(--scalecatalog) * 1px);
text-align: left !important; text-align: left !important;
&.big { &.big {
font-size: calc(22 * var(--scalecatalog) * 1px); font-size: calc(22 * var(--scalecatalog) * 1px);
} }
@@ -109,7 +97,7 @@ body {
word-wrap: break-word; word-wrap: break-word;
} }
.book-link{ .book-link {
font-style: italic; font-style: italic;
font-size: calc(14 * var(--scalecatalog) * 1px); font-size: calc(14 * var(--scalecatalog) * 1px);
} }
@@ -125,6 +113,7 @@ body {
font-size: calc(20 * var(--scalecatalog) * 1px); font-size: calc(20 * var(--scalecatalog) * 1px);
height: calc(380 * var(--scalecatalog) * 1px); height: calc(380 * var(--scalecatalog) * 1px);
} }
.book-text-down { .book-text-down {
font-family: 'DINPro', sans-serif; font-family: 'DINPro', sans-serif;
margin-bottom: calc(5 * var(--scalecatalog) * 1px); margin-bottom: calc(5 * var(--scalecatalog) * 1px);
@@ -138,3 +127,40 @@ body {
font-size: calc(35 * var(--scalecatalog) * 1px); font-size: calc(35 * var(--scalecatalog) * 1px);
height: calc(100 * var(--scalecatalog) * 1px); height: calc(100 * var(--scalecatalog) * 1px);
} }
.categories {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 8px;
padding: 12px;
border-radius: 24px;
background-color: #e6f0ff;
}
.category {
font-family: 'Segoe UI', Arial, sans-serif;
font-size: 0.95rem;
padding: 8px 16px;
background-color: white;
color: #2c3e50;
border: 1px solid #b0c4de;
border-radius: 20px;
cursor: pointer;
transition: all 0.2s ease-in-out;
user-select: none;
}
.category:hover {
background-color: #dbe9ff;
color: #1a3f8a;
border-color: #89aef0;
}
.category_sel {
background-color: #5c8ef4 !important;
color: white !important;
font-weight: 600;
border-color: #5c8ef4 !important;
box-shadow: 0 0 0 2px rgba(92, 142, 244, 0.3);
}

View File

@@ -200,6 +200,10 @@ export default defineComponent({
return !!getCatalogoByMyPage.value return !!getCatalogoByMyPage.value
}) })
const showListaArgomenti = computed(() => {
return optcatalogo.value.showListaArgomenti
})
// Register the scroll event on component mount // Register the scroll event on component mount
const handleScroll = () => { const handleScroll = () => {
const scrollTop = window.scrollY || document.documentElement.scrollTop; const scrollTop = window.scrollY || document.documentElement.scrollTop;
@@ -572,10 +576,14 @@ export default defineComponent({
// Se nel catalogo è stato già generato, allora gli passo quello. // Se nel catalogo è stato già generato, allora gli passo quello.
const trovatocatalogo = getCatalogoByMyPage.value const trovatocatalogo = getCatalogoByMyPage.value
if (trovatocatalogo?.lista_prodotti.length === 0) { if (optcatalogo.value.showListaArgomenti) {
generalista = true generalista = true
} }
/*if (trovatocatalogo?.lista_prodotti.length === 0) {
generalista = true
}*/
if (!generalista && (trovatocatalogo?.lista_prodotti.length > 0)) { if (!generalista && (trovatocatalogo?.lista_prodotti.length > 0)) {
arrprod = trovatocatalogo?.lista_prodotti arrprod = trovatocatalogo?.lista_prodotti
} else { } else {
@@ -604,7 +612,7 @@ export default defineComponent({
// console.log('arrprod', arrprod) // console.log('arrprod', arrprod)
populateDataWithlinkIdTemplate(); populateDataWithlinkIdTemplate();
generatearrProdToViewSorted(!generalista, salva); generatearrProdToViewSorted(!generalista, salva, !optcatalogo.value.showListaArgomenti);
loaddata(); loaddata();
refreshpage.value = false; refreshpage.value = false;
@@ -754,7 +762,7 @@ export default defineComponent({
} }
} }
function generatearrProdToViewSorted(usaprodottiSalvati?: boolean, salva?: boolean) { function generatearrProdToViewSorted(usaprodottiSalvati?: boolean, salva?: boolean, salvasudb?: boolean) {
console.log('generatearrProdToViewSorted... usaprodottiSalvati=', usaprodottiSalvati, ' salva=', salva) console.log('generatearrProdToViewSorted... usaprodottiSalvati=', usaprodottiSalvati, ' salva=', salva)
try { try {
@@ -880,9 +888,11 @@ export default defineComponent({
if (trovatocatalogo) { if (trovatocatalogo) {
trovatocatalogo.lista_prodotti = arrprod trovatocatalogo.lista_prodotti = arrprod
if (salvasudb) {
salvaListaProdotti(false) salvaListaProdotti(false)
} }
} }
}
} catch (e) { } catch (e) {
console.error('Err', e) console.error('Err', e)
@@ -901,7 +911,7 @@ export default defineComponent({
} }
// Salva gli ID dei prodotti nel catalogo // Salva gli ID dei prodotti nel catalogo
tools.saveFieldToServer($q, 'catalogs', getCatalogoByMyPage.value._id, mydata, true, false) tools.saveFieldToServer($q, 'catalogs', getCatalogoByMyPage.value._id, mydata, !optcatalogo.value.showListaArgomenti, false)
if (ricarica) { if (ricarica) {
@@ -1244,7 +1254,10 @@ export default defineComponent({
if (getCatalogoByMyPage.value) { if (getCatalogoByMyPage.value) {
getCatalogoByMyPage.value.lista_prodotti = [...arr] getCatalogoByMyPage.value.lista_prodotti = [...arr]
if (optcatalogo.value.showListaArgomenti)
salvaListaProdotti(true) salvaListaProdotti(true)
else
generatearrProdToViewSorted(true, false);
} }
} }
@@ -1332,6 +1345,7 @@ export default defineComponent({
clickaddNewBook, clickaddNewBook,
addProductToList, addProductToList,
addnewProd, addnewProd,
showListaArgomenti,
} }
} }
}) })

View File

@@ -62,7 +62,35 @@
name="lista" name="lista"
v-if="optcatalogo" v-if="optcatalogo"
> >
<q-tab-panel
v-if="showListaArgomenti"
name="categorie"
>
<div class="row justify-center q-mx-auto bg-blue-1">
<div class="categories">
<div
v-for="(reccat, index) in getCatProds()"
:key="index"
class="category"
:class="{ category_sel: cat === reccat.value }"
@click="cat = reccat.value"
>
{{ reccat.label }}
</div>
</div>
</div>
<div class="text-center q-py-sm prod_trov">
<span v-show="productStore.getNumProdTot() !== arrProducts.length">{{
t('ecomm.prodotti_trovati', {
qta: arrProducts.length,
qtatot: productStore.getNumProdTot(),
})
}}</span>
</div>
</q-tab-panel>
<q-btn <q-btn
v-if="!showListaArgomenti"
rounded rounded
label="Rigenera Ordinamento Libri" label="Rigenera Ordinamento Libri"
color="primary" color="primary"
@@ -70,6 +98,7 @@
></q-btn> ></q-btn>
<q-btn <q-btn
v-if="!showListaArgomenti"
rounded rounded
label="Aggiungi" label="Aggiungi"
icon="fas fa-plus" icon="fas fa-plus"
@@ -103,7 +132,7 @@
> >
<div class="container"> <div class="container">
<q-tabs <q-tabs
v-if="!ispageCatalogata" v-if="showListaArgomenti"
v-model="tabvisu" v-model="tabvisu"
dense dense
class="bg-indigo text-white" class="bg-indigo text-white"
@@ -121,7 +150,7 @@
> >
</q-tab> </q-tab>
<q-tab <q-tab
v-if="!ispageCatalogata" v-if="showListaArgomenti"
name="autori" name="autori"
icon="fas fa-user" icon="fas fa-user"
label="Autori" label="Autori"
@@ -134,7 +163,7 @@
> >
</q-tab> </q-tab>
<q-tab <q-tab
v-if="!ispageCatalogata" v-if="showListaArgomenti"
name="ricerca" name="ricerca"
icon="fas fa-search" icon="fas fa-search"
label="Cerca" label="Cerca"
@@ -154,23 +183,20 @@
keep-alive keep-alive
> >
<q-tab-panel <q-tab-panel
v-if="!ispageCatalogata" v-if="showListaArgomenti"
name="categorie" name="categorie"
> >
<div class="row justify-center q-mx-auto bg-blue-1"> <div class="row justify-center q-mx-auto bg-blue-1">
<div class="categories">
<div <div
v-for="(reccat, index) in getCatProds()" v-for="(reccat, index) in getCatProds()"
:key="index" :key="index"
> class="category"
<span :class="{ category_sel: cat === reccat.value }"
:class="{
category: true,
category_sel: cat === reccat.value,
}"
@click="cat = reccat.value" @click="cat = reccat.value"
>{{ reccat.label }} >
</span> {{ reccat.label }}
| </div>
</div> </div>
</div> </div>
</q-tab-panel> </q-tab-panel>
@@ -261,7 +287,7 @@
</q-tab-panels> </q-tab-panels>
<div <div
v-if="!ispageCatalogata" v-if="showListaArgomenti"
class="row justify-center q-mx-auto" class="row justify-center q-mx-auto"
> >
<q-select <q-select