Search in sources :

Example 71 with TextArea

use of com.vaadin.v7.ui.TextArea in project SORMAS-Project by hzi-braunschweig.

the class PortHealthInfoForm method addOtherFields.

private void addOtherFields() {
    TextArea taDetails = addField(PortHealthInfoDto.DETAILS, TextArea.class);
    taDetails.setRows(7);
}
Also used : TextArea(com.vaadin.v7.ui.TextArea)

Example 72 with TextArea

use of com.vaadin.v7.ui.TextArea in project SORMAS-Project by hzi-braunschweig.

the class TaskEditForm method addFields.

@Override
protected void addFields() {
    addField(TaskDto.CAZE, ComboBox.class);
    addField(TaskDto.EVENT, ComboBox.class);
    addField(TaskDto.CONTACT, ComboBox.class);
    DateTimeField startDate = addDateField(TaskDto.SUGGESTED_START, DateTimeField.class, -1);
    DateTimeField dueDate = addDateField(TaskDto.DUE_DATE, DateTimeField.class, -1);
    dueDate.setImmediate(true);
    addField(TaskDto.PRIORITY, ComboBox.class);
    NullableOptionGroup taskStatus = addField(TaskDto.TASK_STATUS, NullableOptionGroup.class);
    NullableOptionGroup taskContext = addField(TaskDto.TASK_CONTEXT, NullableOptionGroup.class);
    taskContext.setImmediate(true);
    taskContext.addValueChangeListener(event -> updateByTaskContext());
    ComboBox taskTypeField = addField(TaskDto.TASK_TYPE, ComboBox.class);
    taskTypeField.setItemCaptionMode(ItemCaptionMode.ID_TOSTRING);
    taskTypeField.setImmediate(true);
    taskTypeField.addValueChangeListener(e -> {
        TaskType taskType = (TaskType) e.getProperty().getValue();
        if (taskType != null) {
            setRequired(taskType.isCreatorCommentRequired(), TaskDto.CREATOR_COMMENT);
        }
    });
    ComboBox assigneeUser = addField(TaskDto.ASSIGNEE_USER, ComboBox.class);
    assigneeUser.addValueChangeListener(e -> {
        updateObserversList();
        updateByCreatingAndAssignee();
        checkIfUserEmailOrPhoneIsProvided((UserReferenceDto) e.getProperty().getValue(), Strings.infoAssigneeMissingEmail, Strings.infoAssigneeMissingEmailOrPhoneNumber, ASSIGNEE_MISSING_INFO);
    });
    assigneeUser.setImmediate(true);
    TextArea creatorComment = addField(TaskDto.CREATOR_COMMENT, TextArea.class);
    creatorComment.setRows(2);
    creatorComment.setImmediate(true);
    addField(TaskDto.ASSIGNEE_REPLY, TextArea.class).setRows(4);
    MultiSelect<UserReferenceDto> observerUsers = addField(TaskDto.OBSERVER_USERS, MultiSelect.class);
    observerUsers.addValueChangeListener(e -> {
        Collection<UserReferenceDto> userReferences = (Collection<UserReferenceDto>) e.getProperty().getValue();
        for (UserReferenceDto userReference : userReferences) {
            checkIfUserEmailOrPhoneIsProvided(userReference, Strings.infoObserverMissingEmail, Strings.infoObserverMissingEmailOrPhoneNumber, OBSERVER_MISSING_INFO);
        }
    });
    observerUsers.setImmediate(true);
    CssStyles.style(observerUsers, CssStyles.OPTIONGROUP_MAX_HEIGHT_150);
    setRequired(true, TaskDto.TASK_CONTEXT, TaskDto.TASK_TYPE, TaskDto.ASSIGNEE_USER, TaskDto.DUE_DATE, TaskDto.TASK_STATUS);
    setReadOnly(true, TaskDto.TASK_CONTEXT, TaskDto.CAZE, TaskDto.CONTACT, TaskDto.EVENT);
    addValueChangeListener(e -> {
        TaskDto taskDto = getValue();
        if (taskDto.getTaskType() == TaskType.CASE_INVESTIGATION && taskDto.getCaze() != null) {
            taskStatus.addValidator(new TaskStatusValidator(taskDto.getCaze().getUuid(), I18nProperties.getValidationError(Validations.investigationStatusUnclassifiedCase)));
            if (!editedFromTaskGrid) {
                final HorizontalLayout saveInfoLayout = new HorizontalLayout(new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + I18nProperties.getString(Strings.infoSaveOfTask), ContentMode.HTML));
                saveInfoLayout.setSpacing(true);
                saveInfoLayout.setMargin(new MarginInfo(true, false, true, false));
                getContent().addComponent(saveInfoLayout, SAVE_INFO);
            }
        }
        final UserDto userDto = UserProvider.getCurrent().getUser();
        availableUsers = new ArrayList<>();
        if (taskDto.getCaze() != null) {
            availableUsers.addAll(FacadeProvider.getUserFacade().getUsersHavingCaseInJurisdiction(taskDto.getCaze()));
        } else if (taskDto.getContact() != null) {
            availableUsers.addAll(FacadeProvider.getUserFacade().getUsersHavingContactInJurisdiction(taskDto.getContact()));
        } else if (taskDto.getEvent() != null) {
            availableUsers.addAll(FacadeProvider.getUserFacade().getUsersHavingEventInJurisdiction(taskDto.getEvent()));
        } else if (taskDto.getTravelEntry() != null) {
            availableUsers.addAll(FacadeProvider.getUserFacade().getUsersHavingTravelEntryInJurisdiction(taskDto.getTravelEntry()));
        } else {
            availableUsers.addAll(FacadeProvider.getUserFacade().getAllUserRefs(false));
        }
        // For national users, there is no higher level
        if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.ASSIGN_TASKS_TO_HIGHER_LEVEL) && UserRole.getJurisdictionLevel(userDto.getUserRoles()) != JurisdictionLevel.NATION) {
            List<UserReferenceDto> superordinateUsers = FacadeProvider.getUserFacade().getUsersWithSuperiorJurisdiction(userDto);
            if (superordinateUsers != null) {
                availableUsers.addAll(superordinateUsers);
            }
        }
        // Validation
        startDate.addValidator(new DateComparisonValidator(startDate, dueDate, true, false, I18nProperties.getValidationError(Validations.beforeDate, startDate.getCaption(), dueDate.getCaption())));
        dueDate.addValidator(new DateComparisonValidator(dueDate, startDate, false, false, I18nProperties.getValidationError(Validations.afterDate, dueDate.getCaption(), startDate.getCaption())));
        Map<String, Long> userTaskCounts = FacadeProvider.getTaskFacade().getPendingTaskCountPerUser(availableUsers.stream().map(ReferenceDto::getUuid).collect(Collectors.toList()));
        for (UserReferenceDto user : availableUsers) {
            assigneeUser.addItem(user);
            Long userTaskCount = userTaskCounts.get(user.getUuid());
            assigneeUser.setItemCaption(user, user.getCaption() + " (" + (userTaskCount != null ? userTaskCount.toString() : "0") + ")");
            if (!user.equals(assigneeUser.getValue())) {
                // If a user has been assigned to the task, do not make it available for observers field
                observerUsers.addItem(user);
                observerUsers.setItemCaption(user, user.getCaption());
            }
        }
    });
}
Also used : NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) ReferenceDto(de.symeda.sormas.api.ReferenceDto) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) TextArea(com.vaadin.v7.ui.TextArea) ComboBox(com.vaadin.v7.ui.ComboBox) UserDto(de.symeda.sormas.api.user.UserDto) Label(com.vaadin.ui.Label) DateTimeField(de.symeda.sormas.ui.utils.DateTimeField) TaskDto(de.symeda.sormas.api.task.TaskDto) HorizontalLayout(com.vaadin.ui.HorizontalLayout) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) MarginInfo(com.vaadin.shared.ui.MarginInfo) TaskType(de.symeda.sormas.api.task.TaskType) TaskStatusValidator(de.symeda.sormas.ui.utils.TaskStatusValidator) Collection(java.util.Collection)

