@solidstarters/solid-core-ui 1.1.62 → 1.1.64
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/dist/components/core/common/SolidGlobalSearchElement.d.ts.map +1 -1
- package/dist/components/core/common/SolidGlobalSearchElement.js.map +1 -1
- package/dist/components/core/filter/SolidSelectionDynamicFilterElement.js +1 -1
- package/dist/components/core/filter/SolidSelectionDynamicFilterElement.js.map +1 -1
- package/dist/components/core/form/SolidFormView.d.ts +1 -0
- package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
- package/dist/components/core/form/SolidFormView.js +5 -2
- package/dist/components/core/form/SolidFormView.js.map +1 -1
- package/dist/components/core/form/fields/ISolidField.d.ts +2 -1
- package/dist/components/core/form/fields/ISolidField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidDateField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidDateField.js +3 -0
- package/dist/components/core/form/fields/SolidDateField.js.map +1 -1
- package/dist/components/core/form/fields/SolidDateTimeField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidDateTimeField.js +3 -0
- package/dist/components/core/form/fields/SolidDateTimeField.js.map +1 -1
- package/dist/components/core/form/fields/SolidRelationField.d.ts +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.d.ts +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js +29 -14
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js +25 -18
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js.map +1 -1
- package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.d.ts.map +1 -1
- package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.js +0 -1
- package/dist/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.js.map +1 -1
- package/dist/components/core/kanban/SolidKanbanView.js +75 -69
- package/dist/components/core/kanban/SolidKanbanView.js.map +1 -1
- package/dist/components/core/kanban/kanban-fields/SolidMediaSingleKanbanField.d.ts.map +1 -1
- package/dist/components/core/kanban/kanban-fields/SolidMediaSingleKanbanField.js +6 -2
- package/dist/components/core/kanban/kanban-fields/SolidMediaSingleKanbanField.js.map +1 -1
- package/package.json +1 -1
- package/src/components/core/common/SolidGlobalSearchElement.tsx +0 -1
- package/src/components/core/filter/SolidSelectionDynamicFilterElement.tsx +1 -1
- package/src/components/core/form/SolidFormView.tsx +7 -2
- package/src/components/core/form/fields/ISolidField.tsx +3 -2
- package/src/components/core/form/fields/SolidDateField.tsx +3 -1
- package/src/components/core/form/fields/SolidDateTimeField.tsx +3 -1
- package/src/components/core/form/fields/relations/SolidRelationManyToOneField.tsx +25 -6
- package/src/components/core/form/fields/relations/SolidRelationOneToManyField.tsx +3 -0
- package/src/components/core/form/fields/widgets/SolidBooleanCheckboxFieldWidget.tsx +0 -1
- package/src/components/core/kanban/SolidKanbanView.tsx +1 -1
- package/src/components/core/kanban/kanban-fields/SolidMediaSingleKanbanField.tsx +45 -2
package/package.json
CHANGED
|
@@ -59,6 +59,7 @@ export type SolidFormViewProps = {
|
|
|
59
59
|
customCreateHandler?: any
|
|
60
60
|
inlineCreateAutoSave?: boolean,
|
|
61
61
|
customLayout?: any,
|
|
62
|
+
populateData?: any,
|
|
62
63
|
};
|
|
63
64
|
|
|
64
65
|
|
|
@@ -150,7 +151,7 @@ const fieldFactory = (type: string, fieldContext: SolidFieldProps, setLightboxUr
|
|
|
150
151
|
}
|
|
151
152
|
|
|
152
153
|
// solidFieldsMetadata={solidFieldsMetadata} solidView={solidView}
|
|
153
|
-
const SolidField = ({ formik, field, fieldMetadata, initialEntityData, solidFormViewMetaData, modelName, readOnly, viewMode, onChange, onBlur, setLightboxUrls, setOpenLightbox }: any) => {
|
|
154
|
+
const SolidField = ({ formik, field, fieldMetadata, initialEntityData, solidFormViewMetaData, modelName, readOnly, viewMode, onChange, onBlur, populateData, setLightboxUrls, setOpenLightbox }: any) => {
|
|
154
155
|
const fieldContext: SolidFieldProps = {
|
|
155
156
|
// field metadata - coming from the field-metadata table.
|
|
156
157
|
fieldMetadata: fieldMetadata,
|
|
@@ -166,6 +167,9 @@ const SolidField = ({ formik, field, fieldMetadata, initialEntityData, solidForm
|
|
|
166
167
|
onChange: onChange,
|
|
167
168
|
onBlur: onBlur
|
|
168
169
|
}
|
|
170
|
+
if (populateData) {
|
|
171
|
+
fieldContext.populateData = populateData;
|
|
172
|
+
}
|
|
169
173
|
const solidField = fieldFactory(fieldMetadata?.type, fieldContext, setLightboxUrls, setOpenLightbox);
|
|
170
174
|
|
|
171
175
|
return solidField?.render(formik);
|
|
@@ -932,13 +936,14 @@ const SolidFormView = (params: SolidFormViewProps) => {
|
|
|
932
936
|
field={element}
|
|
933
937
|
formik={formik}
|
|
934
938
|
fieldMetadata={fieldMetadata}
|
|
935
|
-
initialEntityData={solidFormViewData ? solidFormViewData.data :
|
|
939
|
+
initialEntityData={solidFormViewData ? solidFormViewData.data : {}}
|
|
936
940
|
solidFormViewMetaData={solidFormViewMetaData}
|
|
937
941
|
modelName={params.modelName}
|
|
938
942
|
readOnly={readOnlyPermission}
|
|
939
943
|
viewMode={viewMode}
|
|
940
944
|
onChange={formFieldOnXXX}
|
|
941
945
|
onBlur={formFieldOnXXX}
|
|
946
|
+
populateData={params.populateData}
|
|
942
947
|
setLightboxUrls={setLightboxUrls}
|
|
943
948
|
setOpenLightbox={setOpenLightbox}
|
|
944
949
|
/>;
|
|
@@ -11,7 +11,8 @@ export type SolidFieldProps = {
|
|
|
11
11
|
readOnly?: any,
|
|
12
12
|
viewMode? :any
|
|
13
13
|
onChange?: any,
|
|
14
|
-
onBlur?: any
|
|
14
|
+
onBlur?: any,
|
|
15
|
+
populateData?: any
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
export type FormikObject = {
|
|
@@ -64,6 +65,6 @@ export type FormikObject = {
|
|
|
64
65
|
export interface ISolidField {
|
|
65
66
|
initialValue(): any;
|
|
66
67
|
validationSchema(): Schema;
|
|
67
|
-
render(formik: FormikObject): React.JSX.Element;
|
|
68
|
+
render(formik: FormikObject): React.JSX.Element | null;
|
|
68
69
|
updateFormData(value: any, formData: FormData): any;
|
|
69
70
|
}
|
|
@@ -32,7 +32,7 @@ export class SolidDateField implements ISolidField {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
validationSchema(): Schema {
|
|
35
|
-
let schema: Yup.DateSchema = Yup.date();
|
|
35
|
+
let schema: Yup.DateSchema<Date | null | undefined> = Yup.date();
|
|
36
36
|
const fieldMetadata = this.fieldContext.fieldMetadata;
|
|
37
37
|
const fieldLayoutInfo = this.fieldContext.field;
|
|
38
38
|
const fieldLabel = fieldLayoutInfo.attrs.label ?? fieldMetadata.displayName;
|
|
@@ -40,6 +40,8 @@ export class SolidDateField implements ISolidField {
|
|
|
40
40
|
// 1. required
|
|
41
41
|
if (fieldMetadata.required) {
|
|
42
42
|
schema = schema.required(`${fieldLabel} is required.`);
|
|
43
|
+
} else {
|
|
44
|
+
schema = schema.nullable();
|
|
43
45
|
}
|
|
44
46
|
return schema;
|
|
45
47
|
}
|
|
@@ -32,7 +32,7 @@ export class SolidDateTimeField implements ISolidField {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
validationSchema(): Schema {
|
|
35
|
-
let schema: Yup.DateSchema = Yup.date();
|
|
35
|
+
let schema: Yup.DateSchema<Date | null | undefined> = Yup.date();
|
|
36
36
|
const fieldMetadata = this.fieldContext.fieldMetadata;
|
|
37
37
|
const fieldLayoutInfo = this.fieldContext.field;
|
|
38
38
|
const fieldLabel = fieldLayoutInfo.attrs.label ?? fieldMetadata.displayName;
|
|
@@ -40,6 +40,8 @@ export class SolidDateTimeField implements ISolidField {
|
|
|
40
40
|
// 1. required
|
|
41
41
|
if (fieldMetadata.required) {
|
|
42
42
|
schema = schema.required(`${fieldLabel} is required.`);
|
|
43
|
+
} else {
|
|
44
|
+
schema = schema.nullable();
|
|
43
45
|
}
|
|
44
46
|
return schema;
|
|
45
47
|
}
|
|
@@ -3,7 +3,7 @@ import { createSolidEntityApi } from "@/redux/api/solidEntityApi";
|
|
|
3
3
|
import { AutoComplete, AutoCompleteCompleteEvent } from "primereact/autocomplete";
|
|
4
4
|
import { Message } from "primereact/message";
|
|
5
5
|
import qs from "qs";
|
|
6
|
-
import { useState } from "react";
|
|
6
|
+
import { useState, useEffect } from "react";
|
|
7
7
|
import * as Yup from 'yup';
|
|
8
8
|
import { Schema } from "yup";
|
|
9
9
|
import { FormikObject, ISolidField, SolidFieldProps } from "../ISolidField";
|
|
@@ -25,15 +25,22 @@ export class SolidRelationManyToOneField implements ISolidField {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
initialValue(): any {
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const fieldMetadata = this.fieldContext.fieldMetadata;
|
|
28
|
+
const manyToOneFieldData = this.fieldContext?.data[this.fieldContext?.field?.attrs?.name];
|
|
29
|
+
const fieldMetadata = this.fieldContext?.fieldMetadata;
|
|
31
30
|
const userKeyField = fieldMetadata?.relationModel?.userKeyField?.name;
|
|
32
31
|
const manyToOneColVal = manyToOneFieldData ? manyToOneFieldData[userKeyField] : '';
|
|
33
32
|
if (manyToOneColVal) {
|
|
34
33
|
return { label: manyToOneColVal || '', value: manyToOneFieldData?.id || '' };
|
|
35
34
|
}
|
|
36
|
-
|
|
35
|
+
|
|
36
|
+
if (this.fieldContext.populateData) {
|
|
37
|
+
const [key, value]: any = Object.entries(this.fieldContext.populateData)[0] || [];
|
|
38
|
+
if (key && value !== undefined) {
|
|
39
|
+
return { label: value.label, value: value.value };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {};
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
updateFormData(value: any, formData: FormData): any {
|
|
@@ -68,7 +75,19 @@ export class SolidRelationManyToOneField implements ISolidField {
|
|
|
68
75
|
const readOnlyPermission = this.fieldContext.readOnly;
|
|
69
76
|
const [visibleCreateRelationEntity, setvisibleCreateRelationEntity] = useState(false);
|
|
70
77
|
|
|
71
|
-
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const newValue = this.initialValue();
|
|
80
|
+
if (this.fieldContext.populateData) {
|
|
81
|
+
formik.setFieldValue(fieldLayoutInfo.attrs.name, newValue);
|
|
82
|
+
}
|
|
83
|
+
}, [this.fieldContext.populateData]);
|
|
84
|
+
|
|
85
|
+
const isVisible = fieldLayoutInfo.attrs?.visible !== false && !this.fieldContext.populateData;
|
|
86
|
+
|
|
87
|
+
if (!isVisible) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
72
91
|
const entityApi = createSolidEntityApi(fieldMetadata.relationCoModelSingularName);
|
|
73
92
|
const { useLazyGetSolidEntitiesQuery } = entityApi;
|
|
74
93
|
const [triggerGetSolidEntities] = useLazyGetSolidEntitiesQuery();
|
|
@@ -68,6 +68,7 @@ export class SolidRelationOneToManyField implements ISolidField {
|
|
|
68
68
|
const readOnlyPermission = this.fieldContext.readOnly;
|
|
69
69
|
const pathname = usePathname();
|
|
70
70
|
const lastPathSegment = pathname.split('/').pop();
|
|
71
|
+
const userKeyField: any = Object.entries(this.fieldContext.solidFormViewMetaData.data.solidFieldsMetadata).find(([_, value]: any) => value.isUserKey)?.[0];
|
|
71
72
|
|
|
72
73
|
const handlePopupOpen = (id: any) => {
|
|
73
74
|
const formviewparams = {
|
|
@@ -76,6 +77,7 @@ export class SolidRelationOneToManyField implements ISolidField {
|
|
|
76
77
|
embeded: true,
|
|
77
78
|
isCustomCreate: false,
|
|
78
79
|
customLayout: fieldLayoutInfo?.attrs?.inlineCreateLayout,
|
|
80
|
+
populateData: userKeyField ? {[userKeyField] : {label: this.fieldContext.data[userKeyField], value: this.fieldContext.data['id']}} : {},
|
|
79
81
|
modelName: camelCase(this.fieldContext.fieldMetadata.relationCoModelSingularName)
|
|
80
82
|
}
|
|
81
83
|
setformViewParams(formviewparams);
|
|
@@ -130,6 +132,7 @@ export class SolidRelationOneToManyField implements ISolidField {
|
|
|
130
132
|
embeded: true,
|
|
131
133
|
isCustomCreate: false,
|
|
132
134
|
customLayout: fieldLayoutInfo?.attrs?.inlineCreateLayout,
|
|
135
|
+
populateData: userKeyField ? {[userKeyField] : {label: this.fieldContext.data[userKeyField], value: this.fieldContext.data['id']}} : {},
|
|
133
136
|
modelName: camelCase(this.fieldContext.fieldMetadata.relationCoModelSingularName),
|
|
134
137
|
}
|
|
135
138
|
setformViewParams(formviewparams)
|
|
@@ -17,7 +17,6 @@ export const SolidBooleanFieldCheckboxWidget = ({ formik, fieldContext }: SolidB
|
|
|
17
17
|
// Set default value to false on mount
|
|
18
18
|
useEffect(() => {
|
|
19
19
|
if (formik.values[fieldLayoutInfo.attrs.name] === undefined) {
|
|
20
|
-
console.log("Setting default value:", false);
|
|
21
20
|
formik.setFieldValue(fieldLayoutInfo.attrs.name, false);
|
|
22
21
|
}
|
|
23
22
|
}, []);
|
|
@@ -499,7 +499,7 @@ export const SolidKanbanView = (params: SolidKanbanViewParams) => {
|
|
|
499
499
|
|
|
500
500
|
|
|
501
501
|
// Handle drag-and-drop functionality
|
|
502
|
-
const onDragEnd = (result: DropResult): void => {
|
|
502
|
+
const onDragEnd = async (result: DropResult): void => {
|
|
503
503
|
const { source, destination } = result;
|
|
504
504
|
if (!destination) return;
|
|
505
505
|
|
|
@@ -11,7 +11,8 @@ import { PDFSvg } from '@/components/Svg/PDFSvg';
|
|
|
11
11
|
import Image from 'next/image';
|
|
12
12
|
import FileImage from '../../../../resources/images/fileTypes/File.png'
|
|
13
13
|
import { ExcelSvg } from '@/components/Svg/ExcelSvg';
|
|
14
|
-
|
|
14
|
+
import MP3Image from '../../../../resources/images/fileTypes/Mp3.png'
|
|
15
|
+
import MP4Image from '../../../../resources/images/fileTypes/Mp4.png'
|
|
15
16
|
|
|
16
17
|
pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.mjs`;
|
|
17
18
|
|
|
@@ -83,11 +84,53 @@ const SolidMediaSingleKanbanField = ({ solidKanbanViewMetaData, fieldMetadata, f
|
|
|
83
84
|
</a>
|
|
84
85
|
</div>
|
|
85
86
|
)}
|
|
87
|
+
|
|
88
|
+
{mimeType && mimeType.includes("audio") && (
|
|
89
|
+
<div className='flex align-items-end gap-2 my-2' onClick={(e) => e.stopPropagation()}>
|
|
90
|
+
<a href={url} download target="_blank" rel="noopener noreferrer">
|
|
91
|
+
<Image
|
|
92
|
+
src={MP3Image}
|
|
93
|
+
alt={fileName}
|
|
94
|
+
className="relative"
|
|
95
|
+
height={50}
|
|
96
|
+
width={50}
|
|
97
|
+
/>
|
|
98
|
+
</a>
|
|
99
|
+
<a href={url} download target="_blank" rel="noopener noreferrer" className='text-color flex align-items-start gap-2' style={{ textDecoration: 'none' }}>
|
|
100
|
+
<p className="text-sm mb-1" style={{ wordWrap: 'break-word', overflowWrap: 'break-word' }}>
|
|
101
|
+
{fileName}
|
|
102
|
+
</p>
|
|
103
|
+
<span className='pi pi-cloud-download'></span>
|
|
104
|
+
</a>
|
|
105
|
+
</div>
|
|
106
|
+
)}
|
|
107
|
+
{mimeType && mimeType.includes("video") && (
|
|
108
|
+
<div className='flex align-items-end gap-2 my-2' onClick={(e) => e.stopPropagation()}>
|
|
109
|
+
<a href={url} download target="_blank" rel="noopener noreferrer">
|
|
110
|
+
<Image
|
|
111
|
+
src={MP4Image}
|
|
112
|
+
alt={fileName}
|
|
113
|
+
className="relative"
|
|
114
|
+
height={50}
|
|
115
|
+
width={50}
|
|
116
|
+
/>
|
|
117
|
+
</a>
|
|
118
|
+
<a href={url} download target="_blank" rel="noopener noreferrer" className='text-color flex align-items-start gap-2' style={{ textDecoration: 'none' }}>
|
|
119
|
+
<p className="text-sm mb-1" style={{ wordWrap: 'break-word', overflowWrap: 'break-word' }}>
|
|
120
|
+
{fileName}
|
|
121
|
+
</p>
|
|
122
|
+
<span className='pi pi-cloud-download'></span>
|
|
123
|
+
</a>
|
|
124
|
+
</div>
|
|
125
|
+
)}
|
|
126
|
+
|
|
86
127
|
{mimeType &&
|
|
87
128
|
!mimeType.includes("image/") &&
|
|
88
129
|
!mimeType.includes("pdf") &&
|
|
89
130
|
!mimeType.includes("excel") &&
|
|
90
|
-
!mimeType.includes("spreadsheet") &&
|
|
131
|
+
!mimeType.includes("spreadsheet") &&
|
|
132
|
+
!mimeType.includes("audio") &&
|
|
133
|
+
!mimeType.includes("video") && (
|
|
91
134
|
<div className='flex align-items-end gap-2 my-2' onClick={(e) => e.stopPropagation()}>
|
|
92
135
|
<a href={url} download target="_blank" rel="noopener noreferrer">
|
|
93
136
|
<Image
|