@visns-studio/visns-components 5.26.0 → 5.26.1

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
@@ -94,7 +94,7 @@
94
94
  "react-dom": "^17.0.0 || ^18.0.0"
95
95
  },
96
96
  "name": "@visns-studio/visns-components",
97
- "version": "5.26.0",
97
+ "version": "5.26.1",
98
98
  "description": "Various packages to assist in the development of our Custom Applications.",
99
99
  "main": "src/index.js",
100
100
  "files": [
@@ -9,7 +9,7 @@ import moment from 'moment';
9
9
  import parse from 'html-react-parser';
10
10
  import _ from 'lodash';
11
11
  import ReactDataGrid from '@visns-studio/visns-datagrid-enterprise';
12
- import { X } from 'lucide-react';
12
+ import { Info, X } from 'lucide-react';
13
13
  import imageCompression from 'browser-image-compression';
14
14
  import { confirmDialog } from './utils/ConfirmDialog';
15
15
 
@@ -3376,82 +3376,128 @@ function Form({
3376
3376
  </div>
3377
3377
  );
3378
3378
  } else if (formType === 'update') {
3379
+ const saveAnotherDisableWhen =
3380
+ formSettings.update?.saveAnother
3381
+ ?.disableWhen;
3382
+ const saveAnotherDisabled =
3383
+ saveAnotherDisableWhen
3384
+ ? evaluateDisableWhen(
3385
+ saveAnotherDisableWhen,
3386
+ formData
3387
+ )
3388
+ : false;
3389
+
3379
3390
  return (
3380
- <div
3381
- className={`${styles.formItem} ${styles.fwItem} ${styles.buttonContainer}`}
3382
- >
3383
- <button
3384
- className={styles.btn}
3385
- onClick={handleSubmit}
3386
- data-type="save"
3391
+ <>
3392
+ <div
3393
+ className={`${styles.formItem} ${styles.fwItem} ${styles.buttonContainer}`}
3387
3394
  >
3388
- Save & Close
3389
- </button>
3390
- {formSettings.update?.hasOwnProperty(
3391
- 'saveAnother'
3392
- ) &&
3393
- (() => {
3394
- const disableWhen =
3395
- formSettings.update
3396
- .saveAnother
3397
- ?.disableWhen;
3398
- const isDisabled =
3399
- disableWhen
3400
- ? evaluateDisableWhen(
3401
- disableWhen,
3402
- formData
3403
- )
3404
- : false;
3405
-
3406
- return (
3407
- <button
3408
- className={
3409
- styles.btn
3410
- }
3411
- onClick={
3412
- handleSubmit
3413
- }
3414
- data-type="saveAnother"
3415
- disabled={
3416
- isDisabled
3417
- }
3418
- title={
3419
- isDisabled
3420
- ? disableWhen?.message ||
3421
- ''
3422
- : undefined
3423
- }
3424
- style={
3425
- isDisabled
3426
- ? {
3427
- opacity: 0.5,
3428
- cursor: 'not-allowed',
3429
- }
3430
- : undefined
3431
- }
3432
- >
3433
- {formSettings
3434
- .update
3435
- .saveAnother
3436
- ?.label ||
3437
- 'Save & Create Another'}
3438
- </button>
3439
- );
3440
- })()}
3441
- {formSettings.update?.hasOwnProperty(
3442
- 'saveExit'
3443
- ) && (
3444
3395
  <button
3445
3396
  className={styles.btn}
3446
3397
  onClick={handleSubmit}
3447
- data-type="saveExit"
3398
+ data-type="save"
3448
3399
  >
3449
- {formSettings.update
3450
- .saveExit?.label ||
3451
- 'Save & Exit'}
3400
+ Save & Close
3452
3401
  </button>
3402
+ {formSettings.update?.hasOwnProperty(
3403
+ 'saveAnother'
3404
+ ) && (
3405
+ <button
3406
+ className={
3407
+ styles.btn
3408
+ }
3409
+ onClick={
3410
+ handleSubmit
3411
+ }
3412
+ data-type="saveAnother"
3413
+ disabled={
3414
+ saveAnotherDisabled
3415
+ }
3416
+ style={
3417
+ saveAnotherDisabled
3418
+ ? {
3419
+ opacity: 0.5,
3420
+ cursor: 'not-allowed',
3421
+ }
3422
+ : undefined
3423
+ }
3424
+ >
3425
+ {formSettings
3426
+ .update
3427
+ .saveAnother
3428
+ ?.label ||
3429
+ 'Save & Create Another'}
3430
+ </button>
3431
+ )}
3432
+ {formSettings.update?.hasOwnProperty(
3433
+ 'saveExit'
3434
+ ) && (
3435
+ <button
3436
+ className={
3437
+ styles.btn
3438
+ }
3439
+ onClick={
3440
+ handleSubmit
3441
+ }
3442
+ data-type="saveExit"
3443
+ >
3444
+ {formSettings
3445
+ .update
3446
+ .saveExit
3447
+ ?.label ||
3448
+ 'Save & Exit'}
3449
+ </button>
3450
+ )}
3451
+ </div>
3452
+ {saveAnotherDisabled && (
3453
+ /* Always-visible note (hover
3454
+ tooltips don't exist on
3455
+ tablets) explaining why the
3456
+ button is disabled */
3457
+ <div
3458
+ className={`${styles.formItem} ${styles.fwItem}`}
3459
+ style={{
3460
+ display: 'flex',
3461
+ justifyContent:
3462
+ 'flex-end',
3463
+ }}
3464
+ >
3465
+ <div
3466
+ style={{
3467
+ display: 'flex',
3468
+ alignItems:
3469
+ 'center',
3470
+ gap: '8px',
3471
+ fontSize:
3472
+ '0.85rem',
3473
+ color: '#1e40af',
3474
+ backgroundColor:
3475
+ '#eff6ff',
3476
+ border: '1px solid #bfdbfe',
3477
+ borderRadius:
3478
+ '6px',
3479
+ padding:
3480
+ '8px 12px',
3481
+ marginTop:
3482
+ '8px',
3483
+ maxWidth:
3484
+ '100%',
3485
+ }}
3486
+ >
3487
+ <Info
3488
+ size={16}
3489
+ style={{
3490
+ flexShrink: 0,
3491
+ }}
3492
+ />
3493
+ <span>
3494
+ {saveAnotherDisableWhen?.message ||
3495
+ 'This action is currently unavailable.'}
3496
+ </span>
3497
+ </div>
3498
+ </div>
3453
3499
  )}
3454
- </div>
3500
+ </>
3455
3501
  );
3456
3502
  } else {
3457
3503
  return (