@solidstarters/solid-core-ui 1.1.21 → 1.1.23

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.
Files changed (95) hide show
  1. package/dist/components/common/SolidBreadcrumb.d.ts +2 -10
  2. package/dist/components/common/SolidBreadcrumb.d.ts.map +1 -1
  3. package/dist/components/common/SolidBreadcrumb.js +28 -8
  4. package/dist/components/common/SolidBreadcrumb.js.map +1 -1
  5. package/dist/components/core/common/SolidGlobalSearchElement.d.ts.map +1 -1
  6. package/dist/components/core/common/SolidGlobalSearchElement.js +1 -0
  7. package/dist/components/core/common/SolidGlobalSearchElement.js.map +1 -1
  8. package/dist/components/core/common/SolidViewLayoutManager.d.ts +13 -0
  9. package/dist/components/core/common/SolidViewLayoutManager.d.ts.map +1 -0
  10. package/dist/components/core/common/SolidViewLayoutManager.js +90 -0
  11. package/dist/components/core/common/SolidViewLayoutManager.js.map +1 -0
  12. package/dist/components/core/extension/solid-core/modelMetadata/list/GenerateModelCodeRowAction.d.ts.map +1 -1
  13. package/dist/components/core/extension/solid-core/modelMetadata/list/GenerateModelCodeRowAction.js +6 -4
  14. package/dist/components/core/extension/solid-core/modelMetadata/list/GenerateModelCodeRowAction.js.map +1 -1
  15. package/dist/components/core/extension/solid-core/moduleMetadata/list/GenerateModuleCodeRowAction.d.ts.map +1 -1
  16. package/dist/components/core/extension/solid-core/moduleMetadata/list/GenerateModuleCodeRowAction.js +5 -3
  17. package/dist/components/core/extension/solid-core/moduleMetadata/list/GenerateModuleCodeRowAction.js.map +1 -1
  18. package/dist/components/core/form/SolidFormLayouts.d.ts.map +1 -1
  19. package/dist/components/core/form/SolidFormLayouts.js +6 -2
  20. package/dist/components/core/form/SolidFormLayouts.js.map +1 -1
  21. package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
  22. package/dist/components/core/form/SolidFormView.js +157 -44
  23. package/dist/components/core/form/SolidFormView.js.map +1 -1
  24. package/dist/components/core/form/fields/ISolidField.d.ts +2 -0
  25. package/dist/components/core/form/fields/ISolidField.d.ts.map +1 -1
  26. package/dist/components/core/form/fields/SolidSelectionStaticField.d.ts.map +1 -1
  27. package/dist/components/core/form/fields/SolidSelectionStaticField.js +3 -1
  28. package/dist/components/core/form/fields/SolidSelectionStaticField.js.map +1 -1
  29. package/dist/components/core/form/fields/SolidShortTextField.d.ts.map +1 -1
  30. package/dist/components/core/form/fields/SolidShortTextField.js +4 -1
  31. package/dist/components/core/form/fields/SolidShortTextField.js.map +1 -1
  32. package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.d.ts.map +1 -1
  33. package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js +0 -2
  34. package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js.map +1 -1
  35. package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js +2 -2
  36. package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js.map +1 -1
  37. package/dist/components/core/list/SolidListView.js +1 -1
  38. package/dist/components/core/model/CreateModel.d.ts.map +1 -1
  39. package/dist/components/core/model/CreateModel.js +3 -9
  40. package/dist/components/core/model/CreateModel.js.map +1 -1
  41. package/dist/components/core/model/FieldMetaData.d.ts +1 -1
  42. package/dist/components/core/model/FieldMetaData.d.ts.map +1 -1
  43. package/dist/components/core/model/FieldMetaData.js +2 -2
  44. package/dist/components/core/model/FieldMetaData.js.map +1 -1
  45. package/dist/components/core/model/FieldMetaDataForm.d.ts +1 -1
  46. package/dist/components/core/model/FieldMetaDataForm.d.ts.map +1 -1
  47. package/dist/components/core/model/FieldMetaDataForm.js +17 -9
  48. package/dist/components/core/model/FieldMetaDataForm.js.map +1 -1
  49. package/dist/components/core/model/ModelMetaData.js +5 -5
  50. package/dist/components/core/model/ModelMetaData.js.map +1 -1
  51. package/dist/components/core/module/CreateModule.d.ts.map +1 -1
  52. package/dist/components/core/module/CreateModule.js +1 -5
  53. package/dist/components/core/module/CreateModule.js.map +1 -1
  54. package/dist/components/core/users/CreateUser.d.ts.map +1 -1
  55. package/dist/components/core/users/CreateUser.js +1 -5
  56. package/dist/components/core/users/CreateUser.js.map +1 -1
  57. package/dist/components/layout/AppSidebar.d.ts.map +1 -1
  58. package/dist/components/layout/AppSidebar.js +21 -34
  59. package/dist/components/layout/AppSidebar.js.map +1 -1
  60. package/dist/helpers/AppTitle.d.ts.map +1 -1
  61. package/dist/helpers/AppTitle.js.map +1 -1
  62. package/dist/helpers/registry.d.ts +6 -0
  63. package/dist/helpers/registry.d.ts.map +1 -0
  64. package/dist/helpers/registry.js +37 -0
  65. package/dist/helpers/registry.js.map +1 -0
  66. package/dist/index.d.ts +3 -1
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +2 -0
  69. package/dist/index.js.map +1 -1
  70. package/package.json +1 -1
  71. package/src/components/common/SolidBreadcrumb.tsx +38 -14
  72. package/src/components/core/common/SolidGlobalSearchElement.tsx +2 -0
  73. package/src/components/core/common/SolidViewLayoutManager.ts +85 -0
  74. package/src/components/core/extension/solid-core/modelMetadata/list/GenerateModelCodeRowAction.tsx +11 -1
  75. package/src/components/core/extension/solid-core/moduleMetadata/list/GenerateModuleCodeRowAction.tsx +16 -7
  76. package/src/components/core/form/SolidFormLayouts.tsx +6 -3
  77. package/src/components/core/form/SolidFormView.tsx +180 -38
  78. package/src/components/core/form/fields/ISolidField.tsx +3 -1
  79. package/src/components/core/form/fields/SolidSelectionStaticField.tsx +2 -1
  80. package/src/components/core/form/fields/SolidShortTextField.tsx +4 -2
  81. package/src/components/core/form/fields/relations/SolidRelationManyToManyField.tsx +0 -2
  82. package/src/components/core/form/fields/relations/SolidRelationManyToOneField.tsx +6 -6
  83. package/src/components/core/list/SolidListView.tsx +1 -1
  84. package/src/components/core/model/CreateModel.tsx +8 -12
  85. package/src/components/core/model/FieldMetaData.tsx +2 -2
  86. package/src/components/core/model/FieldMetaDataForm.tsx +338 -332
  87. package/src/components/core/model/ModelMetaData.tsx +5 -5
  88. package/src/components/core/module/CreateModule.tsx +1 -6
  89. package/src/components/core/users/CreateUser.tsx +1 -6
  90. package/src/components/layout/AppSidebar.tsx +3 -21
  91. package/src/helpers/AppTitle.tsx +0 -2
  92. package/src/helpers/registry.ts +52 -0
  93. package/src/index.ts +16 -1
  94. package/src/types/index.d.ts +26 -1
  95. package/src/types/solid-core.d.ts +90 -0
