6from textual.widgets
import Select, Button, Static, Label
7from textual.widgets
import Button
8from textual.containers
import VerticalScroll
9from rich.console
import RichCast, ConsoleRenderable
13from daqconf.cider.widgets.configuration_controller
import ConfigurationController
14from daqconf.cider.widgets.custom_rich_log
import RichLogWError
19 def __init__(self, relationship_type: str, current_related_dal: Any, relationship_name: str,
20 renderable: ConsoleRenderable | RichCast | str =
"", *, expand: bool =
False,
21 shrink: bool =
False, markup: bool =
True, name: str |
None =
None, id: str |
None =
None,
22 classes: str |
None =
None, disabled: bool =
False) ->
None:
24 super().
__init__(renderable, expand=expand, shrink=shrink, markup=markup,
25 name=name, id=id, classes=classes, disabled=disabled)
37 main_screen = self.app.get_screen(
"main")
38 self.
_config_controller: ConfigurationController = main_screen.query_one(ConfigurationController)
39 self.
_logger: RichLogWError = main_screen.query_one(
"#main_log")
43 yield Select([(repr(rel), rel)
for
47 yield Button(
"Delete", id=
"delete_rel", variant=
"error")
58 except Exception
as e:
64 if event.button.id==
"delete_rel":
69 self.
_logger.write(
"[bold blue]Info:[/bold blue] [blue]Removing duplicate")
74 def __init__(self, relationship_name: str, renderable: ConsoleRenderable | RichCast | str =
"", *, expand: bool =
False, shrink: bool =
False, markup: bool =
True, name: str |
None =
None, id: str |
None =
None, classes: str |
None =
None, disabled: bool =
False) ->
None:
75 super().
__init__(renderable, expand=expand, shrink=shrink, markup=markup, name=name, id=id, classes=classes, disabled=disabled)
80 main_screen = self.app.get_screen(
"main")
81 self.
_config_controller: ConfigurationController = main_screen.query_one(ConfigurationController)
82 self.
_logger: RichLogWError = main_screen.query_one(
"#main_log")
87 self.
_rinfo = relationship_dict[
'rel_info']
100 add_deactivated = (
not self.
_rinfo[
'multivalue'] \
105 yield Button(
"Add Relation",
"success", id=
"add_dal", disabled=add_deactivated)
112 if len(selected_dals)!=len(set(selected_dals)):
113 raise Exception(f
"Error DAL list contains non-unique entry for {self._relationship_name}")
116 if len(selected_dals)==0
and self.
_rinfo[
'not-null']:
117 raise Exception(f
"Error {self._relationship_name} is required but has no DALs...")
121 raise Exception(f
"Error cannot find any objects of type {self._rinfo['type']}")
131 if event.button.id !=
"add_dal":
138 main_screen = self.app.get_screen(
"main")
140 self.
_logger: RichLogWError = main_screen.query_one(
"#main_log")
142 relation_names = [list(r.keys())[0]
for r
in self.
_config_controller.get_relations_to_current_dal()]
146 yield VerticalScroll(
154 r.verify_unique_dals()
155 except Exception
as e: