Search in sources :

Example 21 with Item

use of de.symeda.sormas.app.component.Item in project SORMAS-Project by hzi-braunschweig.

the class CampaignFormDataListActivity method campaignFormMetasToItems.

private List<Item> campaignFormMetasToItems(List<CampaignFormMeta> campaignFormMetas) {
    List<Item> listOut = new ArrayList<>();
    listOut.add(new Item<Integer>("", null));
    for (CampaignFormMeta campaignFormMeta : campaignFormMetas) {
        listOut.add(new Item<>(campaignFormMeta.getFormName(), campaignFormMeta));
    }
    return listOut;
}
Also used : PageMenuItem(de.symeda.sormas.app.component.menu.PageMenuItem) Item(de.symeda.sormas.app.component.Item) ArrayList(java.util.ArrayList) CampaignFormMeta(de.symeda.sormas.app.backend.campaign.form.CampaignFormMeta)

Example 22 with Item

use of de.symeda.sormas.app.component.Item in project SORMAS-Project by hzi-braunschweig.

the class TaskListActivity method addFiltersToPageMenu.

@Override
public void addFiltersToPageMenu() {
    View taskListFilterView = getLayoutInflater().inflate(R.layout.filter_task_list_layout, null);
    FilterTaskListLayoutBinding taskListFilterBinding = DataBindingUtil.bind(taskListFilterView);
    List<Item> taskAssigneeList = DataUtils.getEnumItems(TaskAssignee.class, false);
    taskListFilterBinding.taskAssignee.initializeSpinner(taskAssigneeList);
    pageMenu.addFilter(taskListFilterView);
    taskListFilterBinding.taskAssignee.addValueChangedListener(e -> {
        if (model.getTaskCriteria().getTaskAssignee() != e.getValue()) {
            showPreloader();
            model.getTaskCriteria().taskAssignee((TaskAssignee) e.getValue());
            model.notifyCriteriaUpdated();
        }
    });
}
Also used : PageMenuItem(de.symeda.sormas.app.component.menu.PageMenuItem) Item(de.symeda.sormas.app.component.Item) FilterTaskListLayoutBinding(de.symeda.sormas.app.databinding.FilterTaskListLayoutBinding) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 23 with Item

use of de.symeda.sormas.app.component.Item in project SORMAS-Project by hzi-braunschweig.

the class DataUtils method getMonthItems.

public static List<Item> getMonthItems() {
    List<Item> listOut = new ArrayList<>();
    listOut.add(new Item<Integer>("", null));
    for (Month month : Month.values()) {
        listOut.add(new Item<Integer>(I18nProperties.getEnumCaption(month), month.ordinal()));
    }
    return listOut;
}
Also used : Item(de.symeda.sormas.app.component.Item) Month(de.symeda.sormas.api.Month) ArrayList(java.util.ArrayList)

Example 24 with Item

use of de.symeda.sormas.app.component.Item in project SORMAS-Project by hzi-braunschweig.

the class InfrastructureDaoHelper method initializeRegionAreaFields.

