Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close upload dialog on navigation change #993

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import com.vaadin.flow.dom.Style.Visibility;
import com.vaadin.flow.router.BeforeEnterEvent;
import com.vaadin.flow.router.BeforeEnterObserver;
import com.vaadin.flow.router.BeforeLeaveEvent;
import com.vaadin.flow.router.BeforeLeaveObserver;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.spring.annotation.SpringComponent;
import com.vaadin.flow.spring.annotation.UIScope;
Expand Down Expand Up @@ -50,6 +52,7 @@
import life.qbic.logging.api.Logger;
import life.qbic.logging.service.LoggerFactory;
import life.qbic.projectmanagement.application.ProjectInformationService;
import life.qbic.projectmanagement.application.measurement.MeasurementMetadata;
import life.qbic.projectmanagement.application.measurement.MeasurementService;
import life.qbic.projectmanagement.application.measurement.MeasurementService.MeasurementDeletionException;
import life.qbic.projectmanagement.application.measurement.validation.MeasurementValidationService;
Expand All @@ -76,7 +79,7 @@
@UIScope
@Route(value = "projects/:projectId?/experiments/:experimentId?/measurements", layout = ExperimentMainLayout.class)
@PermitAll
public class MeasurementMain extends Main implements BeforeEnterObserver {
public class MeasurementMain extends Main implements BeforeEnterObserver, BeforeLeaveObserver {

public static final String PROJECT_ID_ROUTE_PARAMETER = "projectId";
public static final String EXPERIMENT_ID_ROUTE_PARAMETER = "experimentId";
Expand All @@ -103,6 +106,7 @@ public class MeasurementMain extends Main implements BeforeEnterObserver {
private final transient ProjectInformationService projectInformationService;
private final transient CancelConfirmationDialogFactory cancelConfirmationDialogFactory;
private final transient MessageSourceNotificationFactory messageFactory;
private MeasurementMetadataUploadDialog dialog;
private transient Context context;

public MeasurementMain(
Expand Down Expand Up @@ -157,7 +161,6 @@ public MeasurementMain(
getClass().getSimpleName(), System.identityHashCode(this),
measurementTemplateListComponent.getClass().getSimpleName(),
System.identityHashCode(measurementTemplateListComponent)));

}

private static String convertErrorCodeToMessage(MeasurementService.ErrorCode errorCode) {
Expand Down Expand Up @@ -359,7 +362,7 @@ private void triggerMeasurementRegistration(
}

private void openEditMeasurementDialog() {
var dialog = new MeasurementMetadataUploadDialog(measurementValidationService,
this.dialog = new MeasurementMetadataUploadDialog(measurementValidationService,
cancelConfirmationDialogFactory,
MODE.EDIT,
context.projectId().orElse(null));
Expand Down Expand Up @@ -601,4 +604,10 @@ static class HandledException extends RuntimeException {
}

}

@Override
public void beforeLeave(BeforeLeaveEvent event) {
Optional.ofNullable(this.dialog).ifPresent(Dialog::close);
}

}
Loading