diff --git a/store/reducers/nodesInputReducer.ts b/store/reducers/nodesInputReducer.ts index 75b815b..3bc1e73 100644 --- a/store/reducers/nodesInputReducer.ts +++ b/store/reducers/nodesInputReducer.ts @@ -56,6 +56,32 @@ const nodesInputSlice = createSlice({ }, setLoading(state, action: PayloadAction){ state.loading = action.payload + }, + updateNumberNode(state, action: PayloadAction<{value: string, number: number}>) { + state.nodes = state.nodes.map((e) => { + var operation = '='; + if (e.value[0] == '>' && e.value[1] == '=') operation = '>=' + if (e.value[0] == '<' && e.value[1] == '=') operation = '<=' + return e.value == e.value ? { + type: e.type, + value: operation + action.payload.number.toString() + } : e + }) + }, + updateOperationNode(state, action: PayloadAction<{value: string, operation: string}>) { + state.nodes = state.nodes.map((e) => { + var value = 0 + if (action.payload.operation.length == 2) { + value = Number.parseInt(e.value.slice(2, e.value.length)) + } + else { + value = Number.parseInt(e.value.slice(1, e.value.length)) + } + return e.value == e.value ? { + type: e.type, + value: action.payload.operation + value + } : e + }) } }, @@ -70,7 +96,14 @@ const nodesInputSlice = createSlice({ } }) -export const {setCurrentWord, createNode, deleteNode, setLoading} = nodesInputSlice.actions; +export const { + setCurrentWord, + createNode, + deleteNode, + setLoading, + updateNumberNode, + updateOperationNode +} = nodesInputSlice.actions; export const hints = createSelector((state: INodesInput) => state.hints, hints => hints) diff --git a/сomponents/search/index.tsx b/сomponents/search/index.tsx index eeda8ef..b4f6898 100644 --- a/сomponents/search/index.tsx +++ b/сomponents/search/index.tsx @@ -2,7 +2,7 @@ import React, { useState } from "react"; import { AutoComplete, Input, Tag, Tooltip } from 'antd'; import { InputNumber, Popover, Radio } from 'antd'; import { useAppDispatch, useAppSelector } from "../../hooks"; -import { createNode, deleteNode, hints, INode, loading, nodes, products, setLoading } from "../../store/reducers/nodesInputReducer"; +import { createNode, deleteNode, hints, INode, loading, nodes, products, setLoading, updateNumberNode, updateOperationNode } from "../../store/reducers/nodesInputReducer"; import { createHints, search } from "../../store/reducers/asyncActions"; import styles from "./search.module.css" @@ -65,16 +65,34 @@ export const Search: React.FC<{onData:(data:any)=>void}> = (props) =>{ if (value.type.split("_")[1] == "numeric"){ let popver =
{value.type.split("_")[0]}
- + { + console.log(e.target.value) + dispatch( + updateOperationNode({value: value.value, operation: e.target.value}) + ) + }}> = - setDisableInput(true)} size="small" min={1} max={100000} defaultValue={100}/> + setDisableInput(true)} + size="small" + min={1} + max={100000} + defaultValue={100} + onChange={(ee) => { + console.log(ee) + dispatch( + updateNumberNode({value: value.value, number: ee!}) + ) + }} + />
- tag = e?null:setDisableInput(false)} content={popver} title="Задать значение"> + tag = e?null:setDisableInput(false)} content={popver} title="Задать значение"> void}> = (props) =>{ ) }} > - + { + console.log(e) + }} + > {value.value.length < 13? value.value:value.value.slice(0,10)+"..."} @@ -95,12 +117,15 @@ export const Search: React.FC<{onData:(data:any)=>void}> = (props) =>{ } const onSelect = (value:string, type:any) =>{ - const vts = value.split('--'); + var vts = value.split('--'); addTag({ 'type': vts[1], 'value': vts[0] }) - + if (vts[1].endsWith('_numeric')){ + vts[1] = '*'+vts[1].split('_')[0] + vts[0] = '=0' + } dispatch(createNode({ 'type': vts[1], 'value': vts[0] @@ -158,7 +183,7 @@ export const Search: React.FC<{onData:(data:any)=>void}> = (props) =>{ {after_str} , - value: e.value.value + '--' + e.value.type + value: e.value.value + '--' + e.value.type + '--' + Date.now().toString() } })} onSelect={onSelect as any}