Fix cleaning custom profile
- picked from bagage/brouter-web@8bcb267 - set default value to what is used in code, display text might change - keep currently selected profile on clean when other than custom
This commit is contained in:
parent
99a37c5a2e
commit
208041c3d8
1 changed files with 14 additions and 7 deletions
|
|
@ -12,6 +12,8 @@ BR.RoutingOptions = BR.Control.extend({
|
|||
option.text = profiles[i];
|
||||
profiles_list.appendChild(option);
|
||||
}
|
||||
// set default value, used as indicator for empty custom profile
|
||||
profiles_list.children[0].value = "Custom";
|
||||
// <custom> profile is empty at start, select next one
|
||||
profiles_list.children[1].selected = true;
|
||||
return BR.Control.prototype.onAdd.call(this, map);
|
||||
|
|
@ -67,13 +69,18 @@ BR.RoutingOptions = BR.Control.extend({
|
|||
option;
|
||||
|
||||
profiles_grp = L.DomUtil.get('profile');
|
||||
option = profiles_grp.children[0]
|
||||
option.value = profile;
|
||||
option = profiles_grp.children[0];
|
||||
option.value = profile || "Custom";
|
||||
option.disabled = !profile;
|
||||
|
||||
if (profile) {
|
||||
$('#profile').find('option:selected').each(function(index) {
|
||||
$(this).prop('selected', false);
|
||||
});
|
||||
} else if (option.selected) {
|
||||
// clear, select next in group when custom deselected
|
||||
profiles_grp.children[1].selected = true;
|
||||
}
|
||||
|
||||
option.selected = !!profile;
|
||||
|
||||
|
|
@ -87,7 +94,7 @@ BR.RoutingOptions = BR.Control.extend({
|
|||
option = profiles_grp.children[0],
|
||||
profile = null;
|
||||
|
||||
if (!option.disabled) {
|
||||
if (option.value !== "Custom") {
|
||||
profile = option.value;
|
||||
}
|
||||
return profile;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue