onshore-forms 1.1.10 → 1.1.12

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.
@@ -367,6 +367,7 @@ class OnshoreFormItemContainer {
367
367
  formContainer;
368
368
  disabled = false;
369
369
  tempLockValue;
370
+ initialFormTemplate = undefined;
370
371
  OnshoreFormTemplateLayout = OnshoreFormTemplateLayout;
371
372
  layout = OnshoreFormTemplateLayout.auto;
372
373
  enabled(enable = true) {
@@ -503,6 +504,7 @@ class OnshoreFormAutocompleteItemComponent {
503
504
  onSelect = new EventEmitter();
504
505
  actionButtonClick = new EventEmitter();
505
506
  disabled = false;
507
+ initialFormTemplate = undefined;
506
508
  searchPrepare(term) {
507
509
  if (term.query != '') {
508
510
  this.search(term.query);
@@ -564,10 +566,14 @@ class OnshoreFormAutocompleteItemComponent {
564
566
  checkExclude() {
565
567
  setTimeout(() => {
566
568
  if (this.exclude) {
567
- this.ngControl.control?.disable();
569
+ if (this.initialFormTemplate === undefined)
570
+ this.initialFormTemplate = this.formTemplate;
571
+ this.ngControl.control?.clearValidators();
568
572
  }
569
573
  else {
570
- this.ngControl.control?.enable();
574
+ if (this.initialFormTemplate !== undefined) {
575
+ this.ngControl.control?.setValidators(this.initialFormTemplate.validators);
576
+ }
571
577
  }
572
578
  this.ngControl.control?.updateValueAndValidity({ onlySelf: false, emitEvent: true });
573
579
  this.cdr.markForCheck();
@@ -637,6 +643,7 @@ class OnshoreFormCheckboxItemComponent {
637
643
  exclude = false;
638
644
  actionButtonClick = new EventEmitter();
639
645
  disabled = false;
646
+ initialFormTemplate = undefined;
640
647
  // ControlValueAccessor interface
641
648
  writeValue(obj) { }
642
649
  registerOnChange(fn) { }
@@ -659,10 +666,14 @@ class OnshoreFormCheckboxItemComponent {
659
666
  checkExclude() {
660
667
  setTimeout(() => {
661
668
  if (this.exclude) {
662
- this.ngControl.control?.disable();
669
+ if (this.initialFormTemplate === undefined)
670
+ this.initialFormTemplate = this.formTemplate;
671
+ this.ngControl.control?.clearValidators();
663
672
  }
664
673
  else {
665
- this.ngControl.control?.enable();
674
+ if (this.initialFormTemplate !== undefined) {
675
+ this.ngControl.control?.setValidators(this.initialFormTemplate.validators);
676
+ }
666
677
  }
667
678
  this.ngControl.control?.updateValueAndValidity({ onlySelf: false, emitEvent: true });
668
679
  this.cdr.markForCheck();
@@ -714,6 +725,7 @@ class OnshoreFormColorpickerItemComponent {
714
725
  actionButtonClick = new EventEmitter();
715
726
  disabled = false;
716
727
  colorPickerValue = '';
728
+ initialFormTemplate = undefined;
717
729
  // ControlValueAccessor interface
718
730
  writeValue(obj) { }
719
731
  registerOnChange(fn) { }
@@ -757,10 +769,14 @@ class OnshoreFormColorpickerItemComponent {
757
769
  checkExclude() {
758
770
  setTimeout(() => {
759
771
  if (this.exclude) {
760
- this.ngControl.control?.disable();
772
+ if (this.initialFormTemplate === undefined)
773
+ this.initialFormTemplate = this.formTemplate;
774
+ this.ngControl.control?.clearValidators();
761
775
  }
762
776
  else {
763
- this.ngControl.control?.enable();
777
+ if (this.initialFormTemplate !== undefined) {
778
+ this.ngControl.control?.setValidators(this.initialFormTemplate.validators);
779
+ }
764
780
  }
765
781
  this.ngControl.control?.updateValueAndValidity({ onlySelf: false, emitEvent: true });
766
782
  this.cdr.markForCheck();
@@ -839,8 +855,8 @@ class OnshoreFormDropdownItemComponent {
839
855
  selectionLimit = 0;
840
856
  minLength = 0;
841
857
  optionLabel = 'label';
842
- optionValue = 'value';
843
- dataKey = 'value';
858
+ optionValue = '';
859
+ dataKey = '';
844
860
  secondOptionLabel = '';
845
861
  thirdOptionLabel = '';
846
862
  optionLabelDivider = '-';
@@ -853,6 +869,7 @@ class OnshoreFormDropdownItemComponent {
853
869
  actionButtonClick = new EventEmitter();
854
870
  entryCreated = new EventEmitter();
855
871
  disabled = false;
872
+ initialFormTemplate = undefined;
856
873
  // ControlValueAccessor interface
857
874
  writeValue(obj) {
858
875
  if (obj) {
@@ -889,6 +906,9 @@ class OnshoreFormDropdownItemComponent {
889
906
  this.ngControl.control?.setValue(this.formTemplate.default);
890
907
  this.cdr.markForCheck();
891
908
  }
909
+ else {
910
+ this.ngControl.control?.setValue(this.multiple ? [] : '');
911
+ }
892
912
  }
893
913
  ngOnDestroy() {
894
914
  this.ngControl.control?.disable();
@@ -896,10 +916,14 @@ class OnshoreFormDropdownItemComponent {
896
916
  checkExclude() {
897
917
  setTimeout(() => {
898
918
  if (this.exclude) {
899
- this.ngControl.control?.disable();
919
+ if (this.initialFormTemplate === undefined)
920
+ this.initialFormTemplate = this.formTemplate;
921
+ this.ngControl.control?.clearValidators();
900
922
  }
901
923
  else {
902
- this.ngControl.control?.enable();
924
+ if (this.initialFormTemplate !== undefined) {
925
+ this.ngControl.control?.setValidators(this.initialFormTemplate.validators);
926
+ }
903
927
  }
904
928
  this.ngControl.control?.updateValueAndValidity({ onlySelf: false, emitEvent: true });
905
929
  this.cdr.markForCheck();
@@ -908,8 +932,13 @@ class OnshoreFormDropdownItemComponent {
908
932
  removeSelected(value, event) {
909
933
  event.preventDefault();
910
934
  event.stopPropagation();
935
+ let selected;
911
936
  // @ts-ignore
912
- const selected = this.ngControl.control?.value.filter((x) => x !== value[this.optionValue]);
937
+ if (this.optionValue)
938
+ selected = this.ngControl.control?.value.filter((x) => x !== value[this.optionValue]);
939
+ // @ts-ignore
940
+ if (this.dataKey)
941
+ selected = this.ngControl.control?.value.filter((x) => x[this.dataKey] !== value[this.dataKey]);
913
942
  this.ngControl.control?.setValue(selected);
914
943
  this.ngControl?.control?.updateValueAndValidity({ onlySelf: false, emitEvent: true });
915
944
  this.ngControl?.control?.markAsDirty();
@@ -1210,6 +1239,7 @@ class OnshoreFormImageItemComponent {
1210
1239
  webcamDialogVisible = false;
1211
1240
  imageChooserDialogVisible = false;
1212
1241
  subscriptions = [];
1242
+ initialFormTemplate = undefined;
1213
1243
  getFileImage(image) {
1214
1244
  this.imageChooserDialogVisible = false;
1215
1245
  if (image) {
@@ -1287,10 +1317,14 @@ class OnshoreFormImageItemComponent {
1287
1317
  checkExclude() {
1288
1318
  setTimeout(() => {
1289
1319
  if (this.exclude) {
1290
- this.ngControl.control?.disable();
1320
+ if (this.initialFormTemplate === undefined)
1321
+ this.initialFormTemplate = this.formTemplate;
1322
+ this.ngControl.control?.clearValidators();
1291
1323
  }
1292
1324
  else {
1293
- this.ngControl.control?.enable();
1325
+ if (this.initialFormTemplate !== undefined) {
1326
+ this.ngControl.control?.setValidators(this.initialFormTemplate.validators);
1327
+ }
1294
1328
  }
1295
1329
  this.ngControl.control?.updateValueAndValidity({ onlySelf: false, emitEvent: true });
1296
1330
  this.cdr.markForCheck();
@@ -1366,6 +1400,7 @@ class OnshoreFormInputItemComponent {
1366
1400
  OnshoreFormTemplateType = OnshoreFormTemplateType;
1367
1401
  passwordVisible = false;
1368
1402
  disabled = false;
1403
+ initialFormTemplate = undefined;
1369
1404
  // ControlValueAccessor interface
1370
1405
  writeValue(obj) { }
1371
1406
  registerOnChange(fn) { }
@@ -1391,10 +1426,14 @@ class OnshoreFormInputItemComponent {
1391
1426
  checkExclude() {
1392
1427
  setTimeout(() => {
1393
1428
  if (this.exclude) {
1394
- this.ngControl.control?.disable();
1429
+ if (this.initialFormTemplate === undefined)
1430
+ this.initialFormTemplate = this.formTemplate;
1431
+ this.ngControl.control?.clearValidators();
1395
1432
  }
1396
1433
  else {
1397
- this.ngControl.control?.enable();
1434
+ if (this.initialFormTemplate !== undefined) {
1435
+ this.ngControl.control?.setValidators(this.initialFormTemplate.validators);
1436
+ }
1398
1437
  }
1399
1438
  this.ngControl.control?.updateValueAndValidity({ onlySelf: false, emitEvent: true });
1400
1439
  this.cdr.markForCheck();
@@ -1464,6 +1503,7 @@ class OnshoreFormSwitchItemComponent {
1464
1503
  valueChange = new EventEmitter();
1465
1504
  actionButtonClick = new EventEmitter();
1466
1505
  disabled = false;
1506
+ initialFormTemplate = undefined;
1467
1507
  // ControlValueAccessor interface
1468
1508
  writeValue(obj) { }
1469
1509
  registerOnChange(fn) { }
@@ -1486,10 +1526,14 @@ class OnshoreFormSwitchItemComponent {
1486
1526
  checkExclude() {
1487
1527
  setTimeout(() => {
1488
1528
  if (this.exclude) {
1489
- this.ngControl.control?.disable();
1529
+ if (this.initialFormTemplate === undefined)
1530
+ this.initialFormTemplate = this.formTemplate;
1531
+ this.ngControl.control?.clearValidators();
1490
1532
  }
1491
1533
  else {
1492
- this.ngControl.control?.enable();
1534
+ if (this.initialFormTemplate !== undefined) {
1535
+ this.ngControl.control?.setValidators(this.initialFormTemplate.validators);
1536
+ }
1493
1537
  }
1494
1538
  this.ngControl.control?.updateValueAndValidity({ onlySelf: false, emitEvent: true });
1495
1539
  this.cdr.markForCheck();
@@ -1546,6 +1590,7 @@ class OnshoreFormDatetimeItemComponent {
1546
1590
  dataType = 'date';
1547
1591
  OnshoreFormTemplateType = OnshoreFormTemplateType;
1548
1592
  disabled = false;
1593
+ initialFormTemplate = undefined;
1549
1594
  // ControlValueAccessor interface
1550
1595
  writeValue(obj) { }
1551
1596
  registerOnChange(fn) { }
@@ -1565,10 +1610,14 @@ class OnshoreFormDatetimeItemComponent {
1565
1610
  checkExclude() {
1566
1611
  setTimeout(() => {
1567
1612
  if (this.exclude) {
1568
- this.ngControl.control?.disable();
1613
+ if (this.initialFormTemplate === undefined)
1614
+ this.initialFormTemplate = this.formTemplate;
1615
+ this.ngControl.control?.clearValidators();
1569
1616
  }
1570
1617
  else {
1571
- this.ngControl.control?.enable();
1618
+ if (this.initialFormTemplate !== undefined) {
1619
+ this.ngControl.control?.setValidators(this.initialFormTemplate.validators);
1620
+ }
1572
1621
  }
1573
1622
  this.ngControl.control?.updateValueAndValidity({ onlySelf: false, emitEvent: true });
1574
1623
  this.cdr.markForCheck();
@@ -1628,6 +1677,7 @@ class OnshoreFormSortItemComponent {
1628
1677
  tempLockValue = [];
1629
1678
  OnshoreFormTemplateType = OnshoreFormTemplateType;
1630
1679
  disabled = false;
1680
+ initialFormTemplate = undefined;
1631
1681
  sortItemsChanged(event) {
1632
1682
  this.sortItems = event;
1633
1683
  this.ngControl?.control?.setValue(event);
@@ -1676,10 +1726,14 @@ class OnshoreFormSortItemComponent {
1676
1726
  checkExclude() {
1677
1727
  setTimeout(() => {
1678
1728
  if (this.exclude) {
1679
- this.ngControl.control?.disable();
1729
+ if (this.initialFormTemplate === undefined)
1730
+ this.initialFormTemplate = this.formTemplate;
1731
+ this.ngControl.control?.clearValidators();
1680
1732
  }
1681
1733
  else {
1682
- this.ngControl.control?.enable();
1734
+ if (this.initialFormTemplate !== undefined) {
1735
+ this.ngControl.control?.setValidators(this.initialFormTemplate.validators);
1736
+ }
1683
1737
  }
1684
1738
  this.ngControl.control?.updateValueAndValidity({ onlySelf: false, emitEvent: true });
1685
1739
  this.cdr.markForCheck();
@@ -1740,6 +1794,7 @@ class OnshoreFormScannerItemComponent {
1740
1794
  webcamClick = new EventEmitter();
1741
1795
  scannerClick = new EventEmitter();
1742
1796
  disabled = false;
1797
+ initialFormTemplate = undefined;
1743
1798
  // ControlValueAccessor interface
1744
1799
  writeValue(obj) { }
1745
1800
  registerOnChange(fn) { }
@@ -1765,10 +1820,14 @@ class OnshoreFormScannerItemComponent {
1765
1820
  checkExclude() {
1766
1821
  setTimeout(() => {
1767
1822
  if (this.exclude) {
1768
- this.ngControl.control?.disable();
1823
+ if (this.initialFormTemplate === undefined)
1824
+ this.initialFormTemplate = this.formTemplate;
1825
+ this.ngControl.control?.clearValidators();
1769
1826
  }
1770
1827
  else {
1771
- this.ngControl.control?.enable();
1828
+ if (this.initialFormTemplate !== undefined) {
1829
+ this.ngControl.control?.setValidators(this.initialFormTemplate.validators);
1830
+ }
1772
1831
  }
1773
1832
  this.ngControl.control?.updateValueAndValidity({ onlySelf: false, emitEvent: true });
1774
1833
  this.cdr.markForCheck();