@onehat/ui 0.3.44 → 0.3.47

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.44",
3
+ "version": "0.3.47",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -601,6 +601,7 @@ function Form(props) {
601
601
  sizeProps.maxHeight = maxHeight;
602
602
  }
603
603
 
604
+ const formButtons = [];
604
605
  let formComponents,
605
606
  editor,
606
607
  additionalButtons,
@@ -616,17 +617,7 @@ function Form(props) {
616
617
  }
617
618
 
618
619
  if (editorType === EDITOR_TYPE__INLINE) {
619
- formComponents = buildFromColumnsConfig();
620
- editor = <ScrollView
621
- horizontal={true}
622
- flex={1}
623
- bg="#fff"
624
- py={1}
625
- borderTopWidth={3}
626
- borderBottomWidth={5}
627
- borderTopColor="primary.100"
628
- borderBottomColor="primary.100"
629
- >{formComponents}</ScrollView>;
620
+ editor = buildFromColumnsConfig();
630
621
  // } else if (editorType === EDITOR_TYPE__PLAIN) {
631
622
  // formComponents = buildFromItems();
632
623
  // const formAncillaryComponents = buildAncillary();
@@ -637,24 +628,35 @@ function Form(props) {
637
628
  } else {
638
629
  formComponents = buildFromItems();
639
630
  const formAncillaryComponents = buildAncillary();
640
- editor = <ScrollView _web={{ minHeight, }} width="100%" pb={1}>
631
+ editor = <>
641
632
  {containerWidth >= CONTAINER_THRESHOLD ? <Row p={4} pl={0}>{formComponents}</Row> : null}
642
633
  {containerWidth < CONTAINER_THRESHOLD ? <Column p={4}>{formComponents}</Column> : null}
643
634
  <Column m={2} pt={4}>{formAncillaryComponents}</Column>
644
- </ScrollView>;
645
- }
646
-
647
- let editorModeF;
648
- switch(editorMode) {
649
- case EDITOR_MODE__VIEW:
650
- editorModeF = 'View';
651
- break;
652
- case EDITOR_MODE__ADD:
653
- editorModeF = 'Add';
654
- break;
655
- case EDITOR_MODE__EDIT:
656
- editorModeF = isMultiple ? 'Edit Multiple' : 'Edit';
657
- break;
635
+ </>;
636
+
637
+ additionalButtons = buildAdditionalButtons(additionalEditButtons);
638
+
639
+ formButtons.push(<Row key="buttonsRow" px={4} pt={4} alignItems="center" justifyContent="flex-end">
640
+ {isSingle && editorMode === EDITOR_MODE__EDIT && onBack &&
641
+ <Button
642
+ key="backBtn"
643
+ onPress={onBack}
644
+ leftIcon={<Icon as={AngleLeft} color="#fff" size="sm" />}
645
+ color="#fff"
646
+ >Back</Button>}
647
+ {isSingle && editorMode === EDITOR_MODE__EDIT && onViewMode &&
648
+ <Button
649
+ key="viewBtn"
650
+ onPress={onViewMode}
651
+ leftIcon={<Icon as={Eye} color="#fff" size="sm" />}
652
+ color="#fff"
653
+ >To View</Button>}
654
+ </Row>);
655
+ if (editorMode === EDITOR_MODE__EDIT && !_.isEmpty(additionalButtons)) {
656
+ formButtons.push(<Row key="additionalButtonsRow" p={4} alignItems="center" justifyContent="flex-end" flexWrap="wrap">
657
+ {additionalButtons}
658
+ </Row>)
659
+ }
658
660
  }
659
661
 
660
662
  if (!_.isEmpty(formState.errors)) {
@@ -671,33 +673,27 @@ function Form(props) {
671
673
  footerProps.alignItems = 'flex-start';
672
674
  }
673
675
 
674
- additionalButtons = buildAdditionalButtons(additionalEditButtons);
675
676
  }
676
677
 
677
678
  return <Column {...sizeProps} onLayout={onLayoutDecorated} ref={formRef}>
678
679
  {containerWidth && <>
679
- <Row px={4} pt={4} alignItems="center" justifyContent="flex-end">
680
- {isSingle && editorMode === EDITOR_MODE__EDIT && onBack &&
681
- <Button
682
- key="backBtn"
683
- onPress={onBack}
684
- leftIcon={<Icon as={AngleLeft} color="#fff" size="sm" />}
685
- color="#fff"
686
- >Back</Button>}
687
- {isSingle && editorMode === EDITOR_MODE__EDIT && onViewMode &&
688
- <Button
689
- key="viewBtn"
690
- onPress={onViewMode}
691
- leftIcon={<Icon as={Eye} color="#fff" size="sm" />}
692
- color="#fff"
693
- >To View</Button>}
694
- </Row>
695
- {editorMode === EDITOR_MODE__EDIT && !_.isEmpty(additionalButtons) &&
696
- <Row p={4} alignItems="center" justifyContent="flex-end" flexWrap="wrap">
697
- {additionalButtons}
698
- </Row>}
699
-
700
- {editor}
680
+
681
+ {editorType === EDITOR_TYPE__INLINE &&
682
+ <ScrollView
683
+ horizontal={true}
684
+ flex={1}
685
+ bg="#fff"
686
+ py={1}
687
+ borderTopWidth={3}
688
+ borderBottomWidth={5}
689
+ borderTopColor="primary.100"
690
+ borderBottomColor="primary.100"
691
+ >{editor}</ScrollView>}
692
+ {editorType !== EDITOR_TYPE__INLINE &&
693
+ <ScrollView _web={{ minHeight, }} width="100%" pb={1}>
694
+ {formButtons}
695
+ {editor}
696
+ </ScrollView>}
701
697
 
702
698
  <Footer justifyContent="flex-end" {...footerProps} {...savingProps}>
703
699
  {onDelete && editorMode === EDITOR_MODE__EDIT && isSingle &&
@@ -144,7 +144,7 @@ export default function withPdfButton(WrappedComponent) {
144
144
  data.id = selection[0].id;
145
145
 
146
146
  const
147
- url = UiGlobals.baseURL + model + '/viewPdf?',
147
+ url = UiGlobals.baseURL + model + '/viewModelPdf?',
148
148
  queryString = qs.stringify(data);
149
149
 
150
150
  window.open(url + queryString, '_blank');
@@ -72,7 +72,7 @@ function ManagerScreen(props) {
72
72
  <IconButton
73
73
  icon={FullWidth}
74
74
  _icon={{
75
- size: '30px',
75
+ size: '25px',
76
76
  color: mode === MODE_FULL ? 'primary.100' : '#000',
77
77
  }}
78
78
  disabled={mode === MODE_FULL}
@@ -82,7 +82,7 @@ function ManagerScreen(props) {
82
82
  <IconButton
83
83
  icon={SideBySide}
84
84
  _icon={{
85
- size: '30px',
85
+ size: '25px',
86
86
  color: mode === MODE_SIDE ? 'primary.100' : '#000',
87
87
  }}
88
88
  disabled={mode === MODE_SIDE}
@@ -222,20 +222,20 @@ function Viewer(props) {
222
222
 
223
223
  return <Column flex={flex} {...props} onLayout={onLayout}>
224
224
  {containerWidth && <>
225
- {onEditMode && <Row px={4} pt={4} alignItems="center" justifyContent="flex-end">
226
- <Button
227
- key="editBtn"
228
- onPress={onEditMode}
229
- leftIcon={<Icon as={Pencil} color="#fff" size="sm" />}
230
- color="#fff"
231
- >To Edit</Button>
232
- </Row>}
233
- {!_.isEmpty(additionalButtons) &&
234
- <Row p={4} alignItems="center" justifyContent="flex-end" flexWrap="wrap">
235
- {additionalButtons}
236
- </Row>}
237
225
 
238
226
  <ScrollView _web={{ height: 1 }} width="100%" pb={1} ref={scrollViewRef}>
227
+ {onEditMode && <Row px={4} pt={4} alignItems="center" justifyContent="flex-end">
228
+ <Button
229
+ key="editBtn"
230
+ onPress={onEditMode}
231
+ leftIcon={<Icon as={Pencil} color="#fff" size="sm" />}
232
+ color="#fff"
233
+ >To Edit</Button>
234
+ </Row>}
235
+ {!_.isEmpty(additionalButtons) &&
236
+ <Row p={4} alignItems="center" justifyContent="flex-end" flexWrap="wrap">
237
+ {additionalButtons}
238
+ </Row>}
239
239
  <Column>
240
240
  {containerWidth >= CONTAINER_THRESHOLD ? <Row p={4} pl={0}>{viewerComponents}</Row> : null}
241
241
  {containerWidth < CONTAINER_THRESHOLD ? <Column p={4}>{viewerComponents}</Column> : null}
@@ -16,6 +16,7 @@ import {
16
16
  FILE_MODE_FILE,
17
17
  } from '../../Constants/File.js';
18
18
  import { Avatar, Dropzone, FileMosaic, FileCard, FileInputButton, } from "@files-ui/react";
19
+ import withAlert from '../../Components/Hoc/withAlert.js';
19
20
  import withData from '../../Components/Hoc/withData.js';
20
21
  import _ from 'lodash';
21
22
 
@@ -40,6 +41,7 @@ function AttachmentsElement(props) {
40
41
  maxFiles = null,
41
42
  disabled = false,
42
43
  clickable = true,
44
+ confirmBeforeDelete = false,
43
45
 
44
46
  // parentContainer
45
47
  selectorSelected,
@@ -47,6 +49,9 @@ function AttachmentsElement(props) {
47
49
  // withData
48
50
  Repository,
49
51
 
52
+ // withAlert
53
+ confirm,
54
+
50
55
  } = props,
51
56
  styles = UiGlobals.styles,
52
57
  model = _.isArray(selectorSelected) && selectorSelected[0] ? selectorSelected[0].repository?.name : selectorSelected?.repository?.name,
@@ -113,6 +118,13 @@ function AttachmentsElement(props) {
113
118
  }
114
119
  },
115
120
  onFileDelete = (id) => {
121
+ if (confirmBeforeDelete) {
122
+ confirm('Are you sure you want to delete?', () => doDelete(id));
123
+ } else {
124
+ doDelete(id);
125
+ }
126
+ },
127
+ doDelete = (id) => {
116
128
  Repository.deleteById(id);
117
129
  };
118
130
 
@@ -263,4 +275,4 @@ function withAdditionalProps(WrappedComponent) {
263
275
  };
264
276
  }
265
277
 
266
- export default withAdditionalProps(withData(AttachmentsElement));
278
+ export default withAdditionalProps(withAlert(withData(AttachmentsElement)));