4
4
from typing import TYPE_CHECKING
5
5
6
6
from qgis .PyQt import uic
7
- from qgis .PyQt .QtWidgets import QDialog
7
+ from qgis .PyQt .QtWidgets import QDialog , QDialogButtonBox
8
8
9
9
from arho_feature_template .core .models import Plan
10
10
from arho_feature_template .project .layers .code_layers import (
@@ -33,6 +33,8 @@ class PlanAttributeForm(QDialog, FormClass): # type: ignore
33
33
producers_plan_identifier_line_edit : QLineEdit
34
34
matter_management_identifier_line_edit : QLineEdit
35
35
36
+ button_box : QDialogButtonBox
37
+
36
38
def __init__ (self , parent = None ):
37
39
super ().__init__ (parent )
38
40
@@ -42,6 +44,25 @@ def __init__(self, parent=None):
42
44
self .lifecycle_status_combo_box .populate_from_code_layer (LifeCycleStatusLayer )
43
45
self .organisation_combo_box .populate_from_code_layer (OrganisationLayer )
44
46
47
+ self .name_line_edit .textChanged .connect (self ._check_required_fields )
48
+ self .organisation_combo_box .currentIndexChanged .connect (self ._check_required_fields )
49
+ self .plan_type_combo_box .currentIndexChanged .connect (self ._check_required_fields )
50
+ self .lifecycle_status_combo_box .currentIndexChanged .connect (self ._check_required_fields )
51
+
52
+ self .button_box .button (QDialogButtonBox .Ok ).setEnabled (False )
53
+
54
+ def _check_required_fields (self ) -> None :
55
+ ok_button = self .button_box .button (QDialogButtonBox .Ok )
56
+ if (
57
+ self .name_line_edit .text () != ""
58
+ and self .plan_type_combo_box .value () is not None
59
+ and self .organisation_combo_box .value () is not None
60
+ and self .lifecycle_status_combo_box .value () is not None
61
+ ):
62
+ ok_button .setEnabled (True )
63
+ else :
64
+ ok_button .setEnabled (False )
65
+
45
66
def get_plan_attributes (self ) -> Plan :
46
67
return Plan (
47
68
id_ = None ,
0 commit comments