diff --git a/dist/ui/components/checklists/ChecklistItem.js b/dist/ui/components/checklists/ChecklistItem.js
index df66a7f9..77a248ac 100644
--- a/dist/ui/components/checklists/ChecklistItem.js
+++ b/dist/ui/components/checklists/ChecklistItem.js
@@ -11,8 +11,14 @@ var _ChecklistItemInput = _interopRequireDefault(require("./ChecklistItemInput")
var _ChecklistItemNotes = _interopRequireDefault(require("./ChecklistItemNotes"));
+var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
+
var _Collapse = _interopRequireDefault(require("@material-ui/core/Collapse"));
+var _Dialog = _interopRequireDefault(require("@material-ui/core/Dialog"));
+
+var _Paper = _interopRequireDefault(require("@material-ui/core/Paper"));
+
var _ChecklistItemFollowUp = _interopRequireDefault(require("./ChecklistItemFollowUp"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -92,6 +98,19 @@ var ChecklistItem = /*#__PURE__*/function (_Component) {
display: "flex",
flexDirection: "row"
};
+ _this.modalStyle = {
+ padding: '15px 25px',
+ textAlign: 'center'
+ };
+
+ _this.closeDialog = function () {
+ _this.setState({
+ openedDialog: false,
+ blocked: false
+ });
+
+ _this.props.onUpdateChecklistItem(_this.state.debounce.oldChecklistItem);
+ };
_this.colorStyle = function (color) {
var _ref;
@@ -119,10 +138,32 @@ var ChecklistItem = /*#__PURE__*/function (_Component) {
};
};
+ _this.onUpdate = function (checklistItem) {
+ var handleError = _this.props.handleError;
+
+ _this.props.updateChecklistItem(checklistItem).then(function () {
+ _this.props.resetSignatures(checklistItem.activityCode);
+ })["catch"](function (error) {
+ handleError(error);
+
+ _this.props.onUpdateChecklistItem(_this.state.debounce.oldChecklistItem);
+
+ _this.setState({
+ debounce: null
+ });
+ })["finally"](function () {
+ _this.setState({
+ openedDialog: false,
+ blocked: false
+ });
+ });
+ };
+
_this.state = {
detailsVisible: false,
blocked: false,
- debounce: null
+ debounce: null,
+ openedDialog: false
};
_this.notes = _react["default"].createRef();
return _this;
@@ -181,21 +222,13 @@ var ChecklistItem = /*#__PURE__*/function (_Component) {
var DEBOUNCE_TIME_MS = 50;
var request = function request() {
- _this2.props.updateChecklistItem(checklistItem).then(function () {
- _this2.props.resetSignatures(checklistItem.activityCode);
- })["catch"](function (error) {
- handleError(error);
-
- _this2.props.onUpdateChecklistItem(checklistItem);
-
+ if (_this2.props.signaturesWarningFlag(_this2.props.checklistItem.activityCode)) {
_this2.setState({
- debounce: null
+ openedDialog: true
});
- })["finally"](function () {
- _this2.setState({
- blocked: false
- });
- });
+ } else {
+ _this2.onUpdate(_this2.props.checklistItem);
+ }
};
this.setState(function (state) {
@@ -405,6 +438,23 @@ var ChecklistItem = /*#__PURE__*/function (_Component) {
var _this5 = this;
var checklistItem = this.props.checklistItem;
+
+ var dialog = /*#__PURE__*/_react["default"].createElement(_Paper["default"], {
+ elevation: 3,
+ style: this.modalStyle
+ }, /*#__PURE__*/_react["default"].createElement("div", {
+ style: {
+ fontSize: '15px',
+ paddingBottom: '3px'
+ }
+ }, "Editing the checklists now will clear the signatures. Do you wish to continue?"), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
+ onClick: this.closeDialog
+ }, "Cancel"), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
+ onClick: function onClick() {
+ return _this5.onUpdate(checklistItem);
+ }
+ }, "Continue")));
+
return /*#__PURE__*/_react["default"].createElement("div", {
style: this.containerStyle(this.state.blocked)
}, checklistItem.color ? /*#__PURE__*/_react["default"].createElement("div", {
@@ -420,7 +470,9 @@ var ChecklistItem = /*#__PURE__*/function (_Component) {
style: {
color: "red"
}
- }, " *")), this.renderChecklistItemInput()), /*#__PURE__*/_react["default"].createElement(_Collapse["default"], {
+ }, " *")), this.renderChecklistItemInput(), /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
+ open: this.state.openedDialog
+ }, dialog)), /*#__PURE__*/_react["default"].createElement(_Collapse["default"], {
"in": this.state.detailsVisible
}, /*#__PURE__*/_react["default"].createElement("div", {
style: this.checklistDetailsStyle
diff --git a/dist/ui/components/checklists/Checklists.js b/dist/ui/components/checklists/Checklists.js
index 4852bb37..7504db9f 100644
--- a/dist/ui/components/checklists/Checklists.js
+++ b/dist/ui/components/checklists/Checklists.js
@@ -229,6 +229,17 @@ var Checklists = /*#__PURE__*/function (_Component) {
});
};
+ _this.getSignaturesResetWarningFlag = function (activityCode) {
+ var activity = _this.state.activities.find(function (activity) {
+ return activity.activityCode === activityCode;
+ });
+
+ var signatures = activity.signatures;
+ return signatures && signatures.some(function (signature) {
+ return signature.signer !== null;
+ });
+ };
+
_this.expandSignature = function (activity, expanded) {
var signaturesCollapsed = _objectSpread({}, _this.state.signaturesCollapsed);
@@ -374,9 +385,11 @@ var Checklists = /*#__PURE__*/function (_Component) {
onUpdateChecklistItem: _this3.onUpdateChecklistItem,
checklistItem: checklist,
handleError: handleError,
+ showSuccess: _this3.props.showSuccess,
minFindingsDropdown: minFindingsDropdown,
getWoLink: getWoLink,
- resetSignatures: _this3.resetSignatures
+ resetSignatures: _this3.resetSignatures,
+ signaturesWarningFlag: _this3.getSignaturesResetWarningFlag
});
}))));
}
diff --git a/src/ui/components/checklists/ChecklistItem.js b/src/ui/components/checklists/ChecklistItem.js
index 38553422..2fa319b8 100644
--- a/src/ui/components/checklists/ChecklistItem.js
+++ b/src/ui/components/checklists/ChecklistItem.js
@@ -1,7 +1,10 @@
import React, {Component} from 'react';
import ChecklistItemInput from './ChecklistItemInput';
import ChecklistItemNotes from './ChecklistItemNotes';
+import Button from '@material-ui/core/Button';
import Collapse from '@material-ui/core/Collapse';
+import Dialog from '@material-ui/core/Dialog';
+import Paper from '@material-ui/core/Paper';
import ChecklistItemFollowUp from "./ChecklistItemFollowUp";
export default class ChecklistItem extends Component {
@@ -10,7 +13,8 @@ export default class ChecklistItem extends Component {
this.state = {
detailsVisible: false,
blocked: false,
- debounce: null
+ debounce: null,
+ openedDialog: false
}
this.notes = React.createRef();
@@ -91,23 +95,26 @@ export default class ChecklistItem extends Component {
flexDirection: "row"
}
+ modalStyle = {
+ padding: '15px 25px',
+ textAlign: 'center',
+ };
+
+ closeDialog = () => {
+ this.setState({openedDialog: false, blocked: false})
+ this.props.onUpdateChecklistItem(this.state.debounce.oldChecklistItem);
+ }
onChange(checklistItem) {
const handleError = this.props.handleError;
const DEBOUNCE_TIME_MS = 50;
-
- const request = () => {
- this.props.updateChecklistItem(checklistItem)
- .then(() =>{
- this.props.resetSignatures(checklistItem.activityCode);
- }).catch(error => {
- handleError(error);
- this.props.onUpdateChecklistItem(checklistItem);
- this.setState({debounce: null});
- }).finally(() => {
- this.setState({blocked: false});
- });
+ const request = () => {
+ if(this.props.signaturesWarningFlag(this.props.checklistItem.activityCode)) {
+ this.setState({openedDialog:true});
+ } else {
+ this.onUpdate(this.props.checklistItem);
+ }
};
this.setState(state => {
@@ -127,6 +134,7 @@ export default class ChecklistItem extends Component {
}
}
});
+
}
descClickHandler() {
@@ -293,8 +301,32 @@ export default class ChecklistItem extends Component {
opacity: blocked ? 0.5 : 1
})
+ onUpdate = (checklistItem) => {
+ const handleError = this.props.handleError;
+ this.props.updateChecklistItem(checklistItem)
+ .then(() =>{
+ this.props.resetSignatures(checklistItem.activityCode);
+ }).catch(error => {
+ handleError(error);
+ this.props.onUpdateChecklistItem(this.state.debounce.oldChecklistItem);
+ this.setState({debounce: null});
+ }).finally(() => {
+ this.setState({openedDialog: false, blocked: false})
+ });
+ }
+
render() {
let {checklistItem} = this.props;
+ const dialog =
+