@@ -16,13 +16,22 @@ const GenerateModuleCodeRowAction = ({ context }: any) => {
16
16
  }
17
17
 
18
18
  return (
19
- <div>
20
- <p className="text-center">Click Ok to proceed with module code generation, please note that if the file already exists and <br></br>you have made custom changes to this file we will create a .bkp file as a backup of the existing file.</p>
21
- <div className="flex gap-5 justify-content-center">
22
- <Button label="Ok" icon="pi pi-check" className='small-button' severity="danger" autoFocus onClick={generateCodeHandler} />
23
- <Button label="Cancel" icon="pi pi-times" className='small-button' onClick={() => context.closeListViewRowActionPopup()} />
24
- </div>
25
- </div >
19
+ <>
20
+ {context?.rowData?.name != "solid-core" ? <div>
21
+ <p className="text-center">Click Ok to proceed with module code generation, please note that if the file already exists and <br></br>you have made custom changes to this file we will create a .bkp file as a backup of the existing file.</p>
22
+ <div className="flex gap-5 justify-content-center">
23
+ <Button label="Ok" icon="pi pi-check" className='small-button' severity="danger" autoFocus onClick={generateCodeHandler} />
24
+ <Button label="Cancel" icon="pi pi-times" className='small-button' onClick={() => context.closeListViewRowActionPopup()} />
25
+ </div>
26
+ </div> :
27
+ <div>
28
+ <p className="">You cannot generate code for Solid Core modules</p>
29
+ <div className="flex gap-5 justify-content-center">
30
+ {/* <Button label="Ok" icon="pi pi-check" className='small-button' severity="danger" autoFocus onClick={generateCodeHandler} /> */}
31
+ <Button label="Close" icon="pi pi-times" className='small-button' onClick={() => context.closeListViewRowActionPopup()} />
32
+ </div>
33
+ </div >}
34
+ </>
26
35
  )
