ballerina-core 1.0.202 → 1.0.204

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "ballerina-core",
3
3
  "author": "Dr. Giuseppe Maggiore",
4
4
  "private": false,
5
- "version": "1.0.202",
5
+ "version": "1.0.204",
6
6
  "main": "main.ts",
7
7
  "scripts": {
8
8
  "prettier": "prettier --write ."
@@ -29,37 +29,48 @@ const initialiseFiltersAndSorting = <
29
29
  >(
30
30
  filterTypes: Map<string, SumNType<any>>,
31
31
  ) => {
32
- return Co<CustomPresentationContext, ExtraContext>().Seq([
33
- Co<CustomPresentationContext, ExtraContext>()
34
- .GetState()
35
- .then((current) => {
36
- const getDefaultFiltersAndSorting =
37
- current.tableApiSource.getDefaultFiltersAndSorting(filterTypes);
38
- return Co<CustomPresentationContext, ExtraContext>()
39
- .Await(getDefaultFiltersAndSorting(current.parseFromApiByType), () =>
40
- console.error("error getting default filters and sorting"),
41
- )
42
- .then((filtersAndSorting) => {
43
- return filtersAndSorting.kind == "l"
44
- ? Co<CustomPresentationContext, ExtraContext>().SetState(
45
- TableAbstractRendererState.Updaters.Core.customFormState.children
46
- .filters(replaceWith(filtersAndSorting.value.filters))
47
- .then(
48
- TableAbstractRendererState.Updaters.Core.customFormState.children.sorting(
49
- replaceWith(filtersAndSorting.value.sorting),
50
- ),
51
- ),
52
- )
53
- : Co<CustomPresentationContext, ExtraContext>().Wait(0);
54
- });
55
- }),
56
- Co<CustomPresentationContext, ExtraContext>().SetState(
57
- TableAbstractRendererState.Updaters.Core.customFormState.children.isFilteringInitialized(
58
- // always set to true even if the first call fails so we don't block the flow
59
- replaceWith(true),
60
- ),
61
- ),
62
- ]);
32
+ return filterTypes.size == 0
33
+ ? Co<CustomPresentationContext, ExtraContext>().SetState(
34
+ TableAbstractRendererState.Updaters.Core.customFormState.children.isFilteringInitialized(
35
+ // always set to true even if the first call fails so we don't block the flow
36
+ replaceWith(true),
37
+ ),
38
+ )
39
+ : Co<CustomPresentationContext, ExtraContext>().Seq([
40
+ Co<CustomPresentationContext, ExtraContext>()
41
+ .GetState()
42
+ .then((current) => {
43
+ const getDefaultFiltersAndSorting =
44
+ current.tableApiSource.getDefaultFiltersAndSorting(filterTypes);
45
+ return Co<CustomPresentationContext, ExtraContext>()
46
+ .Await(
47
+ getDefaultFiltersAndSorting(current.parseFromApiByType),
48
+ () =>
49
+ console.error(
50
+ "error getting default filters and sorting from api",
51
+ ),
52
+ )
53
+ .then((filtersAndSorting) => {
54
+ return filtersAndSorting.kind == "l"
55
+ ? Co<CustomPresentationContext, ExtraContext>().SetState(
56
+ TableAbstractRendererState.Updaters.Core.customFormState.children
57
+ .filters(replaceWith(filtersAndSorting.value.filters))
58
+ .then(
59
+ TableAbstractRendererState.Updaters.Core.customFormState.children.sorting(
60
+ replaceWith(filtersAndSorting.value.sorting),
61
+ ),
62
+ ),
63
+ )
64
+ : Co<CustomPresentationContext, ExtraContext>().Wait(0);
65
+ });
66
+ }),
67
+ Co<CustomPresentationContext, ExtraContext>().SetState(
68
+ TableAbstractRendererState.Updaters.Core.customFormState.children.isFilteringInitialized(
69
+ // always set to true even if the first call fails so we don't block the flow
70
+ replaceWith(true),
71
+ ),
72
+ ),
73
+ ]);
63
74
  };
64
75
 
65
76
  const intialiseTable = <
@@ -80,8 +91,6 @@ const intialiseTable = <
80
91
  current.fromTableApiParser,
81
92
  );
82
93
 
83
- console.debug("params", current.customFormState.filterAndSortParam);
84
-
85
94
  const params =
86
95
  current.customFormState.filterAndSortParam == ""
87
96
  ? Map<string, string>()
