Search in sources :

Example 36 with ComboBox

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

the class PointOfEntryForm method addFields.

@Override
protected void addFields() {
    addField(PointOfEntryDto.NAME, TextField.class);
    addField(PointOfEntryDto.POINT_OF_ENTRY_TYPE, ComboBox.class);
    addField(PointOfEntryDto.ACTIVE, CheckBox.class);
    AccessibleTextField tfLatitude = addField(PointOfEntryDto.LATITUDE, AccessibleTextField.class);
    AccessibleTextField tfLongitude = addField(PointOfEntryDto.LONGITUDE, AccessibleTextField.class);
    ComboBox cbRegion = addInfrastructureField(PointOfEntryDto.REGION);
    ComboBox cbDistrict = addInfrastructureField(PointOfEntryDto.DISTRICT);
    addField(RegionDto.EXTERNAL_ID, TextField.class);
    tfLatitude.setConverter(new StringToAngularLocationConverter());
    tfLatitude.setConversionError(I18nProperties.getValidationError(Validations.onlyGeoCoordinatesAllowed, tfLatitude.getCaption()));
    tfLongitude.setConverter(new StringToAngularLocationConverter());
    tfLongitude.setConversionError(I18nProperties.getValidationError(Validations.onlyGeoCoordinatesAllowed, tfLongitude.getCaption()));
    cbRegion.addValueChangeListener(e -> {
        RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
        FieldHelper.updateItems(cbDistrict, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
    });
    cbRegion.addItems(FacadeProvider.getRegionFacade().getAllActiveAsReference());
    setRequired(true, PointOfEntryDto.NAME, PointOfEntryDto.POINT_OF_ENTRY_TYPE);
    if (!create) {
        cbRegion.setEnabled(false);
        cbDistrict.setEnabled(false);
    } else {
        setRequired(true, PointOfEntryDto.REGION, PointOfEntryDto.DISTRICT);
    }
}
Also used : AccessibleTextField(de.symeda.sormas.ui.location.AccessibleTextField) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) ComboBox(com.vaadin.v7.ui.ComboBox) StringToAngularLocationConverter(de.symeda.sormas.ui.utils.StringToAngularLocationConverter)

Example 37 with ComboBox

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

the class ContactsFilterForm method applyDependenciesOnNewValue.

@Override
protected void applyDependenciesOnNewValue(ContactCriteria newValue) {
    final RegionReferenceDto region = newValue.getRegion();
    final DistrictReferenceDto district = newValue.getDistrict();
    applyRegionAndDistrictFilterDependency(region, ContactCriteria.DISTRICT, district, ContactCriteria.COMMUNITY);
    final UserDto user = currentUserDto();
    ComboBox officerField = getField(ContactCriteria.CONTACT_OFFICER);
    if (user.getRegion() != null) {
        officerField.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRights(user.getRegion(), newValue.getDisease(), UserRight.CONTACT_RESPONSIBLE));
    } else if (region != null) {
        officerField.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRights(region, newValue.getDisease(), UserRight.CONTACT_RESPONSIBLE));
    } else {
        officerField.removeAllItems();
    }
    ComboBox birthDateDD = getField(ContactCriteria.BIRTHDATE_DD);
    if (getField(ContactCriteria.BIRTHDATE_YYYY).getValue() != null && getField(ContactCriteria.BIRTHDATE_MM).getValue() != null) {
        birthDateDD.addItems(DateHelper.getDaysInMonth((Integer) getField(ContactCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(ContactCriteria.BIRTHDATE_YYYY).getValue()));
        birthDateDD.setEnabled(true);
    } else {
        birthDateDD.clear();
        birthDateDD.setEnabled(false);
    }
    // Date/Epi week filter
    HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
    @SuppressWarnings("unchecked") EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<NewCaseDateType>) dateFilterLayout.getComponent(0);
    ContactDateType contactDateType = newValue.getReportDateFrom() != null ? ContactDateType.REPORT_DATE : newValue.getLastContactDateFrom() != null ? ContactDateType.LAST_CONTACT_DATE : null;
    weekAndDateFilter.getDateTypeSelector().setValue(contactDateType);
    weekAndDateFilter.getDateFilterOptionFilter().setValue(newValue.getDateFilterOption());
    Date dateFrom = contactDateType == ContactDateType.REPORT_DATE ? newValue.getReportDateFrom() : contactDateType == ContactDateType.LAST_CONTACT_DATE ? newValue.getLastContactDateFrom() : null;
    Date dateTo = contactDateType == ContactDateType.REPORT_DATE ? newValue.getReportDateTo() : contactDateType == ContactDateType.LAST_CONTACT_DATE ? newValue.getLastContactDateTo() : null;
    if (DateFilterOption.EPI_WEEK.equals(newValue.getDateFilterOption())) {
        weekAndDateFilter.getWeekFromFilter().setValue(dateFrom == null ? null : DateHelper.getEpiWeek(dateFrom));
        weekAndDateFilter.getWeekToFilter().setValue(dateTo == null ? null : DateHelper.getEpiWeek(dateTo));
    } else {
        weekAndDateFilter.getDateFromFilter().setValue(dateFrom);
        weekAndDateFilter.getDateToFilter().setValue(dateTo);
    }
    if (StringUtils.isBlank(newValue.getEventLike())) {
        clearAndDisableFields(ContactCriteria.ONLY_CONTACTS_SHARING_EVENT_WITH_SOURCE_CASE);
    } else {
        enableFields(ContactCriteria.ONLY_CONTACTS_SHARING_EVENT_WITH_SOURCE_CASE);
    }
    ComboBox diseaseField = getField(ContactIndexDto.DISEASE);
    ComboBox diseaseVariantField = getField(ContactCriteria.DISEASE_VARIANT);
    Disease disease = (Disease) diseaseField.getValue();
    if (disease == null) {
        FieldHelper.updateItems(diseaseVariantField, Collections.emptyList());
        FieldHelper.setEnabled(false, diseaseVariantField);
    } else {
        List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
        FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
        FieldHelper.setEnabled(CollectionUtils.isNotEmpty(diseaseVariants), diseaseVariantField);
    }
}
Also used : ContactDateType(de.symeda.sormas.api.contact.ContactDateType) NewCaseDateType(de.symeda.sormas.api.caze.NewCaseDateType) Disease(de.symeda.sormas.api.Disease) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) ComboBox(com.vaadin.v7.ui.ComboBox) UserDto(de.symeda.sormas.api.user.UserDto) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) Date(java.util.Date) HorizontalLayout(com.vaadin.ui.HorizontalLayout) EpiWeekAndDateFilterComponent(de.symeda.sormas.ui.utils.EpiWeekAndDateFilterComponent) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)

Example 38 with ComboBox

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

the class ContactsFilterForm method populateContactResponsiblesForDistrict.

private void populateContactResponsiblesForDistrict(DistrictReferenceDto districtReferenceDto) {
    if (districtReferenceDto != null) {
        Disease selectedDisease = (Disease) getField(ContactIndexDto.DISEASE).getValue();
        List<UserReferenceDto> items = FacadeProvider.getUserFacade().getUserRefsByDistrict(districtReferenceDto, selectedDisease, UserRight.CONTACT_RESPONSIBLE);
        populateContactResponsibles(items);
    } else {
        final ComboBox regionField = getField(ContactCriteria.REGION);
        if (regionField != null) {
            populateContactResponsiblesForRegion((RegionReferenceDto) regionField.getValue());
        }
    }
}
Also used : UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) Disease(de.symeda.sormas.api.Disease) ComboBox(com.vaadin.v7.ui.ComboBox)

Example 39 with ComboBox

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

the class SymptomsForm method addListenerForOnsetFields.

@SuppressWarnings("rawtypes")
private void addListenerForOnsetFields(ComboBox onsetSymptom, DateField onsetDateField) {
    List<String> allPropertyIds = Stream.concat(unconditionalSymptomFieldIds.stream(), conditionalBleedingSymptomFieldIds.stream()).collect(Collectors.toList());
    allPropertyIds.add(LESIONS_THAT_ITCH);
    for (Object sourcePropertyId : allPropertyIds) {
        Field sourceField = getFieldGroup().getField(sourcePropertyId);
        sourceField.addValueChangeListener(event -> {
            if (FieldHelper.getNullableSourceFieldValue(sourceField) == SymptomState.YES) {
                onsetSymptom.addItem(sourceField.getCaption());
                onsetDateField.setEnabled(true);
            } else {
                onsetSymptom.removeItem(sourceField.getCaption());
                boolean isOnsetDateFieldEnabled = isAnySymptomSetToYes(getFieldGroup(), allPropertyIds, Arrays.asList(SymptomState.YES));
                onsetDateField.setEnabled(isOnsetDateFieldEnabled);
                Date onsetDate = getValue().getOnsetDate();
                if (onsetDate != null) {
                    onsetDateField.setValue(onsetDate);
                } else if (!isOnsetDateFieldEnabled) {
                    onsetDateField.setValue(null);
                }
            }
            onsetSymptom.setEnabled(!onsetSymptom.getItemIds().isEmpty());
        });
    }
    // will be updated by listener if needed
    onsetSymptom.setEnabled(false);
    // will be updated by listener if needed
    onsetDateField.setEnabled(false);
}
Also used : AbstractField(com.vaadin.v7.ui.AbstractField) Field(com.vaadin.v7.ui.Field) TextField(com.vaadin.v7.ui.TextField) DateField(com.vaadin.v7.ui.DateField) Date(java.util.Date)

