ЦИТК-979 - Редактор условия запроса - реализовано добавление элемента условия по месту курсора/выделения

This commit is contained in:
Mikhail Chechnev 2025-10-14 14:45:53 +03:00
parent 3df01a36c6
commit 6efbb8508c

View File

@ -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("");