@onehat/ui 0.3.288 → 0.3.290

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.288",
3
+ "version": "0.3.290",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -5,11 +5,12 @@ import testProps from '../../Functions/testProps.js';
5
5
  import IconButton from './IconButton.js';
6
6
  import Rotate from '../Icons/Rotate.js';
7
7
 
8
- export default function ReloadButton(props, isTree = false) {
8
+ export default function ReloadButton(props) {
9
9
  const {
10
10
  iconProps ={},
11
11
  self,
12
12
  Repository,
13
+ isTree = false,
13
14
  } = props,
14
15
  onPress = () => {
15
16
  if (isTree) {
@@ -134,8 +134,8 @@ function Form(props) {
134
134
  }
135
135
  const
136
136
  isMultiple = _.isArray(record),
137
- isSingle = !isMultiple, // for convenience
138
- isPhantom = !skipAll && !!record?.isPhantom, //
137
+ isSingle = _.isNil(record) || !_.isArray(record),
138
+ isPhantom = !skipAll && !!record?.isPhantom,
139
139
  forceUpdate = useForceUpdate(),
140
140
  [previousRecord, setPreviousRecord] = useState(record),
141
141
  [containerWidth, setContainerWidth] = useState(),
@@ -949,6 +949,9 @@ function Form(props) {
949
949
  const formIsDirty = formState.isDirty;
950
950
  // console.log('formIsDirty', formIsDirty);
951
951
  // console.log('isPhantom', isPhantom);
952
+ if (editorType === EDITOR_TYPE__WINDOWED && onCancel) {
953
+ showCancelBtn = true;
954
+ }
952
955
  if (formIsDirty || isPhantom) {
953
956
  if (isSingle && onCancel) {
954
957
  showCancelBtn = true;
@@ -70,6 +70,9 @@ function TreeComponent(props) {
70
70
  }
71
71
  return item[displayIx];
72
72
  },
73
+ getDisplayTextFromSearchResults = (item) => {
74
+ return item.id
75
+ },
73
76
  getNodeIcon = (which, item) => { // decides what icon to show for this node
74
77
  // TODO: Allow for dynamic props on the icon (e.g. special color for some icons)
75
78
  let icon;
@@ -383,7 +386,7 @@ function TreeComponent(props) {
383
386
  // Show modal so user can select which node to go to
384
387
  const searchFormData = [];
385
388
  _.each(found, (item) => {
386
- searchFormData.push([item.id, getNodeText(item)]);
389
+ searchFormData.push([item.id, getDisplayTextFromSearchResults(item)]);
387
390
  });
388
391
  setSearchFormData(searchFormData);
389
392
  setSearchResults(found);
@@ -699,8 +702,9 @@ function TreeComponent(props) {
699
702
 
700
703
  currentNode = currentDatum.item;
701
704
 
702
- // THE MAGIC!
703
- currentDatum.isExpanded = true;
705
+ if (!currentDatum.isExpanded) {
706
+ await loadChildren(currentDatum, 1);
707
+ }
704
708
 
705
709
  cPath = cPathParts.slice(1).join('/'); // put the rest of it back together
706
710
  currentLevelData = currentDatum.children;
@@ -1252,38 +1256,42 @@ function TreeComponent(props) {
1252
1256
  >
1253
1257
  <Column bg="#fff" w={300}>
1254
1258
  <FormPanel
1255
- title="Choose Tree Node"
1259
+ _panel={{
1260
+ title: 'Choose Tree Node',
1261
+ }}
1256
1262
  instructions="Multiple tree nodes matched your search. Please select which one to show."
1257
- flex={1}
1258
- items={[
1259
- {
1260
- type: 'Column',
1261
- flex: 1,
1262
- items: [
1263
- {
1264
- key: 'node_id',
1265
- name: 'node_id',
1266
- type: 'Combo',
1267
- label: 'Tree Node',
1268
- data: searchFormData,
1269
- }
1270
- ],
1263
+ _form={{
1264
+ flex: 1,
1265
+ items: [
1266
+ {
1267
+ type: 'Column',
1268
+ flex: 1,
1269
+ items: [
1270
+ {
1271
+ key: 'node_id',
1272
+ name: 'node_id',
1273
+ type: 'Combo',
1274
+ label: 'Tree Node',
1275
+ data: searchFormData,
1276
+ }
1277
+ ],
1278
+ },
1279
+ ],
1280
+ onCancel: (e) => {
1281
+ setHighlitedDatum(null);
1282
+ setIsModalShown(false);
1283
+ },
1284
+ onSave: (data, e) => {
1285
+ const
1286
+ treeNode = _.find(searchResults, (item) => {
1287
+ return item.id === data.node_id;
1288
+ }),
1289
+ cPath = treeNode.cPath;
1290
+ expandPath(cPath);
1291
+
1292
+ // Close the modal
1293
+ setIsModalShown(false);
1271
1294
  },
1272
- ]}
1273
- onCancel={(e) => {
1274
- setHighlitedDatum(null);
1275
- setIsModalShown(false);
1276
- }}
1277
- onSave={(data, e) => {
1278
- const
1279
- treeNode = _.find(searchResults, (item) => {
1280
- return item.id === data.node_id;
1281
- }),
1282
- cPath = treeNode.cPath;
1283
- expandPath(cPath);
1284
-
1285
- // Close the modal
1286
- setIsModalShown(false);
1287
1295
  }}
1288
1296
  />
1289
1297
  </Column>