nuova veste grafica: myskills, mygoods, mybachecas, myhosps,

- cambiato id (da numero a stringa)
This commit is contained in:
Surya Paolo
2023-04-07 02:45:21 +02:00
parent 8a77dabc22
commit 94ef2c4c85
15 changed files with 1582 additions and 972 deletions

View File

@@ -6,6 +6,8 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const shared_consts = require('../tools/shared_nodejs');
const {ObjectID} = require('mongodb');
// Resolving error Unknown modifier: $pushAll
@@ -86,7 +88,6 @@ const MySkillSchema = new Schema({
},
date_created: {
type: Date,
default: Date.now,
},
date_updated: {
type: Date,
@@ -95,7 +96,8 @@ const MySkillSchema = new Schema({
MySkillSchema.pre('save', async function(next) {
if (this.isNew) {
this.date_created = new Date();
if (!this.date_created)
this.date_created = new Date();
}
next();
@@ -139,36 +141,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
lk_FF: '_id',
lk_as: 'user',
af_objId_tab: 'myId',
lk_proj: {
idSkill: 1,
// idSubSkill: 1,
myskill: 1,
idStatusSkill: 1,
idContribType: 1,
'profile.username_telegram': 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
//**ADDFIELD_MYSKILL
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
lk_proj: this.getProject(),
},
};
@@ -180,20 +153,10 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
const MySkill = this;
let myparskill = {};
if (tools.isNumber(idSkill)) {
myparskill = {'_id': parseInt(idSkill)};
} else {
myparskill = {'_id': idSkill};
}
const query = [
let query = [
{
'$match': {
'$and': [
myparskill,
],
'_id': idSkill,
},
},
{
@@ -237,38 +200,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
note: 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -294,38 +226,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -351,38 +252,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
//'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
/*{
'$lookup': {
@@ -410,38 +280,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -466,40 +305,17 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
},
];
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYSKILLS);
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
query = [...query,
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
reported: 1,
},
},
$project: this.getProject(objadd.proj),
}
];
return MySkill.aggregate(query).then((rec) => {
@@ -507,6 +323,24 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
});
};
MySkillSchema.statics.getProject = function (proj_add2) {
let proj = {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
idStatusSkill: 1,
website: 1,
'numLevel': 1,
//**ADDFIELD_MYSKILL
};
const proj_add = shared_consts.getProjectForAll(proj_add2)
return Object.assign({}, proj, proj_add);
}
MySkillSchema.statics.getCompleteRecord = function(idapp, id) {
const MySkill = this;