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
|
|
@ -1,5 +1,5 @@
|
||||||
BR.RoutingOptions = BR.Control.extend({
|
BR.RoutingOptions = BR.Control.extend({
|
||||||
|
|
||||||
onAdd: function (map) {
|
onAdd: function (map) {
|
||||||
$('#profile-alternative').on('changed.bs.select', this._getChangeHandler());
|
$('#profile-alternative').on('changed.bs.select', this._getChangeHandler());
|
||||||
|
|
||||||
|
|
@ -12,6 +12,8 @@ BR.RoutingOptions = BR.Control.extend({
|
||||||
option.text = profiles[i];
|
option.text = profiles[i];
|
||||||
profiles_list.appendChild(option);
|
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
|
// <custom> profile is empty at start, select next one
|
||||||
profiles_list.children[1].selected = true;
|
profiles_list.children[1].selected = true;
|
||||||
return BR.Control.prototype.onAdd.call(this, map);
|
return BR.Control.prototype.onAdd.call(this, map);
|
||||||
|
|
@ -67,13 +69,18 @@ BR.RoutingOptions = BR.Control.extend({
|
||||||
option;
|
option;
|
||||||
|
|
||||||
profiles_grp = L.DomUtil.get('profile');
|
profiles_grp = L.DomUtil.get('profile');
|
||||||
option = profiles_grp.children[0]
|
option = profiles_grp.children[0];
|
||||||
option.value = profile;
|
option.value = profile || "Custom";
|
||||||
option.disabled = !profile;
|
option.disabled = !profile;
|
||||||
|
|
||||||
$('#profile').find('option:selected').each(function(index) {
|
if (profile) {
|
||||||
$(this).prop('selected', false);
|
$('#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;
|
option.selected = !!profile;
|
||||||
|
|
||||||
|
|
@ -87,7 +94,7 @@ BR.RoutingOptions = BR.Control.extend({
|
||||||
option = profiles_grp.children[0],
|
option = profiles_grp.children[0],
|
||||||
profile = null;
|
profile = null;
|
||||||
|
|
||||||
if (!option.disabled) {
|
if (option.value !== "Custom") {
|
||||||
profile = option.value;
|
profile = option.value;
|
||||||
}
|
}
|
||||||
return profile;
|
return profile;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue