- sendcoins
- font - catalogo
This commit is contained in:
@@ -71,27 +71,29 @@ body {
|
||||
}
|
||||
|
||||
.book-title {
|
||||
font-family: 'DINPro-CondensedBold', sans-serif;
|
||||
font-family: 'DINPro-Condensed-Bold', sans-serif;
|
||||
color: $colore_titolo_libro;
|
||||
text-transform: uppercase;
|
||||
margin-top: calc(5 * var(--scalecatalog) * 1px);
|
||||
margin-bottom: calc(5 * var(--scalecatalog) * 1px);
|
||||
font-size: calc(20 * var(--scalecatalog) * 1px);
|
||||
font-size: calc(18 * var(--scalecatalog) * 1px);
|
||||
line-height: 100%;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.book-author {
|
||||
font-family: 'DIN-Pro-Condensed-Regular', sans-serif;
|
||||
font-size: calc(18 * var(--scalecatalog) * 1px);
|
||||
font-family: 'DINPro-Condensed-Regular', sans-serif;
|
||||
font-size: calc(16 * var(--scalecatalog) * 1px);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.book-descr {
|
||||
font-family: 'DIN-Pro-Condensed-Bold-Italic', sans-serif;
|
||||
font-family: 'DINPro-Condensed-Bold-Italic', sans-serif;
|
||||
font-size: calc(16 * var(--scalecatalog) * 1px);
|
||||
}
|
||||
|
||||
.book-details {
|
||||
font-family: 'DIN-Pro-Condensed-Regular', sans-serif;
|
||||
font-family: 'DINPro-Condensed-Regular', sans-serif;
|
||||
margin-bottom: calc(5 * var(--scalecatalog) * 1px);
|
||||
font-size: calc(13 * var(--scalecatalog) * 1px);
|
||||
text-align: left !important;
|
||||
|
||||
@@ -266,7 +266,7 @@ export default defineComponent({
|
||||
const trovatocatalogo = getCatalogoByMyPage.value
|
||||
|
||||
let imagefile = ''
|
||||
let fit = ''
|
||||
let fit = 'contain'
|
||||
|
||||
if (trovatocatalogo && scheda.isPagIntro) {
|
||||
const recimg = trovatocatalogo.img_intro
|
||||
@@ -284,7 +284,7 @@ export default defineComponent({
|
||||
const trovatocatalogo = getCatalogoByMyPage.value
|
||||
|
||||
let imagefile = ''
|
||||
let fit = ''
|
||||
let fit = 'contain'
|
||||
|
||||
if (trovatocatalogo) {
|
||||
// Cerca prima se c'è un Immagine Introduttiva
|
||||
@@ -301,6 +301,15 @@ export default defineComponent({
|
||||
fit = recimg.fit! || 'contain'
|
||||
imagefile = imagefile ? `url(${tools.getDirUpload() + shared_consts.getDirectoryByTable(shared_consts.TABLES_CATALOG) + '/' + trovatocatalogo._id + '/' + imagefile})` : ''
|
||||
}
|
||||
|
||||
}
|
||||
if (!imagefile) {
|
||||
let myimg = costanti.CATALOGHI.PAG_SFONDO_DEFAULT
|
||||
if (scheda.isPagIntro) {
|
||||
myimg = costanti.CATALOGHI.PAG_INTRO_DEFAULT
|
||||
}
|
||||
// Se non c'è un immagine di sfondo, allora prende quella di default
|
||||
imagefile = `url(${tools.getDirUpload() + shared_consts.getDirectoryByTable(shared_consts.TABLES_CATALOG) + '/' + myimg})`
|
||||
}
|
||||
|
||||
if (!imagefile && scheda) {
|
||||
@@ -366,129 +375,6 @@ export default defineComponent({
|
||||
return editore
|
||||
}
|
||||
|
||||
function calcArrProducts() {
|
||||
// console.log('calcArrProducts')
|
||||
|
||||
let arrargomstr: any = []
|
||||
|
||||
// eventuali titoli specifici estratti dall'array di Prodotti Selezionati
|
||||
//const searchtext = getSearchText()
|
||||
const searchtext = getSearchText()
|
||||
|
||||
let arrprod = productStore.getProducts(cosa.value) || [];
|
||||
const filtroAuthor = filter.value.author || '';
|
||||
|
||||
//++AddCATALOGO_FIELDS
|
||||
|
||||
const filtroProductTypes = optcatalogo.value.productTypes || [0]
|
||||
const filtroExcludeProductTypes = optcatalogo.value.excludeproductTypes || [0]
|
||||
const boolfiltroVuotoProductTypes = (filtroProductTypes.length === 0 || (filtroProductTypes.length === 1 && (filtroProductTypes[0] === 0)))
|
||||
const boolfiltroVuotoExcludeProductTypes = filtroExcludeProductTypes.length === 0
|
||||
|
||||
const editore = getEditoreDaFiltrare(optcatalogo.value.editore)
|
||||
const filtroPublishers = editore || []
|
||||
|
||||
const idCollane = getIdCollaneDaFiltrare(optcatalogo.value.idCollane)
|
||||
const filtroCollane = idCollane || []
|
||||
const boolfiltroVuotoEditore = (filtroPublishers.length === 0)
|
||||
const boolfiltroVuotoCollane = (filtroCollane.length === 0)
|
||||
|
||||
//console.log('filtroVersione', filtroProductTypes)
|
||||
|
||||
const catstr = ''
|
||||
|
||||
if (optcatalogo.value.argomenti && optcatalogo.value.argomenti.length > 0) {
|
||||
// ha la priorità questo scelto sul catalogo
|
||||
arrargomstr = getArgomentiDaFiltrare(optcatalogo.value.argomenti)
|
||||
} else {
|
||||
arrargomstr = getArgomentiDaFiltrare(cat.value ? [cat.value] : [])
|
||||
// catstr = cat.value || ''
|
||||
}
|
||||
|
||||
|
||||
const filtroArgomenti = arrargomstr || []
|
||||
const boolfiltroVuotoArgomenti = (filtroArgomenti.length === 0)
|
||||
|
||||
let gasselstr = ''
|
||||
if (cosa.value === shared_consts.PROD.GAS) {
|
||||
gasselstr = idGasSel.value || '';
|
||||
}
|
||||
let lowerSearchText = (searchtext || '').toLowerCase().trim();
|
||||
lowerSearchText = lowerSearchText.replace(/[-@:=]/g, '');
|
||||
if ((!lowerSearchText || (lowerSearchText && lowerSearchText.length < 2)) && !catstr && boolfiltroVuotoArgomenti && boolfiltroVuotoProductTypes && boolfiltroVuotoExcludeProductTypes && boolfiltroVuotoCollane && boolfiltroVuotoEditore && !filtroAuthor && (!gasselstr && (cosa.value !== shared_consts.PROD.GAS))) {
|
||||
|
||||
} else {
|
||||
|
||||
arrprod = arrprod.filter((product: IProduct) => {
|
||||
if (product && product.productInfo) {
|
||||
const lowerName = (product.productInfo.name || '').toLowerCase();
|
||||
let hasCategoria = false
|
||||
let hasArgomentiCat = true
|
||||
if (arrargomstr && arrargomstr.length > 0) {
|
||||
hasArgomentiCat = (product.productInfo.idCatProds || []).some(idCat => arrargomstr.includes(idCat))
|
||||
hasCategoria = true
|
||||
} else {
|
||||
hasCategoria = (!catstr || (catstr && (product.productInfo.idCatProds || []).includes(catstr))) ? true : false
|
||||
}
|
||||
|
||||
const hasAuthor = !filtroAuthor || (filtroAuthor && (product.productInfo.idAuthors || []).includes(filtroAuthor));
|
||||
|
||||
let hasProductTypes = true
|
||||
let hasPublished = true
|
||||
let hasCollana = true
|
||||
let hasExcludeProductTypes = false
|
||||
|
||||
//++AddCATALOGO_FIELDS
|
||||
|
||||
if (optcatalogo.value && !boolfiltroVuotoProductTypes) {
|
||||
// check if productInfo.productTypes array includes some item in optcatalogo.value.ProductTypes array
|
||||
hasProductTypes = !optcatalogo.value.productTypes || (optcatalogo.value.productTypes && (product.productInfo.productTypes || []).some((item: any) => optcatalogo.value.productTypes!.includes(item)))
|
||||
}
|
||||
if (optcatalogo.value && !boolfiltroVuotoEditore) {
|
||||
hasPublished = !editore || (editore && editore.includes(product.productInfo.idPublisher))
|
||||
}
|
||||
if (optcatalogo.value && !boolfiltroVuotoCollane) {
|
||||
hasCollana = !idCollane || (idCollane && idCollane.includes(product.productInfo.idCollana))
|
||||
}
|
||||
|
||||
if (optcatalogo.value && !boolfiltroVuotoExcludeProductTypes) {
|
||||
// check if productInfo.productTypes array exclude some item in optcatalogo.value.ProductTypes array
|
||||
hasExcludeProductTypes = !optcatalogo.value.excludeproductTypes || (optcatalogo.value.excludeproductTypes && (product.productInfo.productTypes || []).every((item: any) => optcatalogo.value.excludeproductTypes!.includes(item)))
|
||||
}
|
||||
|
||||
let productgassel = true
|
||||
if (gasselstr || (cosa.value === shared_consts.PROD.GAS)) {
|
||||
productgassel = (product.idGasordine === gasselstr)
|
||||
}
|
||||
|
||||
// Use a regular expression to match whole words
|
||||
const codeMatch = new RegExp(`\\b${lowerSearchText}\\b`, 'i');
|
||||
// let nameMatch = new RegExp(`\\b(?=.*\\b${lowerSearchText.split(/\s+/).map(word => `(${word})\\b`).join('.*\\b')}\\b)`, 'i');
|
||||
|
||||
// Check if all words in lowerSearchText are present in lowerName
|
||||
const allWordsPresent = lowerSearchText.split(/\s+/).every(word => new RegExp(`\\b${word}\\b`, 'i').test(lowerName));
|
||||
|
||||
return (codeMatch.test(product.productInfo.code || '') || allWordsPresent) && hasCategoria && hasCollana && hasArgomentiCat && hasAuthor && productgassel && hasProductTypes && hasPublished && !hasExcludeProductTypes;
|
||||
} else {
|
||||
console.error('product or product.productInfo is null');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
arrprod = getProductsSorted(arrprod, filter.value.sort_field, filter.value.sort_dir);
|
||||
|
||||
arrProducts.value = arrprod
|
||||
|
||||
populateDataWithlinkIdTemplate()
|
||||
|
||||
generatearrProdToViewSorted()
|
||||
|
||||
loaddata()
|
||||
|
||||
refreshpage.value = false
|
||||
}
|
||||
|
||||
|
||||
function sovrascriviSchedaFromTemplate(idTemplate: string, origScheda: ISchedaSingola) {
|
||||
if (!optcatalogo.value)
|
||||
@@ -539,110 +425,176 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
|
||||
function getProductsFilteredByScheda(scheda: IMyScheda): IProduct[] {
|
||||
function filterProducts(
|
||||
products: IProduct[],
|
||||
searchtext: string | string[],
|
||||
filtroAuthor: string,
|
||||
filtroProductTypes: number[],
|
||||
filtroExcludeProductTypes: number[],
|
||||
editore: string[],
|
||||
idCollane: string[],
|
||||
arrargomstr: any[],
|
||||
catstr: string,
|
||||
gasselstr: string,
|
||||
cosaValue: any,
|
||||
sortField?: string,
|
||||
sortDir?: string
|
||||
): IProduct[] {
|
||||
const lowerSearchTexts = Array.isArray(searchtext)
|
||||
? searchtext.map((text: string) => text.toLowerCase().trim().replace(/[-@:=]/g, ''))
|
||||
: [searchtext.toLowerCase().trim().replace(/[-@:=]/g, '')];
|
||||
|
||||
const searchtext = scheda.arrProdottiSpeciali
|
||||
const boolfiltroVuotoProductTypes =
|
||||
filtroProductTypes.length === 0 || (filtroProductTypes.length === 1 && filtroProductTypes[0] === 0);
|
||||
const boolfiltroVuotoExcludeProductTypes = filtroExcludeProductTypes.length === 0;
|
||||
const boolfiltroVuotoEditore = editore.length === 0;
|
||||
const boolfiltroVuotoCollane = idCollane.length === 0;
|
||||
const boolfiltroVuotoArgomenti = arrargomstr.length === 0;
|
||||
|
||||
let arrargomstr: any = []
|
||||
return products
|
||||
.filter((product: IProduct) => {
|
||||
if (!product || !product.productInfo) {
|
||||
console.error('product or product.productInfo is null');
|
||||
return false;
|
||||
}
|
||||
|
||||
let arrprod = productStore.getProducts(cosa.value) || [];
|
||||
const filtroAuthor = filter.value.author || '';
|
||||
|
||||
const filtroProductTypes = scheda.productTypes || [0]
|
||||
const filtroExcludeProductTypes = scheda.excludeproductTypes || [0]
|
||||
const boolfiltroVuotoProductTypes = (filtroProductTypes.length === 0 || (filtroProductTypes.length === 1 && (filtroProductTypes[0] === 0)))
|
||||
const boolfiltroVuotoExcludeProductTypes = filtroExcludeProductTypes.length === 0
|
||||
|
||||
const editore = getEditoreDaFiltrare(scheda.editore)
|
||||
const filtroPublishers = editore || []
|
||||
|
||||
const idCollane = getIdCollaneDaFiltrare(scheda.idCollane)
|
||||
const filtroCollane = idCollane || []
|
||||
const boolfiltroVuotoEditore = (filtroPublishers.length === 0)
|
||||
const boolfiltroVuotoCollane = (filtroCollane.length === 0)
|
||||
|
||||
//console.log('filtroVersione', filtroProductTypes)
|
||||
|
||||
let catstr = ''
|
||||
|
||||
if (optcatalogo.value.argomenti && optcatalogo.value.argomenti.length > 0) {
|
||||
// ha la priorità questo scelto sul catalogo
|
||||
arrargomstr = getArgomentiDaFiltrare(optcatalogo.value.argomenti)
|
||||
} else {
|
||||
catstr = cat.value || ''
|
||||
}
|
||||
|
||||
let gasselstr = ''
|
||||
if (cosa.value === shared_consts.PROD.GAS) {
|
||||
gasselstr = idGasSel.value || '';
|
||||
}
|
||||
const lowerSearchTexts = (searchtext || []).map((text: string) =>
|
||||
text.toLowerCase().trim().replace(/[-@:=]/g, '')
|
||||
)
|
||||
// Remove the condition that skips filtering if search text is too short
|
||||
// Now it will work with multiple search terms
|
||||
arrprod = arrprod.filter((product: IProduct) => {
|
||||
if (product && product.productInfo) {
|
||||
const lowerName = (product.productInfo.name || '').toLowerCase();
|
||||
const lowerCode = (product.productInfo.code || '').toLowerCase();
|
||||
|
||||
let hasCategoria = false
|
||||
let hasArgomentiCat = true
|
||||
// Filtri per argomenti e categorie
|
||||
let hasCategoria = false;
|
||||
let hasArgomentiCat = true;
|
||||
if (arrargomstr && arrargomstr.length > 0) {
|
||||
hasArgomentiCat = (product.productInfo.idCatProds || []).some(idCat => arrargomstr.includes(idCat))
|
||||
hasCategoria = true
|
||||
hasArgomentiCat = (product.productInfo.idCatProds || []).some((idCat: any) => arrargomstr.includes(idCat));
|
||||
hasCategoria = true;
|
||||
} else {
|
||||
hasCategoria = (!catstr || (catstr && (product.productInfo.idCatProds || []).includes(catstr))) ? true : false
|
||||
hasCategoria = !catstr || (catstr && (product.productInfo.idCatProds || []).includes(catstr));
|
||||
}
|
||||
|
||||
const hasAuthor = !filtroAuthor || (filtroAuthor && (product.productInfo.idAuthors || []).includes(filtroAuthor));
|
||||
// Filtri per autore
|
||||
const hasAuthor = !filtroAuthor || (product.productInfo.idAuthors || []).includes(filtroAuthor);
|
||||
|
||||
// Check if ANY search term matches the product name or code
|
||||
const searchMatch = lowerSearchTexts.length === 0 || lowerSearchTexts.some((searchTerm: any) => {
|
||||
// Check if the entire search term is a whole word in name or code
|
||||
// Filtri per tipi di prodotto
|
||||
const hasProductTypes = boolfiltroVuotoProductTypes
|
||||
? true
|
||||
: (product.productInfo.productTypes || []).some((item: any) => filtroProductTypes.includes(item));
|
||||
|
||||
// Filtri per esclusione di tipi di prodotto
|
||||
const hasExcludeProductTypes = boolfiltroVuotoExcludeProductTypes
|
||||
? false
|
||||
: (product.productInfo.productTypes || []).every((item: any) => filtroExcludeProductTypes.includes(item));
|
||||
|
||||
// Filtri per editore
|
||||
const hasPublished = boolfiltroVuotoEditore
|
||||
? true
|
||||
: editore.includes(product.productInfo.idPublisher);
|
||||
|
||||
// Filtri per collana
|
||||
const hasCollana = boolfiltroVuotoCollane
|
||||
? true
|
||||
: idCollane.includes(product.productInfo.idCollana);
|
||||
|
||||
// Filtri per GAS
|
||||
const productgassel = !gasselstr || (cosaValue === shared_consts.PROD.GAS && product.idGasordine === gasselstr);
|
||||
|
||||
// Filtri per testo di ricerca
|
||||
const searchMatch = lowerSearchTexts.length === 0 || lowerSearchTexts.some((searchTerm: string) => {
|
||||
const codeMatch = new RegExp(`\\b${searchTerm}\\b`, 'i').test(lowerCode);
|
||||
|
||||
// Check if all words in the search term are present in the name
|
||||
const allWordsPresent = searchTerm.split(/\s+/).every((word: string) =>
|
||||
new RegExp(`\\b${word}\\b`, 'i').test(lowerName)
|
||||
);
|
||||
|
||||
return codeMatch || allWordsPresent;
|
||||
});
|
||||
|
||||
let hasProductTypes = true
|
||||
let hasPublished = true
|
||||
let hasCollane = true
|
||||
let hasExcludeProductTypes = false
|
||||
return (
|
||||
searchMatch &&
|
||||
hasAuthor &&
|
||||
productgassel &&
|
||||
hasProductTypes &&
|
||||
(
|
||||
hasPublished ||
|
||||
hasCollana ||
|
||||
hasCategoria ||
|
||||
hasArgomentiCat
|
||||
)
|
||||
&&
|
||||
!hasExcludeProductTypes
|
||||
);
|
||||
})
|
||||
.sort((a, b) => getProductsSorted([a, b], sortField, sortDir)[0] === a ? -1 : 1);
|
||||
}
|
||||
|
||||
if (!boolfiltroVuotoProductTypes) {
|
||||
// check if productInfo.productTypes array includes some item in scheda.ProductTypes array
|
||||
hasProductTypes = !scheda.productTypes || (scheda.productTypes && (product.productInfo.productTypes || []).some((item: any) => scheda.productTypes!.includes(item)))
|
||||
}
|
||||
if (!boolfiltroVuotoEditore) {
|
||||
hasPublished = !editore || (editore && editore.includes(product.productInfo.idPublisher))
|
||||
}
|
||||
function calcArrProducts() {
|
||||
const searchtext = getSearchText();
|
||||
let arrprod = productStore.getProducts(cosa.value) || [];
|
||||
const filtroAuthor = filter.value.author || '';
|
||||
const filtroProductTypes = optcatalogo.value.productTypes || [0];
|
||||
const filtroExcludeProductTypes = optcatalogo.value.excludeproductTypes || [0];
|
||||
const editore = getEditoreDaFiltrare(optcatalogo.value.editore);
|
||||
const filtroPublishers = editore || [];
|
||||
const idCollane = getIdCollaneDaFiltrare(optcatalogo.value.idCollane);
|
||||
const filtroCollane = idCollane || [];
|
||||
const arrargomstr = optcatalogo.value.argomenti && optcatalogo.value.argomenti.length > 0
|
||||
? getArgomentiDaFiltrare(optcatalogo.value.argomenti)
|
||||
: getArgomentiDaFiltrare(cat.value ? [cat.value] : []);
|
||||
const catstr = cat.value || '';
|
||||
const gasselstr = cosa.value === shared_consts.PROD.GAS ? idGasSel.value || '' : '';
|
||||
|
||||
if (optcatalogo.value && !boolfiltroVuotoCollane) {
|
||||
hasCollane = !idCollane || (idCollane && idCollane.includes(product.productInfo.idCollana))
|
||||
}
|
||||
arrprod = filterProducts(
|
||||
arrprod,
|
||||
searchtext,
|
||||
filtroAuthor,
|
||||
filtroProductTypes,
|
||||
filtroExcludeProductTypes,
|
||||
filtroPublishers,
|
||||
filtroCollane,
|
||||
arrargomstr,
|
||||
catstr,
|
||||
gasselstr,
|
||||
cosa.value,
|
||||
filter.value.sort_field,
|
||||
filter.value.sort_dir
|
||||
);
|
||||
|
||||
if (!boolfiltroVuotoExcludeProductTypes) {
|
||||
// check if productInfo.productTypes array exclude some item in scheda.ProductTypes array
|
||||
hasExcludeProductTypes = !scheda.excludeproductTypes || (scheda.excludeproductTypes && (product.productInfo.productTypes || []).every((item: any) => scheda.excludeproductTypes!.includes(item)))
|
||||
}
|
||||
arrProducts.value = arrprod;
|
||||
populateDataWithlinkIdTemplate();
|
||||
generatearrProdToViewSorted();
|
||||
loaddata();
|
||||
refreshpage.value = false;
|
||||
}
|
||||
|
||||
return searchMatch && hasCategoria && hasArgomentiCat && hasAuthor && hasProductTypes && hasPublished && hasCollane && !hasExcludeProductTypes;
|
||||
} else {
|
||||
console.error('product or product.productInfo is null');
|
||||
return false;
|
||||
}
|
||||
})
|
||||
function getProductsFilteredByScheda(scheda: IMyScheda): IProduct[] {
|
||||
let arrprod = productStore.getProducts(cosa.value) || [];
|
||||
const filtroAuthor = filter.value.author || '';
|
||||
const filtroProductTypes = scheda.productTypes || [0];
|
||||
const filtroExcludeProductTypes = scheda.excludeproductTypes || [0];
|
||||
const editore = getEditoreDaFiltrare(scheda.editore);
|
||||
const filtroPublishers = editore || [];
|
||||
const idCollane = getIdCollaneDaFiltrare(scheda.idCollane);
|
||||
const filtroCollane = idCollane || [];
|
||||
const arrargomstr = optcatalogo.value.argomenti && optcatalogo.value.argomenti.length > 0
|
||||
? getArgomentiDaFiltrare(optcatalogo.value.argomenti)
|
||||
: [];
|
||||
const catstr = cat.value || '';
|
||||
const gasselstr = cosa.value === shared_consts.PROD.GAS ? idGasSel.value || '' : '';
|
||||
|
||||
arrprod = getProductsSorted(arrprod, scheda?.sort_field, scheda?.sort_dir);
|
||||
|
||||
return arrprod
|
||||
arrprod = filterProducts(
|
||||
arrprod,
|
||||
scheda.arrProdottiSpeciali || [],
|
||||
filtroAuthor,
|
||||
filtroProductTypes,
|
||||
filtroExcludeProductTypes,
|
||||
filtroPublishers,
|
||||
filtroCollane,
|
||||
arrargomstr,
|
||||
catstr,
|
||||
gasselstr,
|
||||
cosa.value,
|
||||
scheda?.sort_field,
|
||||
scheda?.sort_dir
|
||||
);
|
||||
|
||||
return arrprod;
|
||||
}
|
||||
|
||||
function getProductsSorted(arrprod: IProduct[], sort_field: string, sort_dir: number): IProduct[] {
|
||||
|
||||
@@ -609,6 +609,6 @@
|
||||
<script lang="ts" src="./catalogo.ts">
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
<style lang="scss" scoped>
|
||||
@import "./catalogo.scss";
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user