@onehat/ui 0.3.350 → 0.3.352

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/ui",
3
- "version": "0.3.350",
3
+ "version": "0.3.352",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -794,7 +794,7 @@ function Form(props) {
794
794
  doReset(defaultValues);
795
795
  }
796
796
  if (formSetup) {
797
- formSetup(formSetValue, formGetValues, formState)
797
+ formSetup(formSetValue, formGetValues, formState);
798
798
  }
799
799
  }, [record]);
800
800
 
@@ -58,6 +58,27 @@ export default function withPdfButtons(WrappedComponent) {
58
58
  buildModalItems = () => {
59
59
  const modalItems = _.map(_.cloneDeep(items), (item, ix) => buildNextLayer(item, ix, columnDefaults)); // clone, as we don't want to alter the item by reference
60
60
 
61
+ // remove additionalEditButtons from the modal
62
+ function walkTreeToDeleteAdditionalEditButtons(item) {
63
+ if (!item) {
64
+ return;
65
+ }
66
+
67
+ let {
68
+ additionalEditButtons,
69
+ items,
70
+ } = item;
71
+ if (!_.isEmpty(items)) {
72
+ _.each(items, (item) => {
73
+ walkTreeToDeleteAdditionalEditButtons(item);
74
+ });
75
+ }
76
+ if (additionalEditButtons) {
77
+ delete item.additionalEditButtons;
78
+ }
79
+ }
80
+ _.each(modalItems, walkTreeToDeleteAdditionalEditButtons);
81
+
61
82
  if (!_.isEmpty(ancillaryItems)) {
62
83
  const
63
84
  ancillaryItemsClone = _.cloneDeep(ancillaryItems),
@@ -144,7 +165,7 @@ export default function withPdfButtons(WrappedComponent) {
144
165
  },
145
166
  getStartingValues = (modalItems) => {
146
167
  const startingValues = {};
147
- function walkTree(item) {
168
+ function walkTreeToSetStartingValues(item) {
148
169
  if (!item) {
149
170
  return;
150
171
  }
@@ -155,14 +176,14 @@ export default function withPdfButtons(WrappedComponent) {
155
176
  } = item;
156
177
  if (!_.isEmpty(items)) {
157
178
  _.each(items, (item) => {
158
- walkTree(item);
179
+ walkTreeToSetStartingValues(item);
159
180
  });
160
181
  }
161
182
  if (name) {
162
183
  startingValues[name] = true;
163
184
  }
164
185
  }
165
- _.each(modalItems, walkTree);
186
+ _.each(modalItems, walkTreeToSetStartingValues);
166
187
  return startingValues;
167
188
  },
168
189
  onChooseFields = (userWantsToEmail = false) => {
@@ -1,4 +1,4 @@
1
- import { useRef, useState, } from 'react';
1
+ import { useEffect, useRef, useState, } from 'react';
2
2
  import {
3
3
  Column,
4
4
  Icon,
@@ -37,7 +37,8 @@ function Viewer(props) {
37
37
  record,
38
38
  additionalViewButtons,
39
39
  canRecordBeEdited,
40
-
40
+ viewerSetup, // this fn will be executed after the viewer setup is complete
41
+
41
42
  // withComponent
42
43
  self,
43
44
 
@@ -235,6 +236,12 @@ function Viewer(props) {
235
236
  setContainerWidth(e.nativeEvent.layout.width);
236
237
  };
237
238
 
239
+ useEffect(() => {
240
+ if (viewerSetup && record?.getSubmitValues) {
241
+ viewerSetup(record.getSubmitValues());
242
+ }
243
+ }, [record]);
244
+
238
245
  if (self) {
239
246
  self.ref = scrollViewRef;
240
247
  }