ver 1.1.20:
- corretto campo foto che non compariva più. - sistemato i campi aggiuntivi e i richiesti. - migliorato la barra in alto di selezione. - aggiunto alcune icone.
This commit is contained in:
108
src/server/models/catalog.js
Executable file
108
src/server/models/catalog.js
Executable file
@@ -0,0 +1,108 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
const { ObjectId } = require('mongodb');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const Foto = {
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
};
|
||||
|
||||
const FilesCataloghi = {
|
||||
per_web: { type: String, },
|
||||
per_stampa: { type: String, },
|
||||
};
|
||||
|
||||
const CatalogSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
active: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
},
|
||||
foto_collana: Foto,
|
||||
idCollana: {
|
||||
type: String,
|
||||
},
|
||||
descr_introduttiva: {
|
||||
type: String,
|
||||
},
|
||||
idTemplateScheda: {
|
||||
type: String,
|
||||
},
|
||||
referenti: [{
|
||||
type: String,
|
||||
}],
|
||||
|
||||
img_bordata_web: Foto,
|
||||
img_bordata_stampa: Foto,
|
||||
img_intro_web: Foto,
|
||||
img_intro_stampa: Foto,
|
||||
|
||||
generati: FilesCataloghi,
|
||||
online: FilesCataloghi,
|
||||
|
||||
date_created: {
|
||||
type: Date,
|
||||
default: Date.now
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
});
|
||||
|
||||
CatalogSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
this._id = new ObjectId();
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
CatalogSchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'title', type: tools.FieldType.string }]
|
||||
};
|
||||
|
||||
CatalogSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params, user);
|
||||
};
|
||||
|
||||
CatalogSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const Catalog = this;
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
const arrrec = await Catalog.find(myfind).lean().sort({ title: 1 });
|
||||
|
||||
return arrrec;
|
||||
};
|
||||
|
||||
const Catalog = mongoose.model('Catalog', CatalogSchema);
|
||||
|
||||
Catalog.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { Catalog };
|
||||
@@ -21,7 +21,7 @@ const CollanaSchema = new Schema({
|
||||
descrizione: {
|
||||
type: String,
|
||||
},
|
||||
Descrizione_Estesa: {
|
||||
descrizione_estesa: {
|
||||
type: String,
|
||||
},
|
||||
dataOra: {
|
||||
@@ -52,7 +52,7 @@ module.exports.executeQueryTable = function (idapp, params) {
|
||||
module.exports.findAllIdApp = async function (idapp) {
|
||||
const myfind = { idapp };
|
||||
|
||||
return await Collana.find(myfind).sort({name: 1, surname: 1});
|
||||
return await Collana.find(myfind).sort({descrizione: 1});
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
|
||||
@@ -526,6 +526,20 @@ module.exports.findAllIdApp = async function (idapp, code, id, all) {
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'collanas',
|
||||
localField: 'productInfo.idCollana',
|
||||
foreignField: '_id',
|
||||
as: 'productInfo.collana'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$productInfo.collana',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'catprods',
|
||||
|
||||
@@ -119,7 +119,7 @@ const productInfoSchema = new Schema({
|
||||
type: String,
|
||||
},
|
||||
idAuthors: [{ type: Schema.Types.ObjectId, ref: 'Author' }],
|
||||
idCollana: { type: Schema.Types.ObjectId, ref: 'Collana' },
|
||||
idCollana: { type: Number },
|
||||
idPublisher: { type: Schema.Types.ObjectId, ref: 'Publisher' },
|
||||
collezione: {
|
||||
type: String,
|
||||
|
||||
Reference in New Issue
Block a user