17
17
)
18
18
19
19
from arho_feature_template .core .models import Regulation , ValueType
20
+ from arho_feature_template .gui .components .code_combobox import HierarchicalCodeComboBox
20
21
from arho_feature_template .gui .components .plan_regulation_input_widgets import (
21
22
DecimalInputWidget ,
22
23
IntegerInputWidget ,
23
24
IntegerRangeInputWidget ,
24
25
MultilineTextInputWidget ,
25
26
SinglelineTextInputWidget ,
26
27
)
27
- from arho_feature_template .project .layers .code_layers import AdditionalInformationTypeLayer
28
+ from arho_feature_template .project .layers .code_layers import AdditionalInformationTypeLayer , VerbalRegulationType
28
29
from arho_feature_template .utils .misc_utils import LANGUAGE , get_layer_by_name , iface
29
30
30
31
if TYPE_CHECKING :
@@ -67,6 +68,7 @@ def __init__(self, regulation: Regulation, parent=None):
67
68
self .file_widgets : list [QgsFileWidget ] = []
68
69
self .theme_widget : SinglelineTextInputWidget | None = None
69
70
self .topic_tag_widget : SinglelineTextInputWidget | None = None
71
+ self .type_of_verbal_regulation_widget : HierarchicalCodeComboBox | None = None
70
72
71
73
self .expanded = True
72
74
self .plan_regulation_name .setText (self .config .name )
@@ -83,6 +85,12 @@ def _init_widgets(self):
83
85
value_type = self .config .value_type
84
86
if value_type :
85
87
self ._add_value_input (value_type , self .config .unit , self .regulation .value )
88
+ if self .config .regulation_code == "sanallinenMaarays" :
89
+ self .type_of_verbal_regulation_widget = HierarchicalCodeComboBox ()
90
+ self .type_of_verbal_regulation_widget .populate_from_code_layer (VerbalRegulationType )
91
+ self ._add_widgets (QLabel ("Sanallisen määräyksen laji" ), self .type_of_verbal_regulation_widget )
92
+ if self .regulation .verbal_regulation_type_id is not None :
93
+ self .type_of_verbal_regulation_widget .set_value (self .regulation .verbal_regulation_type_id )
86
94
87
95
# Additional information
88
96
if self .regulation .additional_information :
@@ -249,7 +257,6 @@ def _add_theme(self, theme_name: str):
249
257
self .theme_widget = SinglelineTextInputWidget (theme_name , False )
250
258
self ._add_widgets (QLabel ("Kaavoitusteema" ), self .theme_widget )
251
259
252
- # Or e.g. "into_regulation"
253
260
def into_model (self ) -> Regulation :
254
261
return Regulation (
255
262
config = self .config ,
@@ -261,5 +268,8 @@ def into_model(self) -> Regulation:
261
268
files = [file .filePath () for file in self .file_widgets ],
262
269
theme = self .theme_widget .get_value () if self .theme_widget else None ,
263
270
topic_tag = self .topic_tag_widget .get_value () if self .topic_tag_widget else None ,
271
+ verbal_regulation_type_id = self .type_of_verbal_regulation_widget .value ()
272
+ if self .type_of_verbal_regulation_widget
273
+ else None ,
264
274
id_ = self .regulation .id_ ,
265
275
)
0 commit comments