Search in sources :

Example 1 with LocationDialog

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

the class PersonEditFragment method setUpControlListeners.

private void setUpControlListeners() {
    onAddressItemClickListener = (v, item) -> {
        final Location address = (Location) item;
        final Location addressClone = (Location) address.clone();
        final LocationDialog dialog = new LocationDialog(BaseActivity.getActiveActivity(), addressClone, null);
        dialog.setPositiveCallback(() -> {
            record.getAddresses().set(record.getAddresses().indexOf(address), addressClone);
            updateAddresses();
        });
        dialog.setDeleteCallback(() -> {
            removeAddress(address);
            dialog.dismiss();
        });
        dialog.show();
        dialog.configureAsPersonAddressDialog(true);
    };
    onPersonContactDetailItemClickListener = (v, item) -> {
        final PersonContactDetail personContactDetail = (PersonContactDetail) item;
        final PersonContactDetail personContactDetailClone = (PersonContactDetail) personContactDetail.clone();
        final PersonContactDetailDialog dialog = new PersonContactDetailDialog(BaseActivity.getActiveActivity(), personContactDetailClone, record, getActivityRootData(), false);
        dialog.setPositiveCallback(() -> checkExistingPrimaryContactDetails(personContactDetailClone, dialog, () -> {
            record.getPersonContactDetails().set(record.getPersonContactDetails().indexOf(personContactDetail), personContactDetailClone);
            updatePersonContactDetails();
        }));
        dialog.setDeleteCallback(() -> {
            removePersonContactDetail(personContactDetail);
            dialog.dismiss();
        });
        dialog.show();
        dialog.configureAsPersonContactDetailDialog(true);
    };
    getContentBinding().btnAddAddress.setOnClickListener(v -> {
        final Location address = DatabaseHelper.getLocationDao().build();
        final LocationDialog dialog = new LocationDialog(BaseActivity.getActiveActivity(), address, null);
        dialog.setPositiveCallback(() -> addAddress(address));
        dialog.show();
        dialog.configureAsPersonAddressDialog(false);
    });
    getContentBinding().btnAddPersonContactDetail.setOnClickListener(v -> {
        final PersonContactDetail personContactDetail = DatabaseHelper.getPersonContactDetailDao().build();
        final PersonContactDetailDialog dialog = new PersonContactDetailDialog(BaseActivity.getActiveActivity(), personContactDetail, record, getActivityRootData(), true);
        dialog.setPositiveCallback(() -> checkExistingPrimaryContactDetails(personContactDetail, dialog, () -> {
            record.getPersonContactDetails().add(0, personContactDetail);
            updatePersonContactDetails();
        }));
        dialog.show();
        dialog.configureAsPersonContactDetailDialog(false);
    });
}
Also used : LocationDialog(de.symeda.sormas.app.component.dialog.LocationDialog) PersonContactDetail(de.symeda.sormas.app.backend.person.PersonContactDetail) Location(de.symeda.sormas.app.backend.location.Location) PersonContactDetailDialog(de.symeda.sormas.app.person.PersonContactDetailDialog)

Example 2 with LocationDialog

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

the class PersonEditFragment method openAddressPopup.

private static void openAddressPopup(final Person record, final BaseEditFragment fragment, final FragmentPersonEditLayoutBinding contentBinding) {
    final Location location = record.getAddress();
    final Location locationClone = (Location) location.clone();
    final LocationDialog locationDialog = new LocationDialog(BaseActivity.getActiveActivity(), locationClone, fragment.getFieldAccessCheckers());
    locationDialog.show();
    locationDialog.setPositiveCallback(() -> {
        contentBinding.personAddress.setValue(locationClone);
        record.setAddress(locationClone);
    });
}
Also used : LocationDialog(de.symeda.sormas.app.component.dialog.LocationDialog) Location(de.symeda.sormas.app.backend.location.Location)

Example 3 with LocationDialog

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

the class ActivityAsCaseDialog method openAddressPopup.

private void openAddressPopup() {
    final Location location = (Location) contentBinding.activityAsCaseLocation.getValue();
    final Location locationClone = (Location) location.clone();
    final LocationDialog locationDialog = new LocationDialog(BaseActivity.getActiveActivity(), locationClone, fieldAccessCheckers);
    locationDialog.show();
    locationDialog.setFacilityFieldsVisible(TypeOfPlace.isFacilityType(data.getTypeOfPlace()), true);
    locationDialog.updateContinentFieldsVisibility();
    locationDialog.setPositiveCallback(() -> {
        contentBinding.activityAsCaseLocation.setValue(locationClone);
        data.setLocation(locationClone);
        if (FacilityTypeGroup.WORKING_PLACE != locationDialog.getContentBinding().facilityTypeGroup.getValue()) {
            contentBinding.activityAsCaseWorkEnvironment.setValue(null);
            contentBinding.activityAsCaseWorkEnvironment.setVisibility(View.GONE);
        } else {
            contentBinding.activityAsCaseWorkEnvironment.setVisibility(View.VISIBLE);
        }
    });
}
Also used : LocationDialog(de.symeda.sormas.app.component.dialog.LocationDialog) Location(de.symeda.sormas.app.backend.location.Location)

Example 4 with LocationDialog

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

the class ExposureDialog method openAddressPopup.

private void openAddressPopup() {
    final Location location = (Location) contentBinding.exposureLocation.getValue();
    final Location locationClone = (Location) location.clone();
    final LocationDialog locationDialog = new LocationDialog(BaseActivity.getActiveActivity(), locationClone, fieldAccessCheckers);
    locationDialog.show();
    locationDialog.setFacilityFieldsVisible(data.getTypeOfPlace() == TypeOfPlace.FACILITY, true);
    locationDialog.updateContinentFieldsVisibility();
    locationDialog.setPositiveCallback(() -> {
        contentBinding.exposureLocation.setValue(locationClone);
        data.setLocation(locationClone);
        if (FacilityTypeGroup.WORKING_PLACE != locationDialog.getContentBinding().facilityTypeGroup.getValue()) {
            contentBinding.exposureWorkEnvironment.setValue(null);
            contentBinding.exposureWorkEnvironment.setVisibility(View.GONE);
        } else {
            contentBinding.exposureWorkEnvironment.setVisibility(View.VISIBLE);
        }
    });
}
Also used : LocationDialog(de.symeda.sormas.app.component.dialog.LocationDialog) Location(de.symeda.sormas.app.backend.location.Location)

Example 5 with LocationDialog

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

the class EventEditFragment method openAddressPopup.

private void openAddressPopup(final FragmentEventEditLayoutBinding contentBinding) {
    final Location location = record.getEventLocation();
    final Location locationClone = (Location) location.clone();
    final LocationDialog locationDialog = new LocationDialog(BaseActivity.getActiveActivity(), locationClone, false, null);
    locationDialog.show();
    if (DatabaseHelper.getEventDao().hasAnyEventParticipantWithoutJurisdiction(record.getUuid())) {
        locationDialog.getContentBinding().locationRegion.setRequired(true);
        locationDialog.getContentBinding().locationDistrict.setRequired(true);
        locationDialog.getContentBinding().locationCountry.setEnabled(false);
    } else {
        locationDialog.setRequiredFieldsBasedOnCountry();
    }
    locationDialog.setFacilityFieldsVisible(record.getTypeOfPlace() == TypeOfPlace.FACILITY, true);
    locationDialog.setPositiveCallback(() -> {
        try {
            FragmentValidator.validate(getContext(), locationDialog.getContentBinding());
            contentBinding.eventEventLocation.setValue(locationClone);
            record.setEventLocation(locationClone);
            if (FacilityTypeGroup.WORKING_PLACE != locationDialog.getContentBinding().facilityTypeGroup.getValue()) {
                contentBinding.eventWorkEnvironment.setValue(null);
                contentBinding.eventWorkEnvironment.setVisibility(View.GONE);
            } else {
                contentBinding.eventWorkEnvironment.setVisibility(View.VISIBLE);
            }
            locationDialog.dismiss();
        } catch (ValidationException e) {
            NotificationHelper.showDialogNotification(locationDialog, ERROR, e.getMessage());
        }
    });
}
Also used : ValidationException(de.symeda.sormas.api.utils.ValidationException) LocationDialog(de.symeda.sormas.app.component.dialog.LocationDialog) Location(de.symeda.sormas.app.backend.location.Location)

Aggregations

Location (de.symeda.sormas.app.backend.location.Location)5 LocationDialog (de.symeda.sormas.app.component.dialog.LocationDialog)5 ValidationException (de.symeda.sormas.api.utils.ValidationException)1 PersonContactDetail (de.symeda.sormas.app.backend.person.PersonContactDetail)1 PersonContactDetailDialog (de.symeda.sormas.app.person.PersonContactDetailDialog)1