Skip to content

Commit

Permalink
Merge branch 'hotfix/2.8.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Syno committed Nov 7, 2019
2 parents b132ee1 + ef6f4e1 commit 3e70a44
Show file tree
Hide file tree
Showing 20 changed files with 243 additions and 122 deletions.
2 changes: 1 addition & 1 deletion routes/application.js
Expand Up @@ -700,7 +700,7 @@ router.get('/list', block_access.isLoggedIn, function(req, res) {

// Get user project for clone url generation
let gitlabProjects = [];
if(gitlabConf.doGit)
if(gitlabConf.doGit && req.session.gitlab && req.session.gitlab.user)
gitlabProjects = await gitlab.getAllProjects(req.session.gitlab.user.id);

for (var i = 0; i < projects.length; i++) {
Expand Down
13 changes: 9 additions & 4 deletions routes/routes.js
Expand Up @@ -352,9 +352,10 @@ router.post('/reset_password_form', block_access.loginAccess, function(req, res)
}
});

let gitlabUser = null;
// Update Gitlab password
if(gitlabConf.doGit){
let gitlabUser = await gitlab.getUser(email_user);
gitlabUser = await gitlab.getUser(email_user);

if(!gitlabUser)
console.warn('Cannot update gitlab user password, user not found.');
Expand All @@ -373,10 +374,11 @@ router.post('/reset_password_form', block_access.loginAccess, function(req, res)
}
});

return connectedUser;
return {connectedUser, gitlabUser};

})().then(connectedUser => {
req.login(connectedUser, err => {
})().then(infos => {

req.login(infos.connectedUser, err => {
if (err) {
console.error(err);
req.session.toastr = [{
Expand All @@ -385,6 +387,9 @@ router.post('/reset_password_form', block_access.loginAccess, function(req, res)
}];
res.redirect('/login');
} else {
req.session.gitlab = {
user: infos.gitlabUser
};
req.session.toastr = [{
message: "login.passwordReset",
level: "success"
Expand Down
22 changes: 11 additions & 11 deletions services/bot.js
Expand Up @@ -2814,29 +2814,29 @@ exports.complete = function (instruction) {

let answer = " ";
let valid = true;
let letiable = false;
let variable = false;
while ((m < l) && (k < n) && (valid)) {
// Check if words are the same, goto next word
if (template[k] == "(.*)" || template[k] == instr[m]) {
letiable = false;
variable = false;
k++;
} else {
// Check if beginning of word are the same
let sublen = instr[m].length;
if (template[k].substring(0, sublen) == instr[m]) {
// Do not increment k, we are still on keyword
letiable = false;
variable = false;
} else {
// If we parse the letiable value
// If we parse the variable value
if (template[k] == "(.*)") {
// Check next word
if (template[k + 1]) {
k++;
letiable = true;
variable = true;
}
} else {
// If we are not parsing a letiable, it means template is not appropriate => Exit
if (!letiable)
// If we are not parsing a variable, it means template is not appropriate => Exit
if (!variable)
valid = false;
}
}
Expand All @@ -2857,12 +2857,12 @@ exports.complete = function (instruction) {
else {
if (template[k - 1] == "type")
answer = answer + "[type] ";
// Return [letiable] to explain this is something dynamic
// Return [variable] to explain this is something dynamic
else
answer = answer + "[letiable] ";
answer = answer + "[variable] ";

// If first loop on letiable, we need to display possible end of instruction
// Else, it means we have keyword at the beginning of suggestion, so we cut on letiable step
// If first loop on variable, we need to display possible end of instruction
// Else, it means we have keyword at the beginning of suggestion, so we cut on variable step
if (!firstLoop)
found = true;
}
Expand Down
3 changes: 2 additions & 1 deletion services/designer.js
Expand Up @@ -1046,7 +1046,7 @@ exports.setFieldKnownAttribute = function (attr, callback) {
}).catch(function (err) {
if (typeof err.parent !== "undefined" && (err.parent.errno == 1062 || err.parent.code == 23505)) {
let err = new Error("structure.field.attributes.duplicateUnique");
} else if(typeof err.parent !== "undefined" && (err.parent.errno == 1146 || err.parent.code == "42P01")){
} else if(typeof err.parent !== "undefined" && (err.parent.errno == 1146 || err.parent.code == "42P01" || err.parent.code == "3F000")){
// Handle case by Newmips, no worry about this one
if(['e_group', 'e_role', 'e_user'].indexOf(attr.name_data_entity) == -1 && attr.options.showValue == 'label'){
// Table do not exist - In case of script it's totally normal, just generate a warning
Expand Down Expand Up @@ -3336,6 +3336,7 @@ exports.createWidgetLastRecords = function (attr, callback) {
if (attr.columns[k].toLowerCase() == 'id') {
attr.columns[k] = {codeName: 'id', name: 'id', found:true};
kFound = true;
continue;
}
for (var i = 0; i < columns.length; i++) {
if (columns[i].codeName.indexOf('s_') == 0)
Expand Down
3 changes: 2 additions & 1 deletion structure/pieces/administration/routes/e_user.js
Expand Up @@ -522,7 +522,8 @@ router.get('/set_status/:id_user/:status/:id_new_status', block_access.actionAcc
status_helper.setStatus('e_user', req.params.id_user, req.params.status, req.params.id_new_status, req.session.passport.user.id, req.query.comment).then(()=> {
res.redirect(req.headers.referer);
}).catch((err)=> {
entity_helper.error(err, req, res, '/user/show?id=' + req.params.id_user, "e_user");
req.session.toastr.push({level: 'error', message: 'component.status.error.action_error'});
res.redirect(req.headers.referer);
});
});

Expand Down
Expand Up @@ -227,7 +227,8 @@ router.get('/set_status/:id_document_template/:status/:id_new_status', block_acc
status_helper.setStatus('e_document_template', req.params.id_document_template, req.params.status, req.params.id_new_status, req.session.passport.user.id, req.query.comment).then(() => {
res.redirect('/document_template/show?id=' + req.params.id_document_template);
}).catch((err) => {
entity_helper.error(err, req, res, '/document_template/show?id=' + req.params.id_document_template);
req.session.toastr.push({level: 'error', message: 'component.status.error.action_error'});
res.redirect(req.headers.referer);
});
});

Expand Down
Expand Up @@ -3,7 +3,7 @@
"status": {
"error": {
"illegal_status": "Ce statut n'est pas valide.",
"action_error": "Une ou plusieurs actions n'ont pas pu être éxecutée. Verifiez que les notifications sont activées et verifiez votre configuration mail."
"action_error": "Une ou plusieurs actions n'ont pas pu être executée. Verifiez que les notifications sont activées et verifiez votre configuration mail."
},
"next_status": "Statut suivant",
"available_status": "Statuts disponibles",
Expand Down
Expand Up @@ -147,7 +147,7 @@ module.exports = (sequelize, DataTypes) => {
}

getGroupAndUserID().then(function(targetIds) {
var entityUrl;
var entityUrl, notificationObj;
try {
try {
// Build show url of targeted entity
Expand All @@ -161,7 +161,7 @@ module.exports = (sequelize, DataTypes) => {
// Will redirect to current page
entityUrl = '#';
}
var notificationObj = {
notificationObj = {
f_color: self.f_color,
f_icon: insertVariablesValue('f_icon'),
f_title: insertVariablesValue('f_title'),
Expand Down
3 changes: 2 additions & 1 deletion structure/pieces/component/status/routes/e_action.js
Expand Up @@ -372,7 +372,8 @@ router.get('/set_status/:id_action/:status/:id_new_status', block_access.actionA
status_helper.setStatus('e_action', req.params.id_action, req.params.status, req.params.id_new_status, req.session.passport.user.id, req.query.comment).then(()=> {
res.redirect('/action/show?id=' + req.params.id_action)
}).catch((err)=> {
entity_helper.error(err, req, res, '/action/show?id=' + req.params.id_action);
req.session.toastr.push({level: 'error', message: 'component.status.error.action_error'});
res.redirect(req.headers.referer);
});
});

Expand Down
3 changes: 2 additions & 1 deletion structure/pieces/component/status/routes/e_media.js
Expand Up @@ -280,7 +280,8 @@ router.get('/set_status/:id_media/:status/:id_new_status', block_access.actionAc
status_helper.setStatus('e_media', req.params.id_media, req.params.status, req.params.id_new_status, req.session.passport.user.id, req.query.comment).then(()=> {
res.redirect('/media/show?id=' + req.params.id_media);
}).catch((err)=> {
entity_helper.error(err, req, res, '/media/show?id=' + req.params.id_media);
req.session.toastr.push({level: 'error', message: 'component.status.error.action_error'});
res.redirect(req.headers.referer);
});
});

Expand Down
3 changes: 2 additions & 1 deletion structure/pieces/routes/data_entity.js
Expand Up @@ -524,7 +524,8 @@ router.get('/set_status/:id_ENTITY_URL_NAME/:status/:id_new_status', block_acces
status_helper.setStatus('ENTITY_NAME', req.params.id_ENTITY_URL_NAME, req.params.status, req.params.id_new_status, req.session.passport.user.id, req.query.comment).then(()=> {
res.redirect(req.headers.referer);
}).catch(err => {
entity_helper.error(err, req, res, '/ENTITY_URL_NAME/show?id=' + req.params.id_ENTITY_URL_NAME, "ENTITY_NAME");
req.session.toastr.push({level: 'error', message: 'component.status.error.action_error'});
res.redirect(req.headers.referer);
});
});

Expand Down
15 changes: 10 additions & 5 deletions structure/structure_data_field.js
Expand Up @@ -397,10 +397,14 @@ function getFieldHtml(type, nameDataField, nameDataEntity, readOnly, file, value
str += " <input type='hidden' name='" + dataField + "' id='" + dataField + "_dropzone_hidden' value='" + value + "'/>\n";
} else {
str += " <div class='input-group'>\n";
str += " <div class='input-group-addon'>\n";
str += " <i class='fa fa-download'></i>\n";
str += " </div>\n";
str += " <a href=/default/download?entity=" + dataEntity + "&f={" + value2 + "|urlencode} class='form-control text-left' name=" + dataField + ">{" + value2 + "|filename}</a>\n";
str += " {?" + value2 + "}\n";
str += " <div class='input-group-addon'>\n";
str += " <i class='fa fa-download'></i>\n";
str += " </div>\n";
str += " <a href=/default/download?entity=" + dataEntity + "&f={" + value2 + "|urlencode} class='form-control text-left' name=" + dataField + ">{" + value2 + "|filename}</a>\n";
str += " {:else}\n";
str += " {#__ key=\"message.empty_file\" /}\n";
str += " {/" + value2 + "}\n";
str += " </div>\n";
}
break;
Expand All @@ -413,7 +417,7 @@ function getFieldHtml(type, nameDataField, nameDataEntity, readOnly, file, value
str += " <input type='hidden' name='" + dataField + "' id='" + dataField + "_dropzone_hidden' value=\"{" + value2 + ".value}\" data-buffer=\"{" + value2 + ".buffer}\"/>\n";
} else {
str += " <div class='input-group'>\n";
str += " <a href=/default/download?entity=" + dataEntity + "&f={" + value2 + ".value|urlencode} ><img src=data:image/;base64,{" + value2 + ".buffer} class='img img-responsive' data-type='picture' alt=" + value + " name=" + dataField + " " + readOnly + " height='400' width='400' /></a>\n";
str += " <a href=/default/download?entity=" + dataEntity + "&f={" + value2 + ".value|urlencode} ><img src=data:image/;base64,{" + value2 + ".buffer} class='img img-responsive' data-type='picture' alt=" + value + " name=" + dataField + " " + readOnly + " height='400' width='400' /></a>\n";
str += " </div>\n";
}
break;
Expand Down Expand Up @@ -630,6 +634,7 @@ exports.setupDataField = function (attr, callback) {
case "mel" :
typeForModel = "STRING";
typeForDatalist = "email";
type_data_field = "email";
break;
case "phone" :
case "tel" :
Expand Down
1 change: 1 addition & 0 deletions structure/template/locales/en-EN.json
Expand Up @@ -173,6 +173,7 @@
"question": "Are you sure you want to delete this entity ?"
},
"empty": "No data to display",
"empty_file": "No file",
"unique": "This field must be unique:",
"relatedtomanycheckbox_required": "A field requires you to check at least one checkbox."
},
Expand Down
1 change: 1 addition & 0 deletions structure/template/locales/fr-FR.json
Expand Up @@ -173,6 +173,7 @@
"question": "Êtes-vous sûr de vouloir supprimer cette entité ?"
},
"empty": "Aucune donnée à afficher",
"empty_file": "Aucun fichier",
"unique": "Ce champ doit être unique:",
"relatedtomanycheckbox_required": "Un champ necessite d'avoir au moins une case cochée."
},
Expand Down
9 changes: 5 additions & 4 deletions structure/template/public/js/Newmips/dataTableBuilder.js
Expand Up @@ -416,7 +416,7 @@ function init_datatable(tableID, doPagination, context) {
valueFromArray = getValue(parts, row);
}
} else {
// Has one sur une sous entité
// Has one relation field
let parts = columns[meta.col].data.split('.');
valueFromArray = getValue(parts, row);
}
Expand All @@ -440,7 +440,7 @@ function init_datatable(tableID, doPagination, context) {
if (typeof columns[meta.col].type != 'undefined') {
// date / datetime
if (columns[meta.col].type == 'date' || columns[meta.col].type == 'datetime') {
if (cellValue != "" && cellValue != null && cellValue != "Invalid date" && cellValue != "Invalid Date") {
if (cellValue != null && cellValue != "" && cellValue.toLowerCase() != "invalid date") {
var tmpDate = moment(new Date(cellValue));
if (!tmpDate.isValid())
cellValue = '-';
Expand Down Expand Up @@ -484,6 +484,9 @@ function init_datatable(tableID, doPagination, context) {
// Get current entity by splitting current table id
var currentEntity = tableID.split("#table_")[1];
var justFilename = cellValue.replace(cellValue.split("_")[0], "").substring(1);
// Remove uuid
if(justFilename[32] == '_')
justFilename = justFilename.substring(33);
cellValue = '<a href="/default/download?entity='+currentEntity+'&amp;f='+encodeURIComponent(cellValue)+'" name="'+columns[meta.col].data+'">'+justFilename+'</a>';
} else
cellValue = '';
Expand Down Expand Up @@ -609,7 +612,6 @@ function init_datatable(tableID, doPagination, context) {
}
]
}
// Global search
table = $(tableID, context).DataTable(tableOptions);

//modal on click on picture cell
Expand Down Expand Up @@ -650,7 +652,6 @@ function init_datatable(tableID, doPagination, context) {
var mainTh = $(this);
var title = $(this).text();

// Custom
var currentField = mainTh.data('field');
var val = getFilter(tableID.substring(1), currentField);
var search = '<input type="text" class="form-control input" value="' + val + '" placeholder="' + title + '" />';
Expand Down
2 changes: 1 addition & 1 deletion structure/template/public/js/newmips.js
Expand Up @@ -425,7 +425,7 @@ function initForm(context) {
if (!confirm('Êtes-vous sûr de vouloir supprimer ce fichier ?'))
return false;
$.ajax({
url: '/default/delete-file-ajax',
url: '/default/delete_file',
type: 'post',
data: {
dataEntity: that.attr("data-entity"),
Expand Down

0 comments on commit 3e70a44

Please sign in to comment.