From a38e7bdbaccaa25687c9ff78cfe30b2731864ef9 Mon Sep 17 00:00:00 2001 From: Niko Aarnio Date: Tue, 11 Feb 2025 13:53:45 +0200 Subject: [PATCH 1/4] add marks (red asterisks) to required fields for predefined widgets and forms --- .../additional_information_widget.ui | 2 +- .../general_regulation_group_widget.ui | 2 +- .../gui/components/plan_document_widget.ui | 20 +++++++++---------- .../gui/components/plan_proposition_widget.ui | 2 +- .../plan_regulation_group_widget.ui | 4 ++-- .../gui/components/plan_regulation_widget.ui | 2 +- .../gui/dialogs/plan_attribute_form.ui | 12 +++++------ .../gui/dialogs/plan_feature_form.ui | 6 +++--- .../gui/dialogs/plan_regulation_group_form.ui | 18 ++++++++--------- 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/arho_feature_template/gui/components/additional_information_widget.ui b/arho_feature_template/gui/components/additional_information_widget.ui index 2e1d78f..df109dd 100644 --- a/arho_feature_template/gui/components/additional_information_widget.ui +++ b/arho_feature_template/gui/components/additional_information_widget.ui @@ -96,7 +96,7 @@ - Laji + Laji: diff --git a/arho_feature_template/gui/components/general_regulation_group_widget.ui b/arho_feature_template/gui/components/general_regulation_group_widget.ui index 31b7bf7..df188c0 100644 --- a/arho_feature_template/gui/components/general_regulation_group_widget.ui +++ b/arho_feature_template/gui/components/general_regulation_group_widget.ui @@ -134,7 +134,7 @@ - Nimi + Otsikko: diff --git a/arho_feature_template/gui/components/plan_document_widget.ui b/arho_feature_template/gui/components/plan_document_widget.ui index 9b26f0e..e5e6839 100644 --- a/arho_feature_template/gui/components/plan_document_widget.ui +++ b/arho_feature_template/gui/components/plan_document_widget.ui @@ -79,7 +79,7 @@ - Nimi + Nimi: @@ -116,7 +116,7 @@ - URL + URL: @@ -126,7 +126,7 @@ - Tyyppi + <span style="color: red;">*</span> Tyyppi: @@ -136,7 +136,7 @@ - Julkisuusluokka + <span style="color: red;">*</span> Julkisuusluokka: @@ -146,7 +146,7 @@ - Kieli + <span style="color: red;">*</span> Kieli: @@ -162,7 +162,7 @@ - Päätös + <html><head/><body><p><span style=" color:#ff0000;">*</span> Päätös:</p></body></html> @@ -175,21 +175,21 @@ - + - Henkilötietosisältö + <span style="color: red;">*</span> Henkilötietosisältö: - Säilytysaika + <span style="color: red;">*</span> Säilytysaika: @@ -203,7 +203,7 @@ - Asiakirjan päivämäärä + <html><head/><body><p><span style=" color:#ff0000;">*</span> Asiakirjan päivämäärä:</p></body></html> diff --git a/arho_feature_template/gui/components/plan_proposition_widget.ui b/arho_feature_template/gui/components/plan_proposition_widget.ui index c1b9049..d0d9d91 100644 --- a/arho_feature_template/gui/components/plan_proposition_widget.ui +++ b/arho_feature_template/gui/components/plan_proposition_widget.ui @@ -107,7 +107,7 @@ - Sisältö + <span style="color: red;">*</span> Sisältö: diff --git a/arho_feature_template/gui/components/plan_regulation_group_widget.ui b/arho_feature_template/gui/components/plan_regulation_group_widget.ui index bda291f..fc019c2 100644 --- a/arho_feature_template/gui/components/plan_regulation_group_widget.ui +++ b/arho_feature_template/gui/components/plan_regulation_group_widget.ui @@ -143,7 +143,7 @@ - Nimi + Otsikko: @@ -163,7 +163,7 @@ - Lyhyt nimi + Lyhyt nimi: diff --git a/arho_feature_template/gui/components/plan_regulation_widget.ui b/arho_feature_template/gui/components/plan_regulation_widget.ui index ec97b39..93e1399 100644 --- a/arho_feature_template/gui/components/plan_regulation_widget.ui +++ b/arho_feature_template/gui/components/plan_regulation_widget.ui @@ -101,7 +101,7 @@ - Laji + Laji: diff --git a/arho_feature_template/gui/dialogs/plan_attribute_form.ui b/arho_feature_template/gui/dialogs/plan_attribute_form.ui index af09f1e..28218ab 100644 --- a/arho_feature_template/gui/dialogs/plan_attribute_form.ui +++ b/arho_feature_template/gui/dialogs/plan_attribute_form.ui @@ -80,7 +80,7 @@ - Pysyvä kaavatunnus: + <html><head/><body><p>Pysyvä kaavatunnus:</p></body></html> permanent_identifier_line_edit @@ -97,7 +97,7 @@ - Nimi*: + <html><head/><body><p><span style=" color:#ff0000;">*</span> Nimi:</p></body></html> name_line_edit @@ -114,7 +114,7 @@ - Kuvaus: + <html><head/><body><p>Kuvaus:</p></body></html> description_text_edit @@ -131,7 +131,7 @@ - Kaavalaji*: + <span style="color: red;">*</span> Kaavalaji: plan_type_combo_box @@ -148,7 +148,7 @@ - Elinkaaren tila*: + <span style="color: red;">*</span> Elinkaaren tila: lifecycle_status_combo_box @@ -165,7 +165,7 @@ - Organisaatio*: + <span style="color: red;">*</span> Organisaatio: diff --git a/arho_feature_template/gui/dialogs/plan_feature_form.ui b/arho_feature_template/gui/dialogs/plan_feature_form.ui index 3e0705c..9081504 100644 --- a/arho_feature_template/gui/dialogs/plan_feature_form.ui +++ b/arho_feature_template/gui/dialogs/plan_feature_form.ui @@ -26,7 +26,7 @@ - Nimi + Nimi: @@ -36,7 +36,7 @@ - Kuvaus + Kuvaus: @@ -53,7 +53,7 @@ - Maanalaisuus + <html><head/><body><p><span style=" color:#ff0000;">*</span> Maanalaisuus:</p></body></html> diff --git a/arho_feature_template/gui/dialogs/plan_regulation_group_form.ui b/arho_feature_template/gui/dialogs/plan_regulation_group_form.ui index fddd83f..3a0ce10 100644 --- a/arho_feature_template/gui/dialogs/plan_regulation_group_form.ui +++ b/arho_feature_template/gui/dialogs/plan_regulation_group_form.ui @@ -29,7 +29,7 @@ - Otsikko + Otsikko: @@ -39,7 +39,7 @@ - Lyhyt nimi + Lyhyt nimi: @@ -49,7 +49,7 @@ - Ryhmänumero + Ryhmänumero: @@ -69,7 +69,7 @@ - Värikoodi + Värikoodi: @@ -79,7 +79,7 @@ - Tyyppi + <html><head/><body><p><span style=" color:#ff0000;">*</span> Tyyppi:</p></body></html> @@ -154,8 +154,8 @@ p, li { white-space: pre-wrap; } 0 0 - 38 - 18 + 587 + 577 @@ -193,8 +193,8 @@ p, li { white-space: pre-wrap; } 0 0 - 120 - 49 + 851 + 577 From 16d43d1141ba8351c42a3ab71418ef71e56aa21c Mon Sep 17 00:00:00 2001 From: Niko Aarnio Date: Tue, 11 Feb 2025 14:40:39 +0200 Subject: [PATCH 2/4] add RequiredFieldLabel widget for creating marked labels in code --- .../components/additional_information_widget.py | 3 ++- .../gui/components/plan_regulation_widget.py | 5 +++-- .../gui/components/required_field_label.py | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 arho_feature_template/gui/components/required_field_label.py diff --git a/arho_feature_template/gui/components/additional_information_widget.py b/arho_feature_template/gui/components/additional_information_widget.py index fdd5590..4deadab 100644 --- a/arho_feature_template/gui/components/additional_information_widget.py +++ b/arho_feature_template/gui/components/additional_information_widget.py @@ -15,6 +15,7 @@ ) from arho_feature_template.core.models import AdditionalInformation +from arho_feature_template.gui.components.required_field_label import RequiredFieldLabel from arho_feature_template.gui.components.value_input_widgets import ( ValueWidgetManager, ) @@ -72,7 +73,7 @@ def __init__(self, additional_information: AdditionalInformation, parent=None): if self.value_widget_manager.value_widget is not None else QLabel("Syötekenttää tälle tyypille ei ole vielä toteutettu") ) - self._add_widget(QLabel("Arvo"), widget) + self._add_widget(RequiredFieldLabel("Arvo"), widget) def _add_widget(self, label: QLabel, widget: QWidget): self.form_layout.addRow(label, widget) diff --git a/arho_feature_template/gui/components/plan_regulation_widget.py b/arho_feature_template/gui/components/plan_regulation_widget.py index 34eab7a..27f77f8 100644 --- a/arho_feature_template/gui/components/plan_regulation_widget.py +++ b/arho_feature_template/gui/components/plan_regulation_widget.py @@ -16,6 +16,7 @@ ) from arho_feature_template.gui.components.additional_information_widget import AdditionalInformationWidget from arho_feature_template.gui.components.code_combobox import HierarchicalCodeComboBox +from arho_feature_template.gui.components.required_field_label import RequiredFieldLabel from arho_feature_template.gui.components.value_input_widgets import ( IntegerInputWidget, SinglelineTextInputWidget, @@ -84,12 +85,12 @@ def __init__(self, regulation: Regulation, parent=None): def _init_widgets(self): # Value input if self.config.default_value: - self._add_widget(QLabel("Arvo"), self.value_widget_manager.value_widget) + self._add_widget(RequiredFieldLabel("Arvo"), self.value_widget_manager.value_widget) if self.config.regulation_code == "sanallinenMaarays": self.type_of_verbal_regulation_widget = HierarchicalCodeComboBox() self.type_of_verbal_regulation_widget.populate_from_code_layer(VerbalRegulationType) - self._add_widget(QLabel("Sanallisen määräyksen laji"), self.type_of_verbal_regulation_widget) + self._add_widget(RequiredFieldLabel("Sanallisen määräyksen laji"), self.type_of_verbal_regulation_widget) if self.regulation.verbal_regulation_type_id is not None: self.type_of_verbal_regulation_widget.set_value(self.regulation.verbal_regulation_type_id) diff --git a/arho_feature_template/gui/components/required_field_label.py b/arho_feature_template/gui/components/required_field_label.py new file mode 100644 index 0000000..6ce7d36 --- /dev/null +++ b/arho_feature_template/gui/components/required_field_label.py @@ -0,0 +1,17 @@ +from __future__ import annotations + +from qgis.PyQt.QtWidgets import QLabel, QWidget + + +class RequiredFieldLabel(QLabel): + """QLabel that prefixes the text with a red asterisk.""" + + def __init__(self, text: str, parent: QWidget | None = None): + super().__init__(self._prefix(text), parent) + + def setText(self, text: str): # noqa: N802 + return super().setText(self._prefix(text)) + + @staticmethod + def _prefix(text: str) -> str: + return f'* {text}' From fd2fb17a1628822089a9824331b33006a0374fb5 Mon Sep 17 00:00:00 2001 From: Lauri Kajan Date: Wed, 12 Feb 2025 11:02:50 +0200 Subject: [PATCH 3/4] Mark code value field as required --- arho_feature_template/gui/components/value_input_widgets.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arho_feature_template/gui/components/value_input_widgets.py b/arho_feature_template/gui/components/value_input_widgets.py index 0c9e086..a8fd89a 100644 --- a/arho_feature_template/gui/components/value_input_widgets.py +++ b/arho_feature_template/gui/components/value_input_widgets.py @@ -132,9 +132,9 @@ def __init__(self, title: str | None = None, code_list: str | None = None, code_ self.code_value_widget = SinglelineTextInputWidget(default_value=code_value, editable=True) layout = QFormLayout() - layout.addRow("Otsikko", self.title_widget) - layout.addRow("Koodisto", self.code_list_widget) - layout.addRow("Koodiarvo", self.code_value_widget) + layout.addRow("Otsikko:", self.title_widget) + layout.addRow("Koodisto:", self.code_list_widget) + layout.addRow('* Koodiarvo:', self.code_value_widget) self.setLayout(layout) def get_value(self) -> tuple[str | None, str | None, str | None]: From 4f26ae5129b122d960943f10232840be1a0ab776 Mon Sep 17 00:00:00 2001 From: Lauri Kajan Date: Wed, 12 Feb 2025 11:03:54 +0200 Subject: [PATCH 4/4] Postfix with colon as other labels --- .../gui/components/additional_information_widget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arho_feature_template/gui/components/additional_information_widget.py b/arho_feature_template/gui/components/additional_information_widget.py index 4deadab..c272bd3 100644 --- a/arho_feature_template/gui/components/additional_information_widget.py +++ b/arho_feature_template/gui/components/additional_information_widget.py @@ -73,7 +73,7 @@ def __init__(self, additional_information: AdditionalInformation, parent=None): if self.value_widget_manager.value_widget is not None else QLabel("Syötekenttää tälle tyypille ei ole vielä toteutettu") ) - self._add_widget(RequiredFieldLabel("Arvo"), widget) + self._add_widget(RequiredFieldLabel("Arvo:"), widget) def _add_widget(self, label: QLabel, widget: QWidget): self.form_layout.addRow(label, widget)