Skip to content

Commit 8564bf1

Browse files
Replace lodash functions with ES6 equivalents in settings.js (#2671)
* Replace lodash functions with ES6 equivalents in settings.js - Replace lodash.orderBy with native JavaScript sort - Replace lodash.get with optional chaining and nullish coalescing operators Fixes #2398 * Fix code formatting with Prettier * remove comments --------- Co-authored-by: openhands <openhands@all-hands.dev>
1 parent 62c2a8d commit 8564bf1

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

dt-assets/js/settings.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,9 @@ jQuery('#add_unavailable_dates').on('click', function () {
262262
let display_dates_unavailable = (list = [], first_run) => {
263263
let date_unavailable_table = jQuery('#unavailable-list');
264264
let rows = ``;
265-
list = window.lodash.orderBy(list, ['start_date'], 'desc');
265+
list = [...list].sort((a, b) => {
266+
return new Date(b.start_date) - new Date(a.start_date);
267+
});
266268
list.forEach((range) => {
267269
rows += `<tr>
268270
<td>${window.SHAREDFUNCTIONS.escapeHTML(range.start_date)}</td>
@@ -295,13 +297,9 @@ let color_workload_buttons = (name) => {
295297
if (name) {
296298
let selected = jQuery(`.status-button[name=${name}]`);
297299
selected.removeClass('hollow');
298-
selected.css(
299-
'background-color',
300-
window.lodash.get(
301-
window.wpApiSettingsPage,
302-
`workload_status_options.${name}.color`,
303-
),
304-
);
300+
const color =
301+
window.wpApiSettingsPage?.workload_status_options?.[name]?.color ?? '';
302+
selected.css('background-color', color);
305303
selected.blur();
306304
}
307305
};

0 commit comments

Comments
 (0)