Fixes 2849 (#2862)
This commit is contained in:
parent
f648eb6d66
commit
41e5a0fcfd
|
|
@ -63,9 +63,10 @@ class ListManager:
|
||||||
# this will return a dictionary with the key as the menu entry to be displayed
|
# this will return a dictionary with the key as the menu entry to be displayed
|
||||||
# and the value is the original value from the self._data container
|
# and the value is the original value from the self._data container
|
||||||
data_formatted = self.reformat(self._data)
|
data_formatted = self.reformat(self._data)
|
||||||
options, header = self._prepare_selection(data_formatted)
|
options = self._prepare_selection(data_formatted)
|
||||||
|
header = self._get_header(data_formatted)
|
||||||
|
|
||||||
items = [MenuItem(o, value=o) for o in options]
|
items = [MenuItem(o[0], value=o[1]) for o in options]
|
||||||
group = MenuItemGroup(items, sort_items=False)
|
group = MenuItemGroup(items, sort_items=False)
|
||||||
|
|
||||||
result = SelectMenu(
|
result = SelectMenu(
|
||||||
|
|
@ -97,23 +98,24 @@ class ListManager:
|
||||||
else:
|
else:
|
||||||
return self._data
|
return self._data
|
||||||
|
|
||||||
def _prepare_selection(self, data_formatted: dict[str, Any]) -> tuple[list[str], str]:
|
def _get_header(self, data_formatted: dict[str, Any]) -> str:
|
||||||
|
table_header = [key for key, val in data_formatted.items() if val is None]
|
||||||
|
header = '\n'.join(table_header)
|
||||||
|
return header
|
||||||
|
|
||||||
|
def _prepare_selection(self, data_formatted: dict[str, Any]) -> list[tuple[str, Any]]:
|
||||||
# header rows are mapped to None so make sure
|
# header rows are mapped to None so make sure
|
||||||
# to exclude those from the selectable data
|
# to exclude those from the selectable data
|
||||||
options: list[str] = [key for key, val in data_formatted.items() if val is not None]
|
options = [(key, val) for key, val in data_formatted.items() if val is not None]
|
||||||
header = ''
|
|
||||||
|
|
||||||
if len(options) > 0:
|
if len(options) > 0:
|
||||||
table_header = [key for key, val in data_formatted.items() if val is None]
|
options.append((self._separator, None))
|
||||||
header = '\n'.join(table_header)
|
|
||||||
|
|
||||||
if len(options) > 0:
|
additional_options = self._base_actions + self._terminate_actions
|
||||||
options.append(self._separator)
|
for o in additional_options:
|
||||||
|
options.append((o, o))
|
||||||
|
|
||||||
options += self._base_actions
|
return options
|
||||||
options += self._terminate_actions
|
|
||||||
|
|
||||||
return options, header
|
|
||||||
|
|
||||||
def _run_actions_on_entry(self, entry: Any) -> None:
|
def _run_actions_on_entry(self, entry: Any) -> None:
|
||||||
options = self.filter_options(entry, self._sub_menu_actions) + [self._cancel_action]
|
options = self.filter_options(entry, self._sub_menu_actions) + [self._cancel_action]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue