use of io.imunity.furms.ui.project.ProjectViewModel in project furms by unity-idm.
the class SettingsView method createUpdateButton.
private Button createUpdateButton() {
Button updateButton = new Button(getTranslation("view.project-admin.settings.button.update"));
updateButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
updateButton.addClickListener(x -> {
binder.validate();
if (binder.isValid()) {
ProjectViewModel projectViewModel = new ProjectViewModel(binder.getBean());
ProjectAdminControlledAttributes project = new ProjectAdminControlledAttributes(projectViewModel.id, projectViewModel.description, projectViewModel.researchField, projectViewModel.logo);
getResultOrException(() -> projectService.update(project)).getException().ifPresentOrElse(e -> showErrorNotification(getTranslation("base.error.message")), () -> {
if (isLogoChange(oldProject, projectViewModel)) {
callReloadLogo(this.getClass());
}
oldProject = projectViewModel;
disableEditorMode();
showSuccessNotification(getTranslation("view.project-admin.settings.update.success"));
});
}
});
return updateButton;
}
use of io.imunity.furms.ui.project.ProjectViewModel in project furms by unity-idm.
the class ProjectFormView method setParameter.
@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
ProjectViewModel projectViewModel = ofNullable(parameter).flatMap(id -> handleExceptions(() -> resolver.resolve(id, UIContext.getCurrent().getZone()))).orElseGet(() -> new ProjectViewModel(ResourceGetter.getCurrentResourceId()));
String trans = parameter == null ? "view.community-admin.project.form.parameter.new" : "view.community-admin.project.form.parameter.update";
breadCrumbParameter = new BreadCrumbParameter(parameter, getTranslation(trans));
projectFormComponent.setFormPools(projectViewModel);
}
use of io.imunity.furms.ui.project.ProjectViewModel in project furms by unity-idm.
the class ProjectFormView method saveProject.
private void saveProject() {
ProjectViewModel projectViewModel = binder.getBean();
Project project = ProjectViewModelMapper.map(projectViewModel);
OptionalException<Void> optionalException;
if (project.getId() == null)
optionalException = getResultOrException(() -> {
projectService.create(project);
});
else
optionalException = getResultOrException(() -> projectService.update(project));
optionalException.getException().ifPresentOrElse(throwable -> NotificationUtils.showErrorNotification(getTranslation(throwable.getMessage())), () -> UI.getCurrent().navigate(ProjectsView.class));
}
Aggregations