@ruiapp/rapid-core 0.2.0 → 0.2.1

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/index.js CHANGED
@@ -2691,10 +2691,14 @@ async function convertEntityFiltersToRowFilters(server, model, baseModel, filter
2691
2691
  else {
2692
2692
  const filterField = filter.field;
2693
2693
  let property = getEntityPropertyByCode(server, model, filterField);
2694
+ let filterValue = filter.value;
2694
2695
  let columnName = "";
2695
2696
  if (property) {
2696
2697
  if (isOneRelationProperty(property)) {
2697
2698
  columnName = property.targetIdColumnName;
2699
+ if (lodash.isPlainObject(filterValue)) {
2700
+ filterValue = filterValue.id;
2701
+ }
2698
2702
  }
2699
2703
  else if (isManyRelationProperty(property)) {
2700
2704
  throw new Error(`Operator "${operator}" is not supported on many-relation property "${property.code}"`);
@@ -2716,6 +2720,9 @@ async function convertEntityFiltersToRowFilters(server, model, baseModel, filter
2716
2720
  });
2717
2721
  if (property) {
2718
2722
  columnName = property.targetIdColumnName;
2723
+ if (lodash.isPlainObject(filterValue)) {
2724
+ filterValue = filterValue.id;
2725
+ }
2719
2726
  }
2720
2727
  else {
2721
2728
  columnName = filterField;
@@ -2729,7 +2736,7 @@ async function convertEntityFiltersToRowFilters(server, model, baseModel, filter
2729
2736
  name: columnName,
2730
2737
  tableName: property && property.isBaseProperty ? baseModel.tableName : model.tableName,
2731
2738
  },
2732
- value: filter.value,
2739
+ value: filterValue,
2733
2740
  itemType: filter.itemType,
2734
2741
  });
2735
2742
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruiapp/rapid-core",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,7 +24,7 @@ import { mapDbRowToEntity, mapEntityToDbRow } from "./entityMapper";
24
24
  import { mapPropertyNameToColumnName } from "./propertyMapper";
25
25
  import { IRpdServer, RapidPlugin } from "~/core/server";
26
26
  import { getEntityPartChanges } from "~/helpers/entityHelpers";
27
- import { cloneDeep, filter, find, first, forEach, isArray, isNumber, isObject, isString, keys, map, reject, uniq } from "lodash";
27
+ import { cloneDeep, filter, find, first, forEach, isArray, isNumber, isObject, isPlainObject, isString, keys, map, reject, uniq } from "lodash";
28
28
  import {
29
29
  getEntityPropertiesIncludingBase,
30
30
  getEntityProperty,
@@ -526,10 +526,15 @@ async function convertEntityFiltersToRowFilters(
526
526
  const filterField = (filter as EntityNonRelationPropertyFilterOptions).field;
527
527
  let property: RpdDataModelProperty = getEntityPropertyByCode(server, model, filterField);
528
528
 
529
+ let filterValue = (filter as any).value;
530
+
529
531
  let columnName = "";
530
532
  if (property) {
531
533
  if (isOneRelationProperty(property)) {
532
534
  columnName = property.targetIdColumnName;
535
+ if (isPlainObject(filterValue)) {
536
+ filterValue = filterValue.id;
537
+ }
533
538
  } else if (isManyRelationProperty(property)) {
534
539
  throw new Error(`Operator "${operator}" is not supported on many-relation property "${property.code}"`);
535
540
  } else {
@@ -549,6 +554,9 @@ async function convertEntityFiltersToRowFilters(
549
554
 
550
555
  if (property) {
551
556
  columnName = property.targetIdColumnName;
557
+ if (isPlainObject(filterValue)) {
558
+ filterValue = filterValue.id;
559
+ }
552
560
  } else {
553
561
  columnName = filterField;
554
562
  }
@@ -562,7 +570,7 @@ async function convertEntityFiltersToRowFilters(
562
570
  name: columnName,
563
571
  tableName: property && property.isBaseProperty ? baseModel.tableName : model.tableName,
564
572
  },
565
- value: (filter as any).value,
573
+ value: filterValue,
566
574
  itemType: (filter as any).itemType,
567
575
  } as any);
568
576
  }