- CMyPopupEdit
- CMyEditor - MySkills
This commit is contained in:
@@ -96,6 +96,12 @@ CitySchema.statics.executeQueryTable = function (idapp, 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);
|
||||
|
||||
|
||||
@@ -21,19 +21,42 @@ const MySkillSchema = new Schema({
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
userId: {type: Schema.Types.ObjectId, ref: 'User'},
|
||||
idSkill: {
|
||||
type: Number,
|
||||
},
|
||||
idStatusSkill: [{
|
||||
idStatusSkill: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
numLevel: {
|
||||
type: Number,
|
||||
},
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
order: {
|
||||
type: Number,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
note: {
|
||||
type: String,
|
||||
},
|
||||
subTitle: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
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) {
|
||||
const myrec = await MySkill.findOne().limit(1).sort({_id:-1});
|
||||
const myrec = await MySkill.findOne().limit(1).sort({_id: -1});
|
||||
if (!!myrec) {
|
||||
if (myrec._doc._id === 0)
|
||||
this._id = 1;
|
||||
@@ -63,11 +86,10 @@ MySkillSchema.pre('save', async function (next) {
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
MySkillSchema.statics.findAllIdApp = function(idapp) {
|
||||
|
||||
const query = [
|
||||
{ $match: { idapp } },
|
||||
{$match: {idapp}},
|
||||
{$sort: {descr: 1}},
|
||||
];
|
||||
|
||||
@@ -78,7 +100,7 @@ MySkillSchema.statics.findAllIdApp = function(idapp) {
|
||||
};
|
||||
|
||||
MySkillSchema.statics.getFieldsForSearch = function() {
|
||||
return [{ field: 'idSkill', type: tools.FieldType.Number }]
|
||||
return [{field: 'idSkill', type: tools.FieldType.Number}];
|
||||
};
|
||||
|
||||
MySkillSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
|
||||
@@ -253,6 +253,9 @@ const UserSchema = new mongoose.Schema({
|
||||
sex: {
|
||||
type: Number,
|
||||
},
|
||||
biografia: {
|
||||
type: String,
|
||||
},
|
||||
motivazioni: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
@@ -293,7 +293,7 @@ function getTableByTableName(tablename) {
|
||||
mytable = MySkill;
|
||||
else if (tablename === 'statusSkills')
|
||||
mytable = StatusSkill;
|
||||
else if (tablename === 'citys')
|
||||
else if (tablename === 'cities')
|
||||
mytable = City;
|
||||
else if (tablename === 'sectors')
|
||||
mytable = Sector;
|
||||
@@ -1281,6 +1281,7 @@ function load(req, res, version) {
|
||||
let skills = Skill.findAllIdApp(idapp);
|
||||
let statusSkills = StatusSkill.findAllIdApp(idapp);
|
||||
let sectors = Sector.findAllIdApp(idapp);
|
||||
let cities = City.findAllIdApp(idapp);
|
||||
let cart = null;
|
||||
let orderscart = null;
|
||||
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,
|
||||
levels, skills, sectors, statusSkills ])
|
||||
levels, skills, sectors, statusSkills, cities ])
|
||||
.then((arrdata) => {
|
||||
// console.table(arrdata);
|
||||
const myuser = req.user;
|
||||
@@ -1309,7 +1310,34 @@ function load(req, res, version) {
|
||||
myuser.password = '';
|
||||
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({
|
||||
bookedevent: arrdata[0],
|
||||
eventlist: arrdata[1],
|
||||
@@ -1339,7 +1367,10 @@ function load(req, res, version) {
|
||||
skills: arrdata[25],
|
||||
sectors: arrdata[26],
|
||||
statusSkills: arrdata[27],
|
||||
cities: arrdata[28]
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e.message);
|
||||
@@ -1464,7 +1495,7 @@ router.post('/upload_from_other_server/:dir', authenticate, (req, res) => {
|
||||
|
||||
function uploadFile(req, res, version) {
|
||||
// console.log('/upload dir:' + dir);
|
||||
const dir = req.params.dir;
|
||||
const dir = tools.invertescapeslash(req.params.dir);
|
||||
const idapp = req.user.idapp;
|
||||
|
||||
const form = new formidable.IncomingForm();
|
||||
@@ -1473,7 +1504,11 @@ function uploadFile(req, res, version) {
|
||||
|
||||
let dirmain = '/statics';
|
||||
if (version > 0) {
|
||||
if (process.env.PROD === 1) {
|
||||
dirmain = '';
|
||||
} else {
|
||||
dirmain = '/public';
|
||||
}
|
||||
}
|
||||
|
||||
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 version = tools.getVersionint(versionstr);
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ router.post('/', authenticate, (req, res) => {
|
||||
// Send 201 - resource created
|
||||
// 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)
|
||||
|
||||
|
||||
@@ -414,6 +414,8 @@ async function faitest() {
|
||||
|
||||
const testfind = false;
|
||||
|
||||
// const $vers = tools.getVersionint('1.92.45');
|
||||
|
||||
if (testfind) {
|
||||
const {City} = require('./models/city');
|
||||
|
||||
|
||||
@@ -2174,10 +2174,20 @@ module.exports = {
|
||||
},
|
||||
|
||||
getVersionint(versionstr) {
|
||||
let version = versionstr.replace('.', '');
|
||||
version = version.replace('.', '');
|
||||
let versionarr = versionstr.split('.');
|
||||
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);
|
||||
},
|
||||
|
||||
invertescapeslash(mystr) {
|
||||
return mystr.replace(/-/g, '/');
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
@@ -39,7 +39,7 @@ module.exports = {
|
||||
'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_UPDATE_LASTMODIFIED: ['myskills'],
|
||||
|
||||
|
||||
Reference in New Issue
Block a user