diff --git a/app/panels/query_editor/components/inspector_query_cond/query_cond_dialog.js b/app/panels/query_editor/components/inspector_query_cond/query_cond_dialog.js index fab290e..2f58d77 100644 --- a/app/panels/query_editor/components/inspector_query_cond/query_cond_dialog.js +++ b/app/panels/query_editor/components/inspector_query_cond/query_cond_dialog.js @@ -50,6 +50,19 @@ const QueryCondDialog = ({ cond, entities, args, onOk, onCancel }) => { } }; + //Добавление значения в редактор по месту курсора + const addCondValueToCursor = value => { + let newValue = conditions + value; + if (coditionInputRef.current) { + newValue = coditionInputRef.current.value; + newValue = + newValue.substring(0, coditionInputRef.current.selectionStart) + value + newValue.substring(coditionInputRef.current.selectionEnd); + coditionInputRef.current.value = newValue; + } + moveCondCursorToEnd(); + setConditions(newValue); + }; + //Нажатие на кнопку "ОК" const handleOk = () => onOk && onOk(conditions); @@ -60,16 +73,10 @@ const QueryCondDialog = ({ cond, entities, args, onOk, onCancel }) => { const handleChange = e => setConditions(e.target.value); //При выборе компонента условия - const handleComponentSelected = value => { - setConditions(pv => pv + value); - moveCondCursorToEnd(); - }; + const handleComponentSelected = value => addCondValueToCursor(value); //При нажатии на кнопку операции - const handleOperationButtonClick = value => { - setConditions(pv => pv + value); - moveCondCursorToEnd(); - }; + const handleOperationButtonClick = value => addCondValueToCursor(value); //При нажатии на кнопку очистки условий const handleClearClick = () => setConditions("");