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

other improvements #17

Merged
merged 7 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion frontend/themes/jmix-windturbines/view/login-view.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ vaadin-login-form-wrapper {
}
vaadin-login-form-wrapper::part(form-title) {
font-size: 0;
background-image: url('icons/login-icon.svg');
background-image: url('/windturbines/icons/login-icon.svg');
background-repeat: no-repeat;
background-position: center;
background-size: contain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import io.jmix.flowui.fragment.FragmentDescriptor;
import io.jmix.flowui.kit.action.ActionPerformedEvent;
import io.jmix.flowui.kit.action.ActionVariant;
import io.jmix.flowui.kit.component.button.JmixButton;
import io.jmix.flowui.view.MessageBundle;
import io.jmix.flowui.view.Subscribe;
import io.jmix.flowui.view.ViewComponent;
import io.jmix.windturbines.entity.TaskStatus;
import io.jmix.windturbines.entity.User;
import io.jmix.windturbines.entity.inspection.Inspection;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -47,17 +49,23 @@ public class AllInspectionCard extends Fragment<VerticalLayout> {
private Span statusBadge;
@ViewComponent
private Span secondRowText;
@ViewComponent
private Span location;

private Inspection inspection;
private Consumer<Inspection> afterAssignmentPerformedHandler;
@ViewComponent
private JmixButton assignBtn;


public void setInspection(Inspection inspection) {
this.inspection = inspection;
inspectionDate.setText(datatypeFormatter.formatLocalDate(inspection.getInspectionDate()));
statusBadge.setText(messages.getMessage(inspection.getTaskStatus()));
statusBadge.getElement().getThemeList().add(inspection.getTaskStatus().getBadgeThemeName());
secondRowText.setText(inspection.technicianName());
secondRowText.setText("%s - %s".formatted(inspection.getTurbine().getManufacturer().getName(), inspection.getTurbine().getModel()));
location.setText(inspection.getTurbine().getLocation());
assignBtn.setEnabled(!TaskStatus.COMPLETED.equals(inspection.getTaskStatus()));
}

@Subscribe("assignAction")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ public class InspectionDetailView extends StandardDetailView<Inspection> {
@ViewComponent
private CollectionPropertyContainer<InspectionFinding> findingsDc;
@Autowired
private UiComponents uiComponents;
@Autowired
private Messages messages;
@Autowired
private Dialogs dialogs;
Expand Down Expand Up @@ -114,19 +112,6 @@ public void onInit(final InitEvent event) {
signaturePadWrapper.add(signature);
}

@Subscribe
public void onValidation(final ValidationEvent event) {
if (signature.isEmpty()) {
ValidationErrors errors = ValidationErrors.of(messages.getMessage("operatorRepSignature.empty"));
event.addErrors(errors);
}
if (!operatorConfirmationField.getValue()) {
ValidationErrors errors = ValidationErrors.of(messages.getMessage("operatorConfirmation.required"));
event.addErrors(errors);
}
}


@Subscribe
public void onBeforeSave(final BeforeSaveEvent event) throws IOException {
getEditedEntity().setOperatorRepSignature(
Expand Down Expand Up @@ -173,7 +158,10 @@ public void onPrevAction(final ActionPerformedEvent event) {
@Subscribe("nextAction")
public void onNextAction(final ActionPerformedEvent event) {
if (currentTabIndex() < LAST_SECTION_INDEX) {
openTab(currentTabIndex() + 1);
ValidationErrors validationErrors = validateView();
if (validationErrors.isEmpty()) {
openTab(currentTabIndex() + 1);
}
}
}

Expand Down Expand Up @@ -201,6 +189,13 @@ private int currentTabIndex() {
public void onFinishAction(final ActionPerformedEvent event) {

ValidationErrors validationErrors = validateView();
if (signature.isEmpty()) {
validationErrors.addAll(ValidationErrors.of(messages.getMessage("operatorRepSignature.empty")));
}
if (!operatorConfirmationField.getValue()) {
validationErrors.addAll(ValidationErrors.of(messages.getMessage("operatorConfirmation.required")));
}

if (!validationErrors.isEmpty()) {
viewValidation.showValidationErrors(validationErrors);
viewValidation.focusProblemComponent(validationErrors);
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ server.tomcat.max-swallow-size=1000MB


jmix.flowui.use-default-security-configuration=false


server.servlet.context-path = /windturbines
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<vbox id="root"
padding="false"
spacing="false"
classNames="m-m white-card cursor-pointer turbine-list-white-card">
classNames="m-m white-card turbine-list-white-card">
<hbox width="100%" classNames="p-s gap-m" padding="false" alignItems="STRETCH">
<icon icon="vaadin:calendar-o" classNames="mr-s"/>
<span id="inspectionDate"/>
Expand All @@ -16,10 +16,16 @@
</hbox>
<hbox width="100%" classNames="p-s gap-m">
<span id="secondRowText" width="100%"/>
<hbox padding="false" justifyContent="END">
<button action="assignAction" themeNames="tertiary-inline outlined"/>
<hbox alignItems="CENTER" width="100%">
<svgIcon resource="/windturbines/icons/location.svg"/>
<span id="location"
width="100%"
classNames="cut-overflow-text"/>
</hbox>
</hbox>
<hbox width="100%" classNames="p-s gap-m">
<button id="assignBtn" action="assignAction" themeNames="primary" width="100%" classNames="cursor-pointer"/>
</hbox>
</vbox>
</content>
</fragment>
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
</hbox>
<hbox width="100%" classNames="p-s gap-m">
<hbox alignItems="CENTER" width="100%">
<svgIcon resource="/icons/location.svg"/>
<svgIcon resource="icons/location.svg"/>
<span id="location"
width="100%"
classNames="cut-overflow-text"/>
</hbox>
<hbox padding="false" justifyContent="END">
<button action="detailsAction" themeNames="tertiary-inline"/>
<button action="detailsAction" themeNames="tertiary-inline" classNames="cursor-pointer"/>
</hbox>
</hbox>
</vbox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ void when_lastPanel_then_nextIsInvisible_and_finishIsVisible() {
// when: to checklist panel
next(detailView).click();

// and: filling out all fields
rotorBladesAnswerField(detailView).setValue(RotorBladesAnswer.YES);
gearboxOilLevelAnswerField(detailView).setValue(GearboxOilLevelAnswer.HIGH);
generatorCheckAnswerField(detailView).setValue(1);
controlSystemStatusField(detailView).setValue(YesNoAnswer.YES);

// and: to findings panel
next(detailView).click();

Expand All @@ -228,6 +234,32 @@ void when_lastPanel_then_nextIsInvisible_and_finishIsVisible() {
assertThat(finish(detailView).isVisible())
.isTrue();
}
@Test
void when_validationErrors_then_tabIsStillTheSame() {
// given
InspectionDetailView detailView = navigateTo(InspectionDetailView.class, inspection, Inspection.class);

// and: to checklist panel
next(detailView).click();

// and:
assertThat(currentTabSheetIndex(detailView))
.isEqualTo(1);

// and: setting fields to null
rotorBladesAnswerField(detailView).setValue(null);
gearboxOilLevelAnswerField(detailView).setValue(null);
generatorCheckAnswerField(detailView).setValue(null);
controlSystemStatusField(detailView).setValue(null);

// when: to findings panel
next(detailView).click();

// then: it is still showing checklist panel
assertThat(currentTabSheetIndex(detailView))
.isEqualTo(1);

}

@Test
void when_finish_then_validationIsPerformed() {
Expand Down
Loading