- CMyPopupEdit

- CMyEditor
 - MySkills
This commit is contained in:
Paolo Arena
2021-10-28 00:38:10 +02:00
parent 300ab15ca7
commit ad7fc67d43
8 changed files with 126 additions and 48 deletions

View File

@@ -96,6 +96,12 @@ CitySchema.statics.executeQueryTable = function (idapp, params) {
return tools.executeQueryTable(this, 0, params); return tools.executeQueryTable(this, 0, params);
}; };
CitySchema.statics.findAllIdApp = async function (idapp) {
const myfind = {};
return City.find(myfind);
};
const City = mongoose.model('City', CitySchema); const City = mongoose.model('City', CitySchema);

View File

@@ -21,19 +21,42 @@ const MySkillSchema = new Schema({
type: String, type: String,
required: true, required: true,
}, },
userId: { type: Schema.Types.ObjectId, ref: 'User' }, userId: {type: Schema.Types.ObjectId, ref: 'User'},
idSkill: { idSkill: {
type: Number, type: Number,
}, },
idStatusSkill: [{ idStatusSkill: [
{
type: Number,
}],
idCity: [
{
type: Number, type: Number,
}], }],
numLevel: { numLevel: {
type: Number, type: Number,
}, },
photos: [
{
imagefile: {
type: String,
},
order: {
type: Number,
},
alt: {
type: String,
},
description: {
type: String,
},
}],
note: { note: {
type: String, type: String,
}, },
subTitle: {
type: String,
},
date_created: { date_created: {
type: Date, type: Date,
default: Date.now, default: Date.now,
@@ -44,9 +67,9 @@ const MySkillSchema = new Schema({
}, },
}); });
MySkillSchema.pre('save', async function (next) { MySkillSchema.pre('save', async function(next) {
if (this.isNew) { if (this.isNew) {
const myrec = await MySkill.findOne().limit(1).sort({_id:-1}); const myrec = await MySkill.findOne().limit(1).sort({_id: -1});
if (!!myrec) { if (!!myrec) {
if (myrec._doc._id === 0) if (myrec._doc._id === 0)
this._id = 1; this._id = 1;
@@ -63,11 +86,10 @@ MySkillSchema.pre('save', async function (next) {
next(); next();
}); });
MySkillSchema.statics.findAllIdApp = function(idapp) { MySkillSchema.statics.findAllIdApp = function(idapp) {
const query = [ const query = [
{ $match: { idapp } }, {$match: {idapp}},
{$sort: {descr: 1}}, {$sort: {descr: 1}},
]; ];
@@ -78,7 +100,7 @@ MySkillSchema.statics.findAllIdApp = function(idapp) {
}; };
MySkillSchema.statics.getFieldsForSearch = function() { MySkillSchema.statics.getFieldsForSearch = function() {
return [{ field: 'idSkill', type: tools.FieldType.Number }] return [{field: 'idSkill', type: tools.FieldType.Number}];
}; };
MySkillSchema.statics.executeQueryTable = function(idapp, params) { MySkillSchema.statics.executeQueryTable = function(idapp, params) {

View File

@@ -253,6 +253,9 @@ const UserSchema = new mongoose.Schema({
sex: { sex: {
type: Number, type: Number,
}, },
biografia: {
type: String,
},
motivazioni: { motivazioni: {
type: String, type: String,
}, },

View File

@@ -293,7 +293,7 @@ function getTableByTableName(tablename) {
mytable = MySkill; mytable = MySkill;
else if (tablename === 'statusSkills') else if (tablename === 'statusSkills')
mytable = StatusSkill; mytable = StatusSkill;
else if (tablename === 'citys') else if (tablename === 'cities')
mytable = City; mytable = City;
else if (tablename === 'sectors') else if (tablename === 'sectors')
mytable = Sector; mytable = Sector;
@@ -1281,6 +1281,7 @@ function load(req, res, version) {
let skills = Skill.findAllIdApp(idapp); let skills = Skill.findAllIdApp(idapp);
let statusSkills = StatusSkill.findAllIdApp(idapp); let statusSkills = StatusSkill.findAllIdApp(idapp);
let sectors = Sector.findAllIdApp(idapp); let sectors = Sector.findAllIdApp(idapp);
let cities = City.findAllIdApp(idapp);
let cart = null; let cart = null;
let orderscart = null; let orderscart = null;
if (sall) { if (sall) {
@@ -1301,7 +1302,7 @@ function load(req, res, version) {
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat, calzoom, producers, cart, storehouses, departments, orderscart, groups, resps, workers, internalpages, return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat, calzoom, producers, cart, storehouses, departments, orderscart, groups, resps, workers, internalpages,
levels, skills, sectors, statusSkills ]) levels, skills, sectors, statusSkills, cities ])
.then((arrdata) => { .then((arrdata) => {
// console.table(arrdata); // console.table(arrdata);
const myuser = req.user; const myuser = req.user;
@@ -1309,7 +1310,34 @@ function load(req, res, version) {
myuser.password = ''; myuser.password = '';
myuser._doc.calcstat = arrdata[13]; myuser._doc.calcstat = arrdata[13];
} }
if (version < 91) {
res.send({
bookedevent: arrdata[0],
eventlist: arrdata[1],
operators: arrdata[2],
wheres: arrdata[3],
contribtype: arrdata[4],
settings: arrdata[5],
permissions: arrdata[6],
disciplines: arrdata[7],
newstosent: arrdata[8],
mailinglist: arrdata[9],
mypage: arrdata[10],
gallery: arrdata[11],
paymenttypes: arrdata[12],
calzoom: arrdata[14],
producers: arrdata[15],
cart: arrdata[16],
storehouses: arrdata[17],
departments: arrdata[18],
orders: arrdata[19],
groups: arrdata[20],
resps: arrdata[21],
workers: arrdata[22],
myuser,
internalpages: arrdata[23]
});
} else {
res.send({ res.send({
bookedevent: arrdata[0], bookedevent: arrdata[0],
eventlist: arrdata[1], eventlist: arrdata[1],
@@ -1339,7 +1367,10 @@ function load(req, res, version) {
skills: arrdata[25], skills: arrdata[25],
sectors: arrdata[26], sectors: arrdata[26],
statusSkills: arrdata[27], statusSkills: arrdata[27],
cities: arrdata[28]
}); });
}
}) })
.catch((e) => { .catch((e) => {
console.log(e.message); console.log(e.message);
@@ -1464,7 +1495,7 @@ router.post('/upload_from_other_server/:dir', authenticate, (req, res) => {
function uploadFile(req, res, version) { function uploadFile(req, res, version) {
// console.log('/upload dir:' + dir); // console.log('/upload dir:' + dir);
const dir = req.params.dir; const dir = tools.invertescapeslash(req.params.dir);
const idapp = req.user.idapp; const idapp = req.user.idapp;
const form = new formidable.IncomingForm(); const form = new formidable.IncomingForm();
@@ -1473,7 +1504,11 @@ function uploadFile(req, res, version) {
let dirmain = '/statics'; let dirmain = '/statics';
if (version > 0) { if (version > 0) {
if (process.env.PROD === 1) {
dirmain = ''; dirmain = '';
} else {
dirmain = '/public';
}
} }
form.uploadDir = folder + '/' + dir; form.uploadDir = folder + '/' + dir;
@@ -1532,7 +1567,7 @@ router.post('/upload/:dir', authenticate, (req, res) => {
}); });
router.post('/upload/:dir/:vers', authenticate, (req, res) => { router.post('/uploadnew/:vers/:dir/', authenticate, (req, res) => {
let versionstr = req.params.vers; let versionstr = req.params.vers;
let version = tools.getVersionint(versionstr); let version = tools.getVersionint(versionstr);

View File

@@ -68,7 +68,7 @@ router.post('/', authenticate, (req, res) => {
// Send 201 - resource created // Send 201 - resource created
// res.status(201).json({ data: 'Subscription saved.' }); // res.status(201).json({ data: 'Subscription saved.' });
console.log('New Subscription id=', subscriptionModel.userId); // console.log('New Subscription id=', subscriptionModel.userId);
// console.log('req.body', req.body) // console.log('req.body', req.body)

View File

@@ -414,6 +414,8 @@ async function faitest() {
const testfind = false; const testfind = false;
// const $vers = tools.getVersionint('1.92.45');
if (testfind) { if (testfind) {
const {City} = require('./models/city'); const {City} = require('./models/city');

View File

@@ -2174,10 +2174,20 @@ module.exports = {
}, },
getVersionint(versionstr) { getVersionint(versionstr) {
let version = versionstr.replace('.', ''); let versionarr = versionstr.split('.');
version = version.replace('.', ''); let version = 0;
versionarr = versionarr.reverse();
for (let i = 0; i < versionarr.length; i++) {
version += versionarr[i] * Math.pow(10, i*2);
}
return parseInt(version); return parseInt(version);
}, },
invertescapeslash(mystr) {
return mystr.replace(/-/g, '/');
},
}; };

View File

@@ -39,7 +39,7 @@ module.exports = {
'In Contanti alla CNM' 'In Contanti alla CNM'
], ],
TABLES_ID_NUMBER: ['permissions', 'levels', 'statusSkills', 'sectors', 'skills', 'city', 'myskills'], TABLES_ID_NUMBER: ['permissions', 'levels', 'statusSkills', 'sectors', 'skills', 'cities', 'myskills'],
TABLES_USER_ID: ['myskills'], TABLES_USER_ID: ['myskills'],
TABLES_UPDATE_LASTMODIFIED: ['myskills'], TABLES_UPDATE_LASTMODIFIED: ['myskills'],