Example 73 with TextArea

use of com.vaadin.v7.ui.TextArea in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasOptionsForm method addFields.

@Override
protected void addFields() {
    ComboBox availableServersCombo = addField(SormasToSormasOptionsDto.ORGANIZATION, ComboBox.class);
    availableServersCombo.setRequired(true);
    List<SormasServerDescriptor> availableServers = FacadeProvider.getSormasToSormasFacade().getAllAvailableServers();
    availableServersCombo.addItems(availableServers);
    if (hasOptions) {
        CheckBox handoverOwnership = addField(SormasToSormasOptionsDto.HAND_OVER_OWNERSHIP);
        CheckBox pseudonimyzePersonalData = addField(SormasToSormasOptionsDto.PSEUDONYMIZE_PERSONAL_DATA);
        CheckBox pseudonymizeSensitiveData = addField(SormasToSormasOptionsDto.PSEUDONYMIZE_SENSITIVE_DATA);
        pseudonymizeSensitiveData.addStyleNames(CssStyles.VSPACE_3);
        availableServersCombo.addValueChangeListener(e -> {
            SormasServerDescriptor selectedServer = (SormasServerDescriptor) e.getProperty().getValue();
            if (selectedServer == null) {
                return;
            }
            Optional<SormasToSormasShareInfoDto> previousShare = findShareByOrganization(currentShares, selectedServer.getId());
            previousShare.ifPresent(s -> {
                if (s.getRequestStatus() != ShareRequestStatus.ACCEPTED) {
                    handoverOwnership.setValue(s.isOwnershipHandedOver());
                }
                pseudonimyzePersonalData.setValue(s.isPseudonymizedPersonalData());
                pseudonimyzePersonalData.setValue(s.isPseudonymizedSensitiveData());
                if (updateCustomOptionsByPreviousShare != null) {
                    updateCustomOptionsByPreviousShare.accept(this, s);
                }
            });
        });
        handoverOwnership.addValueChangeListener(e -> {
            boolean ownershipHandedOver = (boolean) e.getProperty().getValue();
            pseudonimyzePersonalData.setEnabled(!ownershipHandedOver);
            pseudonymizeSensitiveData.setEnabled(!ownershipHandedOver);
            if (ownershipHandedOver) {
                pseudonimyzePersonalData.setValue(false);
                pseudonymizeSensitiveData.setValue(false);
            }
        });
        pseudonimyzePersonalData.addValueChangeListener(e -> {
            boolean pseudonimyze = (boolean) e.getProperty().getValue() || pseudonymizeSensitiveData.getValue();
            handoverOwnership.setEnabled(!pseudonimyze);
            if (pseudonimyze) {
                handoverOwnership.setValue(false);
            }
        });
        pseudonymizeSensitiveData.addValueChangeListener(e -> {
            boolean pseudonimyze = (boolean) e.getProperty().getValue() || pseudonimyzePersonalData.getValue();
            handoverOwnership.setEnabled(!pseudonimyze);
            if (pseudonimyze) {
                handoverOwnership.setValue(false);
            }
        });
        addFields(customOptions);
        TextArea comment = addField(SormasToSormasOptionsDto.COMMENT, TextArea.class);
        comment.setRows(3);
        if (customFieldDependencies != null) {
            customFieldDependencies.accept(this);
        }
        if (CollectionUtils.isEmpty(customOptions)) {
            pseudonymizeSensitiveData.addStyleNames(CssStyles.VSPACE_3);
        } else {
            getField(customOptions.get(customOptions.size() - 1)).addStyleNames(CssStyles.VSPACE_3);
        }
    }
}
Also used : SormasToSormasShareInfoDto(de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoDto) SormasServerDescriptor(de.symeda.sormas.api.sormastosormas.SormasServerDescriptor) TextArea(com.vaadin.v7.ui.TextArea) ComboBox(com.vaadin.v7.ui.ComboBox) CheckBox(com.vaadin.v7.ui.CheckBox)