Example 40 with ComboBox

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

the class BulkTaskDataForm method addFields.

@Override
protected void addFields() {
    if (!initialized) {
        return;
    }
    taskStatusCheckbox = new CheckBox(I18nProperties.getCaption(Captions.bulkTaskStatus));
    getContent().addComponent(taskStatusCheckbox, STATUS_CHECKBOX);
    NullableOptionGroup status = addField(TaskBulkEditData.TASK_STATUS, NullableOptionGroup.class);
    status.setEnabled(false);
    FieldHelper.setRequiredWhen(getFieldGroup(), taskStatusCheckbox, Arrays.asList(TaskBulkEditData.TASK_STATUS), Arrays.asList(true));
    taskStatusCheckbox.addValueChangeListener(e -> {
        status.setEnabled((boolean) e.getProperty().getValue());
    });
    priorityCheckbox = new CheckBox(I18nProperties.getCaption(Captions.bulkTaskPriority));
    getContent().addComponent(priorityCheckbox, PRORITY_CHECKBOX);
    NullableOptionGroup priority = addField(TaskBulkEditData.TASK_PRIORITY, NullableOptionGroup.class);
    priority.setEnabled(false);
    FieldHelper.setRequiredWhen(getFieldGroup(), priorityCheckbox, Arrays.asList(TaskBulkEditData.TASK_PRIORITY), Arrays.asList(true));
    priorityCheckbox.addValueChangeListener(e -> {
        priority.setEnabled((boolean) e.getProperty().getValue());
    });
    assigneeCheckbox = new CheckBox(I18nProperties.getCaption(Captions.bulkTaskAssignee));
    getContent().addComponent(assigneeCheckbox, ASSIGNEE_CHECKBOX);
    ComboBox assignee = addField(TaskBulkEditData.TASK_ASSIGNEE, ComboBox.class);
    assignee.setEnabled(false);
    FieldHelper.addSoftRequiredStyleWhen(getFieldGroup(), assigneeCheckbox, Arrays.asList(TaskBulkEditData.TASK_ASSIGNEE), Arrays.asList(true), null);
    List<UserReferenceDto> users = getUsers();
    Map<String, Long> userTaskCounts = FacadeProvider.getTaskFacade().getPendingTaskCountPerUser(users.stream().map(ReferenceDto::getUuid).collect(Collectors.toList()));
    for (UserReferenceDto user : users) {
        assignee.addItem(user);
        Long userTaskCount = userTaskCounts.get(user.getUuid());
        assignee.setItemCaption(user, user.getCaption() + " (" + (userTaskCount != null ? userTaskCount.toString() : "0") + ")");
    }
    assigneeCheckbox.addValueChangeListener(e -> {
        boolean changeAssignee = (boolean) e.getProperty().getValue();
        assignee.setEnabled(changeAssignee);
        assignee.setRequired(changeAssignee);
    });
}
Also used : NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) ReferenceDto(de.symeda.sormas.api.ReferenceDto) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) CheckBox(com.vaadin.v7.ui.CheckBox) ComboBox(com.vaadin.v7.ui.ComboBox)

Aggregations

ComboBox (com.vaadin.v7.ui.ComboBox)113 TextField (com.vaadin.v7.ui.TextField)43 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)31 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)28 Label (com.vaadin.ui.Label)24 Disease (de.symeda.sormas.api.Disease)24 TextArea (com.vaadin.v7.ui.TextArea)19 UserDto (de.symeda.sormas.api.user.UserDto)19 NullableOptionGroup (de.symeda.sormas.ui.utils.NullableOptionGroup)19 DateField (com.vaadin.v7.ui.DateField)18 List (java.util.List)18 CheckBox (com.vaadin.v7.ui.CheckBox)17 FacadeProvider (de.symeda.sormas.api.FacadeProvider)17 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)17 DateComparisonValidator (de.symeda.sormas.ui.utils.DateComparisonValidator)17 CommunityReferenceDto (de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto)16 AbstractEditForm (de.symeda.sormas.ui.utils.AbstractEditForm)16 Field (com.vaadin.v7.ui.Field)15 FieldVisibilityCheckers (de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers)15 Captions (de.symeda.sormas.api.i18n.Captions)14