@@ -183,6 +192,7 @@ export const TableReinitialiseRunner = <
183
192
  interval: 15,
184
193
  runFilter: (props) =>
185
194
  props.context.customFormState.initializationStatus === "initialized" &&
195
+ props.context.customFormState.isFilteringInitialized &&
186
196
  props.context.customFormState.shouldReinitialize,
187
197
  },
188
198
  );
@@ -197,10 +207,11 @@ export const TableRunner = <
197
207
  interval: 15,
198
208
  runFilter: (props) => {
199
209
  return (
200
- props.context.customFormState.initializationStatus ===
210
+ (props.context.customFormState.initializationStatus ===
201
211
  "not initialized" ||
202
- props.context.customFormState.initializationStatus ===
203
- "reinitializing"
212
+ props.context.customFormState.initializationStatus ===
213
+ "reinitializing") &&
214
+ props.context.customFormState.isFilteringInitialized
204
215
  );
205
216
  },
206
217
  },
@@ -342,12 +342,45 @@ export const TableAbstractRendererState = {
342
342
  const parsedFiltersValues = parsedFilters
343
343
  .map((filter) => filter.map((f) => (f as Value<PredicateValue>).value))
344
344
  .toJS();
345
+
346
+ const valueSorting = sorting
347
+ .entrySeq()
348
+ .filter(([_, direction]) => direction != undefined)
349
+ .map(([columnName, direction]) =>
350
+ PredicateValue.Default.tuple(List([columnName, direction as string])),
351
+ );
352
+
353
+ const parsedValueSorting = ValueOrErrors.Operations.All(
354
+ valueSorting
355
+ .map((sorting) =>
356
+ toApiRaw(
357
+ DispatchParsedType.Default.tuple([
358
+ {
359
+ kind: "primitive",
360
+ name: "string",
361
+ asString: () => "string",
362
+ },
363
+ {
364
+ kind: "primitive",
365
+ name: "string",
366
+ asString: () => "string",
367
+ },
368
+ ]),
369
+ sorting,
370
+ {},
371
+ ),
372
+ )
373
+ .toList(),
374
+ );
375
+
376
+ const finalSorting =
377
+ parsedValueSorting.kind == "errors"
378
+ ? []
379
+ : parsedValueSorting.value.toArray();
380
+
345
381
  const params = {
346
382
  Filters: parsedFiltersValues,
347
- Sorting: sorting
348
- .entrySeq()
349
- .toList()
350
- .filter((sorting) => sorting[1] != undefined),
383
+ Sorting: finalSorting,
351
384
  };
352
385
  return btoa(JSON.stringify(params));
353
386
  },
@@ -11,6 +11,7 @@ import {
11
11
  ListRepo,
12
12
  BasicUpdater,
13
13
  Guid,
14
+ FilterTypeKind,
14
15
  } from "../../../../../../main";
15
16
 
16
17
  export type TuplePredicateExpression = {
@@ -912,6 +913,32 @@ export const PredicateValue = {
912
913
  return PredicateValue.Default.filterEqualsTo(value);
913
914
  }
914
915
  },
916
+ FilterToKindAndValue: (
917
+ filter: ValueFilter,
918
+ ): { kind: FilterTypeKind; value: PredicateValue } => {
919
+ switch (filter.kind) {
920
+ case "contains":
921
+ return { kind: "contains", value: filter.contains };
922
+ case "=":
923
+ return { kind: "=", value: filter.equalsTo };
924
+ case "!=":
925
+ return { kind: "!=", value: filter.notEqualsTo };
926
+ case ">=":
927
+ return { kind: ">=", value: filter.greaterThanOrEqualsTo };
928
+ case ">":
929
+ return { kind: ">", value: filter.greaterThan };
930
+ case "!=null":
931
+ return { kind: "!=null", value: PredicateValue.Default.unit() };
932
+ case "=null":
933
+ return { kind: "=null", value: PredicateValue.Default.unit() };
934
+ case "<=":
935
+ return { kind: "<=", value: filter.smallerThanOrEqualsTo };
936
+ case "<":
937
+ return { kind: "<", value: filter.smallerThan };
938
+ default:
939
+ return { kind: "startsWith", value: filter.startsWith };
940
+ }
941
+ },
915
942
  ParseAsDate: (json: any): ValueOrErrors<PredicateValue, string> => {
916
943
  if (PredicateValue.Operations.IsDate(json))
917
944
  return ValueOrErrors.Default.return(json);