Example 74 with TextArea

use of com.vaadin.v7.ui.TextArea in project SORMAS-Project by hzi-braunschweig.

the class PrescriptionForm method addFields.

@Override
protected void addFields() {
    ComboBox prescriptionTypeField = addField(PrescriptionDto.PRESCRIPTION_TYPE, ComboBox.class);
    prescriptionTypeField.setImmediate(true);
    TextField prescriptionDetailsField = addField(PrescriptionDto.PRESCRIPTION_DETAILS, TextField.class);
    addField(PrescriptionDto.TYPE_OF_DRUG, NullableOptionGroup.class);
    addField(PrescriptionDto.PRESCRIPTION_DATE, DateField.class);
    addField(PrescriptionDto.PRESCRIBING_CLINICIAN, TextField.class);
    DateField prescriptionStartField = addDateField(PrescriptionDto.PRESCRIPTION_START, DateField.class, -1);
    DateField prescriptionEndField = addDateField(PrescriptionDto.PRESCRIPTION_END, DateField.class, -1);
    prescriptionEndField.setImmediate(true);
    addField(PrescriptionDto.FREQUENCY, TextField.class);
    addField(PrescriptionDto.DOSE, TextField.class);
    ComboBox routeField = addField(PrescriptionDto.ROUTE, ComboBox.class);
    addField(PrescriptionDto.ROUTE_DETAILS, TextField.class);
    TextArea additionalNotes = addField(PrescriptionDto.ADDITIONAL_NOTES, TextArea.class);
    additionalNotes.setRows(6);
    additionalNotes.setDescription(I18nProperties.getPrefixDescription(PrescriptionDto.I18N_PREFIX, PrescriptionDto.ADDITIONAL_NOTES, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
    initializeAccessAndAllowedAccesses();
    setRequired(true, PrescriptionDto.PRESCRIPTION_TYPE, PrescriptionDto.PRESCRIPTION_DATE);
    if (isEditableAllowed(PrescriptionDto.PRESCRIPTION_DETAILS)) {
        FieldHelper.setRequiredWhen(getFieldGroup(), prescriptionTypeField, Collections.singletonList(PrescriptionDto.PRESCRIPTION_DETAILS), Arrays.asList(TreatmentType.OTHER, TreatmentType.DRUG_INTAKE));
    }
    if (isEditableAllowed(PrescriptionDto.ROUTE_DETAILS)) {
        FieldHelper.setRequiredWhen(getFieldGroup(), routeField, Arrays.asList(PrescriptionDto.ROUTE_DETAILS), Arrays.asList(TreatmentRoute.OTHER));
    }
    FieldHelper.setVisibleWhen(getFieldGroup(), PrescriptionDto.ROUTE_DETAILS, PrescriptionDto.ROUTE, Arrays.asList(TreatmentRoute.OTHER), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), PrescriptionDto.TYPE_OF_DRUG, PrescriptionDto.PRESCRIPTION_TYPE, Arrays.asList(TreatmentType.DRUG_INTAKE), true);
    prescriptionTypeField.addValueChangeListener(e -> {
        if (e.getProperty().getValue() == TreatmentType.DRUG_INTAKE) {
            prescriptionDetailsField.setCaption(I18nProperties.getPrefixCaption(PrescriptionDto.I18N_PREFIX, PrescriptionDto.DRUG_INTAKE_DETAILS));
        } else {
            prescriptionDetailsField.setCaption(I18nProperties.getPrefixCaption(PrescriptionDto.I18N_PREFIX, PrescriptionDto.PRESCRIPTION_DETAILS));
        }
    });
    prescriptionStartField.addValidator(new DateComparisonValidator(prescriptionStartField, prescriptionEndField, true, false, I18nProperties.getValidationError(Validations.beforeDate, prescriptionStartField.getCaption(), prescriptionEndField.getCaption())));
    prescriptionEndField.addValidator(new DateComparisonValidator(prescriptionEndField, prescriptionStartField, false, false, I18nProperties.getValidationError(Validations.afterDate, prescriptionEndField.getCaption(), prescriptionStartField.getCaption())));
}
Also used : TextArea(com.vaadin.v7.ui.TextArea) ComboBox(com.vaadin.v7.ui.ComboBox) TextField(com.vaadin.v7.ui.TextField) DateField(com.vaadin.v7.ui.DateField) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator)

Example 75 with TextArea

use of com.vaadin.v7.ui.TextArea in project SORMAS-Project by hzi-braunschweig.

the class EventDataForm method addFields.