public static void initializeRegionAreaFields(final ControlSpinnerField areaField, List<Item> initialAreas, Area initialArea, final ControlSpinnerField regionField, List<Item> initialRegions, Region initialRegion, final ControlSpinnerField districtField, List<Item> initialDistricts, District initialDistrict, final ControlSpinnerField communityField, List<Item> initialCommunities, Community initialCommunity) {
    Item areaItem = initialArea != null ? DataUtils.toItem(initialArea) : null;
    Item regionItem = initialRegion != null ? DataUtils.toItem(initialRegion) : null;
    Item districtItem = initialDistrict != null ? DataUtils.toItem(initialDistrict) : null;
    Item communityItem = initialCommunity != null ? DataUtils.toItem(initialCommunity) : null;
    if (areaItem != null && !initialAreas.contains(areaItem)) {
        initialAreas.add(areaItem);
    }
    if (regionItem != null && !initialRegions.contains(regionItem)) {
        initialRegions.add(regionItem);
    }
    if (districtItem != null && !initialDistricts.contains(districtItem)) {
        initialDistricts.add(districtItem);
    }
    if (communityItem != null && !initialCommunities.contains(communityItem)) {
        initialCommunities.add(communityItem);
    }
    areaField.initializeSpinner(initialAreas, field -> {
        Area selectedArea = (Area) field.getValue();
        if (selectedArea != null) {
            List<Item> newRegions = loadRegionsByArea(selectedArea);
            if (initialRegion != null && selectedArea.equals(initialRegion.getArea()) && !newRegions.contains(regionItem)) {
                newRegions.add(regionItem);
            }
            regionField.setSpinnerData(newRegions, regionField.getValue());
        } else {
            regionField.setSpinnerData(null);
        }
    });
    regionField.initializeSpinner(initialRegions, field -> {
        Region selectedRegion = (Region) field.getValue();
        if (selectedRegion != null) {
            List<Item> newDistricts = loadDistricts(selectedRegion);
            if (initialDistrict != null && selectedRegion.equals(initialDistrict.getRegion()) && !newDistricts.contains(districtItem)) {
                newDistricts.add(districtItem);
            }
            districtField.setSpinnerData(newDistricts, districtField.getValue());
            areaField.setValue(selectedRegion.getArea());
        } else {
            districtField.setSpinnerData(null);
        }
    });
    if (communityField != null) {
        districtField.initializeSpinner(initialDistricts, field -> {
            District selectedDistrict = (District) field.getValue();
            if (selectedDistrict != null) {
                List<Item> newCommunities = loadCommunities(selectedDistrict);
                if (initialCommunity != null && selectedDistrict.equals(initialCommunity.getDistrict()) && !newCommunities.contains(communityItem)) {
                    newCommunities.add(communityItem);
                }
                communityField.setSpinnerData(newCommunities, communityField.getValue());
            } else {
                communityField.setSpinnerData(null);
            }
        });
    } else {
        districtField.initializeSpinner(initialDistricts);
    }
    if (communityField != null) {
        communityField.initializeSpinner(initialCommunities);
    }
}
Also used : Item(de.symeda.sormas.app.component.Item) Area(de.symeda.sormas.app.backend.region.Area) Region(de.symeda.sormas.app.backend.region.Region) District(de.symeda.sormas.app.backend.region.District)

Example 25 with Item

use of de.symeda.sormas.app.component.Item in project SORMAS-Project by hzi-braunschweig.

the class InfrastructureFieldsDependencyHandler method handleCommunityChange.

