Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pakollisten kenttien merkitseminen lomakkeissa #190

Merged
merged 4 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Laji</string>
<string>Laji:</string>
</property>
</widget>
</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
</font>
</property>
<property name="text">
<string>Nimi</string>
<string>Otsikko:</string>
</property>
</widget>
</item>
Expand Down
20 changes: 10 additions & 10 deletions arho_feature_template/gui/components/plan_document_widget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Nimi</string>
<string>Nimi:</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -116,7 +116,7 @@
<item row="1" column="0">
<widget class="QLabel" name="url_label">
<property name="text">
<string>URL</string>
<string>URL:</string>
</property>
</widget>
</item>
Expand All @@ -126,7 +126,7 @@
<item row="2" column="0">
<widget class="QLabel" name="document_type_label">
<property name="text">
<string>Tyyppi</string>
<string>&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt; Tyyppi:</string>
</property>
</widget>
</item>
Expand All @@ -136,7 +136,7 @@
<item row="3" column="0">
<widget class="QLabel" name="publicity_label">
<property name="text">
<string>Julkisuusluokka</string>
<string>&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt; Julkisuusluokka:</string>
</property>
</widget>
</item>
Expand All @@ -146,7 +146,7 @@
<item row="4" column="0">
<widget class="QLabel" name="language_label">
<property name="text">
<string>Kieli</string>
<string>&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt; Kieli:</string>
</property>
</widget>
</item>
Expand All @@ -162,7 +162,7 @@
<item row="8" column="0">
<widget class="QLabel" name="decision_label">
<property name="text">
<string>Päätös</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#ff0000;&quot;&gt;*&lt;/span&gt; Päätös:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand All @@ -175,21 +175,21 @@
</sizepolicy>
</property>
<property name="text">
<string> </string>
<string/>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="personal_data_content_label">
<property name="text">
<string>Henkilötietosisältö</string>
<string>&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt; Henkilötietosisältö:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="retention_time_label">
<property name="text">
<string>Säilytysaika</string>
<string>&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt; Säilytysaika:</string>
</property>
</widget>
</item>
Expand All @@ -203,7 +203,7 @@
<item row="7" column="0">
<widget class="QLabel" name="document_date_label">
<property name="text">
<string>Asiakirjan päivämäärä</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#ff0000;&quot;&gt;*&lt;/span&gt; Asiakirjan päivämäärä:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<item row="0" column="0">
<widget class="QLabel" name="value_label">
<property name="text">
<string>Sisältö</string>
<string>&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt; Sisältö:</string>
</property>
</widget>
</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
</font>
</property>
<property name="text">
<string>Nimi</string>
<string>Otsikko:</string>
</property>
</widget>
</item>
Expand All @@ -163,7 +163,7 @@
<item row="1" column="0">
<widget class="QLabel" name="short_name_label">
<property name="text">
<string>Lyhyt nimi</string>
<string>Lyhyt nimi:</string>
</property>
</widget>
</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Laji</string>
<string>Laji:</string>
</property>
</widget>
</item>
Expand Down
17 changes: 17 additions & 0 deletions arho_feature_template/gui/components/required_field_label.py
Original file line number Diff line number Diff line change
@@ -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'<span style="color: red;">* </span>{text}'
6 changes: 3 additions & 3 deletions arho_feature_template/gui/components/value_input_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('<span style="color: red;">*</span> Koodiarvo:', self.code_value_widget)
self.setLayout(layout)

def get_value(self) -> tuple[str | None, str | None, str | None]:
Expand Down
12 changes: 6 additions & 6 deletions arho_feature_template/gui/dialogs/plan_attribute_form.ui
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Pysyvä kaavatunnus:</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Pysyvä kaavatunnus:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="buddy">
<cstring>permanent_identifier_line_edit</cstring>
Expand All @@ -97,7 +97,7 @@
<item row="1" column="0">
<widget class="QLabel" name="nimiLabel">
<property name="text">
<string>Nimi*:</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#ff0000;&quot;&gt;*&lt;/span&gt; Nimi:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="buddy">
<cstring>name_line_edit</cstring>
Expand All @@ -114,7 +114,7 @@
<item row="2" column="0">
<widget class="QLabel" name="kuvausLabel">
<property name="text">
<string>Kuvaus:</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Kuvaus:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="buddy">
<cstring>description_text_edit</cstring>
Expand All @@ -131,7 +131,7 @@
<item row="4" column="0">
<widget class="QLabel" name="tyyppiLabel">
<property name="text">
<string>Kaavalaji*:</string>
<string>&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt; Kaavalaji:</string>
</property>
<property name="buddy">
<cstring>plan_type_combo_box</cstring>
Expand All @@ -148,7 +148,7 @@
<item row="5" column="0">
<widget class="QLabel" name="elinkaarenTilaLabel">
<property name="text">
<string>Elinkaaren tila*:</string>
<string>&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt; Elinkaaren tila:</string>
</property>
<property name="buddy">
<cstring>lifecycle_status_combo_box</cstring>
Expand All @@ -165,7 +165,7 @@
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Organisaatio*:</string>
<string>&lt;span style=&quot;color: red;&quot;&gt;*&lt;/span&gt; Organisaatio:</string>
</property>
</widget>
</item>
Expand Down
6 changes: 3 additions & 3 deletions arho_feature_template/gui/dialogs/plan_feature_form.ui
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<item row="0" column="0">
<widget class="QLabel" name="feature_name_label">
<property name="text">
<string>Nimi</string>
<string>Nimi:</string>
</property>
</widget>
</item>
Expand All @@ -36,7 +36,7 @@
<item row="1" column="0">
<widget class="QLabel" name="feature_description_label">
<property name="text">
<string>Kuvaus</string>
<string>Kuvaus:</string>
</property>
</widget>
</item>
Expand All @@ -53,7 +53,7 @@
<item row="2" column="0">
<widget class="QLabel" name="feature_underground_label">
<property name="text">
<string>Maanalaisuus</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#ff0000;&quot;&gt;*&lt;/span&gt; Maanalaisuus:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand Down
18 changes: 9 additions & 9 deletions arho_feature_template/gui/dialogs/plan_regulation_group_form.ui
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Otsikko</string>
<string>Otsikko:</string>
</property>
</widget>
</item>
Expand All @@ -39,7 +39,7 @@
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Lyhyt nimi</string>
<string>Lyhyt nimi:</string>
</property>
</widget>
</item>
Expand All @@ -49,7 +49,7 @@
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Ryhmänumero</string>
<string>Ryhmänumero:</string>
</property>
</widget>
</item>
Expand All @@ -69,7 +69,7 @@
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Värikoodi</string>
<string>Värikoodi:</string>
</property>
</widget>
</item>
Expand All @@ -79,7 +79,7 @@
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Tyyppi</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#ff0000;&quot;&gt;*&lt;/span&gt; Tyyppi:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -154,8 +154,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>38</width>
<height>18</height>
<width>587</width>
<height>577</height>
</rect>
</property>
<layout class="QVBoxLayout" name="regulations_layout">
Expand Down Expand Up @@ -193,8 +193,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>120</width>
<height>49</height>
<width>851</width>
<height>577</height>
</rect>
</property>
<layout class="QVBoxLayout" name="propositions_layout">
Expand Down
Loading