Skip to content

Commit b8d0e23

Browse files
authored
Merge branch 'development' into feature/cachable-request
2 parents ee74d27 + da00c6c commit b8d0e23

File tree

5 files changed

+138
-9
lines changed

5 files changed

+138
-9
lines changed

project-management/src/main/java/life/qbic/projectmanagement/application/api/AsyncProjectService.java

+70-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
public interface AsyncProjectService {
2424

2525
/**
26-
* Submits a project update request and returns a reactive {@link Mono<ProjectUpdateResponse>}
26+
* Submits a project update request and returns a reactive {@link Mono< ProjectUpdateResponse >}
2727
* object immediately.
2828
* <p>
2929
* The method is non-blocking.
@@ -46,13 +46,18 @@ Mono<ProjectUpdateResponse> update(
4646
ProjectUpdateRequest request)
4747
throws UnknownRequestException, RequestFailedException, AccessDeniedException;
4848

49+
50+
Mono<ProjectCreationResponse> create(ProjectCreationRequest request)
51+
throws UnknownRequestException, RequestFailedException, AccessDeniedException;
52+
53+
4954
/**
5055
* Container of an update request for a service call and part of the
5156
* {@link ProjectUpdateRequest}.
5257
*
5358
* @since 1.9.0
5459
*/
55-
sealed interface UpdateRequestBody permits ProjectDesign {
60+
sealed interface UpdateRequestBody permits FundingInformation, ProjectContacts, ProjectDesign {
5661

5762
}
5863

@@ -62,7 +67,7 @@ sealed interface UpdateRequestBody permits ProjectDesign {
6267
*
6368
* @since 1.9.0
6469
*/
65-
sealed interface UpdateResponseBody permits ProjectDesign {
70+
sealed interface UpdateResponseBody permits FundingInformation, ProjectContacts, ProjectDesign {
6671

6772
}
6873

@@ -97,6 +102,68 @@ record ProjectDesign(String title, String objective) implements UpdateRequestBod
97102

98103
}
99104

105+
/**
106+
* Container for passing information about the different project contacts.
107+
*
108+
* @param investigator the principal investigator
109+
* @param manager the project manager
110+
* @param responsible the responsible person
111+
* @since 1.9.0
112+
*/
113+
record ProjectContacts(ProjectContact investigator, ProjectContact manager,
114+
ProjectContact responsible) implements UpdateRequestBody,
115+
UpdateResponseBody {
116+
117+
}
118+
119+
/**
120+
* A project contact.
121+
*
122+
* @param fullName the full name of the person
123+
* @param email a valid email address for contact
124+
* @since 1.9.0
125+
*/
126+
record ProjectContact(String fullName, String email) {
127+
128+
}
129+
130+
/**
131+
* Container for funding information of a project.
132+
*
133+
* @param grant the grant name
134+
* @param grantId the grant ID
135+
* @since 1.9.0
136+
*/
137+
record FundingInformation(String grant, String grantId) implements UpdateRequestBody,
138+
UpdateResponseBody {
139+
140+
}
141+
142+
/**
143+
* A service request to create a project.
144+
*
145+
* @param design the title and objective of a project
146+
* @param contacts the different contact persons of a project
147+
* @param funding some funding information
148+
* @since 1.9.0
149+
*/
150+
record ProjectCreationRequest(ProjectDesign design, ProjectContacts contacts,
151+
FundingInformation funding) {
152+
153+
}
154+
155+
156+
/**
157+
* A service response from a project creation request
158+
*
159+
* @param projectId
160+
* @since 1.9, 0
161+
*/
162+
record ProjectCreationResponse(String projectId) {
163+
164+
}
165+
166+
100167
/**
101168
* A service request to update project information.
102169
*

project-management/src/main/java/life/qbic/projectmanagement/application/api/AsyncProjectServiceImpl.java

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public Mono<ProjectUpdateResponse> update(@NonNull ProjectUpdateRequest request)
4848
}
4949
}
5050

51+
@Override
52+
public Mono<ProjectCreationResponse> create(ProjectCreationRequest request)
53+
throws UnknownRequestException, RequestFailedException, AccessDeniedException {
54+
throw new RuntimeException("not implemented");
55+
}
56+
5157
/*
5258
Configures and writes the provided security context for a supplier of type Mono<ProjectUpdateResponse>. Without
5359
the context written to the reactive stream, services that have access control methods will fail.

user-interface/src/main/java/life/qbic/datamanager/views/demo/ComponentDemo.java

+35
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,39 @@ public UserInput userInput() {
220220
return steps;
221221
}
222222

223+
private static Div dialogWithOneButton(AppDialog dialog, String dialogType) {
224+
Div content = new Div();
225+
Button showDialog = new Button("Show Dialog");
226+
// Dialog set-up
227+
DialogHeader.withIcon(dialog, dialogType, IconFactory.warningIcon());
228+
DialogFooter.withConfirmOnly(dialog, "Close");
229+
ExampleUserInput userInput = new ExampleUserInput("Expelliarmus");
230+
DialogBody.with(dialog, userInput, userInput);
231+
232+
Div confirmBox = new Div("Click the button and press 'Cancel' or 'Save'");
233+
showDialog.addClickListener(e -> {
234+
dialog.open();
235+
confirmBox.setText("Cancelled the dialog.");
236+
});
237+
238+
dialog.registerCancelAction(() -> {
239+
dialog.close();
240+
if (dialog.hasChanges()) {
241+
confirmBox.setText("Cancelled the dialog although there where changes made!");
242+
} else {
243+
confirmBox.setText("Cancelled the dialog. No changes.");
244+
}
245+
});
246+
dialog.registerConfirmAction(() -> {
247+
dialog.close();
248+
confirmBox.setText("Confirmed the dialog.");
249+
});
250+
251+
content.add(showDialog, confirmBox);
252+
content.addClassNames(FLEX_VERTICAL, GAP_04);
253+
return content;
254+
}
255+
223256
private static Div dialogShowCase(AppDialog dialog, String dialogType) {
224257
Div content = new Div();
225258
Button showDialog = new Button("Show Dialog");
@@ -368,6 +401,8 @@ private static Div dialogShowCase() {
368401
container.add(dialogSectionShowCase());
369402
container.add(createHeading3("Three steps example"));
370403
container.add(stepperDialogShowCase(threeSteps(), "Three steps example"));
404+
container.add(createHeading3("Dialog with one button"));
405+
container.add(dialogWithOneButton(AppDialog.small(), "Dialog with one button"));
371406

372407
return container;
373408
}

user-interface/src/main/java/life/qbic/datamanager/views/general/dialog/DialogFooter.java

+25-5
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,39 @@ private DialogFooter(AppDialog dialog, String abortText, String confirmText) {
1919
addClassNames("flex-horizontal", "gap-04", "footer");
2020
var buttonFactory = new ButtonFactory();
2121
var confirmButton = buttonFactory.createConfirmButton(confirmText);
22-
var cancelButton = buttonFactory.createCancelButton(abortText);
23-
add(cancelButton, confirmButton);
22+
if (abortText != null) {
23+
var cancelButton = buttonFactory.createCancelButton(abortText);
24+
add(cancelButton, confirmButton);
25+
cancelButton.addClickListener(e -> dialog.cancel());
26+
} else {
27+
add(confirmButton);
28+
}
2429
dialog.setFooter(this);
2530
confirmButton.addClickListener(e -> dialog.confirm());
26-
cancelButton.addClickListener(e -> dialog.cancel());
31+
}
32+
33+
private DialogFooter() {
34+
dialog = null;
2735
}
2836

2937
public static DialogFooter with(AppDialog dialog, String abortText, String confirmText) {
3038
return new DialogFooter(dialog, abortText, confirmText);
3139
}
3240

33-
private DialogFooter() {
34-
dialog = null;
41+
/**
42+
* Creates a footer with only one button, a confirm button that also triggers the
43+
* {@link AppDialog#confirm()} action when clicked.
44+
* <p>
45+
* This footer can be used for dialogs that are for display purposes only and do not have any user
46+
* input fields.
47+
*
48+
* @param dialog the dialog to bind to
49+
* @param confirmText the button text to display for the confirmation
50+
* @return A dialog footer bound to the provided dialog with only one button
51+
* @since 1.9.0
52+
*/
53+
public static DialogFooter withConfirmOnly(AppDialog dialog, String confirmText) {
54+
return new DialogFooter(dialog, null, confirmText);
3555
}
3656

3757
public AppDialog getDialog() {

user-interface/src/main/java/life/qbic/datamanager/views/projects/project/info/ProjectSummaryComponent.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.Collection;
2626
import java.util.List;
2727
import java.util.Objects;
28+
import java.util.function.Consumer;
2829
import java.util.function.Predicate;
2930
import life.qbic.application.commons.ApplicationException;
3031
import life.qbic.datamanager.RequestCache;
@@ -85,6 +86,7 @@
8586
import life.qbic.projectmanagement.domain.model.project.Project;
8687
import life.qbic.projectmanagement.domain.model.project.ProjectId;
8788
import org.springframework.beans.factory.annotation.Autowired;
89+
import org.springframework.lang.NonNull;
8890

8991
/**
9092
* <b>Project Summary Component</b>
@@ -548,7 +550,6 @@ private void submitRequest(ProjectUpdateRequest request) {
548550
.subscribe(this::handleSuccess);
549551
}
550552

551-
552553
/*
553554
Handler for successful project updates
554555
*/

0 commit comments

Comments
 (0)