use of de.symeda.sormas.ui.utils.components.automaticdeletion.AutomaticDeletionLabel in project SORMAS-Project by hzi-braunschweig.
the class ImmunizationController method getImmunizationDataEditComponent.
public CommitDiscardWrapperComponent<ImmunizationDataForm> getImmunizationDataEditComponent(ImmunizationDto immunizationDto) {
ImmunizationDataForm immunizationDataForm = new ImmunizationDataForm(immunizationDto.isPseudonymized(), immunizationDto.getRelatedCase());
immunizationDataForm.setValue(immunizationDto);
UserProvider currentUserProvider = UserProvider.getCurrent();
CommitDiscardWrapperComponent<ImmunizationDataForm> editComponent = new CommitDiscardWrapperComponent<ImmunizationDataForm>(immunizationDataForm, currentUserProvider != null && currentUserProvider.hasUserRight(UserRight.IMMUNIZATION_EDIT), immunizationDataForm.getFieldGroup()) {
@Override
public void discard() {
immunizationDataForm.discard();
super.discard();
}
};
AutomaticDeletionInfoDto automaticDeletionInfoDto = FacadeProvider.getImmunizationFacade().getAutomaticDeletionInfo(immunizationDto.getUuid());
if (automaticDeletionInfoDto != null) {
editComponent.getButtonsPanel().addComponentAsFirst(new AutomaticDeletionLabel(automaticDeletionInfoDto));
}
editComponent.addCommitListener(() -> {
if (!immunizationDataForm.getFieldGroup().isModified()) {
ImmunizationDto immunizationDtoValue = immunizationDataForm.getValue();
List<ImmunizationDto> similarImmunizations = findSimilarImmunizations(immunizationDtoValue);
if (similarImmunizations.isEmpty()) {
FacadeProvider.getImmunizationFacade().save(immunizationDtoValue);
if (immunizationDtoValue.getImmunizationStatus() == ImmunizationStatus.ACQUIRED) {
NotificationHelper.showNotification(I18nProperties.getString(Strings.messageImmunizationSavedVaccinationStatusUpdated), Notification.Type.WARNING_MESSAGE, -1);
} else {
Notification.show(I18nProperties.getString(Strings.messageImmunizationSaved), Notification.Type.WARNING_MESSAGE);
}
SormasUI.refreshView();
} else {
showSimilarImmunizationPopup(immunizationDtoValue, similarImmunizations.get(0), this::saveImmunization);
}
}
});
// Initialize 'Delete' button
if (UserProvider.getCurrent().hasUserRight(UserRight.IMMUNIZATION_DELETE)) {
editComponent.addDeleteListener(() -> {
FacadeProvider.getImmunizationFacade().deleteImmunization(immunizationDto.getUuid());
UI.getCurrent().getNavigator().navigateTo(ImmunizationsView.VIEW_NAME);
}, I18nProperties.getString(Strings.entityImmunization));
}
// Initialize 'Archive' button
if (UserProvider.getCurrent().hasUserRight(UserRight.IMMUNIZATION_ARCHIVE)) {
boolean archived = FacadeProvider.getImmunizationFacade().isArchived(immunizationDto.getUuid());
Button archiveButton = ButtonHelper.createButton(archived ? Captions.actionDearchive : Captions.actionArchive, e -> {
if (editComponent.isModified()) {
editComponent.commit();
}
if (archived) {
ControllerProvider.getArchiveController().dearchiveEntity(immunizationDto, FacadeProvider.getImmunizationFacade(), Strings.headingDearchiveImmunization, Strings.confirmationDearchiveImmunization, Strings.entityImmunization, Strings.messageImmunizationDearchived, () -> navigateToImmunization(immunizationDto.getUuid()));
} else {
ControllerProvider.getArchiveController().archiveEntity(immunizationDto, FacadeProvider.getImmunizationFacade(), Strings.headingArchiveImmunization, Strings.confirmationArchiveImmunization, Strings.entityImmunization, Strings.messageImmunizationArchived, () -> navigateToImmunization(immunizationDto.getUuid()));
}
}, ValoTheme.BUTTON_LINK);
editComponent.getButtonsPanel().addComponentAsFirst(archiveButton);
editComponent.getButtonsPanel().setComponentAlignment(archiveButton, Alignment.BOTTOM_LEFT);
}
return editComponent;
}
use of de.symeda.sormas.ui.utils.components.automaticdeletion.AutomaticDeletionLabel in project SORMAS-Project by hzi-braunschweig.
the class CaseController method getCaseDataEditComponent.
// public CommitDiscardWrapperComponent<? extends Component> getCaseCombinedEditComponent(final String caseUuid,
// final ViewMode viewMode) {
//
// CaseDataDto caze = findCase(caseUuid);
// PersonDto person = FacadeProvider.getPersonFacade().getPersonByUuid(caze.getPerson().getUuid());
//
// CaseDataForm caseEditForm = new CaseDataForm(person, caze.getDisease(), viewMode);
// caseEditForm.setValue(caze);
//
// HospitalizationForm hospitalizationForm = new HospitalizationForm(caze, viewMode);
// hospitalizationForm.setValue(caze.getHospitalization());
//
// SymptomsForm symptomsForm = new SymptomsForm(caze, caze.getDisease(), person, SymptomsContext.CASE, viewMode);
// symptomsForm.setValue(caze.getSymptoms());
//
// EpiDataForm epiDataForm = new EpiDataForm(caze.getDisease(), viewMode);
// epiDataForm.setValue(caze.getEpiData());
//
// CommitDiscardWrapperComponent<? extends Component> editView = AbstractEditForm
// .buildCommitDiscardWrapper(caseEditForm, hospitalizationForm, symptomsForm, epiDataForm);
//
// editView.addCommitListener(new CommitListener() {
// @Override
// public void onCommit() {
// CaseDataDto cazeDto = caseEditForm.getValue();
// cazeDto.setHospitalization(hospitalizationForm.getValue());
// cazeDto.setSymptoms(symptomsForm.getValue());
// cazeDto.setEpiData(epiDataForm.getValue());
//
// saveCase(cazeDto);
// }
// });
//
// appendSpecialCommands(caze, editView);
//
// return editView;
// }
public CommitDiscardWrapperComponent<CaseDataForm> getCaseDataEditComponent(final String caseUuid, final ViewMode viewMode) {
CaseDataDto caze = findCase(caseUuid);
AutomaticDeletionInfoDto automaticDeletionInfoDto = FacadeProvider.getCaseFacade().getAutomaticDeletionInfo(caseUuid);
CaseDataForm caseEditForm = new CaseDataForm(caseUuid, FacadeProvider.getPersonFacade().getPersonByUuid(caze.getPerson().getUuid()), caze.getDisease(), caze.getSymptoms(), viewMode, caze.isPseudonymized());
caseEditForm.setValue(caze);
CommitDiscardWrapperComponent<CaseDataForm> editView = new CommitDiscardWrapperComponent<CaseDataForm>(caseEditForm, UserProvider.getCurrent().hasUserRight(UserRight.CASE_EDIT), caseEditForm.getFieldGroup());
if (automaticDeletionInfoDto != null) {
editView.getButtonsPanel().addComponentAsFirst(new AutomaticDeletionLabel(automaticDeletionInfoDto));
}
editView.addCommitListener(() -> {
CaseDataDto oldCase = findCase(caseUuid);
CaseDataDto cazeDto = caseEditForm.getValue();
saveCaseWithFacilityChangedPrompt(cazeDto, oldCase);
});
editView.addDiscardListener(() -> caseEditForm.onDiscard());
appendSpecialCommands(caze, editView);
return editView;
}
use of de.symeda.sormas.ui.utils.components.automaticdeletion.AutomaticDeletionLabel in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantsController method getEventParticipantDataEditComponent.
public CommitDiscardWrapperComponent<?> getEventParticipantDataEditComponent(String eventParticipantUuid) {
final EventParticipantDto eventParticipant = FacadeProvider.getEventParticipantFacade().getEventParticipantByUuid(eventParticipantUuid);
final EventDto event = FacadeProvider.getEventFacade().getEventByUuid(eventParticipant.getEvent().getUuid(), false);
AutomaticDeletionInfoDto automaticDeletionInfoDto = FacadeProvider.getEventParticipantFacade().getAutomaticDeletionInfo(eventParticipantUuid);
final EventParticipantEditForm editForm = new EventParticipantEditForm(event, eventParticipant.isPseudonymized(), eventParticipant.getPerson().isPseudonymized(), false);
editForm.setValue(eventParticipant);
editForm.setWidth(100, Unit.PERCENTAGE);
final CommitDiscardWrapperComponent<EventParticipantEditForm> editComponent = createEventParticipantEditCommitWrapper(editForm, null);
if (automaticDeletionInfoDto != null) {
editComponent.getButtonsPanel().addComponentAsFirst(new AutomaticDeletionLabel(automaticDeletionInfoDto));
}
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTPARTICIPANT_DELETE)) {
editComponent.addDeleteListener(() -> {
FacadeProvider.getEventParticipantFacade().deleteEventParticipant(eventParticipant.toReference());
ControllerProvider.getEventController().navigateToParticipants(eventParticipant.getEvent().getUuid());
}, I18nProperties.getString(Strings.entityEventParticipant));
}
// Initialize 'Archive' button
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTPARTICIPANT_ARCHIVE)) {
boolean archived = FacadeProvider.getEventParticipantFacade().isArchived(eventParticipant.getUuid());
Button archiveButton = ButtonHelper.createButton(archived ? Captions.actionDearchive : Captions.actionArchive, e -> {
if (editComponent.isModified()) {
editComponent.commit();
}
if (archived) {
ControllerProvider.getArchiveController().dearchiveEntity(eventParticipant, FacadeProvider.getEventParticipantFacade(), Strings.headingDearchiveEventParticipant, Strings.confirmationDearchiveEventParticipant, Strings.entityEventParticipant, Strings.messageEventParticipantDearchived, () -> navigateToData(eventParticipant.getUuid()));
} else {
ControllerProvider.getArchiveController().archiveEntity(eventParticipant, FacadeProvider.getEventParticipantFacade(), Strings.headingArchiveEventParticipant, Strings.confirmationArchiveEventParticipant, Strings.entityEventParticipant, Strings.messageEventParticipantArchived, () -> navigateToData(eventParticipant.getUuid()));
}
}, ValoTheme.BUTTON_LINK);
editComponent.getButtonsPanel().addComponentAsFirst(archiveButton);
editComponent.getButtonsPanel().setComponentAlignment(archiveButton, Alignment.BOTTOM_LEFT);
}
return editComponent;
}
use of de.symeda.sormas.ui.utils.components.automaticdeletion.AutomaticDeletionLabel in project SORMAS-Project by hzi-braunschweig.
the class EventController method getEventDataEditComponent.
public CommitDiscardWrapperComponent<EventDataForm> getEventDataEditComponent(final String eventUuid, Consumer<EventStatus> saveCallback) {
EventDto event = findEvent(eventUuid);
AutomaticDeletionInfoDto automaticDeletionInfoDto = FacadeProvider.getEventFacade().getAutomaticDeletionInfo(eventUuid);
EventDataForm eventEditForm = new EventDataForm(false, event.isPseudonymized());
eventEditForm.setValue(event);
final CommitDiscardWrapperComponent<EventDataForm> editView = new CommitDiscardWrapperComponent<EventDataForm>(eventEditForm, UserProvider.getCurrent().hasUserRight(UserRight.EVENT_EDIT), eventEditForm.getFieldGroup());
if (automaticDeletionInfoDto != null) {
editView.getButtonsPanel().addComponentAsFirst(new AutomaticDeletionLabel(automaticDeletionInfoDto));
}
editView.addCommitListener(() -> {
if (!eventEditForm.getFieldGroup().isModified()) {
EventDto eventDto = eventEditForm.getValue();
final UserDto user = UserProvider.getCurrent().getUser();
final RegionReferenceDto userRegion = user.getRegion();
final DistrictReferenceDto userDistrict = user.getDistrict();
final RegionReferenceDto epEventRegion = eventDto.getEventLocation().getRegion();
final DistrictReferenceDto epEventDistrict = eventDto.getEventLocation().getDistrict();
final Boolean eventOutsideJurisdiction = (userRegion != null && !userRegion.equals(epEventRegion) || userDistrict != null && !userDistrict.equals(epEventDistrict));
if (eventOutsideJurisdiction) {
VaadinUiUtil.showConfirmationPopup(I18nProperties.getString(Strings.headingEventJurisdictionUpdated), new Label(I18nProperties.getString(Strings.messageEventJurisdictionUpdated)), I18nProperties.getString(Strings.yes), I18nProperties.getString(Strings.no), 500, confirmed -> {
if (confirmed) {
saveEvent(saveCallback, eventDto);
}
});
} else {
saveEvent(saveCallback, eventDto);
}
}
});
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_DELETE)) {
editView.addDeleteListener(() -> {
if (!existEventParticipantsLinkedToEvent(event)) {
try {
FacadeProvider.getEventFacade().deleteEvent(event.getUuid());
} catch (ExternalSurveillanceToolException e) {
Notification.show(String.format(I18nProperties.getString(Strings.ExternalSurveillanceToolGateway_notificationEntryNotDeleted), DataHelper.getShortUuid(event.getUuid())), "", Type.ERROR_MESSAGE);
}
} else {
VaadinUiUtil.showSimplePopupWindow(I18nProperties.getString(Strings.headingEventNotDeleted), I18nProperties.getString(Strings.messageEventsNotDeletedReason));
}
UI.getCurrent().getNavigator().navigateTo(EventsView.VIEW_NAME);
}, I18nProperties.getString(Strings.entityEvent));
}
// Initialize 'Archive' button
if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_ARCHIVE)) {
boolean archived = FacadeProvider.getEventFacade().isArchived(eventUuid);
Button archiveEventButton = ButtonHelper.createButton(archived ? Captions.actionDearchive : Captions.actionArchive, e -> {
if (editView.isModified()) {
editView.commit();
}
if (archived) {
ControllerProvider.getArchiveController().dearchiveEntity(event, FacadeProvider.getEventFacade(), Strings.headingDearchiveEvent, Strings.confirmationDearchiveEvent, Strings.entityEvent, Strings.messageEventDearchived, () -> navigateToData(event.getUuid()));
} else {
ControllerProvider.getArchiveController().archiveEntity(event, FacadeProvider.getEventFacade(), Strings.headingArchiveEvent, Strings.confirmationArchiveEvent, Strings.entityEvent, Strings.messageEventArchived, () -> navigateToData(event.getUuid()));
}
}, ValoTheme.BUTTON_LINK);
editView.getButtonsPanel().addComponentAsFirst(archiveEventButton);
editView.getButtonsPanel().setComponentAlignment(archiveEventButton, Alignment.BOTTOM_LEFT);
}
return editView;
}
use of de.symeda.sormas.ui.utils.components.automaticdeletion.AutomaticDeletionLabel in project SORMAS-Project by hzi-braunschweig.
the class TravelEntryController method getTravelEntryDataEditComponent.
public CommitDiscardWrapperComponent<TravelEntryDataForm> getTravelEntryDataEditComponent(String travelEntryUuid) {
TravelEntryDto travelEntry = findTravelEntry(travelEntryUuid);
AutomaticDeletionInfoDto automaticDeletionInfoDto = FacadeProvider.getTravelEntryFacade().getAutomaticDeletionInfo(travelEntryUuid);
TravelEntryDataForm travelEntryEditForm = new TravelEntryDataForm(travelEntryUuid, travelEntry.isPseudonymized());
travelEntryEditForm.setValue(travelEntry);
CommitDiscardWrapperComponent<TravelEntryDataForm> editComponent = new CommitDiscardWrapperComponent<>(travelEntryEditForm, UserProvider.getCurrent().hasUserRight(UserRight.TRAVEL_ENTRY_EDIT), travelEntryEditForm.getFieldGroup());
if (automaticDeletionInfoDto != null) {
editComponent.getButtonsPanel().addComponentAsFirst(new AutomaticDeletionLabel(automaticDeletionInfoDto));
}
editComponent.addCommitListener(() -> {
if (!travelEntryEditForm.getFieldGroup().isModified()) {
TravelEntryDto travelEntryDto = travelEntryEditForm.getValue();
FacadeProvider.getTravelEntryFacade().save(travelEntryDto);
Notification.show(I18nProperties.getString(Strings.messageTravelEntrySaved), Notification.Type.WARNING_MESSAGE);
SormasUI.refreshView();
}
});
editComponent.addDiscardListener(() -> travelEntryEditForm.onDiscard());
// Initialize 'Delete' button
if (UserProvider.getCurrent().hasUserRight(UserRight.TRAVEL_ENTRY_DELETE)) {
editComponent.addDeleteListener(() -> {
FacadeProvider.getTravelEntryFacade().deleteTravelEntry(travelEntry.getUuid());
UI.getCurrent().getNavigator().navigateTo(TravelEntriesView.VIEW_NAME);
}, I18nProperties.getString(Strings.entityTravel));
}
// Initialize 'Archive' button
if (UserProvider.getCurrent().hasUserRight(UserRight.TRAVEL_ENTRY_ARCHIVE)) {
boolean archived = FacadeProvider.getTravelEntryFacade().isArchived(travelEntryUuid);
Button archiveTravelEntryButton = ButtonHelper.createButton(archived ? Captions.actionDearchive : Captions.actionArchive, e -> {
if (editComponent.isModified()) {
editComponent.commit();
}
if (archived) {
ControllerProvider.getArchiveController().dearchiveEntity(travelEntry, FacadeProvider.getTravelEntryFacade(), Strings.headingDearchiveTravelEntry, Strings.confirmationDearchiveTravelEntry, Strings.entityTravel, Strings.messageTravelEntryDearchived, () -> navigateToTravelEntry(travelEntry.getUuid()));
} else {
ControllerProvider.getArchiveController().archiveEntity(travelEntry, FacadeProvider.getTravelEntryFacade(), Strings.headingArchiveTravelEntry, Strings.confirmationArchiveTravelEntry, Strings.entityTravel, Strings.messageTravelEntryArchived, () -> navigateToTravelEntry(travelEntry.getUuid()));
}
}, ValoTheme.BUTTON_LINK);
editComponent.getButtonsPanel().addComponentAsFirst(archiveTravelEntryButton);
editComponent.getButtonsPanel().setComponentAlignment(archiveTravelEntryButton, Alignment.BOTTOM_LEFT);
}
return editComponent;
}
Aggregations