diff --git a/app/panels/rrp_conf_editor/components/form.js b/app/components/p8p_dialog.js similarity index 58% rename from app/panels/rrp_conf_editor/components/form.js rename to app/components/p8p_dialog.js index 98030ce..30ab288 100644 --- a/app/panels/rrp_conf_editor/components/form.js +++ b/app/components/p8p_dialog.js @@ -1,6 +1,6 @@ /* - Парус 8 - Панели мониторинга - РО - Редактор настройки регламентированного отчёта - Компонент панели: Форма + Парус 8 - Панели мониторинга + Компонент: Диалог */ //--------------------- @@ -10,33 +10,33 @@ import React, { useEffect, useState } from "react"; //Классы React import PropTypes from "prop-types"; //Контроль свойств компонента import { Dialog, DialogTitle, DialogContent, DialogActions, Button } from "@mui/material"; //Интерфейсные компоненты -import { BUTTONS } from "../../../../app.text"; //Общие текстовые ресурсы -import { FORM_FILED, FormField } from "./form_field"; //Элемент формы +import { BUTTONS } from "../../app.text"; //Общие текстовые ресурсы +import { P8P_INPUT, P8PInput } from "./p8p_input"; //Поле ввода //----------- //Тело модуля //----------- -//Форма -const Form = ({ title, fields = [], children, onOk, onCancel, onClose }) => { - //Состояние формы +//Диалог +const P8PDialog = ({ title, inputs = [], children, onOk, onCancel, onClose }) => { + //Состояние диалога const [state, setState] = useState({}); - //При изменении элемента формы - const handleFieldChange = (name, value) => setState(pv => ({ ...pv, [name]: value })); + //При изменении элемента ввода + const handleInputChange = (name, value) => setState(pv => ({ ...pv, [name]: value })); - //При нажатии на "ОК" формы + //При нажатии на "ОК" диалога const handleOk = () => onOk && onOk(state); - //При нажатии на "Отмена" формы + //При нажатии на "Отмена" диалога const handleCancel = () => onCancel && onCancel(); - //При нажатии на "Закрыть" формы + //При нажатии на "Закрыть" диалога const handleClose = () => (onClose ? onClose() : onCancel ? onCancel() : null); //При подключении к старнице useEffect(() => { - setState(fields.reduce((res, f) => ({ ...res, [f.elementCode]: f.elementValue == undefined ? null : f.elementValue }), {})); + setState(inputs.reduce((res, input) => ({ ...res, [input.name]: input.value == undefined ? null : input.value }), {})); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -45,8 +45,8 @@ const Form = ({ title, fields = [], children, onOk, onCancel, onClose }) => { {title} - {fields.map((f, i) => ( - + {inputs.map((input, i) => ( + ))} {children} @@ -59,10 +59,10 @@ const Form = ({ title, fields = [], children, onOk, onCancel, onClose }) => { ); }; -//Контроль свойств - Форма -Form.propTypes = { +//Контроль свойств - Диалог +P8PDialog.propTypes = { title: PropTypes.string.isRequired, - fields: PropTypes.arrayOf(PropTypes.shape(FORM_FILED)), + inputs: PropTypes.arrayOf(PropTypes.shape(P8P_INPUT)), children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]), onOk: PropTypes.func, onCancel: PropTypes.func, @@ -73,4 +73,4 @@ Form.propTypes = { //Интерфейс модуля //---------------- -export { Form }; +export { P8PDialog }; diff --git a/app/panels/rrp_conf_editor/components/form_field.js b/app/components/p8p_input.js similarity index 62% rename from app/panels/rrp_conf_editor/components/form_field.js rename to app/components/p8p_input.js index 587a1ad..2adc568 100644 --- a/app/panels/rrp_conf_editor/components/form_field.js +++ b/app/components/p8p_input.js @@ -1,6 +1,6 @@ /* - Парус 8 - Панели мониторинга - РО - Редактор настройки регламентированного отчёта - Компонент панели: Поле ввода формы + Парус 8 - Панели мониторинга + Компонент: Поле ввода */ //--------------------- @@ -15,11 +15,11 @@ import { Box, Icon, Input, InputAdornment, FormControl, Select, InputLabel, Menu //Константы //--------- -//Формат свойств поля формы -const FORM_FILED = { - elementCode: PropTypes.string.isRequired, - elementValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.instanceOf(Date)]), - labelText: PropTypes.string.isRequired, +//Формат свойств поля ввода +const P8P_INPUT = { + name: PropTypes.string.isRequired, + value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.instanceOf(Date)]), + label: PropTypes.string.isRequired, onChange: PropTypes.func, dictionary: PropTypes.func, list: PropTypes.array, @@ -33,71 +33,59 @@ const FORM_FILED = { //Тело модуля //----------- -//Поле ввода формы -const FormField = ({ - elementCode, - elementValue, - labelText, - onChange, - dictionary, - list, - type, - freeSolo = false, - disabled = false, - formValues, - ...other -}) => { +//Поле ввода +const P8PInput = ({ name, value, label, onChange, dictionary, list, type, freeSolo = false, disabled = false, formValues, ...other }) => { //Значение элемента - const [value, setValue] = useState(elementValue); + const [currentValue, setCurrentValue] = useState(value); //При получении нового значения из вне useEffect(() => { - setValue(elementValue); - }, [elementValue]); + setCurrentValue(value); + }, [value]); //Выбор значения из словаря const handleDictionaryClick = () => dictionary && dictionary(formValues, res => (res ? res.map(i => handleChangeByName(i.name, i.value)) : null)); //Изменение значения элемента (по событию) const handleChange = e => { - setValue(e.target.value); + setCurrentValue(e.target.value); if (onChange) onChange(e.target.name, e.target.value); }; //Изменение значения элемента (по имени и значению) - const handleChangeByName = (name, value) => { - if (name === elementCode) setValue(value); - if (onChange) onChange(name, value); + const handleChangeByName = (targetName, value) => { + if (targetName === name) setCurrentValue(value); + if (onChange) onChange(targetName, value); }; //Генерация содержимого return ( - + {list ? ( freeSolo ? ( handleChangeByName(elementCode, newValue)} - onInputChange={(event, newInputValue) => handleChangeByName(elementCode, newInputValue)} + inputValue={currentValue ? currentValue : ""} + onChange={(event, newValue) => handleChangeByName(name, newValue)} + onInputChange={(event, newInputValue) => handleChangeByName(name, newInputValue)} options={list} - renderInput={params => } + renderInput={params => } /> ) : ( <> - - {labelText} + + {label} - + list @@ -139,11 +127,11 @@ const FormField = ({ ); }; -//Контроль свойств - Поле ввода формы -FormField.propTypes = FORM_FILED; +//Контроль свойств - Поле ввода +P8PInput.propTypes = P8P_INPUT; //---------------- //Интерфейс модуля //---------------- -export { FORM_FILED, FormField }; +export { P8P_INPUT, P8PInput }; diff --git a/app/panels/panels_editor/components/components_hooks.js b/app/panels/panels_editor/components/components_hooks.js index a23fce5..518cd82 100644 --- a/app/panels/panels_editor/components/components_hooks.js +++ b/app/panels/panels_editor/components/components_hooks.js @@ -59,7 +59,7 @@ const useUserProcDesc = ({ code, refresh }) => { try { setLoading(true); const data = await executeStored({ - stored: "PKG_P8PANELS_EDITOR.USERPROCS_DESC", + stored: "PKG_P8PANELS_PE.USERPROCS_DESC", args: { SCODE: code }, respArg: "COUT", isArray: name => name === "arguments", diff --git a/app/panels/panels_editor/components/editors_common.js b/app/panels/panels_editor/components/editors_common.js index 2c2f172..20bf1d0 100644 --- a/app/panels/panels_editor/components/editors_common.js +++ b/app/panels/panels_editor/components/editors_common.js @@ -17,10 +17,6 @@ import { Typography, Divider, Chip, - Dialog, - DialogTitle, - DialogContent, - DialogActions, Button, TextField, InputAdornment, @@ -34,6 +30,7 @@ import { import client from "../../../core/client"; //Клиент БД import { ApplicationСtx } from "../../../context/application"; //Контекст приложения import { BUTTONS } from "../../../../app.text"; //Общие текстовые ресурсы +import { P8PDialog } from "../../../components/p8p_dialog"; //Типовой диалог import { useUserProcDesc } from "./components_hooks"; //Общие хуки компонентов import "../panels_editor.css"; //Стили редактора @@ -168,14 +165,9 @@ EditorSubHeader.propTypes = { const ConfigDialog = ({ title, children, onOk, onCancel }) => { //Формирование представления return ( - - {title} - {children} - - - - - + + {children} + ); }; diff --git a/app/panels/rrp_conf_editor/components/dialog_help.js b/app/panels/rrp_conf_editor/components/dialog_help.js index b6a8b43..f54c810 100644 --- a/app/panels/rrp_conf_editor/components/dialog_help.js +++ b/app/panels/rrp_conf_editor/components/dialog_help.js @@ -10,7 +10,7 @@ import React from "react"; //Классы React import PropTypes from "prop-types"; //Контроль свойств компонента import { Typography, List, ListItem } from "@mui/material"; //Интерфейсные элементы -import { Form } from "./form"; //Типовая форма +import { P8PDialog } from "../../../components/p8p_dialog"; //Типовой диалог //--------- //Константы @@ -53,7 +53,7 @@ const DialogHelp = ({ onClose }) => { //Генерация содержимого return ( -
+ Карточки показателей содержат сокращенную информацию о типе состава показателя. Список сокращений: @@ -71,7 +71,7 @@ const DialogHelp = ({ onClose }) => { - +
); }; diff --git a/app/panels/rrp_conf_editor/components/dialog_mark_iu.js b/app/panels/rrp_conf_editor/components/dialog_mark_iu.js index 5c726f1..d59bf4f 100644 --- a/app/panels/rrp_conf_editor/components/dialog_mark_iu.js +++ b/app/panels/rrp_conf_editor/components/dialog_mark_iu.js @@ -10,7 +10,7 @@ import React from "react"; //Классы React import PropTypes from "prop-types"; //Контроль свойств компонента import { useDictionary } from "../hooks"; //Кастомные хуки -import { Form } from "./form"; //Типовая форма +import { P8PDialog } from "../../../components/p8p_dialog"; //Типовой диалог //----------- //Тело модуля @@ -67,15 +67,15 @@ const DialogMarkIU = ({ //Генерация содержимого return ( -
{ //Генерация содержимого return ( - showMarkCn(mark, constitution, res => res.success && handleRefresh()); - //При закрытии формы добавления/исправления по "ОК" - const handleIUFormOk = values => { + //При закрытии диалога добавления/исправления по "ОК" + const handleIUDialogOk = values => { if (modMark === true) onMarkInsert && onMarkInsert(values, res => res && setModMark(null)); else onMarkUpdate && onMarkUpdate({ ...modMark, ...values }, res => res && setModMark(null)); }; - //При закрытии формы добавления/исправления по "Отмена" - const handleIUFormCancel = () => setModMark(null); + //При закрытии диалога добавления/исправления по "Отмена" + const handleIUDialogCancel = () => setModMark(null); //Формирование представления return ( @@ -118,7 +118,12 @@ const Marks = ({ marks, order, marksLoading, marksInit, onRefresh, onMarkInsert, {dialogOrder && } {dialogHelp && } {modMark && ( - + )} {marksInit && (marks ? ( diff --git a/app/panels/rrp_conf_editor/components/sections.js b/app/panels/rrp_conf_editor/components/sections.js index 4c63745..3d25186 100644 --- a/app/panels/rrp_conf_editor/components/sections.js +++ b/app/panels/rrp_conf_editor/components/sections.js @@ -118,15 +118,15 @@ const Sections = ({ conf, onSectionChange, onSectionCountChange }) => { //При удалении раздела настройки const handleSectionDelete = section => showMsgWarn("Удалить раздел?", () => deleteSection(section)); - //При закрытии формы добавления/исправления по "ОК" - const handleIUFormOk = async values => { + //При закрытии диалога добавления/исправления по "ОК" + const handleIUDialogOk = async values => { if (modSection === true) await insertSection({ conf, ...values }); else await updateSection({ rn: modSection.NRN, ...values }); setModSection(null); }; - //При закрытии формы добавления/исправления по "Отмена" - const handleIUFormCancel = () => setModSection(null); + //При закрытии диалога добавления/исправления по "Отмена" + const handleIUDialogCancel = () => setModSection(null); //При изменении состава разделов useEffect(() => { @@ -155,8 +155,8 @@ const Sections = ({ conf, onSectionChange, onSectionCountChange }) => { code={modSection?.SCODE} name={modSection?.SNAME} insert={modSection === true} - onOk={handleIUFormOk} - onCancel={handleIUFormCancel} + onOk={handleIUDialogOk} + onCancel={handleIUDialogCancel} /> )} {sections.length > 0 ? ( diff --git a/db/PKG_P8PANELS_EDITOR.pck b/db/PKG_P8PANELS_PE.pck similarity index 97% rename from db/PKG_P8PANELS_EDITOR.pck rename to db/PKG_P8PANELS_PE.pck index 0a7a734..4f70e50 100644 --- a/db/PKG_P8PANELS_EDITOR.pck +++ b/db/PKG_P8PANELS_PE.pck @@ -1,4 +1,4 @@ -create or replace package PKG_P8PANELS_EDITOR as +create or replace package PKG_P8PANELS_PE as /* Список аргументов пользовательской процедуры */ procedure USERPROCS_DESC @@ -7,9 +7,9 @@ create or replace package PKG_P8PANELS_EDITOR as COUT out clob -- Сериализованный список аргументов ); -end PKG_P8PANELS_EDITOR; +end PKG_P8PANELS_PE; / -create or replace package body PKG_P8PANELS_EDITOR as +create or replace package body PKG_P8PANELS_PE as /* Описание пользовательской процедуры */ procedure USERPROCS_DESC @@ -123,5 +123,5 @@ create or replace package body PKG_P8PANELS_EDITOR as end if; end USERPROCS_DESC; -end PKG_P8PANELS_EDITOR; +end PKG_P8PANELS_PE; /