@Override
protected void addFields() {
    if (isCreateForm == null) {
        return;
    }
    Label eventDataHeadingLabel = new Label(I18nProperties.getString(Strings.headingEventData));
    eventDataHeadingLabel.addStyleName(H3);
    getContent().addComponent(eventDataHeadingLabel, EVENT_DATA_HEADING_LOC);
    Label informationSourceHeadingLabel = new Label(I18nProperties.getString(Strings.headingInformationSource));
    informationSourceHeadingLabel.addStyleName(H3);
    getContent().addComponent(informationSourceHeadingLabel, INFORMATION_SOURCE_HEADING_LOC);
    Label locationHeadingLabel = new Label(I18nProperties.getString(Strings.headingLocation));
    locationHeadingLabel.addStyleName(H3);
    getContent().addComponent(locationHeadingLabel, LOCATION_HEADING_LOC);
    addField(EventDto.UUID, TextField.class);
    ComboBox diseaseField = addDiseaseField(EventDto.DISEASE, false, isCreateForm);
    addField(EventDto.DISEASE_DETAILS, TextField.class);
    ComboBox diseaseVariantField = addField(EventDto.DISEASE_VARIANT, ComboBox.class);
    diseaseVariantField.setNullSelectionAllowed(true);
    addFields(EventDto.EXTERNAL_ID);
    TextField diseaseVariantDetailsField = addField(EventDto.DISEASE_VARIANT_DETAILS, TextField.class);
    diseaseVariantDetailsField.setVisible(false);
    TextField externalTokenField = addField(EventDto.EXTERNAL_TOKEN);
    Label externalTokenWarningLabel = new Label(I18nProperties.getString(Strings.messageEventExternalTokenWarning));
    externalTokenWarningLabel.addStyleNames(VSPACE_3, LABEL_WHITE_SPACE_NORMAL);
    getContent().addComponent(externalTokenWarningLabel, EXTERNAL_TOKEN_WARNING_LOC);
    addField(EventDto.INTERNAL_TOKEN);
    DateTimeField startDate = addField(EventDto.START_DATE, DateTimeField.class);
    CheckBox multiDayCheckbox = addField(EventDto.MULTI_DAY_EVENT, CheckBox.class);
    DateTimeField endDate = addField(EventDto.END_DATE, DateTimeField.class);
    initEventDateValidation(startDate, endDate, multiDayCheckbox);
    addField(EventDto.EVENT_STATUS, NullableOptionGroup.class);
    addField(EventDto.RISK_LEVEL);
    ComboBox specificRiskField = addField(EventDto.SPECIFIC_RISK, ComboBox.class);
    specificRiskField.setNullSelectionAllowed(true);
    addField(EventDto.EVENT_MANAGEMENT_STATUS, NullableOptionGroup.class);
    addField(EventDto.EVENT_IDENTIFICATION_SOURCE, NullableOptionGroup.class);
    addField(EventDto.EVENT_INVESTIGATION_STATUS, NullableOptionGroup.class);
    addField(EventDto.EVENT_INVESTIGATION_START_DATE, DateField.class);
    addField(EventDto.EVENT_INVESTIGATION_END_DATE, DateField.class);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EventDto.EVENT_INVESTIGATION_START_DATE, EventDto.EVENT_INVESTIGATION_END_DATE), EventDto.EVENT_INVESTIGATION_STATUS, Arrays.asList(EventInvestigationStatus.ONGOING, EventInvestigationStatus.DONE, EventInvestigationStatus.DISCARDED), true);
    TextField title = addField(EventDto.EVENT_TITLE, TextField.class);
    title.addStyleName(CssStyles.SOFT_REQUIRED);
    TextArea descriptionField = addField(EventDto.EVENT_DESC, TextArea.class, new ResizableTextAreaWrapper<>());
    descriptionField.setRows(2);
    descriptionField.setDescription(I18nProperties.getPrefixDescription(EventDto.I18N_PREFIX, EventDto.EVENT_DESC, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
    addField(EventDto.DISEASE_TRANSMISSION_MODE, ComboBox.class);
    addField(EventDto.NOSOCOMIAL, NullableOptionGroup.class);
    addFields(EventDto.HUMAN_TRANSMISSION_MODE, EventDto.INFECTION_PATH_CERTAINTY);
    addFields(EventDto.PARENTERAL_TRANSMISSION_MODE, EventDto.MEDICALLY_ASSOCIATED_TRANSMISSION_MODE);
    final NullableOptionGroup epidemiologicalEvidence = addField(EventDto.EPIDEMIOLOGICAL_EVIDENCE, NullableOptionGroup.class);
    final NullableOptionGroup laboratoryDiagnosticEvidence = addField(EventDto.LABORATORY_DIAGNOSTIC_EVIDENCE, NullableOptionGroup.class);
    epidemiologicalEvidenceCheckBoxTree = new EpidemiologicalEvidenceCheckBoxTree(Arrays.stream(EpidemiologicalEvidenceDetail.values()).map(epidemiologicalEvidenceDetail -> epidemiologicalEvidenceDetailToCheckBoxElement(epidemiologicalEvidenceDetail)).collect(Collectors.toList()));
    getContent().addComponent(epidemiologicalEvidenceCheckBoxTree, EventDto.EPIDEMIOLOGICAL_EVIDENCE_DETAILS);
    epidemiologicalEvidenceCheckBoxTree.setVisible(false);
    laboratoryDiagnosticEvidenceCheckBoxTree = new LaboratoryDiagnosticEvidenceCheckBoxTree(Arrays.stream(LaboratoryDiagnosticEvidenceDetail.values()).map(laboratoryDiagnosticEvidenceDetail -> laboratoryDiagnosticEvidenceDetailToCheckBoxElement(laboratoryDiagnosticEvidenceDetail)).collect(Collectors.toList()));
    getContent().addComponent(laboratoryDiagnosticEvidenceCheckBoxTree, EventDto.LABORATORY_DIAGNOSTIC_EVIDENCE_DETAILS);
    laboratoryDiagnosticEvidenceCheckBoxTree.setVisible(false);
    DateField evolutionDateField = addField(EventDto.EVOLUTION_DATE, DateField.class);
    TextField evolutionCommentField = addField(EventDto.EVOLUTION_COMMENT, TextField.class);
    Field<?> statusField = getField(EventDto.EVENT_STATUS);
    statusField.addValueChangeListener(e -> {
        if (statusField.getValue() == null) {
            return;
        }
        EventStatus eventStatus = (EventStatus) statusField.getValue();
        // The status will be used to modify the caption of the field
        // However we don't want to have somthing like "Dropped evolution date"
        // So let's ignore the DROPPED status and use the Event entity caption instead
        String statusCaption;
        if (eventStatus == EventStatus.DROPPED) {
            statusCaption = I18nProperties.getCaption(EVENT_ENTITY);
        } else {
            statusCaption = I18nProperties.getEnumCaption(eventStatus);
        }
        evolutionDateField.setCaption(String.format(I18nProperties.getCaption(EVOLUTION_DATE_WITH_STATUS), statusCaption));
        evolutionCommentField.setCaption(String.format(I18nProperties.getCaption(EVOLUTION_COMMENT_WITH_STATUS), statusCaption));
    });
    FieldHelper.setVisibleWhenSourceNotNull(getFieldGroup(), Collections.singletonList(EventDto.EVOLUTION_COMMENT), EventDto.EVOLUTION_DATE, true);
    ComboBox typeOfPlace = addField(EventDto.TYPE_OF_PLACE, ComboBox.class);
    typeOfPlace.setNullSelectionAllowed(true);
    addField(EventDto.TYPE_OF_PLACE_TEXT, TextField.class);
    addField(EventDto.WORK_ENVIRONMENT);
    ComboBox meansOfTransport = addField(EventDto.MEANS_OF_TRANSPORT);
    TextField connectionNumber = addField(EventDto.CONNECTION_NUMBER);
    DateField travelDate = addField(EventDto.TRAVEL_DATE);
    FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(EventDto.MEANS_OF_TRANSPORT), EventDto.TYPE_OF_PLACE, Collections.singletonList(TypeOfPlace.MEANS_OF_TRANSPORT), true);
    TextField meansOfTransportDetails = addField(EventDto.MEANS_OF_TRANSPORT_DETAILS);
    FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(EventDto.MEANS_OF_TRANSPORT_DETAILS), EventDto.MEANS_OF_TRANSPORT, Collections.singletonList(MeansOfTransport.OTHER), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EventDto.CONNECTION_NUMBER, EventDto.TRAVEL_DATE), EventDto.TYPE_OF_PLACE, Collections.singletonList(TypeOfPlace.MEANS_OF_TRANSPORT), true);
    getField(EventDto.MEANS_OF_TRANSPORT).addValueChangeListener(e -> {
        if (e.getProperty().getValue() == MeansOfTransport.PLANE) {
            getField(EventDto.CONNECTION_NUMBER).setCaption(I18nProperties.getCaption(Captions.exposureFlightNumber));
        } else {
            getField(EventDto.CONNECTION_NUMBER).setCaption(I18nProperties.getPrefixCaption(EventDto.I18N_PREFIX, EventDto.CONNECTION_NUMBER));
        }
    });
    DateField reportDate = addField(EventDto.REPORT_DATE_TIME, DateField.class);
    addField(EventDto.REPORTING_USER, ComboBox.class);
    addField(EventDto.TRANSREGIONAL_OUTBREAK, NullableOptionGroup.class);
    ComboBox srcType = addField(EventDto.SRC_TYPE);
    TextField srcFirstName = addField(EventDto.SRC_FIRST_NAME, TextField.class);
    TextField srcLastName = addField(EventDto.SRC_LAST_NAME, TextField.class);
    TextField srcTelNo = addField(EventDto.SRC_TEL_NO, TextField.class);
    addField(EventDto.SRC_EMAIL, TextField.class);
    TextField srcMediaWebsite = addField(EventDto.SRC_MEDIA_WEBSITE, TextField.class);
    TextField srcMediaName = addField(EventDto.SRC_MEDIA_NAME, TextField.class);
    TextArea srcMediaDetails = addField(EventDto.SRC_MEDIA_DETAILS, TextArea.class);
    srcMediaDetails.setRows(4);
    ComboBox srcInstitutionalPartnerType = addField(EventDto.SRC_INSTITUTIONAL_PARTNER_TYPE);
    FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(EventDto.SRC_INSTITUTIONAL_PARTNER_TYPE), EventDto.SRC_TYPE, Collections.singletonList(EventSourceType.INSTITUTIONAL_PARTNER), true);
    TextField srcInstitutionalPartnerTypeDetails = addField(EventDto.SRC_INSTITUTIONAL_PARTNER_TYPE_DETAILS);
    FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(EventDto.SRC_INSTITUTIONAL_PARTNER_TYPE_DETAILS), EventDto.SRC_INSTITUTIONAL_PARTNER_TYPE, Collections.singletonList(InstitutionalPartnerType.OTHER), true);
    addField(EventDto.EVENT_LOCATION, new LocationEditForm(fieldVisibilityCheckers, createFieldAccessCheckers(isPseudonymized, false))).setCaption(null);
    locationForm = (LocationEditForm) getFieldGroup().getField(EventDto.EVENT_LOCATION);
    locationForm.setDistrictRequiredOnDefaultCountry(true);
    ComboBox regionField = (ComboBox) locationForm.getFieldGroup().getField(LocationDto.REGION);
    ComboBox districtField = (ComboBox) locationForm.getFieldGroup().getField(LocationDto.DISTRICT);
    ComboBox responsibleUserField = addField(EventDto.RESPONSIBLE_USER, ComboBox.class);
    responsibleUserField.setNullSelectionAllowed(true);
    addField(EventDto.DELETION_REASON);
    addField(EventDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
    setVisible(false, EventDto.DELETION_REASON, EventDto.OTHER_DELETION_REASON);
    if (isCreateForm) {
        locationForm.hideValidationUntilNextCommit();
    }
    setReadOnly(true, EventDto.UUID, EventDto.REPORTING_USER);
    initializeVisibilitiesAndAllowedVisibilities();
    initializeAccessAndAllowedAccesses();
    FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.WORK_ENVIRONMENT, locationForm.getFacilityTypeGroup(), Collections.singletonList(FacilityTypeGroup.WORKING_PLACE), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(EventDto.DISEASE_DETAILS), EventDto.DISEASE, Collections.singletonList(Disease.OTHER), true);
    FieldHelper.setRequiredWhen(getFieldGroup(), EventDto.DISEASE, Collections.singletonList(EventDto.DISEASE_DETAILS), Collections.singletonList(Disease.OTHER));
    // Customizable enum fields visibilities
    diseaseVariantField.setVisible(false);
    diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
        Disease disease = (Disease) valueChangeEvent.getProperty().getValue();
        List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
        FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
        diseaseVariantField.setVisible(disease != null && CollectionUtils.isNotEmpty(diseaseVariants));
        List<SpecificRisk> specificRiskValues = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.SPECIFIC_EVENT_RISK, disease);
        FieldHelper.updateItems(specificRiskField, specificRiskValues);
        specificRiskField.setVisible(isVisibleAllowed(EventDto.SPECIFIC_RISK) && CollectionUtils.isNotEmpty(specificRiskValues));
    });
    diseaseVariantField.addValueChangeListener(e -> {
        DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
        diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
    });
    setRequired(true, EventDto.EVENT_STATUS, EventDto.UUID, EventDto.EVENT_TITLE, EventDto.REPORT_DATE_TIME, EventDto.REPORTING_USER);
    reportDate.addValidator(new DateComparisonValidator(reportDate, startDate, false, false, I18nProperties.getValidationError(Validations.afterDate, reportDate.getCaption(), startDate.getCaption())));
    startDate.addValidator(new DateComparisonValidator(startDate, reportDate, true, false, I18nProperties.getValidationError(Validations.beforeDate, startDate.getCaption(), reportDate.getCaption())));
    reportDate.addValueChangeListener(e -> startDate.setValidationVisible(!startDate.isValid()));
    startDate.addValueChangeListener(e -> reportDate.setValidationVisible(!reportDate.isValid()));
    FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.END_DATE, EventDto.MULTI_DAY_EVENT, Collections.singletonList(true), true);
    FieldHelper.setCaptionWhen(multiDayCheckbox, startDate, false, I18nProperties.getCaption(Captions.singleDayEventDate), I18nProperties.getCaption(Captions.Event_startDate));
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EventDto.NOSOCOMIAL, EventDto.TRANSREGIONAL_OUTBREAK, EventDto.DISEASE_TRANSMISSION_MODE), EventDto.EVENT_STATUS, Collections.singletonList(EventStatus.CLUSTER), true);
    if (isVisibleAllowed(EventDto.INFECTION_PATH_CERTAINTY)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.INFECTION_PATH_CERTAINTY, EventDto.NOSOCOMIAL, Collections.singletonList(YesNoUnknown.YES), true);
    }
    if (isVisibleAllowed(EventDto.HUMAN_TRANSMISSION_MODE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.HUMAN_TRANSMISSION_MODE, EventDto.DISEASE_TRANSMISSION_MODE, Collections.singletonList(DiseaseTransmissionMode.HUMAN_TO_HUMAN), true);
    }
    if (isVisibleAllowed(EventDto.PARENTERAL_TRANSMISSION_MODE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.PARENTERAL_TRANSMISSION_MODE, EventDto.HUMAN_TRANSMISSION_MODE, Collections.singletonList(HumanTransmissionMode.PARENTERAL), true);
    }
    if (isVisibleAllowed(EventDto.MEDICALLY_ASSOCIATED_TRANSMISSION_MODE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.MEDICALLY_ASSOCIATED_TRANSMISSION_MODE, EventDto.PARENTERAL_TRANSMISSION_MODE, Collections.singletonList(ParenteralTransmissionMode.MEDICALLY_ASSOCIATED), true);
    }
    if (isVisibleAllowed(EventDto.EPIDEMIOLOGICAL_EVIDENCE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.EPIDEMIOLOGICAL_EVIDENCE, EventDto.DISEASE_TRANSMISSION_MODE, Collections.singletonList(DiseaseTransmissionMode.HUMAN_TO_HUMAN), true);
        epidemiologicalEvidence.addValueChangeListener(valueChangeEvent -> {
            if (((NullableOptionGroup) valueChangeEvent.getProperty()).getNullableValue() == YesNoUnknown.YES) {
                epidemiologicalEvidenceCheckBoxTree.setVisible(true);
            } else {
                epidemiologicalEvidenceCheckBoxTree.clearCheckBoxTree();
                epidemiologicalEvidenceCheckBoxTree.setVisible(false);
            }
        });
    }
    if (isVisibleAllowed(EventDto.LABORATORY_DIAGNOSTIC_EVIDENCE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.LABORATORY_DIAGNOSTIC_EVIDENCE, EventDto.DISEASE_TRANSMISSION_MODE, Collections.singletonList(DiseaseTransmissionMode.HUMAN_TO_HUMAN), true);
        laboratoryDiagnosticEvidence.addValueChangeListener(valueChangeEvent -> {
            if (((NullableOptionGroup) valueChangeEvent.getProperty()).getNullableValue() == YesNoUnknown.YES) {
                laboratoryDiagnosticEvidenceCheckBoxTree.setVisible(true);
            } else {
                laboratoryDiagnosticEvidenceCheckBoxTree.clearCheckBoxTree();
                laboratoryDiagnosticEvidenceCheckBoxTree.setVisible(false);
            }
        });
    }
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EventDto.SRC_FIRST_NAME, EventDto.SRC_LAST_NAME, EventDto.SRC_TEL_NO, EventDto.SRC_EMAIL), EventDto.SRC_TYPE, Arrays.asList(EventSourceType.HOTLINE_PERSON, EventSourceType.INSTITUTIONAL_PARTNER), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EventDto.SRC_MEDIA_WEBSITE, EventDto.SRC_MEDIA_NAME, EventDto.SRC_MEDIA_DETAILS), EventDto.SRC_TYPE, Collections.singletonList(EventSourceType.MEDIA_NEWS), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.TYPE_OF_PLACE_TEXT, EventDto.TYPE_OF_PLACE, Collections.singletonList(TypeOfPlace.OTHER), true);
    setTypeOfPlaceTextRequirement();
    locationForm.setFacilityFieldsVisible(getField(EventDto.TYPE_OF_PLACE).getValue() == TypeOfPlace.FACILITY, true);
    typeOfPlace.addValueChangeListener(e -> locationForm.setFacilityFieldsVisible(e.getProperty().getValue() == TypeOfPlace.FACILITY, true));
    regionField.addValueChangeListener(e -> {
        RegionReferenceDto region = (RegionReferenceDto) regionField.getValue();
        if (region != null) {
            regionEventResponsibles = FacadeProvider.getUserFacade().getUsersByRegionAndRights(region, getValue().getDisease(), UserRight.EVENT_RESPONSIBLE);
        } else {
            regionEventResponsibles.clear();
        }
    });
    districtField.addValueChangeListener(e -> {
        DistrictReferenceDto district = (DistrictReferenceDto) districtField.getValue();
        if (district != null) {
            List<UserReferenceDto> districtEventResponsibles = FacadeProvider.getUserFacade().getUserRefsByDistrict(district, getValue().getDisease(), UserRight.EVENT_RESPONSIBLE);
            List<UserReferenceDto> responsibleUsers = new ArrayList<>();
            responsibleUsers.addAll(districtEventResponsibles);
            responsibleUsers.addAll(regionEventResponsibles);
            FieldHelper.updateItems(responsibleUserField, responsibleUsers);
        } else {
            responsibleUserField.removeAllItems();
        }
    });
    FieldHelper.addSoftRequiredStyle(startDate, endDate, typeOfPlace, meansOfTransport, meansOfTransportDetails, connectionNumber, travelDate, responsibleUserField, srcType, srcInstitutionalPartnerType, srcInstitutionalPartnerTypeDetails, srcFirstName, srcLastName, srcTelNo, srcMediaWebsite, srcMediaName);
    // Make external ID field read-only when SORMAS is connected to a SurvNet instance
    if (StringUtils.isNotEmpty(FacadeProvider.getConfigFacade().getExternalSurveillanceToolGatewayUrl())) {
        setEnabled(false, EventDto.EXTERNAL_ID);
        ((TextField) getField(EventDto.EXTERNAL_ID)).setInputPrompt(I18nProperties.getString(Strings.promptExternalIdExternalSurveillanceTool));
    }
    addValueChangeListener((e) -> {
        ValidationUtils.initComponentErrorValidator(externalTokenField, getValue().getExternalToken(), Validations.duplicateExternalToken, externalTokenWarningLabel, (externalToken) -> FacadeProvider.getEventFacade().doesExternalTokenExist(externalToken, getValue().getUuid()));
        epidemiologicalEvidenceCheckBoxTree.initCheckboxes();
        laboratoryDiagnosticEvidenceCheckBoxTree.initCheckboxes();
        // Initialize specific risk field if disease is null
        if (getValue().getDisease() == null) {
            List<SpecificRisk> specificRiskValues = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.SPECIFIC_EVENT_RISK, null);
            FieldHelper.updateItems(specificRiskField, specificRiskValues);
            specificRiskField.setVisible(isVisibleAllowed(EventDto.SPECIFIC_RISK) && CollectionUtils.isNotEmpty(specificRiskValues));
        }
    });
}
Also used : AbstractEditForm(de.symeda.sormas.ui.utils.AbstractEditForm) CheckBoxTree(de.symeda.sormas.ui.utils.CheckBoxTree) H3(de.symeda.sormas.ui.utils.CssStyles.H3) Arrays(java.util.Arrays) DiseaseTransmissionMode(de.symeda.sormas.api.event.DiseaseTransmissionMode) ValidationUtils(de.symeda.sormas.ui.utils.ValidationUtils) CheckBox(com.vaadin.v7.ui.CheckBox) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) LayoutUtil.locs(de.symeda.sormas.ui.utils.LayoutUtil.locs) StringUtils(org.apache.commons.lang3.StringUtils) SpecificRisk(de.symeda.sormas.api.event.SpecificRisk) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) EpidemiologicalEvidenceDetail(de.symeda.sormas.api.event.EpidemiologicalEvidenceDetail) HumanTransmissionMode(de.symeda.sormas.api.event.HumanTransmissionMode) CssStyles(de.symeda.sormas.ui.utils.CssStyles) EventInvestigationStatus(de.symeda.sormas.api.event.EventInvestigationStatus) VSPACE_3(de.symeda.sormas.ui.utils.CssStyles.VSPACE_3) LayoutUtil.fluidRow(de.symeda.sormas.ui.utils.LayoutUtil.fluidRow) ComboBox(com.vaadin.v7.ui.ComboBox) LaboratoryDiagnosticEvidenceDetail(de.symeda.sormas.api.event.LaboratoryDiagnosticEvidenceDetail) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Field(com.vaadin.v7.ui.Field) EventDto(de.symeda.sormas.api.event.EventDto) FieldHelper(de.symeda.sormas.ui.utils.FieldHelper) Collectors(java.util.stream.Collectors) TypeOfPlace(de.symeda.sormas.api.event.TypeOfPlace) List(java.util.List) LayoutUtil.fluidColumnLoc(de.symeda.sormas.ui.utils.LayoutUtil.fluidColumnLoc) InstitutionalPartnerType(de.symeda.sormas.api.event.InstitutionalPartnerType) TextField(com.vaadin.v7.ui.TextField) MeansOfTransport(de.symeda.sormas.api.event.MeansOfTransport) Descriptions(de.symeda.sormas.api.i18n.Descriptions) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) LABEL_WHITE_SPACE_NORMAL(de.symeda.sormas.ui.utils.CssStyles.LABEL_WHITE_SPACE_NORMAL) FacadeProvider(de.symeda.sormas.api.FacadeProvider) VerticalLayout(com.vaadin.ui.VerticalLayout) Converter(com.vaadin.v7.data.util.converter.Converter) EventStatus(de.symeda.sormas.api.event.EventStatus) ArrayList(java.util.ArrayList) CustomizableEnumType(de.symeda.sormas.api.customizableenum.CustomizableEnumType) LayoutUtil.loc(de.symeda.sormas.ui.utils.LayoutUtil.loc) CollectionUtils(org.apache.commons.collections.CollectionUtils) Label(com.vaadin.ui.Label) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) LayoutUtil.fluidRowLocs(de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs) DateField(com.vaadin.v7.ui.DateField) LocationDto(de.symeda.sormas.api.location.LocationDto) Validations(de.symeda.sormas.api.i18n.Validations) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) ResizableTextAreaWrapper(de.symeda.sormas.ui.utils.ResizableTextAreaWrapper) Captions(de.symeda.sormas.api.i18n.Captions) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) ParenteralTransmissionMode(de.symeda.sormas.api.event.ParenteralTransmissionMode) FieldGroup(com.vaadin.v7.data.fieldgroup.FieldGroup) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) UserRight(de.symeda.sormas.api.user.UserRight) Disease(de.symeda.sormas.api.Disease) LocationEditForm(de.symeda.sormas.ui.location.LocationEditForm) TextArea(com.vaadin.v7.ui.TextArea) EventSourceType(de.symeda.sormas.api.event.EventSourceType) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) LayoutUtil.fluidColumn(de.symeda.sormas.ui.utils.LayoutUtil.fluidColumn) DateTimeField(de.symeda.sormas.ui.utils.DateTimeField) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) Disease(de.symeda.sormas.api.Disease) TextArea(com.vaadin.v7.ui.TextArea) Label(com.vaadin.ui.Label) EventStatus(de.symeda.sormas.api.event.EventStatus) ArrayList(java.util.ArrayList) DateTimeField(de.symeda.sormas.ui.utils.DateTimeField) TextField(com.vaadin.v7.ui.TextField) List(java.util.List) ArrayList(java.util.ArrayList) LocationEditForm(de.symeda.sormas.ui.location.LocationEditForm) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) ComboBox(com.vaadin.v7.ui.ComboBox) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) SpecificRisk(de.symeda.sormas.api.event.SpecificRisk) CheckBox(com.vaadin.v7.ui.CheckBox) DateField(com.vaadin.v7.ui.DateField)

Aggregations

TextArea (com.codename1.ui.TextArea)60 Form (com.codename1.ui.Form)23 Component (com.codename1.ui.Component)21 Button (com.codename1.ui.Button)16 Label (com.codename1.ui.Label)16 TextArea (com.vaadin.v7.ui.TextArea)15 Container (com.codename1.ui.Container)13 BorderLayout (com.codename1.ui.layouts.BorderLayout)12 Label (com.vaadin.ui.Label)11 ComboBox (com.vaadin.v7.ui.ComboBox)10 TextField (com.codename1.ui.TextField)9 DateComparisonValidator (de.symeda.sormas.ui.utils.DateComparisonValidator)9 DateField (com.vaadin.v7.ui.DateField)8 TextField (com.vaadin.v7.ui.TextField)8 NullableOptionGroup (de.symeda.sormas.ui.utils.NullableOptionGroup)7 RadioButton (com.codename1.ui.RadioButton)6 Field (com.vaadin.v7.ui.Field)6 BoxLayout (com.codename1.ui.layouts.BoxLayout)5 Paint (android.graphics.Paint)4 CheckBox (com.codename1.ui.CheckBox)4