Skip to content

Commit bc5d19b

Browse files
committed
Merge pull request #1182 from noobaa/ohad-fixes
Apply custom match op to both timezone fields
2 parents 4045bf6 + 4ba77ac commit bc5d19b

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

frontend/src/app/components/management/server-time-form/server-time-form.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h2 class="heading2" data-bind="click: () => expanded.toggle()">
2424
<dropdown params="
2525
options: timezones,
2626
selected: timezone,
27-
searchSelector: timezoneSearchSelector
27+
matchOperator: matchByTimezoneName
2828
"></dropdown>
2929
</editor>
3030

@@ -64,7 +64,11 @@ <h2 class="heading2" data-bind="click: () => expanded.toggle()">
6464
<!-- ko if: usingNTP -->
6565
<section class="container">
6666
<editor params="label: 'Time Zone'">
67-
<dropdown params="options: timezones, selected: timezone"></dropdown>
67+
<dropdown params="
68+
options: timezones,
69+
selected: timezone,
70+
matchOperator: matchByTimezoneName
71+
"></dropdown>
6872
</editor>
6973

7074
<editor params="label: 'NTP Server'">

frontend/src/app/components/management/server-time-form/server-time-form.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ const configTypes = Object.freeze([
1212
{ label: 'Network Time (NTP)', value: 'NTP' }
1313
]);
1414

15-
function timezoneSearchSelector({ label }, input) {
16-
return !!label.toLowerCase().match(
17-
new RegExp(`\\b${input.replace('/', '\\/')}`)
18-
);
19-
}
20-
2115
class ServerTimeFormViewModel {
2216
constructor() {
2317
this.expanded = ko.observable(false);
@@ -156,7 +150,11 @@ class ServerTimeFormViewModel {
156150
ntpServer: this.ntpServer
157151
});
158152

159-
this.timezoneSearchSelector = timezoneSearchSelector;
153+
this.matchByTimezoneName = function({ label }, input) {
154+
return !!label.toLowerCase().match(
155+
new RegExp(`\\b${input.replace('/', '\\/')}`)
156+
);
157+
};
160158
}
161159

162160
applyChanges() {

frontend/src/app/components/shared/dropdown/dropdown.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { isDefined } from 'utils';
55

66
const INPUT_THROTTLE = 1000;
77

8-
function defaultSearchSelector({ label }, input) {
8+
function matchByPrefix({ label }, input) {
99
return label.toString().toLowerCase().startsWith(input);
1010
}
1111

@@ -15,7 +15,7 @@ class DropdownViewModel {
1515
options = [],
1616
placeholder = '',
1717
disabled = false,
18-
searchSelector = defaultSearchSelector
18+
matchOperator = matchByPrefix
1919
}) {
2020
this.name = randomString(5);
2121
this.options = options;
@@ -47,7 +47,7 @@ class DropdownViewModel {
4747
}
4848
);
4949

50-
this.searchSelector = searchSelector;
50+
this.matchOperator = matchOperator;
5151
this.searchInput = '';
5252
this.lastInput = 0;
5353
}
@@ -100,7 +100,7 @@ class DropdownViewModel {
100100
char;
101101

102102
let option = ko.unwrap(this.options).find(
103-
option => this.searchSelector(option, this.searchInput)
103+
option => this.matchOperator(option, this.searchInput)
104104
);
105105

106106
if (option) {

0 commit comments

Comments
 (0)