@bigbinary/neeto-approvals-frontend 0.2.15 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/index.cjs.js +60 -36
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +61 -37
- package/dist/index.js.map +1 -1
- package/package.json +14 -13
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@ The `neeto-approvals-nano` manages approvals within neeto applications. The na
|
|
|
8
8
|
- [Usage](#usage)
|
|
9
9
|
- [Frontend package](#frontend-package)
|
|
10
10
|
- [Installation](#installation-1)
|
|
11
|
+
- [Instructions for development](#instructions-for-development)
|
|
11
12
|
- [Components](#components)
|
|
12
13
|
2. [Instructions for Publishing](#instructions-for-publishing)
|
|
13
14
|
|
|
@@ -62,6 +63,9 @@ The package exports three components: `Approvals`, `Form`, and `Public`.
|
|
|
62
63
|
yarn add @bigbinary/neeto-approvals-frontend
|
|
63
64
|
```
|
|
64
65
|
|
|
66
|
+
### Instructions for development
|
|
67
|
+
Check the [Frontend package development guide](https://neeto-engineering.neetokb.com/p/a-d34cb4b0) for step-by-step instructions to develop the frontend package.
|
|
68
|
+
|
|
65
69
|
### Components
|
|
66
70
|
#### `Approvals` ([source code](https://github.com/bigbinary/neeto-approvals-nano/blob/13500c56e311a488fce886876781b8c26a0f0145/app/javascript/src/components/Approvals/index.jsx))
|
|
67
71
|
This component manages approval requests, approval templates and history of approval requests. It consists of three tabs: `Pending`, `Templates`, and `History`
|
package/dist/index.cjs.js
CHANGED
|
@@ -464,7 +464,7 @@ var getApprovalFilter = function getApprovalFilter() {
|
|
|
464
464
|
|
|
465
465
|
var MemoizedEditorContent$1 = /*#__PURE__*/React__default["default"].memo(neetoEditor.EditorContent);
|
|
466
466
|
var RequestDetailsPane = function RequestDetailsPane(_ref) {
|
|
467
|
-
var _window$globalProps, _window$globalProps2
|
|
467
|
+
var _window$globalProps, _window$globalProps2;
|
|
468
468
|
var isOpen = _ref.isOpen,
|
|
469
469
|
onClose = _ref.onClose,
|
|
470
470
|
approvalDetails = _ref.approvalDetails,
|
|
@@ -557,7 +557,7 @@ var RequestDetailsPane = function RequestDetailsPane(_ref) {
|
|
|
557
557
|
label: t("neetoApprovals.common.note"),
|
|
558
558
|
value: note,
|
|
559
559
|
placeholder: t("neetoApprovals.inputs.placeholders.add_", {
|
|
560
|
-
what:
|
|
560
|
+
what: t("neetoApprovals.common.note")
|
|
561
561
|
}),
|
|
562
562
|
onChange: utils.withEventTargetValue(setNote)
|
|
563
563
|
}), !isPending && note && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -788,24 +788,28 @@ var fetch$2 = function fetch(params) {
|
|
|
788
788
|
params: params
|
|
789
789
|
});
|
|
790
790
|
};
|
|
791
|
-
var show$1 = function show(
|
|
792
|
-
|
|
791
|
+
var show$1 = function show(_ref) {
|
|
792
|
+
var id = _ref.id,
|
|
793
|
+
params = _ref.params;
|
|
794
|
+
return axios__default["default"].get("".concat(TEMPLATE_URL, "/").concat(id), {
|
|
795
|
+
params: params
|
|
796
|
+
});
|
|
793
797
|
};
|
|
794
|
-
var create = function create(
|
|
795
|
-
var
|
|
796
|
-
url =
|
|
797
|
-
payload =
|
|
798
|
+
var create = function create(_ref2) {
|
|
799
|
+
var _ref2$url = _ref2.url,
|
|
800
|
+
url = _ref2$url === void 0 ? TEMPLATE_URL : _ref2$url,
|
|
801
|
+
payload = _ref2.payload;
|
|
798
802
|
return axios__default["default"].post(url, payload);
|
|
799
803
|
};
|
|
800
|
-
var update = function update(
|
|
801
|
-
var id =
|
|
802
|
-
payload =
|
|
803
|
-
|
|
804
|
-
url =
|
|
804
|
+
var update = function update(_ref3) {
|
|
805
|
+
var id = _ref3.id,
|
|
806
|
+
payload = _ref3.payload,
|
|
807
|
+
_ref3$url = _ref3.url,
|
|
808
|
+
url = _ref3$url === void 0 ? BASE_URL : _ref3$url;
|
|
805
809
|
return axios__default["default"].put("".concat(url, "/").concat(id), payload);
|
|
806
810
|
};
|
|
807
|
-
var destroy = function destroy(
|
|
808
|
-
var templateId =
|
|
811
|
+
var destroy = function destroy(_ref4) {
|
|
812
|
+
var templateId = _ref4.templateId;
|
|
809
813
|
return axios__default["default"]["delete"]("".concat(TEMPLATE_URL, "/").concat(templateId));
|
|
810
814
|
};
|
|
811
815
|
var templatesApi = {
|
|
@@ -835,6 +839,18 @@ var useFetchTemplates = function useFetchTemplates() {
|
|
|
835
839
|
}
|
|
836
840
|
}, options));
|
|
837
841
|
};
|
|
842
|
+
var useFetchTemplate = function useFetchTemplate(_ref2) {
|
|
843
|
+
var id = _ref2.id,
|
|
844
|
+
params = _ref2.params;
|
|
845
|
+
return reactQuery.useQuery([QUERY_KEYS.SHOW_TEMPLATE, id, params], function () {
|
|
846
|
+
return templatesApi.show({
|
|
847
|
+
id: id,
|
|
848
|
+
params: params
|
|
849
|
+
});
|
|
850
|
+
}, {
|
|
851
|
+
enabled: !!id
|
|
852
|
+
});
|
|
853
|
+
};
|
|
838
854
|
var useCreateTemplate = function useCreateTemplate(options) {
|
|
839
855
|
return reactUtils.useMutationWithInvalidation(templatesApi.create, _objectSpread$8({
|
|
840
856
|
keysToInvalidate: [QUERY_KEYS.TEMPLATES, QUERY_KEYS.VIEWS]
|
|
@@ -877,8 +893,8 @@ var MessageEditor = reactUtils.withT(function (_ref) {
|
|
|
877
893
|
_ref$initialValue = _ref.initialValue,
|
|
878
894
|
initialValue = _ref$initialValue === void 0 ? "" : _ref$initialValue;
|
|
879
895
|
return /*#__PURE__*/React__default["default"].createElement(neetoEditor.FormikEditor, {
|
|
880
|
-
required: true,
|
|
881
896
|
initialValue: initialValue,
|
|
897
|
+
required: true,
|
|
882
898
|
label: t("neetoApprovals.inputs.labels.message"),
|
|
883
899
|
name: "message",
|
|
884
900
|
rows: 3,
|
|
@@ -947,10 +963,10 @@ var Form$2 = function Form(_ref) {
|
|
|
947
963
|
what: t("neetoApprovals.common.template", constants.SINGULAR)
|
|
948
964
|
});
|
|
949
965
|
return /*#__PURE__*/React__default["default"].createElement(neetoui.Pane, {
|
|
950
|
-
initialFocusRef: inputReference,
|
|
951
|
-
size: "large",
|
|
952
966
|
isOpen: isOpen,
|
|
953
|
-
onClose: onClose
|
|
967
|
+
onClose: onClose,
|
|
968
|
+
initialFocusRef: inputReference,
|
|
969
|
+
size: "large"
|
|
954
970
|
}, /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Header, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
955
971
|
style: "h2"
|
|
956
972
|
}, header)), /*#__PURE__*/React__default["default"].createElement(formik$1.Form, {
|
|
@@ -998,11 +1014,11 @@ var Create = function Create(_ref) {
|
|
|
998
1014
|
});
|
|
999
1015
|
};
|
|
1000
1016
|
return /*#__PURE__*/React__default["default"].createElement(Form$2, {
|
|
1001
|
-
placeholders: templatePlaceholders,
|
|
1002
1017
|
isLoading: isLoading,
|
|
1003
1018
|
isOpen: isOpen,
|
|
1004
1019
|
onClose: onClose,
|
|
1005
|
-
onSubmit: onSubmit
|
|
1020
|
+
onSubmit: onSubmit,
|
|
1021
|
+
placeholders: templatePlaceholders
|
|
1006
1022
|
});
|
|
1007
1023
|
};
|
|
1008
1024
|
|
|
@@ -1036,12 +1052,12 @@ var Edit = function Edit(_ref) {
|
|
|
1036
1052
|
descriptionEnabled: !!template.description
|
|
1037
1053
|
});
|
|
1038
1054
|
return /*#__PURE__*/React__default["default"].createElement(Form$2, {
|
|
1039
|
-
|
|
1040
|
-
placeholders: templatePlaceholders,
|
|
1055
|
+
initialData: initialData,
|
|
1041
1056
|
isOpen: isOpen,
|
|
1042
1057
|
onClose: onClose,
|
|
1043
1058
|
onSubmit: onSubmit,
|
|
1044
|
-
|
|
1059
|
+
isLoading: isUpdating,
|
|
1060
|
+
placeholders: templatePlaceholders
|
|
1045
1061
|
});
|
|
1046
1062
|
};
|
|
1047
1063
|
|
|
@@ -1572,23 +1588,34 @@ var Form$1 = function Form(_ref) {
|
|
|
1572
1588
|
var _useTranslation = reactI18next.useTranslation(),
|
|
1573
1589
|
t = _useTranslation.t;
|
|
1574
1590
|
var _useFormikContext = formik.useFormikContext(),
|
|
1575
|
-
resetForm = _useFormikContext.resetForm,
|
|
1576
1591
|
setFieldValue = _useFormikContext.setFieldValue;
|
|
1577
1592
|
var inputRef = React.useRef(null);
|
|
1578
1593
|
var _useState = React.useState(null),
|
|
1579
1594
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1580
1595
|
approverId = _useState2[0],
|
|
1581
1596
|
setApproverId = _useState2[1];
|
|
1582
|
-
var
|
|
1597
|
+
var _useState3 = React.useState(null),
|
|
1598
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1599
|
+
templateId = _useState4[0],
|
|
1600
|
+
setTemplateId = _useState4[1];
|
|
1601
|
+
var params = {
|
|
1583
1602
|
requestableId: requestableId,
|
|
1584
1603
|
approverId: approverId,
|
|
1585
1604
|
approvalRequestorId: (_globalProps$user = initializers.globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.id
|
|
1586
1605
|
};
|
|
1587
|
-
var _useFetchTemplates = useFetchTemplates(
|
|
1606
|
+
var _useFetchTemplates = useFetchTemplates(),
|
|
1588
1607
|
_useFetchTemplates$da = _useFetchTemplates.data,
|
|
1589
1608
|
_useFetchTemplates$da2 = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da,
|
|
1590
1609
|
_useFetchTemplates$da3 = _useFetchTemplates$da2.templates,
|
|
1591
1610
|
templates = _useFetchTemplates$da3 === void 0 ? [] : _useFetchTemplates$da3;
|
|
1611
|
+
var _useFetchTemplate = useFetchTemplate({
|
|
1612
|
+
id: templateId,
|
|
1613
|
+
params: params
|
|
1614
|
+
}),
|
|
1615
|
+
_useFetchTemplate$dat = _useFetchTemplate.data,
|
|
1616
|
+
_useFetchTemplate$dat2 = _useFetchTemplate$dat === void 0 ? {} : _useFetchTemplate$dat,
|
|
1617
|
+
_useFetchTemplate$dat3 = _useFetchTemplate$dat2.template,
|
|
1618
|
+
template = _useFetchTemplate$dat3 === void 0 ? {} : _useFetchTemplate$dat3;
|
|
1592
1619
|
var _useFetchApprovers = useFetchApprovers(),
|
|
1593
1620
|
_useFetchApprovers$da = _useFetchApprovers.data,
|
|
1594
1621
|
_useFetchApprovers$da2 = _useFetchApprovers$da === void 0 ? {} : _useFetchApprovers$da,
|
|
@@ -1608,27 +1635,24 @@ var Form$1 = function Form(_ref) {
|
|
|
1608
1635
|
value: template.id
|
|
1609
1636
|
};
|
|
1610
1637
|
});
|
|
1611
|
-
var updateMessage = function updateMessage(
|
|
1638
|
+
var updateMessage = function updateMessage() {
|
|
1612
1639
|
var _inputRef$current;
|
|
1613
1640
|
var message = template.parsedMessage || template.message;
|
|
1614
1641
|
setFieldValue("message", message);
|
|
1615
1642
|
inputRef === null || inputRef === void 0 || (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || (_inputRef$current = _inputRef$current.editor) === null || _inputRef$current === void 0 || (_inputRef$current = _inputRef$current.commands) === null || _inputRef$current === void 0 || _inputRef$current.setContent(message);
|
|
1616
1643
|
};
|
|
1617
1644
|
var handleTemplateChange = function handleTemplateChange(selectedTemplate) {
|
|
1618
|
-
|
|
1619
|
-
var template = neetoCist.findById(selectedTemplate.value, templates);
|
|
1620
|
-
setSelectedTemplateData(template);
|
|
1621
|
-
updateMessage(template);
|
|
1645
|
+
setTemplateId(selectedTemplate.value);
|
|
1622
1646
|
};
|
|
1623
1647
|
var handleApproverChange = function handleApproverChange(approver) {
|
|
1624
1648
|
setApproverId(approver.value);
|
|
1625
1649
|
setFieldValue("approver", approver);
|
|
1626
1650
|
};
|
|
1627
1651
|
React.useEffect(function () {
|
|
1628
|
-
if (
|
|
1629
|
-
|
|
1630
|
-
updateMessage(
|
|
1631
|
-
}, [
|
|
1652
|
+
if (ramda.isEmpty(template)) return;
|
|
1653
|
+
setSelectedTemplateData(template);
|
|
1654
|
+
updateMessage();
|
|
1655
|
+
}, [template]);
|
|
1632
1656
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1633
1657
|
className: "w-full space-y-6"
|
|
1634
1658
|
}, /*#__PURE__*/React__default["default"].createElement(neetoui.Select, {
|