dropdown list: Separate get_data() function, no functional change.

This commit is contained in:
evykassirer 2023-02-09 12:42:27 -08:00 committed by Tim Abbott
parent e5dd2810ee
commit e786c3ac98
1 changed files with 8 additions and 7 deletions

View File

@ -99,6 +99,13 @@ export class DropdownListWidget {
}); });
} }
get_data = (data) => {
if (this.include_current_item) {
return data;
}
return data.filter((x) => x.value !== this.value.toString());
};
setup_dropdown_widget(data) { setup_dropdown_widget(data) {
const $dropdown_list_body = $( const $dropdown_list_body = $(
`#${CSS.escape(this.container_id)} .dropdown-list-body`, `#${CSS.escape(this.container_id)} .dropdown-list-body`,
@ -106,14 +113,8 @@ export class DropdownListWidget {
const $search_input = $( const $search_input = $(
`#${CSS.escape(this.container_id)} .dropdown-search > input[type=text]`, `#${CSS.escape(this.container_id)} .dropdown-search > input[type=text]`,
); );
const get_data = () => {
if (this.include_current_item) {
return data;
}
return data.filter((x) => x.value !== this.value.toString());
};
ListWidget.create($dropdown_list_body, get_data(data), { ListWidget.create($dropdown_list_body, this.get_data(data), {
name: `${CSS.escape(this.widget_name)}_list`, name: `${CSS.escape(this.widget_name)}_list`,
modifier(item) { modifier(item) {
return render_dropdown_list({item}); return render_dropdown_list({item});