27
36
  }
28
37
 
@@ -18,7 +18,6 @@ type SolidViewParams = {
18
18
  };
19
19
 
20
20
  const SolidFormLayouts = ({ params }: any) => {
21
-
22
21
  const {
23
22
  data: modelData,
24
23
  error,
@@ -27,7 +26,9 @@ const SolidFormLayouts = ({ params }: any) => {
27
26
  refetch
28
27
  } = useGetmodelByIdQuery(params.id);
29
28
  useEffect(() => {
30
- refetch();
29
+ if (params?.id !== 'new') {
30
+ refetch();
31
+ }
31
32
  }, [refetch]);
32
33
 
33
34
  const {
@@ -49,7 +50,9 @@ const SolidFormLayouts = ({ params }: any) => {
49
50
  refetch: refetchuser
50
51
  } = useGetusersByIdQuery(params.id);
51
52
  useEffect(() => {
52
- refetchuser();
53
+ if (params?.modelName === 'user') {
54
+ refetchuser();
55
+ }
53
56
  }, [refetchuser]);
54
57
 
55
58
  return (
@@ -14,7 +14,7 @@ import { Dialog } from "primereact/dialog";
14
14
  import { TabPanel, TabView } from "primereact/tabview";
15
15
  import { Toast } from "primereact/toast";
16
16
  import qs from "qs";
17
- import { useEffect, useRef, useState } from "react";
17
+ import { ChangeEvent, useEffect, useRef, useState } from "react";
18
18
  import * as Yup from "yup";
19
19
  import { FormikObject, ISolidField, SolidFieldProps } from "./fields/ISolidField";
20
20
  import { SolidBooleanField } from "./fields/SolidBooleanField";
@@ -33,9 +33,10 @@ import { SolidSelectionStaticField } from "./fields/SolidSelectionStaticField";
33
33
  import { SolidShortTextField } from "./fields/SolidShortTextField";
34
34
  import { SolidTimeField } from "./fields/SolidTimeField";
35
35
  import { BackButton } from "@/components/common/BackButton";
36
- import { SolidFormStepper } from "@/components/common/SolidFormStepper";
37
36
  import { OverlayPanel } from "primereact/overlaypanel";
38
37
  import { SolidBreadcrumb } from "@/components/common/SolidBreadcrumb";
38
+ import { SolidUiEvent } from "@/types";
39
+ import { getExtensionComponent, getExtensionFunction } from "@/helpers/registry";
39
40
 
40
41
  export type SolidFormViewProps = {
41
42
  moduleName: string;
@@ -131,7 +132,7 @@ const fieldFactory = (type: string, fieldContext: SolidFieldProps): ISolidField
131
132
  }
132
133
 
133
134
  // solidFieldsMetadata={solidFieldsMetadata} solidView={solidView}
134
- const SolidField = ({ formik, field, fieldMetadata, initialEntityData, solidFormViewMetaData, modelName, readOnly }: any) => {
135
+ const SolidField = ({ formik, field, fieldMetadata, initialEntityData, solidFormViewMetaData, modelName, readOnly, onChange, onBlur }: any) => {
135
136
  const fieldContext: SolidFieldProps = {
136
137
  // field metadata - coming from the field-metadata table.
137
138
  fieldMetadata: fieldMetadata,
@@ -142,7 +143,9 @@ const SolidField = ({ formik, field, fieldMetadata, initialEntityData, solidForm
142
143
  // complete form view metadata - this includes layout of the whole form & metadata about all fields in the corresponding model.
143
144
  solidFormViewMetaData: solidFormViewMetaData,
144
145
  modelName: modelName,
145
- readOnly: readOnly
146
+ readOnly: readOnly,
147
+ onChange: onChange,
148
+ onBlur: onBlur
146
149
  }
147
150
  const solidField = fieldFactory(fieldMetadata?.type, fieldContext);
148
151
 
@@ -470,7 +473,7 @@ const SolidFormView = (params: SolidFormViewProps) => {
470
473
  field: layoutFieldsObj[key],
471
474
  data: initialEntityData,
472
475
  solidFormViewMetaData: solidFormViewMetaData,
473
- modelName: params.modelName,
476
+ modelName: params.modelName
474
477
  }
475
478
 
476
479
  let solidField = fieldFactory(fieldMetadata?.type, fieldContext);
@@ -538,6 +541,8 @@ const SolidFormView = (params: SolidFormViewProps) => {
538
541
  }
539
542
  }
540
543
  }
544
+ // TODO: Possible optimisation here, we are firing 2 queries to load the form view data object.
545
+ // once without populate & populateMedia and then again once after that.
541
546
  const formViewDataQs = qs.stringify({ populate: toPopulate, populateMedia: toPopulateMedia }, {
542
547
  encodeValuesOnly: true,
543
548
  });
@@ -560,6 +565,7 @@ const SolidFormView = (params: SolidFormViewProps) => {
560
565
 
561
566
  let formik: FormikObject;
562
567
 
568
+ // If either the metadata or the data of this form is loading, then we simply render a loading screen...
563
569
  if (solidFormViewMetaDataIsLoading || solidFormViewDataIsLoading || !formViewLayout) {
564
570
  formik = useFormik({
565
571
  initialValues: {},
@@ -570,6 +576,7 @@ const SolidFormView = (params: SolidFormViewProps) => {
570
576
 
571
577
  return <div>Rendering form...</div>;
572
578
  }
579
+ // At this point everything required to render the form is loaded, so we go ahead and start rendering things dynamically...
573
580
  else {
574
581
 
575
582
  // Initialize formik...
@@ -590,7 +597,7 @@ const SolidFormView = (params: SolidFormViewProps) => {
590
597
  field: formLayoutField,
591
598
  data: initialEntityData,
592
599
  solidFormViewMetaData: solidFormViewMetaData,
593
- modelName: params.modelName,
600
+ modelName: params.modelName
594
601
  }
595
602
  let solidField = fieldFactory(fieldMetadata?.type, fieldContext);
596
603
  if (!fieldMetadata?.type) {
@@ -615,42 +622,174 @@ const SolidFormView = (params: SolidFormViewProps) => {
615
622
  onSubmit: onFormikSubmit,
616
623
  });
617
624
 
625
+ const formFieldOnXXX = async (event: ChangeEvent<HTMLInputElement>, eventType: string) => {
626
+
627
+ // Invoke the formik change
628
+ if (eventType === 'onFieldChange') {
629
+ formik.handleChange(event);
630
+ }
631
+
632
+ // get details from the form event
633
+ const { name: fieldName, value, type, checked } = event.target;
634
+ // console.log(`${eventType}: formFieldOnXXX ${fieldName} invoked for change with value:`, value);
635
+
636
+ // TODO: check if there is a change handler registered with this form view, load it and fire it.
637
+ const changeHandler = solidView.layout[eventType];
638
+ // console.log(`changeHandler for this form is ${changeHandler}`);
639
+
640
+ if (changeHandler) {
641
+ // Get hold of the dynamic module...
642
+ // const dynamicChangeHandler = await loadDynamicModule(changeHandler);
643
+ const dynamicChangeHandler = getExtensionFunction(changeHandler);
644
+
645
+ // Invoke the dynamic module...
646
+ if (dynamicChangeHandler) {
647
+ const event: SolidUiEvent = {
648
+ fieldsMetadata: solidFieldsMetadata,
649
+ formData: formik.values,
650
+ modifiedField: fieldName,
651
+ modifiedFieldValue: value,
652
+ // @ts-ignore
653
+ // TODO: HP & OR: This will be fixed once we figure out how to get types exported from solid-core-ui
654
+ type: eventType,
655
+ viewMetadata: solidView
656
+ }
657
+ const updatedFormInfo = dynamicChangeHandler(event);
658
+ // console.log(`${eventType}: formFieldOnXXX response received: `, updatedFormInfo);
659
+
660
+ // If dataChanged is true, update Formik values
661
+ if (updatedFormInfo?.dataChanged && updatedFormInfo.newFormData) {
662
+ // This does one field at a time.
663
+ Object.entries(updatedFormInfo.newFormData).forEach(([key, newValue]) => {
664
+ formik.setFieldValue(key, newValue);
665
+ });
666
+
667
+ // This does all at once.
668
+ // if (updatedFormInfo?.dataChanged && updatedFormInfo.newData) {
669
+ // formik.setValues({
670
+ // ...formik.values,
671
+ // ...updatedFormInfo.newFormData
672
+ // });
673
+ // }
674
+ }
675
+
676
+ // if layout has changed then we need to re-render.
677
+ if (updatedFormInfo?.layoutChanged && updatedFormInfo.newLayout) {
678
+ // setFormViewMetaData({ ...formViewMetaData, layout: updatedFormInfo.newLayout });
679
+ // console.log(`Existing form view metadata is: `, formViewMetaData);
680
+
681
+ // TODO: this will trigger a useEffect dependent on formViewMetadata that invokes setFormViewLayout, which means that this will not work if custom layout has been injected as a prop.
682
+ setFormViewLayout(updatedFormInfo.newLayout);
683
+ setFormViewMetaData((prevMetaData: any) => {
684
+ const updatedFormViewMetadata = {
685
+ ...prevMetaData,
686
+ data: {
687
+ ...prevMetaData.data,
688
+ solidView: {
689
+ ...prevMetaData.data.solidView,
690
+ layout: updatedFormInfo.newLayout,
691
+ },
692
+ },
693
+ };
694
+ // console.log(`Updated form view metadata is: `, updatedFormViewMetadata);
695
+ return updatedFormViewMetadata;
696
+ });
697
+ }
698
+ }
699
+ else {
700
+ console.log(`Unable to load dynamic module:`, changeHandler);
701
+ }
702
+ }
703
+ }
704
+
618
705
  // Now render the form dynamically...
619
706
  const renderFormElementDynamically: any = (element: any, solidFormViewMetaData: any) => {
620
- const { type, attrs, children } = element;
707
+ let { type, attrs, body, children } = element;
621
708
 
622
709
  // const key = attrs?.name ?? generateRandomKey();
623
710
  const key = attrs?.name;
711
+ let visible = attrs?.visible;
712
+ if (visible === undefined || visible === null) {
713
+ visible = true;
714
+ }
715
+ // console.log(`Resolved visibility of form element ${key} to ${visible}`);
716
+ // console.log(`Form element ${key}: `, attrs);
624
717
 
625
718
  switch (type) {
626
719
  case "form":
720
+ if (!children)
721
+ children = [];
627
722
  return <div key={key}>{children.map((element: any) => renderFormElementDynamically(element, solidFormViewMetaData))}</div>;
723
+ case "div":
724
+ if (!children)
725
+ children = [];
726
+ return <div key={key} {...attrs}>{children.map((element: any) => renderFormElementDynamically(element, solidFormViewMetaData))}</div>
727
+ case "span":
728
+ return <span key={key} {...attrs}>{body}</span>
729
+ case "p":
730
+ return <p key={key} {...attrs}>{body}</p>
731
+ case "h1":
732
+ return <h1 key={key} {...attrs}>{body}</h1>
733
+ case "h2":
734
+ return <h2 key={key} {...attrs}>{body}</h2>
735
+ case "ul":
736
+ if (!children)
737
+ children = [];
738
+ return <ul key={key} {...attrs}>{children.map((element: any) => renderFormElementDynamically(element, solidFormViewMetaData))}</ul>
739
+ case "li":
740
+ return <li key={key} {...attrs}>{body}</li>
628
741
  case "sheet":
629
742
  return <SolidSheet key={key}>{children.map((element: any) => renderFormElementDynamically(element, solidFormViewMetaData))}</SolidSheet>;
630
743
  case "group":
631
- return <SolidGroup key={key} attrs={attrs}>{children.map((element: any) => renderFormElementDynamically(element, solidFormViewMetaData))}</SolidGroup>;
744
+ if (visible === true) {
745
+ return <SolidGroup key={key} attrs={attrs}>{children.map((element: any) => renderFormElementDynamically(element, solidFormViewMetaData))}</SolidGroup>;
746
+ }
632
747
  case "row":
633
- return <SolidRow key={key} attrs={attrs}>{children.map((element: any) => renderFormElementDynamically(element, solidFormViewMetaData))}</SolidRow>;
748
+ if (visible === true) {
749
+ return <SolidRow key={key} attrs={attrs}>{children.map((element: any) => renderFormElementDynamically(element, solidFormViewMetaData))}</SolidRow>;
750
+ }
634
751
  case "column":
635
- return <SolidColumn key={key} attrs={attrs}>{children.map((element: any) => renderFormElementDynamically(element, solidFormViewMetaData))}</SolidColumn>;
752
+ if (visible === true) {
753
+ return <SolidColumn key={key} attrs={attrs}>{children.map((element: any) => renderFormElementDynamically(element, solidFormViewMetaData))}</SolidColumn>;
754
+ }
636
755
  case "field": {
637
- // const fieldMetadata = solidFieldsMetadata[attrs.name];
638
- const fieldMetadata = solidFormViewMetaData.data.solidFieldsMetadata[attrs.name];
639
- // Read only permission if there is no update permission on model and router doesnt contains new
640
- const readOnlyPermission = !actionsAllowed.includes(`${updatePermission(params.modelName)}`) && params.id !== "new"
641
- return <SolidField key={key} field={element} formik={formik} fieldMetadata={fieldMetadata} initialEntityData={solidFormViewData ? solidFormViewData.data : null} solidFormViewMetaData={solidFormViewMetaData} modelName={params.modelName} readOnly={readOnlyPermission} />;
756
+ if (visible === true) {
757
+
758
+ // const fieldMetadata = solidFieldsMetadata[attrs.name];
759
+ const fieldMetadata = solidFormViewMetaData.data.solidFieldsMetadata[attrs.name];
760
+ // Read only permission if there is no update permission on model and router doesnt contains new
761
+ const readOnlyPermission = !actionsAllowed.includes(`${updatePermission(params.modelName)}`) && params.id !== "new"
762
+ return <SolidField
763
+ key={key}
764
+ field={element}
765
+ formik={formik}
766
+ fieldMetadata={fieldMetadata}
767
+ initialEntityData={solidFormViewData ? solidFormViewData.data : null}
768
+ solidFormViewMetaData={solidFormViewMetaData}
769
+ modelName={params.modelName}
770
+ readOnly={readOnlyPermission}
771
+ onChange={formFieldOnXXX}
772
+ onBlur={formFieldOnXXX}
773
+ />;
774
+ }
642
775
  }
643
776
  case "notebook":
644
- return <SolidNotebook key={key}>{children.map((element: any) => renderFormElementDynamically(element, solidFormViewMetaData))}</SolidNotebook>;
777
+ if (visible === true) {
778
+ return <SolidNotebook key={key}>{children.map((element: any) => renderFormElementDynamically(element, solidFormViewMetaData))}</SolidNotebook>;
779
+ }
645
780
  case "page":
646
- const pageChildren = children.map((element: any) => renderFormElementDynamically(element, solidFormViewMetaData));
647
- return SolidPage({ children: pageChildren, attrs: attrs, key: key });
781
+ // console.log(`Resolved visibility of form element ${key} to ${visible}`);
782
+ if (visible === true) {
783
+ const pageChildren = children.map((element: any) => renderFormElementDynamically(element, solidFormViewMetaData));
784
+ return SolidPage({ children: pageChildren, attrs: attrs, key: key });
785
+ }
648
786
  default:
649
787
  return null;
650
788
  }
651
789
  };
652
790
 
653
791
  const renderFormDynamically = (solidFormViewMetaData: any) => {
792
+ // console.log(`renderFormDynamically invoked....`);
654
793
  if (!solidFormViewMetaData) {
655
794
  return;
656
795
  }
@@ -737,31 +876,20 @@ const SolidFormView = (params: SolidFormViewProps) => {
737
876
  onClick={() => setDeleteDialogVisible(true)}
738
877
  />
739
878
  }
740
- {params.embeded == true &&
741
- actionsAllowed.includes(`${deletePermission(params.modelName)}`) &&
742
- !formViewLayout.attrs.readonly &&
743
- <Button
744
- text
745
- type="button"
746
- className="w-8rem text-left gap-2"
747
- label="Delete"
748
- size="small"
749
- iconPos="left"
750
- severity="danger"
751
- icon={'pi pi-trash'}
752
- onClick={() => setDeleteDialogVisible(true)}
753
- />
754
- }
755
879
  </div>
756
880
  </OverlayPanel>
757
881
  </div>
758
882
  )
759
883
  }
760
884
 
761
- const breadcrumbData = [
762
- { label: 'Book', link: '/admin/core/library-management/book/list' },
763
- { label: params.id === "new" ? `Add ${params.modelName}` : `Edit ${params.modelName}` },
764
- ];
885
+ // TODO: This was simply to demonstrate how we can use dynamic components, we will remove this and use it in a more sensible way in the layout.
886
+ // TODO: to demonstrated this you can simply add the below to the layout of the book form view.
887
+ // TODO: "header": "BookFormViewDynamicComponent",
888
+ const dynamicHeader = solidView.layout?.header;
889
+ let DynamicHeaderComponent = null;
890
+ if (dynamicHeader) {
891
+ DynamicHeaderComponent = getExtensionComponent(dynamicHeader);
892
+ }
765
893
 
766
894
  return (
767
895
  <div className="solid-form-wrapper">
@@ -878,6 +1006,19 @@ const SolidFormView = (params: SolidFormViewProps) => {
878
1006
  />
879
1007
  </div>
880
1008
  } */}
1009
+ {params.embeded == true &&
1010
+ actionsAllowed.includes(`${deletePermission(params.modelName)}`) &&
1011
+ !formViewLayout.attrs.readonly &&
1012
+ <div>
1013
+ <Button
1014
+ size="small"
1015
+ type="button"
1016
+ label="Delete"
1017
+ severity="danger"
1018
+ onClick={() => setDeleteDialogVisible(true)}
1019
+ />
1020
+ </div>
1021
+ }
881
1022
  {params.embeded == true &&
882
1023
  <Button outlined size="small" type="button" label="Close" onClick={() => params.handlePopupClose()} className='bg-primary-reverse' />
883
1024
 
@@ -890,13 +1031,14 @@ const SolidFormView = (params: SolidFormViewProps) => {
890
1031
  </>
891
1032
  )}
892
1033
  </div>
893
- <SolidBreadcrumb breadcrumbItems={breadcrumbData} />
1034
+ <SolidBreadcrumb />
894
1035
  {/* {params.embeded !== true &&
895
1036
  <div className="solid-form-stepper">
896
1037
  <SolidFormStepper />
897
1038
  </div>
898
1039
  } */}
899
1040
  <div className="p-4 solid-form-content">
1041
+ {DynamicHeaderComponent && <DynamicHeaderComponent />}
900
1042
  {renderFormDynamically(formViewMetaData)}
901
1043
  </div>
902
1044
  </form>
@@ -8,7 +8,9 @@ export type SolidFieldProps = {
8
8
  field: any,
9
9
  data: any,
10
10
  modelName?: any,
11
- readOnly?: any
11
+ readOnly?: any,
12
+ onChange?: any,
13
+ onBlur?: any
12
14
  };
13
15
 
14
16
  export type FormikObject = {
@@ -117,7 +117,8 @@ export class SolidSelectionStaticField implements ISolidField {
117
117
  suggestions={selectionStaticItems}
118
118
  completeMethod={selectionStaticSearch}
119
119
  // onChange={(e) => updateInputs(index, e.value)} />
120
- onChange={formik.handleChange}
120
+ // onChange={formik.handleChange}
121
+ onChange={(e) => this.fieldContext.onChange(e, 'onFieldChange')}
121
122
  className="solid-standard-autocomplete"
122
123
  />
123
124
  </div>
@@ -29,7 +29,6 @@ export class SolidShortTextField implements ISolidField {
29
29
  return existingValue !== undefined && existingValue !== null ? existingValue : fieldDefaultValue || '';
30
30
  }
31
31
 
32
-
33
32
  validationSchema(): Schema {
34
33
  let schema: Yup.StringSchema<string | null | undefined> = Yup.string();
35
34
 
@@ -93,8 +92,11 @@ export class SolidShortTextField implements ISolidField {
93
92
  readOnly={formReadonly || fieldReadonly || readOnlyPermission}
94
93
  disabled={formDisabled || fieldDisabled}
95
94
  id={fieldLayoutInfo.attrs.name}
95
+ name={fieldMetadata.name}
96
96
  aria-describedby={`${fieldLayoutInfo.attrs.name}-help`}
97
- onChange={formik.handleChange}
97
+ // onChange={formik.handleChange}
98
+ onChange={(e) => this.fieldContext.onChange(e, 'onFieldChange')}
99
+ onBlur={(e) => this.fieldContext.onBlur(e, 'onFieldBlur')}
98
100
  value={formik.values[fieldLayoutInfo.attrs.name] || ''}
99
101
  />
100
102
  </div>
@@ -13,7 +13,6 @@ import * as Yup from 'yup';
13
13
  import { Schema } from "yup";
14
14
  import SolidFormView from "../../SolidFormView";
15
15
  import { FormikObject, ISolidField, SolidFieldProps } from "../ISolidField";
16
- import { useRouter } from "next/router";
17
16
 
18
17
 
19
18
 
@@ -138,7 +137,6 @@ export class SolidRelationManyToManyField implements ISolidField {
138
137
  const className = fieldLayoutInfo.attrs?.className || 'field col-12';
139
138
  const fieldLabel = fieldLayoutInfo.attrs.label ?? fieldMetadata.displayName;
140
139
  const showFieldLabel = fieldLayoutInfo?.attrs?.showLabel;
141
- const router = useRouter();
142
140
 
143
141
  const readOnlyPermission = this.fieldContext.readOnly;
144
142
 
@@ -137,12 +137,12 @@ export class SolidRelationManyToOneField implements ISolidField {
137
137
  }
138
138
  return (
139
139
  <div className={className}>
140
- <div className="flex flex-column gap-2 mt-4">
141
- {showFieldLabel != false &&
142
- <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">
143
- {fieldLabel}
144
- </label>
145
- }
140
+ {showFieldLabel != false &&
141
+ <label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">
142
+ {fieldLabel}
143
+ </label>
144
+ }
145
+ <div className="flex align-items-center gap-3">
146
146
  <AutoComplete
147
147
  readOnly={formReadonly || fieldReadonly || readOnlyPermission}
148
148
  disabled={formDisabled || fieldDisabled || readOnlyPermission}
@@ -702,7 +702,7 @@ export const SolidListView = (params: SolidListViewParams) => {
702
702
  loadingIcon="pi pi-spinner"
703
703
  selection={[...selectedRecords, ...selectedRecoverRecords]}
704
704
  onSelectionChange={onSelectionChange}
705
- selectionMode="multiple"
705
+ selectionMode="checkbox"
706
706
  removableSort
707
707
  filterIcon={<FilterIcon />}
708
708
  tableClassName="solid-data-table"
@@ -356,11 +356,6 @@ const CreateModel = ({ data, params }: any) => {
356
356
  )
357
357
  }
358
358
 
359
- const breadcrumbData = [
360
- { label: 'Model', link: '/admin/core/solid-core/model-metadata/list' },
361
- { label: params.id === "new" ? 'Create Model' : 'Edit Model' },
362
- ];
363
-
364
359
  const [isDirty, setIsDirty] = useState(false);
365
360
 
366
361
 
@@ -376,9 +371,9 @@ const CreateModel = ({ data, params }: any) => {
376
371
  <div className="form-wrapper-title">Create Model</div>
377
372
  </div>
378
373
  <div className="gap-3 flex">
379
- {isDirty &&
374
+ {/* {isDirty && */}
380
375
  <Button label="Save" size="small" onClick={handleSubmit} type="submit" />
381
- }
376
+ {/* } */}
382
377
  <CancelButton />
383
378
  </div>
384
379
  </>
@@ -392,13 +387,13 @@ const CreateModel = ({ data, params }: any) => {
392
387
  {data?.isSystem !== true &&
393
388
  <>
394
389
  <div>
395
- {isDirty &&
390
+ {/* {isDirty && */}
396
391
  <Button label="Save" size="small" type="submit" onClick={handleSubmit} />
397
- }
392
+ {/* } */}
398
393
  </div>
399
- <div>
394
+ {/* <div>
400
395
  <Button outlined label="Delete" size="small" severity="danger" type="button" onClick={() => setDeleteEntity(true)} />
401
- </div>
396
+ </div> */}
402
397
  </>
403
398
  }
404
399
  <CancelButton />
@@ -407,7 +402,7 @@ const CreateModel = ({ data, params }: any) => {
407
402
  </>
408
403
  }
409
404
  </div>
410
- <SolidBreadcrumb breadcrumbItems={breadcrumbData} />
405
+ <SolidBreadcrumb />
411
406
  {/* <div className="solid-form-stepper">
412
407
  <SolidFormStepper />
413
408
  </div> */}
@@ -450,6 +445,7 @@ const CreateModel = ({ data, params }: any) => {
450
445
  nextTab={nextTab}
451
446
  formikFieldsMetadataRef={formikFieldsMetadataRef}
452
447
  params={params}
448
+ setIsDirty={setIsDirty}
453
449
  ></FieldMetaData>
454
450
  </TabPanel>
455
451
  </TabView>
@@ -11,7 +11,7 @@ import { useRef, useState } from "react";
11
11
  import FieldMetaDataForm from "./FieldMetaDataForm";
12
12
 
13
13
 
14
- const FieldMetaData = ({ modelMetaData, fieldMetaData, setFieldMetaData, deleteModelFunction, nextTab, formikFieldsMetadataRef, params }: any) => {
14
+ const FieldMetaData = ({ setIsDirty, modelMetaData, fieldMetaData, setFieldMetaData, deleteModelFunction, nextTab, formikFieldsMetadataRef, params }: any) => {
15
15
  const pathname = usePathname();
16
16
  const msgs = useRef<Messages>(null);
17
17
 
@@ -156,7 +156,7 @@ const FieldMetaData = ({ modelMetaData, fieldMetaData, setFieldMetaData, deleteM
156
156
  }}
157
157
  showHeader={false}
158
158
  >
159
- <FieldMetaDataForm modelMetaData={modelMetaData} fieldMetaData={selectedFieldMetaData} allFields={fieldMetaData} setFieldMetaData={setFieldMetaData} deleteModelFunction={deleteModelFunction} setVisiblePopup={setVisiblePopup} formikFieldsMetadataRef={formikFieldsMetadataRef} params={params} setIsRequiredPopUp={setIsRequiredPopUp} showToaster={showToaster}></FieldMetaDataForm>
159
+ <FieldMetaDataForm setIsDirty={setIsDirty} modelMetaData={modelMetaData} fieldMetaData={selectedFieldMetaData} allFields={fieldMetaData} setFieldMetaData={setFieldMetaData} deleteModelFunction={deleteModelFunction} setVisiblePopup={setVisiblePopup} formikFieldsMetadataRef={formikFieldsMetadataRef} params={params} setIsRequiredPopUp={setIsRequiredPopUp} showToaster={showToaster}></FieldMetaDataForm>
160
160
  </Dialog>
161
161
  <Dialog
162
162
  visible={isRequiredPopUp}