@asaleh37/ui-base 25.12.121 → 25.12.123

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.
@@ -1,198 +1,198 @@
1
- import moment from "moment";
2
- import { TemplateGridColDef } from "../DataEntryTypes";
3
- import Datefield from "../TemplateDataForm/FormFields/Datefield";
4
- import { DATE_FORMAT, DATE_TIME_FORMAT } from "../../../../util/constants";
5
- import DatetimeField from "../TemplateDataForm/FormFields/DatetimeField";
6
- import ComboBox from "../TemplateDataForm/FormFields/ComboBox";
7
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
8
- import CheckBox from "../TemplateDataForm/FormFields/CheckBox";
9
-
10
- export const generateDateColumn: any = (colDef: TemplateGridColDef) => {
11
- const column: TemplateGridColDef = {
12
- ...colDef,
13
- type: "string",
14
- renderEditCell: (params: any) => {
15
- return (
16
- <Datefield
17
- sx={{ width: "100%" }}
18
- label=""
19
- value={params.value}
20
- onChangeCallBack={(v: any) => {
21
- params.api.setEditCellValue({
22
- id: params.id,
23
- field: params.field,
24
- value: v,
25
- });
26
- }}
27
- />
28
- );
29
- },
30
- valueParser: (value: any, row: any, column: any) => {
31
- let v = null;
32
- if (value !== null) {
33
- v = moment(value).format(DATE_FORMAT);
34
- }
35
- return v;
36
- },
37
- valueFormatter: (value: any, row: any, column: any) => {
38
- return row[column.field];
39
- },
40
- };
41
- return column;
42
- };
43
-
44
- export const generateDateTimeColumn: any = (colDef: TemplateGridColDef) => {
45
- const column: TemplateGridColDef = {
46
- ...colDef,
47
- type: "string",
48
- renderEditCell: (params: any) => {
49
- return (
50
- <DatetimeField
51
- sx={{ width: "100%" }}
52
- label=""
53
- value={params.value}
54
- onChangeCallBack={(v: any) => {
55
- params.api.setEditCellValue({
56
- id: params.id,
57
- field: params.field,
58
- value: v,
59
- });
60
- }}
61
- />
62
- );
63
- },
64
- valueParser: (value: any, row: any, column: any) => {
65
- let v = null;
66
- if (value !== null) {
67
- v = moment(value).format(DATE_TIME_FORMAT);
68
- }
69
- return v;
70
- },
71
- valueFormatter: (value: any, row: any, column: any) => {
72
- return row[column.field];
73
- },
74
- };
75
- return column;
76
- };
77
-
78
- type ComboBoxColumnProps = TemplateGridColDef & {
79
- lookupType?: string;
80
- options?: Array<any>;
81
- displayField: string;
82
- valueField: string;
83
- };
84
- export const generateComboColumn: (
85
- props: ComboBoxColumnProps
86
- ) => TemplateGridColDef = (colDef: ComboBoxColumnProps) => {
87
- debugger;
88
- const column: TemplateGridColDef = {
89
- ...colDef,
90
- type: "custom",
91
- valueGetter: (value) => {
92
- if (value) {
93
- return value;
94
- }
95
- return value;
96
- },
97
- renderCell: (parameters: any) => {
98
- let record = null;
99
- try {
100
- record = parameters.colDef.options.find(
101
- (item: any) => item[parameters.colDef.valueField] == parameters.value
102
- );
103
- } catch (e) {}
104
- return (
105
- <div>
106
- {record != null
107
- ? record[parameters.colDef.displayField]
108
- : parameters.value}
109
- </div>
110
- );
111
- },
112
- commonStoreKey: colDef?.commonStoreKey,
113
- dataQueryId: colDef?.dataQueryId,
114
- storeUrl: colDef?.storeUrl,
115
- storeLoadParam: colDef?.storeLoadParam,
116
- renderEditCell: (params: any) => {
117
- return (
118
- <ComboBox
119
- {...params}
120
- sx={{ width: "100%" }}
121
- options={params?.colDef?.options}
122
- // commonStoreKey={params?.colDef?.commonStoreKey}
123
- // dataQueryId={params?.colDef?.dataQueryId}
124
- // storeUrl={params?.colDef?.storeUrl}
125
- // storeLoadParam={params?.colDef?.storeLoadParam}
126
- valueField={params?.colDef?.valueField}
127
- displayField={params?.colDef?.displayField}
128
- groupField={params?.colDef?.comboboxGroupField}
129
- onChangeCallBack={(v: any, selectedRecord: any) => {
130
- if (v === null) {
131
- params.api.setEditCellValue({
132
- id: params.id,
133
- field: params.field,
134
- value: null,
135
- });
136
- }
137
- params.api.setEditCellValue({
138
- id: params.id,
139
- field: params.field,
140
- value: v,
141
- });
142
- }}
143
- />
144
- );
145
- },
146
- };
147
- return column;
148
- };
149
-
150
- type CheckBoxColumnProps = TemplateGridColDef & {
151
- checkedValue?: string;
152
- unCheckedValue?: string;
153
- };
154
-
155
- export const generateCheckBoxColumn: (
156
- props: CheckBoxColumnProps
157
- ) => TemplateGridColDef = (colDef: CheckBoxColumnProps) => {
158
- return {
159
- ...colDef,
160
- type: "custom",
161
- valueGetter: (value) => {
162
- if (value == null || value == undefined) {
163
- return null;
164
- } else {
165
- return value;
166
- }
167
- },
168
- renderCell: (parameters: any) => {
169
- const value = parameters?.value;
170
- if (
171
- value === colDef.checkedValue ||
172
- value === "true" ||
173
- value === 1 ||
174
- value === true
175
- ) {
176
- return <FontAwesomeIcon icon="check" color="green" />;
177
- } else {
178
- return <FontAwesomeIcon icon="xmark" color="red" />;
179
- }
180
- },
181
- renderEditCell: (params: any) => {
182
- return (
183
- <CheckBox
184
- {...params}
185
- checkedValue={colDef?.checkedValue || true}
186
- unCheckedValue={colDef?.unCheckedValue || false}
187
- onChangeCallBack={(v: any) => {
188
- params.api.setEditCellValue({
189
- id: params.id,
190
- field: params.field,
191
- value: v,
192
- });
193
- }}
194
- />
195
- );
196
- },
197
- };
198
- };
1
+ import moment from "moment";
2
+ import { TemplateGridColDef } from "../DataEntryTypes";
3
+ import Datefield from "../TemplateDataForm/FormFields/Datefield";
4
+ import { DATE_FORMAT, DATE_TIME_FORMAT } from "../../../../util/constants";
5
+ import DatetimeField from "../TemplateDataForm/FormFields/DatetimeField";
6
+ import ComboBox from "../TemplateDataForm/FormFields/ComboBox";
7
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
8
+ import CheckBox from "../TemplateDataForm/FormFields/CheckBox";
9
+
10
+ export const generateDateColumn: any = (colDef: TemplateGridColDef) => {
11
+ const column: TemplateGridColDef = {
12
+ ...colDef,
13
+ type: "string",
14
+ renderEditCell: (params: any) => {
15
+ return (
16
+ <Datefield
17
+ sx={{ width: "100%" }}
18
+ label=""
19
+ value={params.value}
20
+ onChangeCallBack={(v: any) => {
21
+ params.api.setEditCellValue({
22
+ id: params.id,
23
+ field: params.field,
24
+ value: v,
25
+ });
26
+ }}
27
+ />
28
+ );
29
+ },
30
+ valueParser: (value: any, row: any, column: any) => {
31
+ let v = null;
32
+ if (value !== null) {
33
+ v = moment(value).format(DATE_FORMAT);
34
+ }
35
+ return v;
36
+ },
37
+ valueFormatter: (value: any, row: any, column: any) => {
38
+ return row[column.field];
39
+ },
40
+ };
41
+ return column;
42
+ };
43
+
44
+ export const generateDateTimeColumn: any = (colDef: TemplateGridColDef) => {
45
+ const column: TemplateGridColDef = {
46
+ ...colDef,
47
+ type: "string",
48
+ renderEditCell: (params: any) => {
49
+ return (
50
+ <DatetimeField
51
+ sx={{ width: "100%" }}
52
+ label=""
53
+ value={params.value}
54
+ onChangeCallBack={(v: any) => {
55
+ params.api.setEditCellValue({
56
+ id: params.id,
57
+ field: params.field,
58
+ value: v,
59
+ });
60
+ }}
61
+ />
62
+ );
63
+ },
64
+ valueParser: (value: any, row: any, column: any) => {
65
+ let v = null;
66
+ if (value !== null) {
67
+ v = moment(value).format(DATE_TIME_FORMAT);
68
+ }
69
+ return v;
70
+ },
71
+ valueFormatter: (value: any, row: any, column: any) => {
72
+ return row[column.field];
73
+ },
74
+ };
75
+ return column;
76
+ };
77
+
78
+ type ComboBoxColumnProps = TemplateGridColDef & {
79
+ lookupType?: string;
80
+ options?: Array<any>;
81
+ displayField: string;
82
+ valueField: string;
83
+ };
84
+ export const generateComboColumn: (
85
+ props: ComboBoxColumnProps
86
+ ) => TemplateGridColDef = (colDef: ComboBoxColumnProps) => {
87
+ debugger;
88
+ const column: TemplateGridColDef = {
89
+ ...colDef,
90
+ type: "custom",
91
+ valueGetter: (value) => {
92
+ if (value) {
93
+ return value;
94
+ }
95
+ return value;
96
+ },
97
+ renderCell: (parameters: any) => {
98
+ let record = null;
99
+ try {
100
+ record = parameters.colDef.options.find(
101
+ (item: any) => item[parameters.colDef.valueField] == parameters.value
102
+ );
103
+ } catch (e) {}
104
+ return (
105
+ <div>
106
+ {record != null
107
+ ? record[parameters.colDef.displayField]
108
+ : parameters.value}
109
+ </div>
110
+ );
111
+ },
112
+ commonStoreKey: colDef?.commonStoreKey,
113
+ dataQueryId: colDef?.dataQueryId,
114
+ storeUrl: colDef?.storeUrl,
115
+ storeLoadParam: colDef?.storeLoadParam,
116
+ renderEditCell: (params: any) => {
117
+ return (
118
+ <ComboBox
119
+ {...params}
120
+ sx={{ width: "100%" }}
121
+ options={params?.colDef?.options}
122
+ // commonStoreKey={params?.colDef?.commonStoreKey}
123
+ // dataQueryId={params?.colDef?.dataQueryId}
124
+ // storeUrl={params?.colDef?.storeUrl}
125
+ // storeLoadParam={params?.colDef?.storeLoadParam}
126
+ valueField={params?.colDef?.valueField}
127
+ displayField={params?.colDef?.displayField}
128
+ groupField={params?.colDef?.comboboxGroupField}
129
+ onChangeCallBack={(v: any, selectedRecord: any) => {
130
+ if (v === null) {
131
+ params.api.setEditCellValue({
132
+ id: params.id,
133
+ field: params.field,
134
+ value: null,
135
+ });
136
+ }
137
+ params.api.setEditCellValue({
138
+ id: params.id,
139
+ field: params.field,
140
+ value: v,
141
+ });
142
+ }}
143
+ />
144
+ );
145
+ },
146
+ };
147
+ return column;
148
+ };
149
+
150
+ type CheckBoxColumnProps = TemplateGridColDef & {
151
+ checkedValue?: string;
152
+ unCheckedValue?: string;
153
+ };
154
+
155
+ export const generateCheckBoxColumn: (
156
+ props: CheckBoxColumnProps
157
+ ) => TemplateGridColDef = (colDef: CheckBoxColumnProps) => {
158
+ return {
159
+ ...colDef,
160
+ type: "custom",
161
+ valueGetter: (value) => {
162
+ if (value == null || value == undefined) {
163
+ return null;
164
+ } else {
165
+ return value;
166
+ }
167
+ },
168
+ renderCell: (parameters: any) => {
169
+ const value = parameters?.value;
170
+ if (
171
+ value === colDef.checkedValue ||
172
+ value === "true" ||
173
+ value === 1 ||
174
+ value === true
175
+ ) {
176
+ return <FontAwesomeIcon icon="check" color="green" />;
177
+ } else {
178
+ return <FontAwesomeIcon icon="xmark" color="red" />;
179
+ }
180
+ },
181
+ renderEditCell: (params: any) => {
182
+ return (
183
+ <CheckBox
184
+ {...params}
185
+ checkedValue={colDef?.checkedValue || true}
186
+ unCheckedValue={colDef?.unCheckedValue || false}
187
+ onChangeCallBack={(v: any) => {
188
+ params.api.setEditCellValue({
189
+ id: params.id,
190
+ field: params.field,
191
+ value: v,
192
+ });
193
+ }}
194
+ />
195
+ );
196
+ },
197
+ };
198
+ };