@@ -24,7 +24,12 @@ const ContribtypeSchema = new Schema({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ContribtypeSchema.statics.getFieldsForSearch = function () {
|
||||||
|
return ['label']
|
||||||
|
};
|
||||||
|
|
||||||
ContribtypeSchema.statics.executeQueryTable = function (idapp, params) {
|
ContribtypeSchema.statics.executeQueryTable = function (idapp, params) {
|
||||||
|
params.fieldsearch = this.getFieldsForSearch();
|
||||||
return tools.executeQueryTable(this, idapp, params);
|
return tools.executeQueryTable(this, idapp, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
88
server/models/discipline.js
Normal file
88
server/models/discipline.js
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
const mongoose = require('mongoose');
|
||||||
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
mongoose.Promise = global.Promise;
|
||||||
|
mongoose.level = "F";
|
||||||
|
|
||||||
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
|
const { ObjectID } = require('mongodb');
|
||||||
|
|
||||||
|
// Resolving error Unknown modifier: $pushAll
|
||||||
|
mongoose.plugin(schema => {
|
||||||
|
schema.options.usePushEach = true
|
||||||
|
});
|
||||||
|
|
||||||
|
const DisciplineSchema = new Schema({
|
||||||
|
idapp: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
typol_code: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
linkpage: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
img_small: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
img: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
showinnewsletter: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
showinhome: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
teachers: [{
|
||||||
|
username: {
|
||||||
|
type: String,
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
|
||||||
|
DisciplineSchema.statics.findAllIdApp = function (idapp) {
|
||||||
|
const Discipline = this;
|
||||||
|
|
||||||
|
const query = [
|
||||||
|
{ $match: { idapp } },
|
||||||
|
{ $sort: { order: 1 } }
|
||||||
|
];
|
||||||
|
|
||||||
|
return Discipline
|
||||||
|
.aggregate(query)
|
||||||
|
.then((arrrec) => {
|
||||||
|
return arrrec
|
||||||
|
})
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
DisciplineSchema.statics.getFieldsForSearch = function () {
|
||||||
|
return ['label', 'description']
|
||||||
|
};
|
||||||
|
|
||||||
|
DisciplineSchema.statics.executeQueryTable = function (idapp, params) {
|
||||||
|
params.fieldsearch = this.getFieldsForSearch();
|
||||||
|
return tools.executeQueryTable(this, idapp, params);
|
||||||
|
};
|
||||||
|
|
||||||
|
const Discipline = mongoose.model('Discipline', DisciplineSchema);
|
||||||
|
|
||||||
|
module.exports = { Discipline };
|
||||||
@@ -88,6 +88,10 @@ OperatorSchema.statics.getEmailByUsername = async function (idapp, username) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
OperatorSchema.statics.getFieldsForSearch = function () {
|
||||||
|
return ['name', 'surname', 'email', 'cell']
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
OperatorSchema.statics.executeQueryTable = function (idapp, params) {
|
OperatorSchema.statics.executeQueryTable = function (idapp, params) {
|
||||||
params.fieldsearch = this.getFieldsForSearch();
|
params.fieldsearch = this.getFieldsForSearch();
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ PermissionSchema.pre('save', async function (next) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
PermissionSchema.statics.executeQueryTable = function (idapp, params) {
|
PermissionSchema.statics.executeQueryTable = function (idapp, params) {
|
||||||
|
params.fieldsearch = this.getFieldsForSearch();
|
||||||
return tools.executeQueryTable(this, 0, params);
|
return tools.executeQueryTable(this, 0, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,12 @@ const SettingsSchema = new Schema({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
SettingsSchema.statics.getFieldsForSearch = function () {
|
||||||
|
return ['key', 'value_str']
|
||||||
|
};
|
||||||
|
|
||||||
SettingsSchema.statics.executeQueryTable = function (idapp, params) {
|
SettingsSchema.statics.executeQueryTable = function (idapp, params) {
|
||||||
|
params.fieldsearch = this.getFieldsForSearch();
|
||||||
return tools.executeQueryTable(this, idapp, params);
|
return tools.executeQueryTable(this, idapp, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,12 @@ const WhereSchema = new Schema({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
WhereSchema.statics.getFieldsForSearch = function () {
|
||||||
|
return ['placename']
|
||||||
|
};
|
||||||
|
|
||||||
WhereSchema.statics.executeQueryTable = function (idapp, params) {
|
WhereSchema.statics.executeQueryTable = function (idapp, params) {
|
||||||
|
params.fieldsearch = this.getFieldsForSearch();
|
||||||
return tools.executeQueryTable(this, idapp, params);
|
return tools.executeQueryTable(this, idapp, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const { Operator } = require('../models/operator');
|
|||||||
const { Where } = require('../models/where');
|
const { Where } = require('../models/where');
|
||||||
const { MyEvent } = require('../models/myevent');
|
const { MyEvent } = require('../models/myevent');
|
||||||
const { Contribtype } = require('../models/contribtype');
|
const { Contribtype } = require('../models/contribtype');
|
||||||
|
const { Discipline } = require('../models/discipline');
|
||||||
const { Settings } = require('../models/settings');
|
const { Settings } = require('../models/settings');
|
||||||
const { SendMsg } = require('../models/sendmsg');
|
const { SendMsg } = require('../models/sendmsg');
|
||||||
const { Permission } = require('../models/permission');
|
const { Permission } = require('../models/permission');
|
||||||
@@ -143,6 +144,8 @@ function getTableByTableName(tablename) {
|
|||||||
mytable = MyEvent;
|
mytable = MyEvent;
|
||||||
else if (tablename === 'contribtype')
|
else if (tablename === 'contribtype')
|
||||||
mytable = Contribtype;
|
mytable = Contribtype;
|
||||||
|
else if (tablename === 'disciplines')
|
||||||
|
mytable = Discipline;
|
||||||
else if (tablename === 'settings')
|
else if (tablename === 'settings')
|
||||||
mytable = Settings;
|
mytable = Settings;
|
||||||
else if (tablename === 'permissions')
|
else if (tablename === 'permissions')
|
||||||
@@ -339,11 +342,12 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
|||||||
const operators = Operator.findAllIdApp(idapp);
|
const operators = Operator.findAllIdApp(idapp);
|
||||||
const wheres = Where.findAllIdApp(idapp);
|
const wheres = Where.findAllIdApp(idapp);
|
||||||
const contribtype = Contribtype.findAllIdApp(idapp);
|
const contribtype = Contribtype.findAllIdApp(idapp);
|
||||||
|
const disciplines = Discipline.findAllIdApp(idapp);
|
||||||
const settings = Settings.findAllIdApp(idapp);
|
const settings = Settings.findAllIdApp(idapp);
|
||||||
const permissions = Permission.findAllIdApp();
|
const permissions = Permission.findAllIdApp();
|
||||||
|
|
||||||
|
|
||||||
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions])
|
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines])
|
||||||
.then((arrdata) => {
|
.then((arrdata) => {
|
||||||
// console.table(arrdata);
|
// console.table(arrdata);
|
||||||
res.send({
|
res.send({
|
||||||
@@ -354,6 +358,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
|||||||
contribtype: arrdata[4],
|
contribtype: arrdata[4],
|
||||||
settings: arrdata[5],
|
settings: arrdata[5],
|
||||||
permissions: arrdata[6],
|
permissions: arrdata[6],
|
||||||
|
disciplines: arrdata[7],
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ module.exports = {
|
|||||||
select: 32,
|
select: 32,
|
||||||
number: 64,
|
number: 64,
|
||||||
typeinrec: 128,
|
typeinrec: 128,
|
||||||
|
multiselect: 256,
|
||||||
},
|
},
|
||||||
|
|
||||||
MAX_PHASES: 5,
|
MAX_PHASES: 5,
|
||||||
|
|||||||
Reference in New Issue
Block a user