generated from dopt-python/py311
info banners for linking
This commit is contained in:
+96
-7
@@ -3634,13 +3634,6 @@ class Page_Consulting(QWidget):
|
|||||||
db_index_layout.addWidget(db_index_set_button)
|
db_index_layout.addWidget(db_index_set_button)
|
||||||
container_layout.addLayout(db_index_layout)
|
container_layout.addLayout(db_index_layout)
|
||||||
|
|
||||||
test_flex_datetime = FlexibleDateTimeInput()
|
|
||||||
test_flex_datetime.setSizePolicy(
|
|
||||||
QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed
|
|
||||||
)
|
|
||||||
|
|
||||||
container_layout.addWidget(test_flex_datetime)
|
|
||||||
|
|
||||||
separator2 = QFrame()
|
separator2 = QFrame()
|
||||||
separator2.setFrameShape(QFrame.Shape.HLine)
|
separator2.setFrameShape(QFrame.Shape.HLine)
|
||||||
separator2.setFrameShadow(QFrame.Shadow.Sunken)
|
separator2.setFrameShadow(QFrame.Shadow.Sunken)
|
||||||
@@ -3648,6 +3641,14 @@ class Page_Consulting(QWidget):
|
|||||||
|
|
||||||
container_layout.addSpacing(30)
|
container_layout.addSpacing(30)
|
||||||
|
|
||||||
|
# --- BANNER ---
|
||||||
|
self.link_banner_container = QWidget()
|
||||||
|
self.link_banners: list[InfoBanner] = []
|
||||||
|
self.link_banner_layout = QVBoxLayout(self.link_banner_container)
|
||||||
|
self.link_banner_layout.setContentsMargins(0, 0, 0, 0)
|
||||||
|
self.link_banner_layout.setSpacing(6)
|
||||||
|
container_layout.addWidget(self.link_banner_container)
|
||||||
|
|
||||||
# --- BUTTONS ---
|
# --- BUTTONS ---
|
||||||
self.edit_buttons = EditButtons(add_reset_btn=False)
|
self.edit_buttons = EditButtons(add_reset_btn=False)
|
||||||
# reset_btn = self.edit_buttons.reset_btn
|
# reset_btn = self.edit_buttons.reset_btn
|
||||||
@@ -3753,6 +3754,7 @@ class Page_Consulting(QWidget):
|
|||||||
|
|
||||||
logger_page_consulting.debug("[Consulting Page] Selected cons_type: %s", cons_type)
|
logger_page_consulting.debug("[Consulting Page] Selected cons_type: %s", cons_type)
|
||||||
self.STATE.beratungs_typ = cons_type
|
self.STATE.beratungs_typ = cons_type
|
||||||
|
self._sync_state_to_GUI()
|
||||||
|
|
||||||
def _debug_get_state(self) -> None:
|
def _debug_get_state(self) -> None:
|
||||||
logger_page_consulting.debug("[Consulting Page] Call get state on table...")
|
logger_page_consulting.debug("[Consulting Page] Call get state on table...")
|
||||||
@@ -3781,6 +3783,29 @@ class Page_Consulting(QWidget):
|
|||||||
|
|
||||||
self.load_database(db_index)
|
self.load_database(db_index)
|
||||||
|
|
||||||
|
def _open_linking_dialogue(self) -> None:
|
||||||
|
logger_page_consulting.info("[Consulting Page] Linking dialogue triggered")
|
||||||
|
|
||||||
|
def _clear_linking_banners(self) -> None:
|
||||||
|
while self.link_banners:
|
||||||
|
banner = self.link_banners[0]
|
||||||
|
self.link_banner_layout.removeWidget(banner)
|
||||||
|
self.link_banners.remove(banner)
|
||||||
|
banner.deleteLater()
|
||||||
|
|
||||||
|
def _add_linking_banner(
|
||||||
|
self,
|
||||||
|
text: str,
|
||||||
|
button_text: str,
|
||||||
|
) -> None:
|
||||||
|
banner = InfoBanner(
|
||||||
|
text=text,
|
||||||
|
button_text=button_text,
|
||||||
|
)
|
||||||
|
self.link_banners.append(banner)
|
||||||
|
banner.link_clicked.connect(self._open_linking_dialogue)
|
||||||
|
self.link_banner_layout.addWidget(banner)
|
||||||
|
|
||||||
def _sync_state_to_GUI(self) -> None:
|
def _sync_state_to_GUI(self) -> None:
|
||||||
match self.STATE.beratungs_typ:
|
match self.STATE.beratungs_typ:
|
||||||
case ConsultingType.PAUSCHAL:
|
case ConsultingType.PAUSCHAL:
|
||||||
@@ -3797,6 +3822,26 @@ class Page_Consulting(QWidget):
|
|||||||
self.type_pauschal_btn.setEnabled(True)
|
self.type_pauschal_btn.setEnabled(True)
|
||||||
self.type_individual_btn.setEnabled(True)
|
self.type_individual_btn.setEnabled(True)
|
||||||
|
|
||||||
|
# info banners needed
|
||||||
|
self._clear_linking_banners()
|
||||||
|
if self.STATE.un_id is None and self.STATE.pers_id is None:
|
||||||
|
# link missing
|
||||||
|
self._add_linking_banner(
|
||||||
|
text="⚠️ Dieser Eintrag ist noch nicht mit einer Entität verknüpft.",
|
||||||
|
button_text="Jetzt verknüpfen",
|
||||||
|
)
|
||||||
|
elif (
|
||||||
|
self.STATE.beratungs_typ is ConsultingType.INDIVIDUAL
|
||||||
|
and self.STATE.pers_id is None
|
||||||
|
):
|
||||||
|
self._add_linking_banner(
|
||||||
|
text=(
|
||||||
|
"⚠️ Dies ist eine Individualberatung, aber die Verknüpfgung zu "
|
||||||
|
"einer Person fehlt."
|
||||||
|
),
|
||||||
|
button_text="Jetzt verknüpfen",
|
||||||
|
)
|
||||||
|
|
||||||
# child modules
|
# child modules
|
||||||
# call to child modules' syncing method not needed because these are initialised by
|
# call to child modules' syncing method not needed because these are initialised by
|
||||||
# their own "load_state" method which again calls the modules sync method
|
# their own "load_state" method which again calls the modules sync method
|
||||||
@@ -4501,6 +4546,50 @@ class Page_Consulting_Table(QWidget):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class InfoBanner(QFrame):
|
||||||
|
link_clicked = Signal()
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
text: str,
|
||||||
|
button_text: str,
|
||||||
|
parent: QWidget | None = None,
|
||||||
|
):
|
||||||
|
super().__init__(parent)
|
||||||
|
|
||||||
|
self.setStyleSheet("""
|
||||||
|
InfoBanner {
|
||||||
|
background-color: #FFF3CD;
|
||||||
|
border: 1px solid #FFEBAA;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
QLabel {
|
||||||
|
color: #856404;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
QPushButton {
|
||||||
|
background-color: #856404;
|
||||||
|
color: white;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 4px 10px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
QPushButton:hover {
|
||||||
|
background-color: #6C5204;
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
layout = QHBoxLayout(self)
|
||||||
|
layout.setContentsMargins(15, 10, 15, 10)
|
||||||
|
|
||||||
|
self.label = QLabel(text)
|
||||||
|
self.button = QPushButton(button_text)
|
||||||
|
layout.addWidget(self.label)
|
||||||
|
layout.addStretch()
|
||||||
|
layout.addWidget(self.button)
|
||||||
|
|
||||||
|
self.button.clicked.connect(self.link_clicked.emit)
|
||||||
|
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user