ui-soxo-bootstrap-core 2.6.30 → 2.6.31

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.
@@ -203,6 +203,53 @@ function FormCreator({
203
203
  }
204
204
  }
205
205
 
206
+ const submitFormValues = async (values) => {
207
+ setLoading(true);
208
+
209
+ const nextValues = { ...values };
210
+
211
+ // Keep the same value preparation path for normal submit and search reset.
212
+ fields.forEach((field) => {
213
+
214
+ if (field.field && field.field.includes('date')) {
215
+
216
+ nextValues[field.field] = moment(nextValues[field.field]).valueOf();
217
+
218
+ }
219
+
220
+ if (field.type === ('time')) {
221
+
222
+ nextValues[field.field] = moment(nextValues[field.field]).format('HH:mm A');
223
+
224
+ }
225
+ })
226
+
227
+ try {
228
+ if (onSubmit) {
229
+ await onSubmit(nextValues);
230
+ }
231
+ } finally {
232
+ setLoading(false);
233
+ }
234
+ }
235
+
236
+ const handleSearchReset = async (fieldName) => {
237
+ if (!fieldName) return;
238
+
239
+ const values = {
240
+ ...form.getFieldsValue(true),
241
+ [fieldName]: [],
242
+ };
243
+
244
+ form.setFieldsValue({ [fieldName]: [] });
245
+
246
+ if (onFormValuesChange) {
247
+ onFormValuesChange(values);
248
+ }
249
+
250
+ await submitFormValues(values);
251
+ }
252
+
206
253
  return (
207
254
  <section className="form-creator">
208
255
 
@@ -223,41 +270,7 @@ function FormCreator({
223
270
  {...layoutValue}
224
271
  className="new-record"
225
272
  name="new-record"
226
- onFinish={(values) => {
227
-
228
- setLoading(true);
229
-
230
- // Do a screening to check if date fields are
231
- fields.forEach((field) => {
232
-
233
- if (field.field && field.field.includes('date')) {
234
-
235
- // values[field.field] = new Timestamp(new Date());
236
-
237
- values[field.field] = moment(values[field.field]).valueOf();
238
-
239
- } else {
240
-
241
- }
242
-
243
- if (field.type === ('time')) {
244
-
245
- // values[field.field] = new Timestamp(new Date());
246
-
247
- values[field.field] = moment(values[field.field]).format('HH:mm A');
248
-
249
- } else {
250
-
251
- }
252
- })
253
-
254
- onSubmit(values).then(() => {
255
-
256
- setLoading(false);
257
-
258
- });
259
-
260
- }}
273
+ onFinish={submitFormValues}
261
274
  // layout="inline"
262
275
 
263
276
  onFieldsChange={onFieldsChange}
@@ -276,6 +289,7 @@ function FormCreator({
276
289
  fields={fields}
277
290
  reportId={reportId}
278
291
  onChange={onChange}
292
+ onSearchReset={handleSearchReset}
279
293
  selectedInformation={selectedInformation}
280
294
  onUpload={onUpload}
281
295
  onFieldUpdate={onFieldUpdate}
@@ -311,6 +325,7 @@ function FieldMapper({
311
325
  fields = [],
312
326
  reportId,
313
327
  onChange,
328
+ onSearchReset,
314
329
  selectedInformation,
315
330
  onUpload,
316
331
  onFieldUpdate,
@@ -350,6 +365,7 @@ function FieldMapper({
350
365
  fields={tab.fields}
351
366
  reportId={reportId}
352
367
  onChange={onChange}
368
+ onSearchReset={onSearchReset}
353
369
  onUpload={onUpload}
354
370
  onFieldUpdate={onFieldUpdate}
355
371
  onFieldRemove={onFieldRemove}
@@ -370,6 +386,7 @@ function FieldMapper({
370
386
  ?
371
387
  <UserInput
372
388
  onChange={onChange}
389
+ onSearchReset={onSearchReset}
373
390
  reportId={reportId}
374
391
  index={index}
375
392
  key={index}
@@ -384,6 +401,7 @@ function FieldMapper({
384
401
  } else {
385
402
  return <UserInput
386
403
  onChange={onChange}
404
+ onSearchReset={onSearchReset}
387
405
  reportId={reportId}
388
406
  key={index}
389
407
  selectedInformation={selectedInformation}
@@ -411,7 +429,7 @@ function FieldMapper({
411
429
  *
412
430
  * @param {*} param0
413
431
  */
414
- function UserInput({ field, onUpload, selectedInformation, onChange, onFieldUpdate, onFieldRemove, index, reportId }) {
432
+ function UserInput({ field, onUpload, selectedInformation, onChange, onSearchReset, onFieldUpdate, onFieldRemove, index, reportId }) {
415
433
 
416
434
  let props = {};
417
435
 
@@ -438,7 +456,7 @@ function UserInput({ field, onUpload, selectedInformation, onChange, onFieldUpda
438
456
  switch (field.type) {
439
457
 
440
458
  case 'search':
441
- return <AdvancedSearchSelect {...field} reportId={reportId} style={{ width: '100%' }} />
459
+ return <AdvancedSearchSelect {...field} reportId={reportId} style={{ width: '100%' }} onReset={onSearchReset} />
442
460
 
443
461
  case 'number':
444
462
  return <InputNumber required={field.required} />
@@ -140,10 +140,24 @@ export default function AdvancedSearchSelect({ reportId, onReset, field, value,
140
140
  onChange(newValues);
141
141
  };
142
142
 
143
+ const notifyReset = () => {
144
+ if (finalOnReset) {
145
+ finalOnReset(fieldName);
146
+ }
147
+ };
148
+
143
149
  const handleReset = () => {
144
150
  onChange([]);
145
- if (finalOnReset) {
146
- finalOnReset(); // 🔥 trigger dashboard refresh
151
+ notifyReset();
152
+ };
153
+
154
+ const handleSelectChange = (nextValue) => {
155
+ const nextValues = Array.isArray(nextValue) ? nextValue : [];
156
+
157
+ onChange(nextValues);
158
+
159
+ if (safeValue.length > 0 && nextValues.length === 0) {
160
+ notifyReset();
147
161
  }
148
162
  };
149
163
 
@@ -177,7 +191,7 @@ export default function AdvancedSearchSelect({ reportId, onReset, field, value,
177
191
  // Always pass an array back to the parent to be consistent with the Select mode.
178
192
  onChange(text ? [text] : []);
179
193
  if (!text && finalOnReset) {
180
- finalOnReset();
194
+ finalOnReset(fieldName);
181
195
  }
182
196
  }}
183
197
  />
@@ -205,7 +219,7 @@ export default function AdvancedSearchSelect({ reportId, onReset, field, value,
205
219
  }}
206
220
  allowClear
207
221
  maxTagCount={1}
208
- onChange={onChange}
222
+ onChange={handleSelectChange}
209
223
  maxTagPlaceholder={(omittedValues) => (
210
224
  <span className="tag-placeholder-count">
211
225
  +{omittedValues.length}
@@ -435,7 +435,12 @@ export default function ReportingDashboard({
435
435
 
436
436
  if (!hasSearchValues) {
437
437
  const currentUrlParams = Location.search();
438
- const { script_id, selected_card, ...cleanParams } = currentUrlParams;
438
+ const searchKeys = new Set(searchParameters.map((parameter) => parameter.field));
439
+ const cleanParams = Object.fromEntries(
440
+ Object.entries(currentUrlParams).filter(
441
+ ([key]) => key !== 'script_id' && key !== 'selected_card' && !searchKeys.has(key)
442
+ )
443
+ );
439
444
 
440
445
  const newParams = new URLSearchParams({
441
446
  ...cleanParams,
@@ -520,14 +525,22 @@ export default function ReportingDashboard({
520
525
  return parameter;
521
526
  });
522
527
 
523
- // Remove keys with undefined, null, or empty string values
528
+ const currentParams = Location.search();
529
+ // Mark existing empty values as null so Location.search removes stale query params.
524
530
  const filteredParams = Object.fromEntries(
525
- Object.entries(urlsToUpdate).filter(([_, value]) => value !== undefined && value !== null && value !== '')
531
+ Object.entries(urlsToUpdate).flatMap(([key, value]) => {
532
+ const shouldRemove = value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0);
533
+ if (shouldRemove && !Object.prototype.hasOwnProperty.call(currentParams, key)) {
534
+ return [];
535
+ }
536
+
537
+ return [[key, shouldRemove ? null : value]];
538
+ })
526
539
  );
527
540
 
528
541
  setformContents(formContent);
529
542
  setLiveFormContents(formContent);
530
- Location.search({ ...Location.search(), ...filteredParams });
543
+ Location.search({ ...currentParams, ...filteredParams });
531
544
  }
532
545
 
533
546
  // Reset Pagination Data
@@ -568,6 +581,7 @@ export default function ReportingDashboard({
568
581
  <MenuDashBoardComponent
569
582
  dashBoardIds={dashBoardIds} //Pass the available dashboard IDs to the componen
570
583
  activeId={Number(urlParams?.selected_card || 0)}
584
+ dbPtr={dbPtr}
571
585
  callback={(record) => {
572
586
  const selectedCard = record?.id;
573
587
  if (record.other_details) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui-soxo-bootstrap-core",
3
- "version": "2.6.30",
3
+ "version": "2.6.31",
4
4
  "description": "All the Core Components for you to start",
5
5
  "keywords": [
6
6
  "all in one"