Skip to content
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
39 changes: 39 additions & 0 deletions src/ui/pages/work/Workorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import CustomFields from '../../components/customfields/CustomFields';
import EDMSDoclightIframeContainer from "../../components/iframes/EDMSDoclightIframeContainer";
import Entity from '../Entity';
import EamlightToolbarContainer from './../../components/EamlightToolbarContainer';
import ConfirmationDialog from '../../components/ConfirmationDialog'
import Activities from './activities/Activities';
import WorkorderChildren from "./childrenwo/WorkorderChildren";
import MeterReadingContainerWO from './meter/MeterReadingContainerWO';
Expand Down Expand Up @@ -618,6 +619,37 @@ class Workorder extends Entity {
this.checklists && this.checklists.readActivities(this.state.workorder.number);
};

saveHandler() {
// Validate all children and continue when all have passed
if (!this.validateFields(this.children)) {
this.props.showError('Several errors have occurred')
return
}

const terminalStatuses = ['T', 'TF', 'TT', 'TP', 'TI', 'TX'];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean I cannot cancel a work order without completing the checklist?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proper way would be to check the system code instead, but this field is not available on the response.


// Check for open checklist items on a terminé status update
if (
this.checklists
&& this.checklists.hasIncompleteChecklists
&& this.checklists.hasIncompleteChecklists()
&& terminalStatuses.includes(this.state.workorder.statusCode)
){
this.incompleteChecklistsConfirmation.show();
} else {
this.commitSave();
}
}

commitSave() {
// Create new or update existing entity
if (this.state.layout.newEntity) {
this.createEntity(this.state[this.settings.entity])
} else {
this.updateEntity({...this.state[this.settings.entity], confirmedIncompleteChecklist: true})
}
}

renderWorkOrder() {
const { layout, workorder } = this.state;
const {
Expand All @@ -633,6 +665,13 @@ class Workorder extends Entity {
const regions = this.getRegions();
return (
<div className="entityContainer">
<ConfirmationDialog
ref={incompleteChecklistsConfirmation => this.incompleteChecklistsConfirmation = incompleteChecklistsConfirmation}
onConfirm={this.commitSave.bind(this)}
title=""
content="Open checklist items still exist. Continue?"
confirmButtonText="Yes"
/>
<BlockUi tag="div" blocking={layout.blocking} style={{height: "100%", width: "100%"}}>

<EamlightToolbarContainer isModified={layout.isModified}
Expand Down