public void handleCommunityChange(ControlPropertyField communityField, ControlSpinnerField districtField, ControlSpinnerField facilityField, ControlSpinnerField typeField, Facility initialFacility) {
    Item facilityItem = initialFacility != null ? DataUtils.toItem(initialFacility) : null;
    Community selectedCommunity = (Community) communityField.getValue();
    District selectedDistrict = (District) districtField.getValue();
    final List<Item> newFacilities;
    if (selectedCommunity != null && typeField == null) {
        newFacilities = loadFacilities(null, selectedCommunity, FacilityType.HOSPITAL);
        if (initialFacility != null && selectedCommunity.equals(initialFacility.getCommunity()) && !newFacilities.contains(facilityItem)) {
            newFacilities.add(facilityItem);
        }
    } else if (selectedCommunity != null && typeField.getValue() != null) {
        newFacilities = loadFacilities(null, selectedCommunity, (FacilityType) typeField.getValue());
        if (initialFacility != null && selectedCommunity.equals(initialFacility.getCommunity()) && !newFacilities.contains(facilityItem)) {
            newFacilities.add(facilityItem);
        }
    } else {
        if (!isEmptyDistrict(selectedDistrict) && typeField == null) {
            newFacilities = loadFacilities(selectedDistrict, null, FacilityType.HOSPITAL);
            if (initialFacility != null && selectedDistrict.equals(initialFacility.getDistrict()) && !newFacilities.contains(facilityItem)) {
                newFacilities.add(facilityItem);
            }
        } else if (!isEmptyDistrict(selectedDistrict) && typeField.getValue() != null) {
            newFacilities = loadFacilities(selectedDistrict, null, (FacilityType) typeField.getValue());
            if (initialFacility != null && selectedDistrict.equals(initialFacility.getDistrict()) && !newFacilities.contains(facilityItem)) {
                newFacilities.add(facilityItem);
            }
        } else {
            newFacilities = itemsWithEmpty();
            if (initialFacility != null && !newFacilities.contains(facilityItem)) {
                newFacilities.add(facilityItem);
            }
        }
    }
    Facility selectedFacility = (Facility) facilityField.getValue();
    if (selectedFacility == null) {
        facilityField.setSpinnerData(addUnknownItem(newFacilities, unknownFacility));
    } else {
        if (isEmptyFacility(selectedFacility) && !isEmptyFacility(initialFacility) && !isEmptyDistrict(selectedDistrict)) {
            selectedFacility = null;
        }
        facilityField.setSpinnerData(addUnknownItem(newFacilities, unknownFacility), selectedFacility);
    }
}
Also used : Item(de.symeda.sormas.app.component.Item) Facility(de.symeda.sormas.app.backend.facility.Facility) InfrastructureDaoHelper.unknownFacility(de.symeda.sormas.app.util.InfrastructureDaoHelper.unknownFacility) InfrastructureDaoHelper.isUnknownFacility(de.symeda.sormas.app.util.InfrastructureDaoHelper.isUnknownFacility) InfrastructureDaoHelper.isEmptyFacility(de.symeda.sormas.app.util.InfrastructureDaoHelper.isEmptyFacility) InfrastructureDaoHelper.isEmptyDistrict(de.symeda.sormas.app.util.InfrastructureDaoHelper.isEmptyDistrict) InfrastructureDaoHelper.isUnknownDistrict(de.symeda.sormas.app.util.InfrastructureDaoHelper.isUnknownDistrict) InfrastructureDaoHelper.unknownDistrict(de.symeda.sormas.app.util.InfrastructureDaoHelper.unknownDistrict) District(de.symeda.sormas.app.backend.region.District) Community(de.symeda.sormas.app.backend.region.Community) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType)

Aggregations

Item (de.symeda.sormas.app.component.Item)29 View (android.view.View)7 PageMenuItem (de.symeda.sormas.app.component.menu.PageMenuItem)7 District (de.symeda.sormas.app.backend.region.District)6 ArrayList (java.util.ArrayList)6 AdapterView (android.widget.AdapterView)5 RecyclerView (androidx.recyclerview.widget.RecyclerView)5 Facility (de.symeda.sormas.app.backend.facility.Facility)5 InfrastructureDaoHelper.isEmptyDistrict (de.symeda.sormas.app.util.InfrastructureDaoHelper.isEmptyDistrict)5 InfrastructureDaoHelper.isUnknownDistrict (de.symeda.sormas.app.util.InfrastructureDaoHelper.isUnknownDistrict)5 InfrastructureDaoHelper.unknownDistrict (de.symeda.sormas.app.util.InfrastructureDaoHelper.unknownDistrict)5 FacilityType (de.symeda.sormas.api.infrastructure.facility.FacilityType)4 InfrastructureDaoHelper.isEmptyFacility (de.symeda.sormas.app.util.InfrastructureDaoHelper.isEmptyFacility)4 InfrastructureDaoHelper.isUnknownFacility (de.symeda.sormas.app.util.InfrastructureDaoHelper.isUnknownFacility)4 InfrastructureDaoHelper.unknownFacility (de.symeda.sormas.app.util.InfrastructureDaoHelper.unknownFacility)4 TypeOfPlace (de.symeda.sormas.api.event.TypeOfPlace)3 PresentCondition (de.symeda.sormas.api.person.PresentCondition)3 Region (de.symeda.sormas.app.backend.region.Region)3 TextView (android.widget.TextView)2 FacilityTypeGroup (de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup)2