mirror of https://gitlab.crans.org/bde/nk20
Last and first name didn't auto-complete because of a bug
This commit is contained in:
parent
a52741b87f
commit
1b03eac95b
|
@ -67,6 +67,7 @@ function displayNote(note, alias, user_note_field=null, profile_pic_field=null)
|
||||||
note.display_image = new_note.display_image.replace("http:", "https:");
|
note.display_image = new_note.display_image.replace("http:", "https:");
|
||||||
note.name = new_note.name;
|
note.name = new_note.name;
|
||||||
note.balance = new_note.balance;
|
note.balance = new_note.balance;
|
||||||
|
note.user = new_note.user;
|
||||||
|
|
||||||
displayNote(note, alias, user_note_field, profile_pic_field);
|
displayNote(note, alias, user_note_field, profile_pic_field);
|
||||||
});
|
});
|
||||||
|
@ -151,10 +152,13 @@ function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes
|
||||||
|
|
||||||
let old_pattern = null;
|
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) {
|
field.keypress(function(event) {
|
||||||
if (event.originalEvent.charCode === 13)
|
if (event.originalEvent.charCode === 13) {
|
||||||
$("#" + alias_matched_id + " li").first().trigger("click");
|
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
|
// When the user type something, the matched aliases are refreshed
|
||||||
|
|
|
@ -39,10 +39,21 @@ $(document).ready(function() {
|
||||||
|
|
||||||
last.quantity = 1;
|
last.quantity = 1;
|
||||||
|
|
||||||
$.getJSON("/api/user/" + last.note.user + "/", function(user) {
|
if (!last.note.user) {
|
||||||
$("#last_name").val(user.last_name);
|
$.getJSON("/api/note/note/" + last.note.id + "/?format=json", function(note) {
|
||||||
$("#first_name").val(user.first_name);
|
last.note.user = note.user;
|
||||||
});
|
$.getJSON("/api/user/" + last.note.user + "/", function(user) {
|
||||||
|
$("#last_name").val(user.last_name);
|
||||||
|
$("#first_name").val(user.first_name);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$.getJSON("/api/user/" + last.note.user + "/", function(user) {
|
||||||
|
$("#last_name").val(user.last_name);
|
||||||
|
$("#first_name").val(user.first_name);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue