- Added TablesList page

- Added Insert Record empty
This commit is contained in:
Paolo Arena
2019-10-20 01:21:54 +02:00
parent 3424b20e9a
commit 93eae51ab8
16 changed files with 568 additions and 88 deletions

View File

@@ -66,6 +66,10 @@ module.exports = {
'completed_at', 'expiring_at', 'enableExpiring', 'id_prev', 'progress', 'modified', 'phase', 'assigned_to_userId', 'hoursplanned', 'hoursworked', 'start_date', 'themecolor', 'themebgcolor']
},
allfieldMyEvent: function () {
return ['userId',]
},
allfieldTodoWithId: function () {
return ['_id', ...this.allfieldTodo()]
},
@@ -333,7 +337,8 @@ module.exports = {
},
isManagAndAdminDifferent(idapp) {
return this.getManagerEmailByIdApp(idapp) !== this.getAdminEmailByIdApp(idapp)
const manag = this.getManagerEmailByIdApp(idapp);
return (manag !== this.getAdminEmailByIdApp(idapp)) && (manag !== '');
},
getManagerEmailByIdApp: function (idapp) {
@@ -344,6 +349,63 @@ module.exports = {
return '';
},
getQueryTable(idapp, params) {
// console.log('idapp', idapp);
// console.table(params);
if (typeof params.startRow !== 'number') {
throw new Error('startRow must be number')
} else if (typeof params.endRow !== 'number') {
throw new Error('endRow must be number')
}
const query = [
{ $match: Object.assign({ idapp }, params.filter) }
];
if (params.sortBy) {
// maybe we want to sort by blog title or something
const mysort = { $sort: params.sortBy };
// console.log('sortBy', params.sortBy);
// console.table(mysort);
query.push(mysort)
}
query.push(
{
$group: {
_id: null,
// get a count of every result that matches until now
count: { $sum: 1 },
// keep our results for the next operation
results: { $push: '$$ROOT' }
}
},
// and finally trim the results to within the range given by start/endRow
{
$project: {
count: 1,
rows: { $slice: ['$results', params.startRow, params.endRow] }
}
}
);
return query
},
executeQueryTable(mythistable, idapp, params) {
let query = this.getQueryTable(idapp, params);
return mythistable
.aggregate(query)
.then(([{ count, rows }]) => {
return ({ count, rows })
})
.catch(err => {
return {
count: 0, rows: []
}
});
}
};