mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
B: Fix small bugs and refactor away useEffect
This commit is contained in:
parent
df06e7a7b9
commit
86f90149ee
|
@ -1,6 +1,6 @@
|
||||||
import { queryOptions } from '@tanstack/react-query';
|
import { queryOptions } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { axiosDelete, axiosGet, axiosPatch, axiosPost } from '@/backend/apiTransport';
|
import { axiosGet, axiosPatch, axiosPost } from '@/backend/apiTransport';
|
||||||
import { DELAYS } from '@/backend/configuration';
|
import { DELAYS } from '@/backend/configuration';
|
||||||
import { ILibraryItemReference, ILibraryItemVersioned, LibraryItemID, VersionID } from '@/models/library';
|
import { ILibraryItemReference, ILibraryItemVersioned, LibraryItemID, VersionID } from '@/models/library';
|
||||||
import { ICstSubstitute, ICstSubstitutions } from '@/models/oss';
|
import { ICstSubstitute, ICstSubstitutions } from '@/models/oss';
|
||||||
|
@ -182,7 +182,7 @@ export const rsformsApi = {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
cstDelete: ({ itemID, data }: { itemID: LibraryItemID; data: IConstituentaList }) =>
|
cstDelete: ({ itemID, data }: { itemID: LibraryItemID; data: IConstituentaList }) =>
|
||||||
axiosDelete<IConstituentaList, IRSFormDTO>({
|
axiosPatch<IConstituentaList, IRSFormDTO>({
|
||||||
endpoint: `/api/rsforms/${itemID}/delete-multiple-cst`,
|
endpoint: `/api/rsforms/${itemID}/delete-multiple-cst`,
|
||||||
request: {
|
request: {
|
||||||
data: data,
|
data: data,
|
||||||
|
|
|
@ -22,7 +22,7 @@ function BadgeConstituenta({ value, prefixID, className, style }: BadgeConstitue
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
id={`${prefixID}${value.id}`}
|
id={prefixID ? `${prefixID}${value.id}` : undefined}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'min-w-[3.1rem] max-w-[3.1rem]',
|
'min-w-[3.1rem] max-w-[3.1rem]',
|
||||||
'px-1',
|
'px-1',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { useEffect, useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
import BadgeConstituenta from '@/components/info/BadgeConstituenta';
|
import BadgeConstituenta from '@/components/info/BadgeConstituenta';
|
||||||
import { CProps } from '@/components/props';
|
import { CProps } from '@/components/props';
|
||||||
|
@ -12,16 +12,14 @@ import { CstMatchMode } from '@/models/miscellaneous';
|
||||||
import { IConstituenta } from '@/models/rsform';
|
import { IConstituenta } from '@/models/rsform';
|
||||||
import { matchConstituenta } from '@/models/rsformAPI';
|
import { matchConstituenta } from '@/models/rsformAPI';
|
||||||
import { APP_COLORS } from '@/styling/color';
|
import { APP_COLORS } from '@/styling/color';
|
||||||
import { prefixes } from '@/utils/constants';
|
|
||||||
import { describeConstituenta } from '@/utils/labels';
|
import { describeConstituenta } from '@/utils/labels';
|
||||||
|
|
||||||
interface PickConstituentaProps extends CProps.Styling {
|
interface PickConstituentaProps extends CProps.Styling {
|
||||||
id?: string;
|
id?: string;
|
||||||
|
items: IConstituenta[];
|
||||||
value?: IConstituenta;
|
value?: IConstituenta;
|
||||||
onChange: (newValue: IConstituenta) => void;
|
onChange: (newValue: IConstituenta) => void;
|
||||||
|
|
||||||
prefixID: string;
|
|
||||||
data?: IConstituenta[];
|
|
||||||
rows?: number;
|
rows?: number;
|
||||||
|
|
||||||
initialFilter?: string;
|
initialFilter?: string;
|
||||||
|
@ -34,11 +32,10 @@ const columnHelper = createColumnHelper<IConstituenta>();
|
||||||
|
|
||||||
function PickConstituenta({
|
function PickConstituenta({
|
||||||
id,
|
id,
|
||||||
data,
|
items,
|
||||||
value,
|
value,
|
||||||
initialFilter = '',
|
initialFilter = '',
|
||||||
rows = 4,
|
rows = 4,
|
||||||
prefixID = prefixes.cst_list,
|
|
||||||
describeFunc = describeConstituenta,
|
describeFunc = describeConstituenta,
|
||||||
matchFunc = (cst, filter) => matchConstituenta(cst, filter, CstMatchMode.ALL),
|
matchFunc = (cst, filter) => matchConstituenta(cst, filter, CstMatchMode.ALL),
|
||||||
onBeginFilter,
|
onBeginFilter,
|
||||||
|
@ -46,21 +43,10 @@ function PickConstituenta({
|
||||||
className,
|
className,
|
||||||
...restProps
|
...restProps
|
||||||
}: PickConstituentaProps) {
|
}: PickConstituentaProps) {
|
||||||
const [filteredData, setFilteredData] = useState<IConstituenta[]>([]);
|
|
||||||
const [filterText, setFilterText] = useState(initialFilter);
|
const [filterText, setFilterText] = useState(initialFilter);
|
||||||
|
|
||||||
useEffect(() => {
|
const initialData = onBeginFilter ? items.filter(onBeginFilter) : items;
|
||||||
if (!data) {
|
const filteredData = filterText === '' ? initialData : initialData.filter(cst => matchFunc(cst, filterText));
|
||||||
setFilteredData([]);
|
|
||||||
} else {
|
|
||||||
const newData = onBeginFilter ? data.filter(onBeginFilter) : data;
|
|
||||||
if (filterText) {
|
|
||||||
setFilteredData(newData.filter(cst => matchFunc(cst, filterText)));
|
|
||||||
} else {
|
|
||||||
setFilteredData(newData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [data, filterText, matchFunc, onBeginFilter]);
|
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
columnHelper.accessor('alias', {
|
columnHelper.accessor('alias', {
|
||||||
|
@ -68,7 +54,7 @@ function PickConstituenta({
|
||||||
size: 65,
|
size: 65,
|
||||||
minSize: 65,
|
minSize: 65,
|
||||||
maxSize: 65,
|
maxSize: 65,
|
||||||
cell: props => <BadgeConstituenta value={props.row.original} prefixID={prefixID} />
|
cell: props => <BadgeConstituenta value={props.row.original} />
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor(cst => describeFunc(cst), {
|
columnHelper.accessor(cst => describeFunc(cst), {
|
||||||
id: 'description',
|
id: 'description',
|
||||||
|
|
|
@ -22,9 +22,8 @@ interface PickMultiConstituentaProps extends CProps.Styling {
|
||||||
onChange: React.Dispatch<React.SetStateAction<ConstituentaID[]>>;
|
onChange: React.Dispatch<React.SetStateAction<ConstituentaID[]>>;
|
||||||
|
|
||||||
schema: IRSForm;
|
schema: IRSForm;
|
||||||
data: IConstituenta[];
|
items: IConstituenta[];
|
||||||
|
|
||||||
prefixID: string;
|
|
||||||
rows?: number;
|
rows?: number;
|
||||||
noBorder?: boolean;
|
noBorder?: boolean;
|
||||||
}
|
}
|
||||||
|
@ -34,8 +33,7 @@ const columnHelper = createColumnHelper<IConstituenta>();
|
||||||
function PickMultiConstituenta({
|
function PickMultiConstituenta({
|
||||||
id,
|
id,
|
||||||
schema,
|
schema,
|
||||||
data,
|
items,
|
||||||
prefixID,
|
|
||||||
rows,
|
rows,
|
||||||
noBorder,
|
noBorder,
|
||||||
value,
|
value,
|
||||||
|
@ -44,12 +42,13 @@ function PickMultiConstituenta({
|
||||||
...restProps
|
...restProps
|
||||||
}: PickMultiConstituentaProps) {
|
}: PickMultiConstituentaProps) {
|
||||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
||||||
const [filtered, setFiltered] = useState<IConstituenta[]>(data);
|
|
||||||
const [filterText, setFilterText] = useState('');
|
const [filterText, setFilterText] = useState('');
|
||||||
|
|
||||||
|
const [filtered, setFiltered] = useState<IConstituenta[]>(items);
|
||||||
|
|
||||||
// TODO: extract graph fold logic to separate function
|
// TODO: extract graph fold logic to separate function
|
||||||
const foldedGraph = (() => {
|
const foldedGraph = (() => {
|
||||||
if (data.length === schema.items.length) {
|
if (items.length === schema.items.length) {
|
||||||
return schema.graph;
|
return schema.graph;
|
||||||
}
|
}
|
||||||
const newGraph = new Graph();
|
const newGraph = new Graph();
|
||||||
|
@ -60,7 +59,7 @@ function PickMultiConstituenta({
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
schema.items
|
schema.items
|
||||||
.filter(item => data.find(cst => cst.id === item.id) === undefined)
|
.filter(item => items.find(cst => cst.id === item.id) === undefined)
|
||||||
.forEach(item => {
|
.forEach(item => {
|
||||||
newGraph.foldNode(item.id);
|
newGraph.foldNode(item.id);
|
||||||
});
|
});
|
||||||
|
@ -80,17 +79,17 @@ function PickMultiConstituenta({
|
||||||
}, [filtered, setRowSelection, value]);
|
}, [filtered, setRowSelection, value]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data.length === 0) {
|
if (items.length === 0) {
|
||||||
setFiltered([]);
|
setFiltered([]);
|
||||||
} else if (filterText) {
|
} else if (filterText) {
|
||||||
setFiltered(data.filter(cst => matchConstituenta(cst, filterText, CstMatchMode.ALL)));
|
setFiltered(items.filter(cst => matchConstituenta(cst, filterText, CstMatchMode.ALL)));
|
||||||
} else {
|
} else {
|
||||||
setFiltered(data);
|
setFiltered(items);
|
||||||
}
|
}
|
||||||
}, [filterText, data]);
|
}, [filterText, items]);
|
||||||
|
|
||||||
function handleRowSelection(updater: React.SetStateAction<RowSelectionState>) {
|
function handleRowSelection(updater: React.SetStateAction<RowSelectionState>) {
|
||||||
if (!data) {
|
if (!items) {
|
||||||
onChange([]);
|
onChange([]);
|
||||||
} else {
|
} else {
|
||||||
const newRowSelection = typeof updater === 'function' ? updater(rowSelection) : updater;
|
const newRowSelection = typeof updater === 'function' ? updater(rowSelection) : updater;
|
||||||
|
@ -109,7 +108,7 @@ function PickMultiConstituenta({
|
||||||
id: 'alias',
|
id: 'alias',
|
||||||
header: () => <span className='pl-3'>Имя</span>,
|
header: () => <span className='pl-3'>Имя</span>,
|
||||||
size: 65,
|
size: 65,
|
||||||
cell: props => <BadgeConstituenta value={props.row.original} prefixID={prefixID} />
|
cell: props => <BadgeConstituenta value={props.row.original} />
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor(cst => describeConstituenta(cst), {
|
columnHelper.accessor(cst => describeConstituenta(cst), {
|
||||||
id: 'description',
|
id: 'description',
|
||||||
|
@ -122,7 +121,7 @@ function PickMultiConstituenta({
|
||||||
<div className={clsx(noBorder ? '' : 'border', className)} {...restProps}>
|
<div className={clsx(noBorder ? '' : 'border', className)} {...restProps}>
|
||||||
<div className={clsx('px-3 flex justify-between items-center', 'clr-input', 'border-b', 'rounded-t-md')}>
|
<div className={clsx('px-3 flex justify-between items-center', 'clr-input', 'border-b', 'rounded-t-md')}>
|
||||||
<div className='w-[24ch] select-none whitespace-nowrap'>
|
<div className='w-[24ch] select-none whitespace-nowrap'>
|
||||||
{data.length > 0 ? `Выбраны ${value.length} из ${data.length}` : 'Конституенты'}
|
{items.length > 0 ? `Выбраны ${value.length} из ${items.length}` : 'Конституенты'}
|
||||||
</div>
|
</div>
|
||||||
<SearchBar
|
<SearchBar
|
||||||
id='dlg_constituents_search'
|
id='dlg_constituents_search'
|
||||||
|
|
|
@ -25,7 +25,6 @@ interface PickSubstitutionsProps extends CProps.Styling {
|
||||||
|
|
||||||
suggestions?: ICstSubstitute[];
|
suggestions?: ICstSubstitute[];
|
||||||
|
|
||||||
prefixID: string;
|
|
||||||
rows?: number;
|
rows?: number;
|
||||||
allowSelfSubstitution?: boolean;
|
allowSelfSubstitution?: boolean;
|
||||||
|
|
||||||
|
@ -39,7 +38,6 @@ function PickSubstitutions({
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
suggestions,
|
suggestions,
|
||||||
prefixID,
|
|
||||||
rows,
|
rows,
|
||||||
schemas,
|
schemas,
|
||||||
filter,
|
filter,
|
||||||
|
@ -162,9 +160,7 @@ function PickSubstitutions({
|
||||||
columnHelper.accessor(item => item.substitution.alias, {
|
columnHelper.accessor(item => item.substitution.alias, {
|
||||||
id: 'left_alias',
|
id: 'left_alias',
|
||||||
size: 65,
|
size: 65,
|
||||||
cell: props => (
|
cell: props => <BadgeConstituenta value={props.row.original.substitution} />
|
||||||
<BadgeConstituenta value={props.row.original.substitution} prefixID={`${prefixID}_${props.row.index}_1_`} />
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
columnHelper.display({
|
columnHelper.display({
|
||||||
id: 'status',
|
id: 'status',
|
||||||
|
@ -174,9 +170,7 @@ function PickSubstitutions({
|
||||||
columnHelper.accessor(item => item.original.alias, {
|
columnHelper.accessor(item => item.original.alias, {
|
||||||
id: 'right_alias',
|
id: 'right_alias',
|
||||||
size: 65,
|
size: 65,
|
||||||
cell: props => (
|
cell: props => <BadgeConstituenta value={props.row.original.original} />
|
||||||
<BadgeConstituenta value={props.row.original.original} prefixID={`${prefixID}_${props.row.index}_2_`} />
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor(item => item.original_source.alias, {
|
columnHelper.accessor(item => item.original_source.alias, {
|
||||||
id: 'right_schema',
|
id: 'right_schema',
|
||||||
|
|
|
@ -64,7 +64,7 @@ function Checkbox({
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'max-w-[1rem] min-w-[1rem] h-4', //
|
'max-w-[1rem] min-w-[1rem] h-4', //
|
||||||
'pt-[0.1rem] pl-[0.1rem]',
|
'pt-[0.05rem] pl-[0.05rem]',
|
||||||
'border rounded-sm',
|
'border rounded-sm',
|
||||||
'cc-animate-color',
|
'cc-animate-color',
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,7 +66,7 @@ function CheckboxTristate({
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'w-4 h-4', //
|
'w-4 h-4', //
|
||||||
'pt-[0.1rem] pl-[0.1rem]',
|
'pt-[0.05rem] pl-[0.05rem]',
|
||||||
'border rounded-sm',
|
'border rounded-sm',
|
||||||
'cc-animate-color',
|
'cc-animate-color',
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,6 @@ import NoData from '@/components/ui/NoData';
|
||||||
import { IConstituenta, IRSForm } from '@/models/rsform';
|
import { IConstituenta, IRSForm } from '@/models/rsform';
|
||||||
import { IArgumentValue } from '@/models/rslang';
|
import { IArgumentValue } from '@/models/rslang';
|
||||||
import { APP_COLORS } from '@/styling/color';
|
import { APP_COLORS } from '@/styling/color';
|
||||||
import { prefixes } from '@/utils/constants';
|
|
||||||
|
|
||||||
interface TabArgumentsProps {
|
interface TabArgumentsProps {
|
||||||
state: IArgumentsState;
|
state: IArgumentsState;
|
||||||
|
@ -189,9 +188,8 @@ function TabArguments({ state, schema, partialUpdate }: TabArgumentsProps) {
|
||||||
<PickConstituenta
|
<PickConstituenta
|
||||||
id='dlg_argument_picker'
|
id='dlg_argument_picker'
|
||||||
value={selectedCst}
|
value={selectedCst}
|
||||||
data={schema.items}
|
items={schema.items}
|
||||||
onChange={handleSelectConstituenta}
|
onChange={handleSelectConstituenta}
|
||||||
prefixID={prefixes.cst_modal_list}
|
|
||||||
rows={7}
|
rows={7}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import SelectSingle from '@/components/ui/SelectSingle';
|
||||||
import TextArea from '@/components/ui/TextArea';
|
import TextArea from '@/components/ui/TextArea';
|
||||||
import { CATEGORY_CST_TYPE, IConstituenta, IRSForm } from '@/models/rsform';
|
import { CATEGORY_CST_TYPE, IConstituenta, IRSForm } from '@/models/rsform';
|
||||||
import { applyFilterCategory } from '@/models/rsformAPI';
|
import { applyFilterCategory } from '@/models/rsformAPI';
|
||||||
import { prefixes } from '@/utils/constants';
|
|
||||||
|
|
||||||
export interface ITemplateState {
|
export interface ITemplateState {
|
||||||
templateID?: number;
|
templateID?: number;
|
||||||
|
@ -101,9 +100,8 @@ function TabTemplate({ state, partialUpdate, templateSchema }: TabTemplateProps)
|
||||||
<PickConstituenta
|
<PickConstituenta
|
||||||
id='dlg_template_picker'
|
id='dlg_template_picker'
|
||||||
value={state.prototype}
|
value={state.prototype}
|
||||||
data={filteredData}
|
items={filteredData}
|
||||||
onChange={cst => partialUpdate({ prototype: cst })}
|
onChange={cst => partialUpdate({ prototype: cst })}
|
||||||
prefixID={prefixes.cst_template_ist}
|
|
||||||
className='rounded-t-none'
|
className='rounded-t-none'
|
||||||
rows={8}
|
rows={8}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -3,7 +3,6 @@ import TextArea from '@/components/ui/TextArea';
|
||||||
import { ICstSubstitute } from '@/models/oss';
|
import { ICstSubstitute } from '@/models/oss';
|
||||||
import { IRSForm } from '@/models/rsform';
|
import { IRSForm } from '@/models/rsform';
|
||||||
import { APP_COLORS } from '@/styling/color';
|
import { APP_COLORS } from '@/styling/color';
|
||||||
import { prefixes } from '@/utils/constants';
|
|
||||||
|
|
||||||
interface TabSynthesisProps {
|
interface TabSynthesisProps {
|
||||||
validationText: string;
|
validationText: string;
|
||||||
|
@ -27,7 +26,6 @@ function TabSynthesis({
|
||||||
<div className='cc-fade-in cc-column mt-3'>
|
<div className='cc-fade-in cc-column mt-3'>
|
||||||
<PickSubstitutions
|
<PickSubstitutions
|
||||||
schemas={schemas}
|
schemas={schemas}
|
||||||
prefixID={prefixes.dlg_cst_substitutes_list}
|
|
||||||
rows={8}
|
rows={8}
|
||||||
value={substitutions}
|
value={substitutions}
|
||||||
onChange={setSubstitutions}
|
onChange={setSubstitutions}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import { parseEntityReference, parseGrammemes } from '@/models/languageAPI';
|
||||||
import { CstMatchMode } from '@/models/miscellaneous';
|
import { CstMatchMode } from '@/models/miscellaneous';
|
||||||
import { IConstituenta, IRSForm } from '@/models/rsform';
|
import { IConstituenta, IRSForm } from '@/models/rsform';
|
||||||
import { matchConstituenta } from '@/models/rsformAPI';
|
import { matchConstituenta } from '@/models/rsformAPI';
|
||||||
import { prefixes } from '@/utils/constants';
|
|
||||||
import { IGrammemeOption, SelectorGrammemes } from '@/utils/selectors';
|
import { IGrammemeOption, SelectorGrammemes } from '@/utils/selectors';
|
||||||
|
|
||||||
import { IReferenceInputState } from './DlgEditReference';
|
import { IReferenceInputState } from './DlgEditReference';
|
||||||
|
@ -63,9 +62,8 @@ function TabEntityReference({ initial, schema, onChangeValid, onChangeReference
|
||||||
id='dlg_reference_entity_picker'
|
id='dlg_reference_entity_picker'
|
||||||
initialFilter={initial.text}
|
initialFilter={initial.text}
|
||||||
value={selectedCst}
|
value={selectedCst}
|
||||||
data={schema.items}
|
items={schema.items}
|
||||||
onChange={handleSelectConstituenta}
|
onChange={handleSelectConstituenta}
|
||||||
prefixID={prefixes.cst_modal_list}
|
|
||||||
describeFunc={cst => cst.term_resolved}
|
describeFunc={cst => cst.term_resolved}
|
||||||
matchFunc={(cst, filter) => matchConstituenta(cst, filter, CstMatchMode.TERM)}
|
matchFunc={(cst, filter) => matchConstituenta(cst, filter, CstMatchMode.TERM)}
|
||||||
onBeginFilter={cst => cst.term_resolved !== ''}
|
onBeginFilter={cst => cst.term_resolved !== ''}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import { useRSFormSuspense } from '@/backend/rsform/useRSForm';
|
||||||
import PickMultiConstituenta from '@/components/select/PickMultiConstituenta';
|
import PickMultiConstituenta from '@/components/select/PickMultiConstituenta';
|
||||||
import { LibraryItemID } from '@/models/library';
|
import { LibraryItemID } from '@/models/library';
|
||||||
import { ConstituentaID } from '@/models/rsform';
|
import { ConstituentaID } from '@/models/rsform';
|
||||||
import { prefixes } from '@/utils/constants';
|
|
||||||
|
|
||||||
interface TabConstituentsProps {
|
interface TabConstituentsProps {
|
||||||
itemID: LibraryItemID;
|
itemID: LibraryItemID;
|
||||||
|
@ -16,14 +15,7 @@ function TabConstituents({ itemID, selected, setSelected }: TabConstituentsProps
|
||||||
const { schema } = useRSFormSuspense({ itemID });
|
const { schema } = useRSFormSuspense({ itemID });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PickMultiConstituenta
|
<PickMultiConstituenta schema={schema} items={schema.items} rows={13} value={selected} onChange={setSelected} />
|
||||||
schema={schema}
|
|
||||||
data={schema.items}
|
|
||||||
rows={13}
|
|
||||||
prefixID={prefixes.cst_inline_synth_list}
|
|
||||||
value={selected}
|
|
||||||
onChange={setSelected}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import PickSubstitutions from '@/components/select/PickSubstitutions';
|
||||||
import { LibraryItemID } from '@/models/library';
|
import { LibraryItemID } from '@/models/library';
|
||||||
import { ICstSubstitute } from '@/models/oss';
|
import { ICstSubstitute } from '@/models/oss';
|
||||||
import { ConstituentaID, IRSForm } from '@/models/rsform';
|
import { ConstituentaID, IRSForm } from '@/models/rsform';
|
||||||
import { prefixes } from '@/utils/constants';
|
|
||||||
|
|
||||||
interface TabSubstitutionsProps {
|
interface TabSubstitutionsProps {
|
||||||
receiver: IRSForm;
|
receiver: IRSForm;
|
||||||
|
@ -25,7 +24,6 @@ function TabSubstitutions({ sourceID, receiver, selected, substitutions, setSubs
|
||||||
value={substitutions}
|
value={substitutions}
|
||||||
onChange={setSubstitutions}
|
onChange={setSubstitutions}
|
||||||
rows={10}
|
rows={10}
|
||||||
prefixID={prefixes.cst_inline_synth_substitutes}
|
|
||||||
schemas={schemas}
|
schemas={schemas}
|
||||||
filter={cst => cst.id !== source?.id || selected.includes(cst.id)}
|
filter={cst => cst.id !== source?.id || selected.includes(cst.id)}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -18,7 +18,6 @@ import { IOperation, IOperationSchema } from '@/models/oss';
|
||||||
import { getRelocateCandidates } from '@/models/ossAPI';
|
import { getRelocateCandidates } from '@/models/ossAPI';
|
||||||
import { ConstituentaID } from '@/models/rsform';
|
import { ConstituentaID } from '@/models/rsform';
|
||||||
import { useDialogsStore } from '@/stores/dialogs';
|
import { useDialogsStore } from '@/stores/dialogs';
|
||||||
import { prefixes } from '@/utils/constants';
|
|
||||||
|
|
||||||
export interface DlgRelocateConstituentsProps {
|
export interface DlgRelocateConstituentsProps {
|
||||||
oss: IOperationSchema;
|
oss: IOperationSchema;
|
||||||
|
@ -124,9 +123,8 @@ function DlgRelocateConstituents() {
|
||||||
<PickMultiConstituenta
|
<PickMultiConstituenta
|
||||||
noBorder
|
noBorder
|
||||||
schema={sourceData.schema}
|
schema={sourceData.schema}
|
||||||
data={filteredConstituents}
|
items={filteredConstituents}
|
||||||
rows={12}
|
rows={12}
|
||||||
prefixID={prefixes.dlg_cst_constituents_list}
|
|
||||||
value={selected}
|
value={selected}
|
||||||
onChange={setSelected}
|
onChange={setSelected}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -9,7 +9,6 @@ import { HelpTopic } from '@/models/miscellaneous';
|
||||||
import { ICstSubstitute, ICstSubstitutions } from '@/models/oss';
|
import { ICstSubstitute, ICstSubstitutions } from '@/models/oss';
|
||||||
import { IRSForm } from '@/models/rsform';
|
import { IRSForm } from '@/models/rsform';
|
||||||
import { useDialogsStore } from '@/stores/dialogs';
|
import { useDialogsStore } from '@/stores/dialogs';
|
||||||
import { prefixes } from '@/utils/constants';
|
|
||||||
|
|
||||||
export interface DlgSubstituteCstProps {
|
export interface DlgSubstituteCstProps {
|
||||||
schema: IRSForm;
|
schema: IRSForm;
|
||||||
|
@ -43,7 +42,6 @@ function DlgSubstituteCst() {
|
||||||
value={substitutions}
|
value={substitutions}
|
||||||
onChange={setSubstitutions}
|
onChange={setSubstitutions}
|
||||||
rows={6}
|
rows={6}
|
||||||
prefixID={prefixes.dlg_cst_substitutes_list}
|
|
||||||
schemas={[schema]}
|
schemas={[schema]}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
|
@ -14,7 +14,7 @@ import Indicator from '@/components/ui/Indicator';
|
||||||
import Overlay from '@/components/ui/Overlay';
|
import Overlay from '@/components/ui/Overlay';
|
||||||
import SubmitButton from '@/components/ui/SubmitButton';
|
import SubmitButton from '@/components/ui/SubmitButton';
|
||||||
import TextArea from '@/components/ui/TextArea';
|
import TextArea from '@/components/ui/TextArea';
|
||||||
import { ConstituentaID, CstType } from '@/models/rsform';
|
import { CstType } from '@/models/rsform';
|
||||||
import { isBaseSet, isBasicConcept, isFunctional } from '@/models/rsformAPI';
|
import { isBaseSet, isBasicConcept, isFunctional } from '@/models/rsformAPI';
|
||||||
import { IExpressionParse, ParsingStatus } from '@/models/rslang';
|
import { IExpressionParse, ParsingStatus } from '@/models/rslang';
|
||||||
import { useDialogsStore } from '@/stores/dialogs';
|
import { useDialogsStore } from '@/stores/dialogs';
|
||||||
|
@ -31,7 +31,6 @@ interface FormConstituentaProps {
|
||||||
toggleReset: boolean;
|
toggleReset: boolean;
|
||||||
|
|
||||||
onEditTerm: () => void;
|
onEditTerm: () => void;
|
||||||
onOpenEdit?: (cstID: ConstituentaID) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function FormConstituenta({
|
function FormConstituenta({
|
||||||
|
@ -39,11 +38,10 @@ function FormConstituenta({
|
||||||
id,
|
id,
|
||||||
|
|
||||||
toggleReset,
|
toggleReset,
|
||||||
onEditTerm,
|
onEditTerm
|
||||||
onOpenEdit
|
|
||||||
}: FormConstituentaProps) {
|
}: FormConstituentaProps) {
|
||||||
const { cstUpdate } = useCstUpdate();
|
const { cstUpdate } = useCstUpdate();
|
||||||
const { schema, activeCst } = useRSEdit();
|
const { schema, activeCst, navigateCst } = useRSEdit();
|
||||||
const { isModified, setIsModified } = useModificationStore();
|
const { isModified, setIsModified } = useModificationStore();
|
||||||
const isProcessing = useMutatingRSForm();
|
const isProcessing = useMutatingRSForm();
|
||||||
|
|
||||||
|
@ -146,7 +144,7 @@ function FormConstituenta({
|
||||||
maxHeight='8rem'
|
maxHeight='8rem'
|
||||||
placeholder='Обозначение для текстовых определений'
|
placeholder='Обозначение для текстовых определений'
|
||||||
schema={schema}
|
schema={schema}
|
||||||
onOpenEdit={onOpenEdit}
|
onOpenEdit={navigateCst}
|
||||||
value={term}
|
value={term}
|
||||||
initialValue={activeCst?.term_raw ?? ''}
|
initialValue={activeCst?.term_raw ?? ''}
|
||||||
resolved={activeCst?.term_resolved ?? 'Конституента не выбрана'}
|
resolved={activeCst?.term_resolved ?? 'Конституента не выбрана'}
|
||||||
|
@ -191,7 +189,7 @@ function FormConstituenta({
|
||||||
onChangeExpression={newValue => setExpression(newValue)}
|
onChangeExpression={newValue => setExpression(newValue)}
|
||||||
onChangeTypification={setTypification}
|
onChangeTypification={setTypification}
|
||||||
onChangeLocalParse={setLocalParse}
|
onChangeLocalParse={setLocalParse}
|
||||||
onOpenEdit={onOpenEdit}
|
onOpenEdit={navigateCst}
|
||||||
onShowTypeGraph={handleTypeGraph}
|
onShowTypeGraph={handleTypeGraph}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
@ -203,7 +201,7 @@ function FormConstituenta({
|
||||||
minHeight='3.75rem'
|
minHeight='3.75rem'
|
||||||
maxHeight='8rem'
|
maxHeight='8rem'
|
||||||
schema={schema}
|
schema={schema}
|
||||||
onOpenEdit={onOpenEdit}
|
onOpenEdit={navigateCst}
|
||||||
value={textDefinition}
|
value={textDefinition}
|
||||||
initialValue={activeCst.definition_raw}
|
initialValue={activeCst.definition_raw}
|
||||||
resolved={activeCst.definition_resolved}
|
resolved={activeCst.definition_resolved}
|
||||||
|
|
|
@ -193,7 +193,7 @@ export const RSEditState = ({
|
||||||
navigateRSForm({ tab: activeTab, activeID: newCst.id });
|
navigateRSForm({ tab: activeTab, activeID: newCst.id });
|
||||||
if (activeTab === RSTabID.CST_LIST) {
|
if (activeTab === RSTabID.CST_LIST) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const element = document.getElementById(`${prefixes.cst_list}${newCst.alias}`);
|
const element = document.getElementById(`${prefixes.cst_list}${newCst.id}`);
|
||||||
if (element) {
|
if (element) {
|
||||||
element.scrollIntoView({
|
element.scrollIntoView({
|
||||||
behavior: 'smooth',
|
behavior: 'smooth',
|
||||||
|
|
|
@ -36,7 +36,7 @@ function TableSideConstituents({
|
||||||
}
|
}
|
||||||
if (autoScroll) {
|
if (autoScroll) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const element = document.getElementById(`${prefixes.cst_side_table}${activeCst.alias}`);
|
const element = document.getElementById(`${prefixes.cst_side_table}${activeCst.id}`);
|
||||||
if (element) {
|
if (element) {
|
||||||
element.scrollIntoView({
|
element.scrollIntoView({
|
||||||
behavior: 'smooth',
|
behavior: 'smooth',
|
||||||
|
|
|
@ -125,15 +125,9 @@ export const prefixes = {
|
||||||
page_size: 'page_size_',
|
page_size: 'page_size_',
|
||||||
oss_list: 'oss_list_',
|
oss_list: 'oss_list_',
|
||||||
cst_list: 'cst_list_',
|
cst_list: 'cst_list_',
|
||||||
cst_inline_synth_list: 'cst_inline_synth_list_',
|
|
||||||
cst_inline_synth_substitutes: 'cst_inline_synth_substitutes_',
|
|
||||||
cst_side_table: 'cst_side_table_',
|
cst_side_table: 'cst_side_table_',
|
||||||
cst_hidden_list: 'cst_hidden_list_',
|
cst_hidden_list: 'cst_hidden_list_',
|
||||||
cst_modal_list: 'cst_modal_list_',
|
|
||||||
cst_template_ist: 'cst_template_list_',
|
|
||||||
cst_wordform_list: 'cst_wordform_list_',
|
|
||||||
cst_status_list: 'cst_status_list_',
|
cst_status_list: 'cst_status_list_',
|
||||||
cst_match_mode_list: 'cst_match_mode_list_',
|
|
||||||
cst_source_list: 'cst_source_list_',
|
cst_source_list: 'cst_source_list_',
|
||||||
cst_delete_list: 'cst_delete_list_',
|
cst_delete_list: 'cst_delete_list_',
|
||||||
cst_dependant_list: 'cst_dependant_list_',
|
cst_dependant_list: 'cst_dependant_list_',
|
||||||
|
@ -150,7 +144,5 @@ export const prefixes = {
|
||||||
user_subs: 'user_subs_',
|
user_subs: 'user_subs_',
|
||||||
user_editors: 'user_editors_',
|
user_editors: 'user_editors_',
|
||||||
wordform_list: 'wordform_list_',
|
wordform_list: 'wordform_list_',
|
||||||
rsedit_btn: 'rsedit_btn_',
|
rsedit_btn: 'rsedit_btn_'
|
||||||
dlg_cst_substitutes_list: 'dlg_cst_substitutes_list_',
|
|
||||||
dlg_cst_constituents_list: 'dlg_cst_constituents_list_'
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user