misc: check "manual address" box when a manual address has been entered (#88332)
gitea/wcs/pipeline/head This commit looks good
Details
gitea/wcs/pipeline/head This commit looks good
Details
This commit is contained in:
parent
520e52d1a7
commit
083f3cf3dd
|
@ -113,9 +113,26 @@ function init_sync_from_template_address() {
|
|||
}
|
||||
}
|
||||
$(widget_selector).each(function(idx, elem) {
|
||||
// enable manual address mode if there is an error in one of the manual address fields.
|
||||
var $manual_checkbox = $(elem).find('input.wcs-manual-address');
|
||||
if ($(elem).nextUntil('.template-address', '[data-geolocation].widget-with-error').length) {
|
||||
$(elem).find('input.wcs-manual-address').prop('checked', true).trigger('change');
|
||||
// enable manual address mode if there is an error in one of the manual address fields.
|
||||
$manual_checkbox.prop('checked', true).trigger('change');
|
||||
} else {
|
||||
// enable manual address mode if a manual field has data while the select is empty
|
||||
// (typically when going back to a previous page)
|
||||
var has_val = $(elem).find('select').val();
|
||||
if (! has_val) {
|
||||
var has_manual_var = false;
|
||||
$(elem).nextUntil('.template-address', 'div[data-geolocation]').find('input').each(function(idx, manual_elem) {
|
||||
if ($(manual_elem).val()) has_manual_var = true;
|
||||
})
|
||||
$(elem).nextUntil('.template-address', 'div[data-geolocation]').find('textarea').each(function(idx, manual_elem) {
|
||||
if ($(manual_elem).val()) has_manual_var = true;
|
||||
})
|
||||
if (has_manual_var) {
|
||||
$manual_checkbox.prop('checked', true).trigger('change');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue