mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-26 11:57:41 +02:00
Add shortcuts for transfers and credits in the activity entry page
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ function reset() {
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
console.log(42);
|
||||
autoCompleteNote("source_note", "source_alias_matched", "source_note_list", sources, sources_notes_display,
|
||||
"source_alias", "source_note", "user_note", "profile_pic");
|
||||
autoCompleteNote("dest_note", "dest_alias_matched", "dest_note_list", dests, dests_notes_display,
|
||||
@ -61,16 +62,25 @@ $(document).ready(function() {
|
||||
|
||||
|
||||
// Ensure we begin in gift mode. Removing these lines may cause problems when reloading.
|
||||
$("#type_gift").prop('checked', 'true');
|
||||
let type_gift = $("#type_gift"); // Default mode
|
||||
type_gift.removeAttr('checked');
|
||||
$("#type_transfer").removeAttr('checked');
|
||||
$("#type_credit").removeAttr('checked');
|
||||
$("#type_debit").removeAttr('checked');
|
||||
$("label[for='type_gift']").attr('class', 'btn btn-sm btn-outline-primary');
|
||||
$("label[for='type_transfer']").attr('class', 'btn btn-sm btn-outline-primary');
|
||||
$("label[for='type_credit']").attr('class', 'btn btn-sm btn-outline-primary');
|
||||
$("label[for='type_debit']").attr('class', 'btn btn-sm btn-outline-primary');
|
||||
|
||||
console.log("#type_" + location.hash.substr(1));
|
||||
if (location.hash)
|
||||
$("#type_" + location.hash.substr(1)).click();
|
||||
else
|
||||
type_gift.click();
|
||||
location.hash = "";
|
||||
});
|
||||
|
||||
$("#transfer").click(function() {
|
||||
$("#btn_transfer").click(function() {
|
||||
if ($("#type_gift").is(':checked')) {
|
||||
dests_notes_display.forEach(function (dest) {
|
||||
$.post("/api/note/transaction/transaction/",
|
||||
|
Reference in New Issue
Block a user