1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-29 12:50:55 +02:00

Add shortcuts for transfers and credits in the activity entry page

This commit is contained in:
Yohann D'ANELLO
2020-04-06 07:06:52 +02:00
parent 6498a20b87
commit 9d584ae87a
8 changed files with 232 additions and 152 deletions

View File

@ -19,23 +19,32 @@ function pretty_money(value) {
* Add a message on the top of the page.
* @param msg The message to display
* @param alert_type The type of the alert. Choices: info, success, warning, danger
* @param timeout The delay (in millis) after that the message is auto-closed. If negative, then it is ignored.
*/
function addMsg(msg, alert_type) {
function addMsg(msg, alert_type, timeout=-1) {
let msgDiv = $("#messages");
let html = msgDiv.html();
let id = Math.floor(10000 * Math.random() + 1);
html += "<div class=\"alert alert-" + alert_type + " alert-dismissible\">" +
"<button class=\"close\" data-dismiss=\"alert\" href=\"#\"><span aria-hidden=\"true\">×</span></button>"
"<button id=\"close-message-" + id + "\" class=\"close\" data-dismiss=\"alert\" href=\"#\"><span aria-hidden=\"true\">×</span></button>"
+ msg + "</div>\n";
msgDiv.html(html);
if (timeout > 0) {
setTimeout(function () {
$("#close-message-" + id).click();
}, timeout);
}
}
/**
* add Muliple error message from err_obj
* @param errs_obj [{error_code:erro_message}]
* @param timeout The delay (in millis) after that the message is auto-closed. If negative, then it is ignored.
*/
function errMsg(errs_obj){
function errMsg(errs_obj, timeout=-1) {
for (const err_msg of Object.values(errs_obj)) {
addMsg(err_msg,'danger');
addMsg(err_msg,'danger', timeout);
}
}