@@ -104,6 +104,7 @@ public class ContactCreateForm extends AbstractEditForm<ContactDto> {
104
104
private Disease disease ;
105
105
private final Boolean hasCaseRelation ;
106
106
private final boolean asSourceContact ;
107
+ private final boolean isPersonReadOnly ;
107
108
private NullableOptionGroup contactCategory ;
108
109
private TextField contactProximityDetails ;
109
110
@@ -123,10 +124,19 @@ public class ContactCreateForm extends AbstractEditForm<ContactDto> {
123
124
private final boolean showPersonSearchButton ;
124
125
private Window warningSimilarPersons ;
125
126
127
+ public ContactCreateForm (Disease disease , boolean hasCaseRelation , boolean asSourceContact , boolean showPersonSearchButton ) {
128
+ this (disease , hasCaseRelation , asSourceContact , showPersonSearchButton , false );
129
+ }
130
+
126
131
/**
127
132
* TODO use disease and case relation information given in ContactDto
128
133
*/
129
- public ContactCreateForm (Disease disease , boolean hasCaseRelation , boolean asSourceContact , boolean showPersonSearchButton ) {
134
+ public ContactCreateForm (
135
+ Disease disease ,
136
+ boolean hasCaseRelation ,
137
+ boolean asSourceContact ,
138
+ boolean showPersonSearchButton ,
139
+ boolean isPersonReadOnly ) {
130
140
super (
131
141
ContactDto .class ,
132
142
ContactDto .I18N_PREFIX ,
@@ -137,6 +147,7 @@ public ContactCreateForm(Disease disease, boolean hasCaseRelation, boolean asSou
137
147
this .disease = disease ;
138
148
this .hasCaseRelation = hasCaseRelation ;
139
149
this .asSourceContact = asSourceContact ;
150
+ this .isPersonReadOnly = isPersonReadOnly ;
140
151
this .showPersonSearchButton = showPersonSearchButton ;
141
152
142
153
addFields ();
@@ -158,11 +169,18 @@ protected void addFields() {
158
169
addField (ContactDto .DISEASE_DETAILS , TextField .class );
159
170
160
171
personCreateForm = new PersonCreateForm (false , false , false , showPersonSearchButton );
172
+ if (isPersonReadOnly ) {
173
+ personCreateForm .setPersonDetailsReadOnly ();
174
+ }
161
175
personCreateForm .setWidth (100 , Unit .PERCENTAGE );
162
176
personCreateForm .setValue (new PersonDto ());
163
177
getContent ().addComponent (personCreateForm , ContactDto .PERSON );
164
178
165
179
personCreateForm .getNationalHealthIdField ().addTextFieldValueChangeListener (e -> {
180
+ // Only check if the health ID can be edited
181
+ if (!personCreateForm .getNationalHealthIdField ().isEnabled ()) {
182
+ return ;
183
+ }
166
184
warningSimilarPersons = PersonFormHelper
167
185
.warningSimilarPersons (personCreateForm .getNationalHealthIdField ().getValue (), null , () -> warningSimilarPersons = null );
168
186
});
@@ -406,10 +424,6 @@ public void setPerson(PersonDto person, boolean isNewPerson) {
406
424
personCreateForm .setPerson (person , isNewPerson );
407
425
}
408
426
409
- public void setPersonDetailsReadOnly () {
410
- personCreateForm .setPersonDetailsReadOnly ();
411
- }
412
-
413
427
public void setDiseaseReadOnly () {
414
428
getField (CaseDataDto .DISEASE ).setEnabled (false );
415
429
}
0 commit comments