Short name autofill

This commit is contained in:
Claude Brisson
2024-04-15 21:44:55 +02:00
parent c64974c58b
commit 7088591260
2 changed files with 26 additions and 0 deletions

View File

@@ -1,3 +1,12 @@
let manualShortName;
function autofillShortName(dt, loc) {
if (!manualShortName && dt !== '' && loc !== '') {
let ymd = parseDate(dt).replaceAll(/-/g, '');
$('input[name="shortName"]')[0].value = `${ymd}-${loc}`;
}
}
onLoad(() => { onLoad(() => {
$('#edit').on('click', e => { $('#edit').on('click', e => {
e.preventDefault(); e.preventDefault();
@@ -253,4 +262,20 @@ onLoad(() => {
} }
}); });
}); });
let shortName = $('input[name="shortName"]');
manualShortName = (shortName[0].value !== '');
let startDate = $('input[name="startDate"]');
let location = $('input[name="location"]');
startDate.on('change', e => {
if (!manualShortName) autofillShortName(startDate[0].value, location[0].value)
});
$('#date-range').on('changeDate', e => {
if (!manualShortName) autofillShortName(startDate[0].value, location[0].value)
});
location.on('input', e => {
if (!manualShortName) autofillShortName(startDate[0].value, location[0].value)
});
shortName.on('input', e => {
manualShortName = true;
});
}); });

View File

@@ -1,4 +1,5 @@
const SEARCH_DELAY = 100; const SEARCH_DELAY = 100;
const SEARCH_DELAY = 100;
let searchTimer = undefined; let searchTimer = undefined;
let resultTemplate; let resultTemplate;
let searchResult; let searchResult;