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

@@ -1765,6 +1765,11 @@ module.exports = {
return myquery;
},
getNumTabByTable(table) {
const myrec = shared_consts.MYTABS.find((rec) => rec.table === table)
return myrec ? myrec.id : -1
},
getGroupnameLookupPipeLine(params, proj) {
let myquery = [
@@ -1796,7 +1801,7 @@ module.exports = {
return myquery;
},
getLookup: function (params, num, pass_proj) {
getLookup: function (params, num, pass_proj, proj_add) {
const query = [];
if (!params)
@@ -1819,6 +1824,8 @@ module.exports = {
if (!!pass_proj) {
proj = pass_proj;
}
proj = Object.assign({}, proj, proj_add);
query.push(
{
$lookup: {
@@ -1910,6 +1917,77 @@ module.exports = {
return myquery;
},
addNumFavoriteAndBookmarkToQuery(idapp, numtab) {
let query =
[{
$lookup: {
from: 'users',
let: {
tab: numtab,
id: '$_id',
},
pipeline: [
{
$unwind: '$profile.favorite',
},
{
$match: {
$expr: {
$and: [
{ $eq: ['$profile.favorite.id', '$$id'] },
{ $eq: ['$profile.favorite.tab', '$$tab'] },
{ $eq: ['$idapp', idapp] },
],
},
},
},
{ $project: { username: 1, name: 1, surname: 1, 'profile.resid_province': 1, 'profile.img': 1, 'profile.qualifica': 1 } },
],
as: 'myfav',
},
},
{
$lookup: {
from: "users",
let: {
tab: numtab,
id: '$_id',
},
pipeline: [
{
$unwind: '$profile.bookmark',
},
{
$match: {
$expr: {
$and: [
{ $eq: ['$profile.bookmark.id', '$$id'] },
{ $eq: ['$profile.bookmark.tab', '$$tab'] },
{ $eq: ['$idapp', idapp] },
],
},
},
},
{
$project: {
username: 1, name: 1, surname: 1, 'profile.resid_province': 1, 'profile.img': 1,
'profile.qualifica': 1,
}
},
],
as: 'mybook',
},
},
];
proj = {
myfav: 1,
mybook: 1,
};
return { query, proj };
},
getQueryTable: async function (idapp, params, user) {
if (typeof params.startRow !== 'number') {
@@ -2103,10 +2181,10 @@ module.exports = {
if (params.options) {
if (this.isBitActive(params.options,
shared_consts.OPTIONS_SEARCH_ONLY_FULL_WORDS)) {
}
}
if (params.filterextra) {
if (params.filterextra.length > 0)
query = [...query, ...params.filterextra]
@@ -2352,23 +2430,34 @@ module.exports = {
query.push({ $unwind: params.unwind0 });
}
const q1 = this.getLookup(params.lookup1, 1, proj);
let objadd = { query: [], proj: {} };
let numtab = this.getNumTabByTable(params.table);
if (params.options && this.isBitActive(params.options,
shared_consts.OPTIONS_ADD_COUNT_FAVORITE)) {
objadd = this.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
}
const q1 = this.getLookup(params.lookup1, 1, proj, objadd.proj);
if (q1) query = [...query, ...q1];
if (params.unwind1) {
query.push({ $unwind: params.unwind1 });
}
const q2 = this.getLookup(params.lookup2, 2, proj);
const q2 = this.getLookup(params.lookup2, 2, proj, objadd.proj);
if (q2) query = [...query, ...q2];
const q3 = this.getLookup(params.lookup3, 3, proj);
const q3 = this.getLookup(params.lookup3, 3, proj, objadd.proj);
if (q3) query = [...query, ...q3];
const q4 = this.getLookup(params.lookup4, 4, proj);
const q4 = this.getLookup(params.lookup4, 4, proj, objadd.proj);
if (q4) query = [...query, ...q4];
const q5 = this.getLookup(params.lookup5, 5, proj);
const q5 = this.getLookup(params.lookup5, 5, proj, objadd.proj);
if (q5) query = [...query, ...q5];
if (params.filtersearch2) {
@@ -2377,6 +2466,7 @@ module.exports = {
}
}
let filteradmin = false;
if (params.filtercustom) {
let condition = {};
@@ -2480,6 +2570,7 @@ module.exports = {
}
}
if (params.filter && params.fieldsearch_last) {
const querytemp = this.getFilterParam(params.filter,
params.fieldsearch_last);
@@ -3776,4 +3867,5 @@ module.exports = {
return `<a href='${link}'>${username}</a>`;
},
};