mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-29 12:50:55 +02:00
Merge branch 'master' into front_club
This commit is contained in:
@ -70,11 +70,12 @@ function li(id, text) {
|
||||
*/
|
||||
function displayNote(note, alias, user_note_field=null, profile_pic_field=null) {
|
||||
if (!note.display_image) {
|
||||
note.display_image = 'https://nk20.ynerant.fr/media/pic/default.png';
|
||||
note.display_image = '/media/pic/default.png';
|
||||
$.getJSON("/api/note/note/" + note.id + "/?format=json", function(new_note) {
|
||||
note.display_image = new_note.display_image.replace("http:", "https:");
|
||||
note.name = new_note.name;
|
||||
note.balance = new_note.balance;
|
||||
note.user = new_note.user;
|
||||
|
||||
displayNote(note, alias, user_note_field, profile_pic_field);
|
||||
});
|
||||
@ -159,10 +160,13 @@ function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes
|
||||
|
||||
let old_pattern = null;
|
||||
|
||||
// When the user type "Enter", the first alias is clicked
|
||||
// When the user type "Enter", the first alias is clicked, and the informations are displayed
|
||||
field.keypress(function(event) {
|
||||
if (event.originalEvent.charCode === 13)
|
||||
$("#" + alias_matched_id + " li").first().trigger("click");
|
||||
if (event.originalEvent.charCode === 13) {
|
||||
let li_obj = $("#" + alias_matched_id + " li").first();
|
||||
displayNote(notes[0], li_obj.text(), user_note_field, profile_pic_field);
|
||||
li_obj.trigger("click");
|
||||
}
|
||||
});
|
||||
|
||||
// When the user type something, the matched aliases are refreshed
|
||||
@ -269,7 +273,16 @@ function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes
|
||||
}
|
||||
|
||||
// When a validate button is clicked, we switch the validation status
|
||||
function de_validate(id, validated) {
|
||||
function in_validate(id, validated) {
|
||||
|
||||
let invalidity_reason;
|
||||
let reason_obj = $("#invalidity_reason_" + id);
|
||||
|
||||
if (validated)
|
||||
invalidity_reason = reason_obj.val();
|
||||
else
|
||||
invalidity_reason = null;
|
||||
|
||||
$("#validate_" + id).html("<strong style=\"font-size: 16pt;\">⟳ ...</strong>");
|
||||
|
||||
// Perform a PATCH request to the API in order to update the transaction
|
||||
@ -282,12 +295,13 @@ function de_validate(id, validated) {
|
||||
"X-CSRFTOKEN": CSRF_TOKEN
|
||||
},
|
||||
data: {
|
||||
"resourcetype": "RecurrentTransaction",
|
||||
valid: !validated
|
||||
resourcetype: "RecurrentTransaction",
|
||||
valid: !validated,
|
||||
invalidity_reason: invalidity_reason,
|
||||
},
|
||||
success: function () {
|
||||
// Refresh jQuery objects
|
||||
$(".validate").click(de_validate);
|
||||
$(".validate").click(in_validate);
|
||||
|
||||
refreshBalance();
|
||||
// error if this method doesn't exist. Please define it.
|
||||
|
Reference in New Issue
Block a user