use of de.symeda.sormas.api.contact.ContactBulkEditData in project SORMAS-Project by hzi-braunschweig.
the class ContactController method showBulkContactDataEditComponent.
public void showBulkContactDataEditComponent(Collection<? extends ContactIndexDto> selectedContacts, String caseUuid) {
if (selectedContacts.size() == 0) {
new Notification(I18nProperties.getString(Strings.headingNoContactsSelected), I18nProperties.getString(Strings.messageNoContactsSelected), Type.WARNING_MESSAGE, false).show(Page.getCurrent());
return;
}
// Check if cases with multiple districts have been selected
String districtUuid = null;
for (ContactIndexDto selectedContact : selectedContacts) {
String selectedDistrictUuid = selectedContact.getDistrictUuid();
if (districtUuid == null) {
districtUuid = selectedDistrictUuid;
} else if (!districtUuid.equals(selectedDistrictUuid)) {
districtUuid = null;
break;
}
}
DistrictReferenceDto district = districtUuid != null ? FacadeProvider.getDistrictFacade().getReferenceByUuid(districtUuid) : null;
// Create a temporary contact in order to use the CommitDiscardWrapperComponent
ContactBulkEditData bulkEditData = new ContactBulkEditData();
BulkContactDataForm form = new BulkContactDataForm(district, selectedContacts);
form.setValue(bulkEditData);
final CommitDiscardWrapperComponent<BulkContactDataForm> editView = new CommitDiscardWrapperComponent<BulkContactDataForm>(form, form.getFieldGroup());
Window popupWindow = VaadinUiUtil.showModalPopupWindow(editView, I18nProperties.getString(Strings.headingEditContacts));
editView.addCommitListener(() -> {
ContactBulkEditData updatedBulkEditData = form.getValue();
ContactFacade contactFacade = FacadeProvider.getContactFacade();
boolean classificationChange = form.getClassificationCheckBox().getValue();
boolean contactOfficerChange = district != null ? form.getContactOfficerCheckBox().getValue() : false;
int changedContacts = bulkEdit(selectedContacts, updatedBulkEditData, contactFacade, classificationChange, contactOfficerChange);
popupWindow.close();
if (caseUuid == null) {
overview();
} else {
caseContactsOverview(caseUuid);
}
if (changedContacts == selectedContacts.size()) {
Notification.show(I18nProperties.getString(Strings.messageContactsEdited), Type.HUMANIZED_MESSAGE);
} else {
NotificationHelper.showNotification(String.format(I18nProperties.getString(Strings.messageContactsEditedExceptArchived), changedContacts), Type.HUMANIZED_MESSAGE, -1);
}
});
editView.addDiscardListener(() -> popupWindow.close());
}
Aggregations