- Cataloghi: qualita di stampa e margini

This commit is contained in:
Surya Paolo
2024-11-22 20:23:31 +01:00
parent b1b952d120
commit 479934a8fb
5 changed files with 31 additions and 23 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 MiB

View File

@@ -4,7 +4,7 @@ const Schema = mongoose.Schema;
const tools = require('../tools/general'); const tools = require('../tools/general');
const { ObjectID, ObjectId } = require('mongodb'); const { ObjectID, ObjectId } = require('mongodb');
const { MySchedaSchema, IDimensioni, IImg } = require('../models/myscheda'); const { MySchedaSchema, IDimensioni, IImg, IText, IAreaDiStampa } = require('../models/myscheda');
mongoose.Promise = global.Promise; mongoose.Promise = global.Promise;
mongoose.level = "F"; mongoose.level = "F";
@@ -63,16 +63,9 @@ const catalogo = new Schema(
pdf_filename: { type: String }, pdf_filename: { type: String },
printable: { type: Boolean }, printable: { type: Boolean },
first_page_img: { type: String }, first_page: IDimensioni,
first_page_html: { type: String }, last_page: IDimensioni,
first_page_width: { type: Number }, areadistampa: IAreaDiStampa,
first_page_height: { type: Number },
last_page_img: { type: String },
last_page_html: { type: String },
last_page_height: { type: Number },
last_page_width: { type: Number },
imgsfondo_def: IImg,
dimensioni_def: IElementiPagina, dimensioni_def: IElementiPagina,

View File

@@ -34,27 +34,40 @@ const IImg = new Schema({
fit: { type: String }, fit: { type: String },
}) })
const IText = new Schema(
{
contenuto: String,
maxlength: Number,
font: IFont,
}
);
const IDimensioni = new Schema({ const IDimensioni = new Schema({
size: ISize, size: ISize,
margini: IBorders, margini: IBorders,
padding: IBorders, padding: IBorders,
imgsfondo: IImg, imgsfondo: IImg,
text_html: IText,
});
const IAreaDiStampa = new Schema({
margini: IBorders,
unit: String,
format: [{ type: Number }],
orientation: String,
compress: Boolean,
scale: Number,
scalecanvas: Number,
}); });
const IBarCode = new Schema( const IBarCode = new Schema(
{ {
show: Boolean, show: Boolean,
format: String, format: Number,
size: ISize, size: ISize,
font: IFont, font: IFont,
} }
); );
const IText = new Schema(
{
contenuto: String,
maxlength: Number,
}
);
const IElementiScheda = new Schema({ const IElementiScheda = new Schema({
pagina: IDimensioni, pagina: IDimensioni,
@@ -70,6 +83,7 @@ const scheletroScheda = {
line_height: { type: Number }, line_height: { type: Number },
numschede_perRiga: { type: Number }, numschede_perRiga: { type: Number },
numschede_perCol: { type: Number }, numschede_perCol: { type: Number },
show_separatore: { type: Boolean },
testo_right: IText, testo_right: IText,
testo_bottom: IText, testo_bottom: IText,
posiz_text: { type: Number }, posiz_text: { type: Number },
@@ -113,4 +127,4 @@ MyScheda.createIndexes((err) => {
if (err) throw err; if (err) throw err;
}); });
module.exports = { MyScheda, MySchedaSchema, IDimensioni, IImg }; module.exports = { MyScheda, MySchedaSchema, IDimensioni, IImg, IText, IAreaDiStampa };

View File

@@ -827,7 +827,7 @@ router.post('/getpage', async (req, res) => {
}); });
async function duplicatePage(pageId) { async function duplicatePage(pageId, newpath) {
try { try {
// Trova il record di Page da duplicare // Trova il record di Page da duplicare
const pageToDuplicate = await MyPage.findById(pageId); const pageToDuplicate = await MyPage.findById(pageId);
@@ -841,8 +841,8 @@ async function duplicatePage(pageId) {
...pageToDuplicate.toObject(), // Converte il documento Moongose in oggetto ...pageToDuplicate.toObject(), // Converte il documento Moongose in oggetto
_id: new mongoose.Types.ObjectId(), // Genera un nuovo ID _id: new mongoose.Types.ObjectId(), // Genera un nuovo ID
// modifiche ai campi se necessario, per esempio: // modifiche ai campi se necessario, per esempio:
path: `${pageToDuplicate.path}-copia`, // Modifica il campo path per identificare la copia path: newpath,
title: `${pageToDuplicate.title}-copia`, // Modifica il campo path per identificare la copia title: newpath,
date_updated: new Date() date_updated: new Date()
}); });
@@ -878,12 +878,13 @@ router.post('/duppage', async (req, res) => {
const params = req.body; const params = req.body;
const idapp = req.body.idapp; const idapp = req.body.idapp;
const mypath = params.path; const mypath = params.path;
const newpath = params.newpath;
try { try {
let found = await MyPage.findOne({ idapp, path: mypath }) let found = await MyPage.findOne({ idapp, path: mypath })
.then(async (ris) => { .then(async (ris) => {
const result = await duplicatePage(ris._id); const result = await duplicatePage(ris._id, newpath);
if (result) { if (result) {
return res.send({ code: server_constants.RIS_CODE_OK, msg: '' }); return res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
} else { } else {