diff --git a/client/src/components/report-center-modal/report-center-modal-filters-sorters-component.jsx b/client/src/components/report-center-modal/report-center-modal-filters-sorters-component.jsx
index 765dd14b9..f4d2ee721 100644
--- a/client/src/components/report-center-modal/report-center-modal-filters-sorters-component.jsx
+++ b/client/src/components/report-center-modal/report-center-modal-filters-sorters-component.jsx
@@ -1,8 +1,9 @@
-import {Button, Col, Form, Input, Row, Select} from "antd";
+import {Button, Col, Form, Input, InputNumber, Row, Select} from "antd";
import React, {useEffect, useState} from "react";
import {fetchFilterData} from "../../utils/RenderTemplate";
import {DeleteFilled} from "@ant-design/icons";
import {useTranslation} from "react-i18next";
+import {getOperatorsByType} from "../../utils/graphQLmodifier";
export default function ReportCenterModalFiltersSortersComponent({form}) {
return (
@@ -15,7 +16,7 @@ export default function ReportCenterModalFiltersSortersComponent({form}) {
);
}
-function RenderFilters({templateId}) {
+function RenderFilters({templateId, form}) {
const [state, setState] = useState(null);
console.log("state", state);
@@ -36,6 +37,7 @@ function RenderFilters({templateId}) {
}
}, [templateId]);
+
if (!templateId || !state) return null;
return (
@@ -63,8 +65,6 @@ function RenderFilters({templateId}) {
options={
state.filters
? state.filters.map((f) => {
- console.log('filter added');
- console.dir(f);
return {
value: f.name,
label: f?.translation ? t(f.translation) : f.label,
@@ -76,59 +76,67 @@ function RenderFilters({templateId}) {
-
- {
- () => {
- console.log('Dependencies fired')
- return
-
-
-
+
+ {
+ () => {
+ const name = form.getFieldValue(['filters', field.name, "field"]);
+ const type = state.filters.find(f => f.name === name)?.type;
+ return
+
+ }
+ }
- }
- }
-
-
-
+
+ {
+ () => {
+ const name = form.getFieldValue(['filters', field.name, "field"]);
+ const type = state.filters.find(f => f.name === name)?.type;
+
+ return
+ {type === 'number' ?
+ {
+ form.setFieldsValue({[field.name]: {value: parseInt(value)}});
+ }}
+ />
+ :
+ {
+ form.setFieldsValue({[field.name]: {value: value.toString()}});
+ }}
+ />
+ }
+
+ }
+ }
+
);
diff --git a/client/src/utils/graphQLmodifier.js b/client/src/utils/graphQLmodifier.js
index 55a59302d..3ff134a8a 100644
--- a/client/src/utils/graphQLmodifier.js
+++ b/client/src/utils/graphQLmodifier.js
@@ -1,33 +1,29 @@
-import {Kind, visit, parse, print} from "graphql";
+import {Kind, parse, print, visit} from "graphql";
-export const numberOperators = [
- {value: "_eq", label: "Equals"},
- {value: "_ne", label: "Not Equals"},
- {value: "_gt", label: "Greater Than"},
- {value: "_lt", label: "Less Than"},
- {value: "_gte", label: "Greater Than or Equal To"},
- {value: "_lte", label: "Less Than or Equal To"},
-];
-
-export const stringOperators = [
- {value: "_eq", label: "Equals", type: 'string'},
- {value: "_ne", label: "Not Equals", type: 'string'},
- {value: "_in", label: "In", type: 'string'},
- {value: "_nin", label: "Not In", type: 'string'},
- {value: "_contains", label: "Contains", type: 'string'},
- {value: "_ncontains", label: "Does Not Contain", type: 'string'},
-];
-
-export const numberSorters = [
- {value: "asc", label: "Ascending"},
- {value: "desc", label: "Descending"},
-];
-
-export const stringSorters = [
- {value: "asc", label: "Alphabetically Ascending"},
- {value: "desc", label: "Alphabetically Descending"},
+const STRING_OPERATORS = [
+ {value: "_eq", label: "equals"},
+ {value: "_neq", label: "does not equal"},
+ {value: "_like", label: "contains"},
+ {value: "_nlike", label: "does not contain"},
+ {value: "_ilike", label: "contains case-insensitive"},
+ {value: "_nilike", label: "does not contain case-insensitive"}
+];
+const NUMBER_OPERATORS = [
+ {value: "_eq", label: "equals"},
+ {value: "_neq", label: "does not equal"},
+ {value: "_gt", label: "greater than"},
+ {value: "_lt", label: "less than"},
+ {value: "_gte", label: "greater than or equal"},
+ {value: "_lte", label: "less than or equal"}
];
+export function getOperatorsByType(type = 'string') {
+ const operators = {
+ string: STRING_OPERATORS,
+ number: NUMBER_OPERATORS
+ };
+ return operators[type];
+}
/* eslint-disable no-loop-func */