- Add New Record directly by the QSelect

This commit is contained in:
paoloar77
2022-01-28 00:57:39 +01:00
parent 842a041fe5
commit fd79893ddc
7 changed files with 133 additions and 83 deletions

View File

@@ -22,6 +22,9 @@ const MySkillSchema = new Schema({
required: true,
},
userId: {type: Schema.Types.ObjectId, ref: 'User'},
idSector: {
type: Number,
},
idSkill: {
type: Number,
default: 0,
@@ -65,6 +68,9 @@ const MySkillSchema = new Schema({
subTitle: {
type: String,
},
descr: {
type: String,
},
date_created: {
type: Date,
default: Date.now,
@@ -209,6 +215,7 @@ MySkillSchema.statics.getMySkillByIdkill = function (idapp, idSkill) {
"$project": {
"recSkill": 1,
"sector": 1,
"idSector": 1,
"idSkill": 1,
"idSubSkill": 1,
"idStatusSkill": 1,
@@ -257,6 +264,7 @@ MySkillSchema.statics.getMySkillByIdkill = function (idapp, idSkill) {
"$project": {
"recSkill": 1,
"sector": 1,
"idSector": 1,
"idSkill": 1,
"idSubSkill": 1,
"idStatusSkill": 1,
@@ -305,6 +313,7 @@ MySkillSchema.statics.getMySkillByIdkill = function (idapp, idSkill) {
"$project": {
"recSkill": 1,
"sector": 1,
"idSector": 1,
"idSkill": 1,
"idSubSkill": 1,
"idStatusSkill": 1,
@@ -353,6 +362,7 @@ MySkillSchema.statics.getMySkillByIdkill = function (idapp, idSkill) {
"$project": {
"recSkill": 1,
"sector": 1,
"idSector": 1,
"idSkill": 1,
"idSubSkill": 1,
"idStatusSkill": 1,
@@ -401,6 +411,7 @@ MySkillSchema.statics.getMySkillByIdkill = function (idapp, idSkill) {
"$project": {
"recSkill": 1,
"sector": 1,
"idSector": 1,
"idSkill": 1,
"idSubSkill": 1,
"idStatusSkill": 1,

View File

@@ -41,12 +41,6 @@ module.exports = {
"__v" : 0,
"label" : "Scambio di Lavoro"
},
{
"_id" : ObjectID("61cae7da4c7b5931a5f367c9"),
"idapp" : "1",
"__v" : 0,
"label" : "Sardex"
},
{
"_id" : ObjectID("615a353c002c8298f4495bf7"),
"idapp" : "12",
@@ -86,11 +80,5 @@ module.exports = {
"__v" : 0,
"label" : "Scambio di Lavoro"
},
{
"_id" : ObjectID("61cae7da4c7b5931a5f36712"),
"idapp" : "12",
"__v" : 0,
"label" : "Sardex"
},
]
}

View File

@@ -25,7 +25,8 @@ module.exports = {
},
popolaTabelleNuove() {
const abilita = false;
const abilita = true;
const scrivi_citta = false;
let ris = null;
if (abilita) {
@@ -41,6 +42,7 @@ module.exports = {
const { SubSkill } = require('../models/subskill');
this.insertIntoDb('subskills', SubSkill)
if (scrivi_citta) {
// Cities
const {City} = require('../models/city');
this.insertIntoDb('cities', City)
@@ -48,6 +50,7 @@ module.exports = {
// Province
const {Province} = require('../models/province');
this.insertIntoDb('provinces', Province)
}
// Contribtypes
const { Contribtype } = require('../models/contribtype');

View File

@@ -6,31 +6,51 @@ module.exports = {
},
{
_id: 2,
descr: "Arte",
},
{
_id: 3,
descr: "Alimentazione",
},
{
_id: 1,
_id: 4,
descr: "Artigianato",
},
{
_id: 5,
descr: "Assistenza Legale",
},
{
_id: 6,
descr: "Benessere e Salute",
},
{
_id: 7,
descr: "Gruppi Locali",
},
{
_id: 1,
_id: 8,
descr: "Istruzione",
},
{
_id: 1,
_id: 9,
descr: "Mobilità",
},
{
_id: 1,
descr: "Salute",
},
{
_id: 1,
_id: 10,
descr: "Sport",
},
{
_id: 1,
_id: 11,
descr: "Servizi",
},
{
_id: 12,
descr: "Tecnologia",
},
{
_id: 13,
descr: "Turismo",
},
]
}

View File

@@ -339,6 +339,14 @@ router.post('/settable', authenticate, (req, res) => {
mydata.idapp = req.user.idapp;
let consentito = false;
try {
if (User.isAdmin(req.user.perm) || User.isManager(req.user.perm) ||
User.isEditor(req.user.perm) || User.isTutor(req.user.perm)) {
consentito = true;
}
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) &&
!User.isEditor(req.user.perm) && !User.isTutor(req.user.perm)) &&
!tools.ModificheConsentite(params.table, fieldsvalue)) {
@@ -351,6 +359,12 @@ router.post('/settable', authenticate, (req, res) => {
mydata.userId = req.user._id;
}
if (shared_consts.TABLES_PERM_NEWREC.includes(params.table)) {
if (!consentito) {
mydata.verifyrec = false;
}
}
delete mydata['__v'];
delete mydata['__proto__'];
@@ -397,6 +411,10 @@ router.post('/settable', authenticate, (req, res) => {
}
});
}catch (e) {
return res.status(400).send(e);
}
});
router.post('/setsubrec', authenticate, (req, res) => {
@@ -1653,13 +1671,19 @@ function uploadFile(req, res, version) {
// Salva le immagini in formato compresso
(async () => {
await resizer(newname, setup_image_compress);
try {
const ris = await resizer(newname, setup_image_compress);
if (ris) {
tools.delete(newname, false, () => {})
tools.move(resized_img, newname, (err) => {
})
}
}catch (e) {
console.error('newname', e);
}
})();
res.end();

View File

@@ -2090,6 +2090,9 @@ module.exports = {
if (shared_consts.TABLES_PERM_CHANGE_FOR_USERS.includes(table)) {
return true;
}
if (shared_consts.TABLES_PERM_NEWREC.includes(table)) {
return true;
}
return false;
},

View File

@@ -73,6 +73,7 @@ module.exports = {
TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybots'],
TABLES_PERM_CHANGE_FOR_USERS: ['myskills'],
TABLES_PERM_NEWREC: ['skills', 'subskills'],
VISIB_ALL: 0,
VISIB_ONLYIF_VERIFIED: 1,