@onehat/ui 0.4.74 → 0.4.76

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.4.74",
3
+ "version": "0.4.76",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -33,6 +33,7 @@ function InlineEditor(props) {
33
33
  onEditorSave,
34
34
  onEditorClose,
35
35
  editorStateRef,
36
+ showSelectHandle = true,
36
37
 
37
38
  // withComponent
38
39
  self,
@@ -152,6 +153,7 @@ function InlineEditor(props) {
152
153
  onClose={onEditorClose}
153
154
  parent={self}
154
155
  reference="form"
156
+ showSelectHandle={showSelectHandle}
155
157
  className={clsx(
156
158
  'InlineEditor-Form',
157
159
  'flex-1',
@@ -88,6 +88,7 @@ export const ComboComponent = forwardRef((props, ref) => {
88
88
  isInTag = false,
89
89
  minimizeForRow = false,
90
90
  reloadOnTrigger = false,
91
+ searchHasInitialPercent = false,
91
92
  menuHeight,
92
93
  placeholder,
93
94
  onRowPress,
@@ -483,7 +484,7 @@ export const ComboComponent = forwardRef((props, ref) => {
483
484
  filterName = getFilterName(isId);
484
485
  if (Repository.isRemote) {
485
486
  // remote
486
- const filterValue = _.isEmpty(value) ? null : (isId ? value.match(idRegex)[1] : value + '%');
487
+ const filterValue = _.isEmpty(value) ? null : (isId ? value.match(idRegex)[1] : (searchHasInitialPercent ? '%' : '') + value + '%');
487
488
  await Repository.filter(filterName, filterValue);
488
489
  if (!Repository.isAutoLoad) {
489
490
  await Repository.reload();
@@ -112,6 +112,7 @@ function Form(props) {
112
112
  additionalFooterButtons,
113
113
  disableFooter = false,
114
114
  hideResetButton = false,
115
+ showSelectHandle = false,
115
116
 
116
117
  // sizing of outer container
117
118
  maxHeight,
@@ -414,6 +415,9 @@ function Form(props) {
414
415
  }
415
416
 
416
417
  let elementClassName = 'Form-Element';
418
+ if (showSelectHandle && ix === 0) {
419
+ elementClassName += ' ml-[40px]';
420
+ }
417
421
  if (type.match(/Tag/)) {
418
422
  elementClassName += ' overflow-auto';
419
423
  }
@@ -10,6 +10,7 @@ import {
10
10
  UPLOAD_DOWNLOAD,
11
11
  DOWNLOAD,
12
12
  } from '../../Constants/Commands.js';
13
+ import Inflector from 'inflector-js';
13
14
  import Clipboard from '../Icons/Clipboard.js';
14
15
  import Duplicate from '../Icons/Duplicate.js';
15
16
  import Edit from '../Icons/Edit.js';
@@ -78,7 +79,10 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
78
79
  disableDuplicate = !isEditor,
79
80
  disablePrint = !isGrid,
80
81
  protectedValues, // records with these values cannot be edited or deleted
81
-
82
+ addDisplayMsg,
83
+ editDisplayMsg,
84
+ deleteDisplayMsg,
85
+
82
86
  // withAlert
83
87
  showInfo,
84
88
 
@@ -90,6 +94,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
90
94
  self,
91
95
 
92
96
  // withData
97
+ model,
93
98
  Repository,
94
99
 
95
100
  // withPermissions
@@ -219,7 +224,16 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
219
224
  switch(type) {
220
225
  case ADD:
221
226
  key = 'addBtn';
222
- text = 'Add';
227
+ if (addDisplayMsg) {
228
+ text = addDisplayMsg;
229
+ } else {
230
+ text = 'Add';
231
+ if (model) {
232
+ let inflected = Inflector.singularize(model); // can only add one at a time
233
+ inflected = Inflector.camel2words(Inflector.humanize(Inflector.underscore(inflected))); // Separate with spaces, capitalize each word
234
+ text += ' ' + inflected;
235
+ }
236
+ }
223
237
  handler = (parent, e) => {
224
238
  onAdd();
225
239
  };
@@ -232,7 +246,21 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
232
246
  break;
233
247
  case EDIT:
234
248
  key = 'editBtn';
235
- text = 'Edit';
249
+ if (editDisplayMsg) {
250
+ text = editDisplayMsg;
251
+ } else {
252
+ text = 'Edit';
253
+ if (model) {
254
+ let inflected = model;
255
+ if (selection.length <= 1) {
256
+ inflected = Inflector.singularize(inflected);
257
+ } else {
258
+ inflected = Inflector.pluralize(inflected);
259
+ }
260
+ inflected = Inflector.camel2words(Inflector.humanize(Inflector.underscore(inflected))); // Separate with spaces, capitalize each word
261
+ text += ' ' + inflected;
262
+ }
263
+ }
236
264
  handler = (parent, e) => {
237
265
  onEdit();
238
266
  };
@@ -248,7 +276,21 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
248
276
  break;
249
277
  case DELETE:
250
278
  key = 'deleteBtn';
251
- text = 'Delete';
279
+ if (deleteDisplayMsg) {
280
+ text = deleteDisplayMsg;
281
+ } else {
282
+ text = 'Delete';
283
+ if (model) {
284
+ let inflected = model;
285
+ if (selection.length <= 1) {
286
+ inflected = Inflector.singularize(inflected);
287
+ } else {
288
+ inflected = Inflector.pluralize(inflected);
289
+ }
290
+ inflected = Inflector.camel2words(Inflector.humanize(Inflector.underscore(inflected))); // Separate with spaces, capitalize each word
291
+ text += ' ' + inflected;
292
+ }
293
+ }
252
294
  handler = onDelete;
253
295
  handler = (parent, e) => {
254
296
  onDelete();
@@ -133,7 +133,7 @@ function Report(props) {
133
133
  reportType: REPORT_TYPES__EXCEL,
134
134
  showReportHeaders,
135
135
  }),
136
- disabledOnInvalid: true,
136
+ disableOnInvalid: true,
137
137
  });
138
138
  }
139
139
  if (!disablePdf) {