Compare commits
No commits in common. "25029a212bb63e1cc656cd08b1a69a43655656aa" and "d8286e63391a4cf3e70f041c326f8f10b6ae5e19" have entirely different histories.
25029a212b
...
d8286e6339
|
@ -83,6 +83,7 @@ export { LuNewspaper as IconDefinition } from 'react-icons/lu';
|
||||||
export { LuDna as IconTerminology } from 'react-icons/lu';
|
export { LuDna as IconTerminology } from 'react-icons/lu';
|
||||||
export { FaRegHandshake as IconConvention } from 'react-icons/fa6';
|
export { FaRegHandshake as IconConvention } from 'react-icons/fa6';
|
||||||
export { LiaCloneSolid as IconChild } from 'react-icons/lia';
|
export { LiaCloneSolid as IconChild } from 'react-icons/lia';
|
||||||
|
export { RiParentLine as IconParent } from 'react-icons/ri';
|
||||||
export { TbTopologyRing as IconConsolidation } from 'react-icons/tb';
|
export { TbTopologyRing as IconConsolidation } from 'react-icons/tb';
|
||||||
export { BiSpa as IconPredecessor } from 'react-icons/bi';
|
export { BiSpa as IconPredecessor } from 'react-icons/bi';
|
||||||
export { LuArchive as IconArchive } from 'react-icons/lu';
|
export { LuArchive as IconArchive } from 'react-icons/lu';
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { toast } from 'react-toastify';
|
||||||
|
|
||||||
import BadgeConstituenta from '@/components/info/BadgeConstituenta';
|
import BadgeConstituenta from '@/components/info/BadgeConstituenta';
|
||||||
import SelectConstituenta from '@/components/select/SelectConstituenta';
|
import SelectConstituenta from '@/components/select/SelectConstituenta';
|
||||||
import DataTable, { createColumnHelper, IConditionalStyle } from '@/components/ui/DataTable';
|
import DataTable, { createColumnHelper } from '@/components/ui/DataTable';
|
||||||
import MiniButton from '@/components/ui/MiniButton';
|
import MiniButton from '@/components/ui/MiniButton';
|
||||||
import { useConceptOptions } from '@/context/ConceptOptionsContext';
|
import { useConceptOptions } from '@/context/ConceptOptionsContext';
|
||||||
import { ILibraryItem } from '@/models/library';
|
import { ILibraryItem } from '@/models/library';
|
||||||
|
@ -13,14 +13,13 @@ import { ICstSubstitute, IMultiSubstitution } from '@/models/oss';
|
||||||
import { ConstituentaID, IConstituenta, IRSForm } from '@/models/rsform';
|
import { ConstituentaID, IConstituenta, IRSForm } from '@/models/rsform';
|
||||||
import { errors } from '@/utils/labels';
|
import { errors } from '@/utils/labels';
|
||||||
|
|
||||||
import { IconAccept, IconPageLeft, IconPageRight, IconRemove, IconReplace } from '../Icons';
|
import { IconPageLeft, IconPageRight, IconRemove, IconReplace } from '../Icons';
|
||||||
import NoData from '../ui/NoData';
|
import NoData from '../ui/NoData';
|
||||||
import SelectLibraryItem from './SelectLibraryItem';
|
import SelectLibraryItem from './SelectLibraryItem';
|
||||||
|
|
||||||
interface PickSubstitutionsProps {
|
interface PickSubstitutionsProps {
|
||||||
substitutions: ICstSubstitute[];
|
substitutions: ICstSubstitute[];
|
||||||
setSubstitutions: React.Dispatch<React.SetStateAction<ICstSubstitute[]>>;
|
setSubstitutions: React.Dispatch<React.SetStateAction<ICstSubstitute[]>>;
|
||||||
suggestions?: ICstSubstitute[];
|
|
||||||
|
|
||||||
prefixID: string;
|
prefixID: string;
|
||||||
rows?: number;
|
rows?: number;
|
||||||
|
@ -35,7 +34,6 @@ const columnHelper = createColumnHelper<IMultiSubstitution>();
|
||||||
function PickSubstitutions({
|
function PickSubstitutions({
|
||||||
substitutions,
|
substitutions,
|
||||||
setSubstitutions,
|
setSubstitutions,
|
||||||
suggestions,
|
|
||||||
prefixID,
|
prefixID,
|
||||||
rows,
|
rows,
|
||||||
schemas,
|
schemas,
|
||||||
|
@ -57,15 +55,6 @@ function PickSubstitutions({
|
||||||
const [deleteRight, setDeleteRight] = useState(true);
|
const [deleteRight, setDeleteRight] = useState(true);
|
||||||
const toggleDelete = () => setDeleteRight(prev => !prev);
|
const toggleDelete = () => setDeleteRight(prev => !prev);
|
||||||
|
|
||||||
const [ignores, setIgnores] = useState<ICstSubstitute[]>([]);
|
|
||||||
const filteredSuggestions = useMemo(
|
|
||||||
() =>
|
|
||||||
suggestions?.filter(
|
|
||||||
item => !ignores.find(ignore => ignore.original === item.original && ignore.substitution === item.substitution)
|
|
||||||
) ?? [],
|
|
||||||
[ignores, suggestions]
|
|
||||||
);
|
|
||||||
|
|
||||||
const getSchemaByCst = useCallback(
|
const getSchemaByCst = useCallback(
|
||||||
(id: ConstituentaID): IRSForm | undefined => {
|
(id: ConstituentaID): IRSForm | undefined => {
|
||||||
for (const schema of schemas) {
|
for (const schema of schemas) {
|
||||||
|
@ -93,23 +82,14 @@ function PickSubstitutions({
|
||||||
);
|
);
|
||||||
|
|
||||||
const substitutionData: IMultiSubstitution[] = useMemo(
|
const substitutionData: IMultiSubstitution[] = useMemo(
|
||||||
() => [
|
() =>
|
||||||
...substitutions.map(item => ({
|
substitutions.map(item => ({
|
||||||
original_source: getSchemaByCst(item.original)!,
|
original_source: getSchemaByCst(item.original)!,
|
||||||
original: getConstituenta(item.original)!,
|
original: getConstituenta(item.original)!,
|
||||||
substitution: getConstituenta(item.substitution)!,
|
substitution: getConstituenta(item.substitution)!,
|
||||||
substitution_source: getSchemaByCst(item.substitution)!,
|
substitution_source: getSchemaByCst(item.substitution)!
|
||||||
is_suggestion: false
|
|
||||||
})),
|
})),
|
||||||
...filteredSuggestions.map(item => ({
|
[getConstituenta, getSchemaByCst, substitutions]
|
||||||
original_source: getSchemaByCst(item.original)!,
|
|
||||||
original: getConstituenta(item.original)!,
|
|
||||||
substitution: getConstituenta(item.substitution)!,
|
|
||||||
substitution_source: getSchemaByCst(item.substitution)!,
|
|
||||||
is_suggestion: true
|
|
||||||
}))
|
|
||||||
],
|
|
||||||
[getConstituenta, getSchemaByCst, substitutions, filteredSuggestions]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
function addSubstitution() {
|
function addSubstitution() {
|
||||||
|
@ -141,34 +121,19 @@ function PickSubstitutions({
|
||||||
setRightCst(undefined);
|
setRightCst(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDeclineSuggestion = useCallback(
|
const handleDeleteRow = useCallback(
|
||||||
(item: IMultiSubstitution) => {
|
(row: number) => {
|
||||||
setIgnores(prev => [...prev, { original: item.original.id, substitution: item.substitution.id }]);
|
|
||||||
},
|
|
||||||
[setIgnores]
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleAcceptSuggestion = useCallback(
|
|
||||||
(item: IMultiSubstitution) => {
|
|
||||||
setSubstitutions(prev => [...prev, { original: item.original.id, substitution: item.substitution.id }]);
|
|
||||||
},
|
|
||||||
[setSubstitutions]
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleDeleteSubstitution = useCallback(
|
|
||||||
(target: IMultiSubstitution) => {
|
|
||||||
handleDeclineSuggestion(target);
|
|
||||||
setSubstitutions(prev => {
|
setSubstitutions(prev => {
|
||||||
const newItems: ICstSubstitute[] = [];
|
const newItems: ICstSubstitute[] = [];
|
||||||
prev.forEach(item => {
|
prev.forEach((item, index) => {
|
||||||
if (item.original !== target.original.id || item.substitution !== target.substitution.id) {
|
if (index !== row) {
|
||||||
newItems.push(item);
|
newItems.push(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return newItems;
|
return newItems;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[setSubstitutions, handleDeclineSuggestion]
|
[setSubstitutions]
|
||||||
);
|
);
|
||||||
|
|
||||||
const columns = useMemo(
|
const columns = useMemo(
|
||||||
|
@ -204,47 +169,19 @@ function PickSubstitutions({
|
||||||
}),
|
}),
|
||||||
columnHelper.display({
|
columnHelper.display({
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
cell: props =>
|
cell: props => (
|
||||||
props.row.original.is_suggestion ? (
|
|
||||||
<div className='max-w-fit'>
|
|
||||||
<MiniButton
|
|
||||||
noHover
|
|
||||||
title='Принять предложение'
|
|
||||||
icon={<IconAccept size='1rem' className='icon-green' />}
|
|
||||||
onClick={() => handleAcceptSuggestion(props.row.original)}
|
|
||||||
/>
|
|
||||||
<MiniButton
|
|
||||||
noHover
|
|
||||||
title='Игнорировать предложение'
|
|
||||||
icon={<IconRemove size='1rem' className='icon-red' />}
|
|
||||||
onClick={() => handleDeclineSuggestion(props.row.original)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className='max-w-fit'>
|
<div className='max-w-fit'>
|
||||||
<MiniButton
|
<MiniButton
|
||||||
noHover
|
noHover
|
||||||
title='Удалить'
|
title='Удалить'
|
||||||
icon={<IconRemove size='1rem' className='icon-red' />}
|
icon={<IconRemove size='1rem' className='icon-red' />}
|
||||||
onClick={() => handleDeleteSubstitution(props.row.original)}
|
onClick={() => handleDeleteRow(props.row.index)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
[handleDeleteSubstitution, handleDeclineSuggestion, handleAcceptSuggestion, colors, prefixID]
|
[handleDeleteRow, colors, prefixID]
|
||||||
);
|
|
||||||
|
|
||||||
const conditionalRowStyles = useMemo(
|
|
||||||
(): IConditionalStyle<IMultiSubstitution>[] => [
|
|
||||||
{
|
|
||||||
when: (item: IMultiSubstitution) => item.is_suggestion,
|
|
||||||
style: {
|
|
||||||
backgroundColor: colors.bgOrange50
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[colors]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -328,7 +265,6 @@ function PickSubstitutions({
|
||||||
<p>Добавьте отождествление</p>
|
<p>Добавьте отождествление</p>
|
||||||
</NoData>
|
</NoData>
|
||||||
}
|
}
|
||||||
conditionalRowStyles={conditionalRowStyles}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,7 +6,6 @@ import Label from './Label';
|
||||||
export interface TextAreaProps extends CProps.Editor, CProps.Colors, CProps.TextArea {
|
export interface TextAreaProps extends CProps.Editor, CProps.Colors, CProps.TextArea {
|
||||||
dense?: boolean;
|
dense?: boolean;
|
||||||
noResize?: boolean;
|
noResize?: boolean;
|
||||||
fitContent?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function TextArea({
|
function TextArea({
|
||||||
|
@ -19,7 +18,6 @@ function TextArea({
|
||||||
noOutline,
|
noOutline,
|
||||||
noResize,
|
noResize,
|
||||||
className,
|
className,
|
||||||
fitContent,
|
|
||||||
colors = 'clr-input',
|
colors = 'clr-input',
|
||||||
...restProps
|
...restProps
|
||||||
}: TextAreaProps) {
|
}: TextAreaProps) {
|
||||||
|
@ -42,7 +40,6 @@ function TextArea({
|
||||||
'leading-tight',
|
'leading-tight',
|
||||||
'overflow-x-hidden overflow-y-auto',
|
'overflow-x-hidden overflow-y-auto',
|
||||||
{
|
{
|
||||||
'cc-fit-content': fitContent,
|
|
||||||
'resize-none': noResize,
|
'resize-none': noResize,
|
||||||
'border': !noBorder,
|
'border': !noBorder,
|
||||||
'flex-grow max-w-full': dense,
|
'flex-grow max-w-full': dense,
|
||||||
|
|
|
@ -134,13 +134,12 @@ export const OssState = ({ itemID, children }: OssStateProps) => {
|
||||||
onError: setProcessingError,
|
onError: setProcessingError,
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
model.owner = newOwner;
|
model.owner = newOwner;
|
||||||
library.reloadItems(() => {
|
library.localUpdateItem(model);
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[itemID, model, library.reloadItems]
|
[itemID, model, library.localUpdateItem]
|
||||||
);
|
);
|
||||||
|
|
||||||
const setAccessPolicy = useCallback(
|
const setAccessPolicy = useCallback(
|
||||||
|
@ -158,13 +157,12 @@ export const OssState = ({ itemID, children }: OssStateProps) => {
|
||||||
onError: setProcessingError,
|
onError: setProcessingError,
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
model.access_policy = newPolicy;
|
model.access_policy = newPolicy;
|
||||||
library.reloadItems(() => {
|
library.localUpdateItem(model);
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[itemID, model, library.reloadItems]
|
[itemID, model, library.localUpdateItem]
|
||||||
);
|
);
|
||||||
|
|
||||||
const setLocation = useCallback(
|
const setLocation = useCallback(
|
||||||
|
@ -182,13 +180,12 @@ export const OssState = ({ itemID, children }: OssStateProps) => {
|
||||||
onError: setProcessingError,
|
onError: setProcessingError,
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
model.location = newLocation;
|
model.location = newLocation;
|
||||||
library.reloadItems(() => {
|
library.localUpdateItem(model);
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[itemID, model, library.reloadItems]
|
[itemID, model, library.localUpdateItem]
|
||||||
);
|
);
|
||||||
|
|
||||||
const setEditors = useCallback(
|
const setEditors = useCallback(
|
||||||
|
@ -206,13 +203,11 @@ export const OssState = ({ itemID, children }: OssStateProps) => {
|
||||||
onError: setProcessingError,
|
onError: setProcessingError,
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
model.editors = newEditors;
|
model.editors = newEditors;
|
||||||
library.reloadItems(() => {
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[itemID, model, library.reloadItems]
|
[itemID, model]
|
||||||
);
|
);
|
||||||
|
|
||||||
const savePositions = useCallback(
|
const savePositions = useCallback(
|
||||||
|
|
|
@ -59,7 +59,14 @@ function DlgChangeLocation({ hideWindow, initial, onChangeLocation }: DlgChangeL
|
||||||
onChange={handleSelectLocation}
|
onChange={handleSelectLocation}
|
||||||
className='max-h-[9.2rem]'
|
className='max-h-[9.2rem]'
|
||||||
/>
|
/>
|
||||||
<TextArea id='dlg_cst_body' label='Путь' rows={3} value={body} onChange={event => setBody(event.target.value)} />
|
<TextArea
|
||||||
|
id='dlg_cst_body'
|
||||||
|
label='Путь'
|
||||||
|
className='w-[23rem]'
|
||||||
|
rows={3}
|
||||||
|
value={body}
|
||||||
|
onChange={event => setBody(event.target.value)}
|
||||||
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,7 @@ function DlgCloneLibraryItem({ hideWindow, base, initialLocation, selected, tota
|
||||||
<TextArea
|
<TextArea
|
||||||
id='dlg_cst_body'
|
id='dlg_cst_body'
|
||||||
label='Путь'
|
label='Путь'
|
||||||
|
className='w-[18rem]'
|
||||||
rows={3}
|
rows={3}
|
||||||
value={body}
|
value={body}
|
||||||
onChange={event => setBody(event.target.value)}
|
onChange={event => setBody(event.target.value)}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import Modal, { ModalProps } from '@/components/ui/Modal';
|
||||||
import Overlay from '@/components/ui/Overlay';
|
import Overlay from '@/components/ui/Overlay';
|
||||||
import TabLabel from '@/components/ui/TabLabel';
|
import TabLabel from '@/components/ui/TabLabel';
|
||||||
import AnimateFade from '@/components/wrap/AnimateFade';
|
import AnimateFade from '@/components/wrap/AnimateFade';
|
||||||
import { useLibrary } from '@/context/LibraryContext';
|
|
||||||
import usePartialUpdate from '@/hooks/usePartialUpdate';
|
import usePartialUpdate from '@/hooks/usePartialUpdate';
|
||||||
import { HelpTopic } from '@/models/miscellaneous';
|
import { HelpTopic } from '@/models/miscellaneous';
|
||||||
import { CstType, ICstCreateData, IRSForm } from '@/models/rsform';
|
import { CstType, ICstCreateData, IRSForm } from '@/models/rsform';
|
||||||
|
@ -34,10 +33,8 @@ export enum TabID {
|
||||||
}
|
}
|
||||||
|
|
||||||
function DlgConstituentaTemplate({ hideWindow, schema, onCreate, insertAfter }: DlgConstituentaTemplateProps) {
|
function DlgConstituentaTemplate({ hideWindow, schema, onCreate, insertAfter }: DlgConstituentaTemplateProps) {
|
||||||
const { retrieveTemplate } = useLibrary();
|
|
||||||
const [activeTab, setActiveTab] = useState(TabID.TEMPLATE);
|
const [activeTab, setActiveTab] = useState(TabID.TEMPLATE);
|
||||||
|
|
||||||
const [templateSchema, setTemplateSchema] = useState<IRSForm | undefined>(undefined);
|
|
||||||
const [template, updateTemplate] = usePartialUpdate<ITemplateState>({});
|
const [template, updateTemplate] = usePartialUpdate<ITemplateState>({});
|
||||||
const [substitutes, updateSubstitutes] = usePartialUpdate<IArgumentsState>({
|
const [substitutes, updateSubstitutes] = usePartialUpdate<IArgumentsState>({
|
||||||
definition: '',
|
definition: '',
|
||||||
|
@ -46,7 +43,7 @@ function DlgConstituentaTemplate({ hideWindow, schema, onCreate, insertAfter }:
|
||||||
const [constituenta, updateConstituenta] = usePartialUpdate<ICstCreateData>({
|
const [constituenta, updateConstituenta] = usePartialUpdate<ICstCreateData>({
|
||||||
cst_type: CstType.TERM,
|
cst_type: CstType.TERM,
|
||||||
insert_after: insertAfter ?? null,
|
insert_after: insertAfter ?? null,
|
||||||
alias: generateAlias(CstType.TERM, schema),
|
alias: '',
|
||||||
convention: '',
|
convention: '',
|
||||||
definition_formal: '',
|
definition_formal: '',
|
||||||
definition_raw: '',
|
definition_raw: '',
|
||||||
|
@ -58,12 +55,8 @@ function DlgConstituentaTemplate({ hideWindow, schema, onCreate, insertAfter }:
|
||||||
const handleSubmit = () => onCreate(constituenta);
|
const handleSubmit = () => onCreate(constituenta);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!template.templateID) {
|
updateConstituenta({ alias: generateAlias(constituenta.cst_type, schema) });
|
||||||
setTemplateSchema(undefined);
|
}, [constituenta.cst_type, updateConstituenta, schema]);
|
||||||
} else {
|
|
||||||
retrieveTemplate(template.templateID, setTemplateSchema);
|
|
||||||
}
|
|
||||||
}, [template.templateID, retrieveTemplate]);
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!template.prototype) {
|
if (!template.prototype) {
|
||||||
|
@ -79,7 +72,6 @@ function DlgConstituentaTemplate({ hideWindow, schema, onCreate, insertAfter }:
|
||||||
} else {
|
} else {
|
||||||
updateConstituenta({
|
updateConstituenta({
|
||||||
cst_type: template.prototype.cst_type,
|
cst_type: template.prototype.cst_type,
|
||||||
alias: generateAlias(template.prototype.cst_type, schema),
|
|
||||||
definition_raw: template.prototype.definition_raw,
|
definition_raw: template.prototype.definition_raw,
|
||||||
definition_formal: template.prototype.definition_formal,
|
definition_formal: template.prototype.definition_formal,
|
||||||
term_raw: template.prototype.term_raw
|
term_raw: template.prototype.term_raw
|
||||||
|
@ -93,7 +85,7 @@ function DlgConstituentaTemplate({ hideWindow, schema, onCreate, insertAfter }:
|
||||||
}))
|
}))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [template.prototype, updateConstituenta, updateSubstitutes, schema]);
|
}, [template.prototype, updateConstituenta, updateSubstitutes]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (substitutes.arguments.length === 0 || !template.prototype) {
|
if (substitutes.arguments.length === 0 || !template.prototype) {
|
||||||
|
@ -103,13 +95,12 @@ function DlgConstituentaTemplate({ hideWindow, schema, onCreate, insertAfter }:
|
||||||
const type = inferTemplatedType(template.prototype.cst_type, substitutes.arguments);
|
const type = inferTemplatedType(template.prototype.cst_type, substitutes.arguments);
|
||||||
updateConstituenta({
|
updateConstituenta({
|
||||||
cst_type: type,
|
cst_type: type,
|
||||||
alias: generateAlias(type, schema),
|
|
||||||
definition_formal: definition
|
definition_formal: definition
|
||||||
});
|
});
|
||||||
updateSubstitutes({
|
updateSubstitutes({
|
||||||
definition: definition
|
definition: definition
|
||||||
});
|
});
|
||||||
}, [substitutes.arguments, template.prototype, updateConstituenta, updateSubstitutes, schema]);
|
}, [substitutes.arguments, template.prototype, updateConstituenta, updateSubstitutes]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
setValidated(!!template.prototype && validateNewAlias(constituenta.alias, constituenta.cst_type, schema));
|
setValidated(!!template.prototype && validateNewAlias(constituenta.alias, constituenta.cst_type, schema));
|
||||||
|
@ -118,10 +109,10 @@ function DlgConstituentaTemplate({ hideWindow, schema, onCreate, insertAfter }:
|
||||||
const templatePanel = useMemo(
|
const templatePanel = useMemo(
|
||||||
() => (
|
() => (
|
||||||
<TabPanel>
|
<TabPanel>
|
||||||
<TabTemplate state={template} partialUpdate={updateTemplate} templateSchema={templateSchema} />
|
<TabTemplate state={template} partialUpdate={updateTemplate} />
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
),
|
),
|
||||||
[template, templateSchema, updateTemplate]
|
[template, updateTemplate]
|
||||||
);
|
);
|
||||||
|
|
||||||
const argumentsPanel = useMemo(
|
const argumentsPanel = useMemo(
|
||||||
|
|
|
@ -216,7 +216,6 @@ function TabArguments({ state, schema, partialUpdate }: TabArgumentsProps) {
|
||||||
|
|
||||||
<RSInput
|
<RSInput
|
||||||
disabled
|
disabled
|
||||||
noTooltip
|
|
||||||
id='result'
|
id='result'
|
||||||
placeholder='Итоговое определение'
|
placeholder='Итоговое определение'
|
||||||
className='mt-[1.2rem]'
|
className='mt-[1.2rem]'
|
||||||
|
|
|
@ -11,7 +11,6 @@ import { useLibrary } from '@/context/LibraryContext';
|
||||||
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';
|
import { prefixes } from '@/utils/constants';
|
||||||
|
|
||||||
export interface ITemplateState {
|
export interface ITemplateState {
|
||||||
templateID?: number;
|
templateID?: number;
|
||||||
prototype?: IConstituenta;
|
prototype?: IConstituenta;
|
||||||
|
@ -21,11 +20,11 @@ export interface ITemplateState {
|
||||||
interface TabTemplateProps {
|
interface TabTemplateProps {
|
||||||
state: ITemplateState;
|
state: ITemplateState;
|
||||||
partialUpdate: Dispatch<Partial<ITemplateState>>;
|
partialUpdate: Dispatch<Partial<ITemplateState>>;
|
||||||
templateSchema?: IRSForm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function TabTemplate({ state, partialUpdate, templateSchema }: TabTemplateProps) {
|
function TabTemplate({ state, partialUpdate }: TabTemplateProps) {
|
||||||
const { templates } = useLibrary();
|
const { templates, retrieveTemplate } = useLibrary();
|
||||||
|
const [templateSchema, setTemplateSchema] = useState<IRSForm | undefined>(undefined);
|
||||||
|
|
||||||
const [filteredData, setFilteredData] = useState<IConstituenta[]>([]);
|
const [filteredData, setFilteredData] = useState<IConstituenta[]>([]);
|
||||||
|
|
||||||
|
@ -66,6 +65,14 @@ function TabTemplate({ state, partialUpdate, templateSchema }: TabTemplateProps)
|
||||||
}
|
}
|
||||||
}, [templates, state.templateID, partialUpdate]);
|
}, [templates, state.templateID, partialUpdate]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!state.templateID) {
|
||||||
|
setTemplateSchema(undefined);
|
||||||
|
} else {
|
||||||
|
retrieveTemplate(state.templateID, setTemplateSchema);
|
||||||
|
}
|
||||||
|
}, [state.templateID, retrieveTemplate]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!templateSchema) {
|
if (!templateSchema) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useState } from 'react';
|
import { useEffect, useLayoutEffect, useState } from 'react';
|
||||||
|
|
||||||
import Modal, { ModalProps } from '@/components/ui/Modal';
|
import Modal, { ModalProps } from '@/components/ui/Modal';
|
||||||
import usePartialUpdate from '@/hooks/usePartialUpdate';
|
import usePartialUpdate from '@/hooks/usePartialUpdate';
|
||||||
import { CstType, ICstCreateData, IRSForm } from '@/models/rsform';
|
import { CstType, ICstCreateData, IRSForm } from '@/models/rsform';
|
||||||
import { generateAlias } from '@/models/rsformAPI';
|
import { generateAlias, validateNewAlias } from '@/models/rsformAPI';
|
||||||
|
|
||||||
import FormCreateCst from './FormCreateCst';
|
import FormCreateCst from './FormCreateCst';
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ function DlgCreateCst({ hideWindow, initial, schema, onCreate }: DlgCreateCstPro
|
||||||
initial || {
|
initial || {
|
||||||
cst_type: CstType.BASE,
|
cst_type: CstType.BASE,
|
||||||
insert_after: null,
|
insert_after: null,
|
||||||
alias: generateAlias(CstType.BASE, schema),
|
alias: '',
|
||||||
convention: '',
|
convention: '',
|
||||||
definition_formal: '',
|
definition_formal: '',
|
||||||
definition_raw: '',
|
definition_raw: '',
|
||||||
|
@ -32,6 +32,14 @@ function DlgCreateCst({ hideWindow, initial, schema, onCreate }: DlgCreateCstPro
|
||||||
|
|
||||||
const handleSubmit = () => onCreate(cstData);
|
const handleSubmit = () => onCreate(cstData);
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
updateCstData({ alias: generateAlias(cstData.cst_type, schema) });
|
||||||
|
}, [cstData.cst_type, updateCstData, schema]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setValidated(validateNewAlias(cstData.alias, cstData.cst_type, schema));
|
||||||
|
}, [cstData.alias, cstData.cst_type, schema]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
header='Создание конституенты'
|
header='Создание конституенты'
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { AnimatePresence } from 'framer-motion';
|
import { AnimatePresence } from 'framer-motion';
|
||||||
import { useCallback, useLayoutEffect, useMemo, useState } from 'react';
|
import { useLayoutEffect, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import BadgeHelp from '@/components/info/BadgeHelp';
|
import BadgeHelp from '@/components/info/BadgeHelp';
|
||||||
import RSInput from '@/components/RSInput';
|
import RSInput from '@/components/RSInput';
|
||||||
|
@ -33,6 +33,7 @@ function FormCreateCst({ schema, state, partialUpdate, setValidated }: FormCreat
|
||||||
const showConvention = useMemo(() => !!state.convention || forceComment || isBasic, [state, forceComment, isBasic]);
|
const showConvention = useMemo(() => !!state.convention || forceComment || isBasic, [state, forceComment, isBasic]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
|
partialUpdate({ alias: generateAlias(state.cst_type, schema) });
|
||||||
setForceComment(false);
|
setForceComment(false);
|
||||||
}, [state.cst_type, partialUpdate, schema]);
|
}, [state.cst_type, partialUpdate, schema]);
|
||||||
|
|
||||||
|
@ -42,51 +43,44 @@ function FormCreateCst({ schema, state, partialUpdate, setValidated }: FormCreat
|
||||||
}
|
}
|
||||||
}, [state.alias, state.cst_type, schema, setValidated]);
|
}, [state.alias, state.cst_type, schema, setValidated]);
|
||||||
|
|
||||||
const handleTypeChange = useCallback(
|
|
||||||
(target: CstType) => partialUpdate({ cst_type: target, alias: generateAlias(target, schema) }),
|
|
||||||
[partialUpdate, schema, generateAlias]
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
<div key='dlg_cst_alias_picker' className='flex items-center self-center gap-3'>
|
<div key='dlg_cst_alias_picker' className='flex items-center self-center'>
|
||||||
<SelectSingle
|
<SelectSingle
|
||||||
id='dlg_cst_type'
|
id='dlg_cst_type'
|
||||||
placeholder='Выберите тип'
|
placeholder='Выберите тип'
|
||||||
className='w-[15rem]'
|
className='w-[15rem]'
|
||||||
options={SelectorCstType}
|
options={SelectorCstType}
|
||||||
value={{ value: state.cst_type, label: labelCstType(state.cst_type) }}
|
value={{ value: state.cst_type, label: labelCstType(state.cst_type) }}
|
||||||
onChange={data => handleTypeChange(data?.value ?? CstType.BASE)}
|
onChange={data => partialUpdate({ cst_type: data?.value ?? CstType.BASE })}
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
id='dlg_cst_alias'
|
|
||||||
dense
|
|
||||||
label='Имя'
|
|
||||||
className='w-[7rem] mr-8'
|
|
||||||
value={state.alias}
|
|
||||||
onChange={event => partialUpdate({ alias: event.target.value })}
|
|
||||||
/>
|
/>
|
||||||
<BadgeHelp
|
<BadgeHelp
|
||||||
topic={HelpTopic.CC_CONSTITUENTA}
|
topic={HelpTopic.CC_CONSTITUENTA}
|
||||||
offset={16}
|
offset={16}
|
||||||
className={clsx(PARAMETER.TOOLTIP_WIDTH, 'sm:max-w-[40rem]')}
|
className={clsx(PARAMETER.TOOLTIP_WIDTH, 'sm:max-w-[40rem]')}
|
||||||
/>
|
/>
|
||||||
|
<TextInput
|
||||||
|
id='dlg_cst_alias'
|
||||||
|
dense
|
||||||
|
label='Имя'
|
||||||
|
className='w-[7rem] ml-3'
|
||||||
|
value={state.alias}
|
||||||
|
onChange={event => partialUpdate({ alias: event.target.value })}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<TextArea
|
<TextArea
|
||||||
key='dlg_cst_term'
|
key='dlg_cst_term'
|
||||||
id='dlg_cst_term'
|
id='dlg_cst_term'
|
||||||
fitContent
|
|
||||||
spellCheck
|
spellCheck
|
||||||
label='Термин'
|
label='Термин'
|
||||||
placeholder='Обозначение, используемое в текстовых определениях'
|
placeholder='Обозначение, используемое в текстовых определениях'
|
||||||
className='max-h-[3.6rem]'
|
className='cc-fit-content max-h-[3.6rem]'
|
||||||
value={state.term_raw}
|
value={state.term_raw}
|
||||||
onChange={event => partialUpdate({ term_raw: event.target.value })}
|
onChange={event => partialUpdate({ term_raw: event.target.value })}
|
||||||
/>
|
/>
|
||||||
<AnimateFade key='dlg_cst_expression' hideContent={!state.definition_formal && isElementary}>
|
<AnimateFade key='dlg_cst_expression' hideContent={!state.definition_formal && isElementary}>
|
||||||
<RSInput
|
<RSInput
|
||||||
id='dlg_cst_expression'
|
id='dlg_cst_expression'
|
||||||
noTooltip
|
|
||||||
label={
|
label={
|
||||||
state.cst_type === CstType.STRUCTURED
|
state.cst_type === CstType.STRUCTURED
|
||||||
? 'Область определения'
|
? 'Область определения'
|
||||||
|
@ -108,10 +102,9 @@ function FormCreateCst({ schema, state, partialUpdate, setValidated }: FormCreat
|
||||||
<TextArea
|
<TextArea
|
||||||
id='dlg_cst_definition'
|
id='dlg_cst_definition'
|
||||||
spellCheck
|
spellCheck
|
||||||
fitContent
|
|
||||||
label='Текстовое определение'
|
label='Текстовое определение'
|
||||||
placeholder='Текстовая интерпретация формального выражения'
|
placeholder='Текстовая интерпретация формального выражения'
|
||||||
className='max-h-[3.6rem]'
|
className='cc-fit-content max-h-[3.6rem]'
|
||||||
value={state.definition_raw}
|
value={state.definition_raw}
|
||||||
onChange={event => partialUpdate({ definition_raw: event.target.value })}
|
onChange={event => partialUpdate({ definition_raw: event.target.value })}
|
||||||
/>
|
/>
|
||||||
|
@ -133,10 +126,9 @@ function FormCreateCst({ schema, state, partialUpdate, setValidated }: FormCreat
|
||||||
key='dlg_cst_convention'
|
key='dlg_cst_convention'
|
||||||
id='dlg_cst_convention'
|
id='dlg_cst_convention'
|
||||||
spellCheck
|
spellCheck
|
||||||
fitContent
|
|
||||||
label={isBasic ? 'Конвенция' : 'Комментарий'}
|
label={isBasic ? 'Конвенция' : 'Комментарий'}
|
||||||
placeholder={isBasic ? 'Договоренность об интерпретации' : 'Пояснение разработчика'}
|
placeholder={isBasic ? 'Договоренность об интерпретации' : 'Пояснение разработчика'}
|
||||||
className='max-h-[5.4rem]'
|
className='cc-fit-content max-h-[5.4rem]'
|
||||||
value={state.convention}
|
value={state.convention}
|
||||||
onChange={event => partialUpdate({ convention: event.target.value })}
|
onChange={event => partialUpdate({ convention: event.target.value })}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { useCallback, useLayoutEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { TabList, TabPanel, Tabs } from 'react-tabs';
|
import { TabList, TabPanel, Tabs } from 'react-tabs';
|
||||||
|
|
||||||
import BadgeHelp from '@/components/info/BadgeHelp';
|
import BadgeHelp from '@/components/info/BadgeHelp';
|
||||||
|
@ -54,10 +54,7 @@ function DlgEditOperation({ hideWindow, oss, target, onSubmit }: DlgEditOperatio
|
||||||
() => inputOperations.map(operation => operation.result).filter(id => id !== null),
|
() => inputOperations.map(operation => operation.result).filter(id => id !== null),
|
||||||
[inputOperations]
|
[inputOperations]
|
||||||
);
|
);
|
||||||
|
|
||||||
const [substitutions, setSubstitutions] = useState<ICstSubstitute[]>(target.substitutions);
|
const [substitutions, setSubstitutions] = useState<ICstSubstitute[]>(target.substitutions);
|
||||||
const [suggestions, setSuggestions] = useState<ICstSubstitute[]>([]);
|
|
||||||
|
|
||||||
const cache = useRSFormCache();
|
const cache = useRSFormCache();
|
||||||
const schemas = useMemo(
|
const schemas = useMemo(
|
||||||
() => schemasIDs.map(id => cache.getSchema(id)).filter(item => item !== undefined),
|
() => schemasIDs.map(id => cache.getSchema(id)).filter(item => item !== undefined),
|
||||||
|
@ -66,11 +63,11 @@ function DlgEditOperation({ hideWindow, oss, target, onSubmit }: DlgEditOperatio
|
||||||
|
|
||||||
const canSubmit = useMemo(() => alias !== '', [alias]);
|
const canSubmit = useMemo(() => alias !== '', [alias]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useEffect(() => {
|
||||||
cache.preload(schemasIDs);
|
cache.preload(schemasIDs);
|
||||||
}, [schemasIDs]);
|
}, [schemasIDs]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useEffect(() => {
|
||||||
if (cache.loading || schemas.length !== schemasIDs.length) {
|
if (cache.loading || schemas.length !== schemasIDs.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -89,14 +86,13 @@ function DlgEditOperation({ hideWindow, oss, target, onSubmit }: DlgEditOperatio
|
||||||
);
|
);
|
||||||
}, [schemasIDs, schemas, cache.loading]);
|
}, [schemasIDs, schemas, cache.loading]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useEffect(() => {
|
||||||
if (cache.loading || schemas.length !== schemasIDs.length) {
|
if (cache.loading || schemas.length !== schemasIDs.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const validator = new SubstitutionValidator(schemas, substitutions);
|
const validator = new SubstitutionValidator(schemas, substitutions);
|
||||||
setIsCorrect(validator.validate());
|
setIsCorrect(validator.validate());
|
||||||
setValidationText(validator.msg);
|
setValidationText(validator.msg);
|
||||||
setSuggestions(validator.suggestions);
|
|
||||||
}, [substitutions, cache.loading, schemas, schemasIDs.length]);
|
}, [substitutions, cache.loading, schemas, schemasIDs.length]);
|
||||||
|
|
||||||
const handleSubmit = useCallback(() => {
|
const handleSubmit = useCallback(() => {
|
||||||
|
@ -155,11 +151,10 @@ function DlgEditOperation({ hideWindow, oss, target, onSubmit }: DlgEditOperatio
|
||||||
isCorrect={isCorrect}
|
isCorrect={isCorrect}
|
||||||
substitutions={substitutions}
|
substitutions={substitutions}
|
||||||
setSubstitutions={setSubstitutions}
|
setSubstitutions={setSubstitutions}
|
||||||
suggestions={suggestions}
|
|
||||||
/>
|
/>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
),
|
),
|
||||||
[cache.loading, cache.error, substitutions, suggestions, schemas, validationText, isCorrect]
|
[cache.loading, cache.error, substitutions, schemas, validationText, isCorrect]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -16,7 +16,6 @@ interface TabSynthesisProps {
|
||||||
schemas: IRSForm[];
|
schemas: IRSForm[];
|
||||||
substitutions: ICstSubstitute[];
|
substitutions: ICstSubstitute[];
|
||||||
setSubstitutions: React.Dispatch<React.SetStateAction<ICstSubstitute[]>>;
|
setSubstitutions: React.Dispatch<React.SetStateAction<ICstSubstitute[]>>;
|
||||||
suggestions: ICstSubstitute[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function TabSynthesis({
|
function TabSynthesis({
|
||||||
|
@ -26,8 +25,7 @@ function TabSynthesis({
|
||||||
validationText,
|
validationText,
|
||||||
isCorrect,
|
isCorrect,
|
||||||
substitutions,
|
substitutions,
|
||||||
setSubstitutions,
|
setSubstitutions
|
||||||
suggestions
|
|
||||||
}: TabSynthesisProps) {
|
}: TabSynthesisProps) {
|
||||||
const { colors } = useConceptOptions();
|
const { colors } = useConceptOptions();
|
||||||
return (
|
return (
|
||||||
|
@ -38,14 +36,8 @@ function TabSynthesis({
|
||||||
rows={10}
|
rows={10}
|
||||||
substitutions={substitutions}
|
substitutions={substitutions}
|
||||||
setSubstitutions={setSubstitutions}
|
setSubstitutions={setSubstitutions}
|
||||||
suggestions={suggestions}
|
|
||||||
/>
|
|
||||||
<TextArea
|
|
||||||
disabled
|
|
||||||
value={validationText}
|
|
||||||
rows={4}
|
|
||||||
style={{ borderColor: isCorrect ? undefined : colors.fgRed }}
|
|
||||||
/>
|
/>
|
||||||
|
<TextArea disabled value={validationText} style={{ borderColor: isCorrect ? undefined : colors.fgRed }} />
|
||||||
</DataLoader>
|
</DataLoader>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,27 +241,27 @@ export class Graph {
|
||||||
|
|
||||||
topologicalOrder(): number[] {
|
topologicalOrder(): number[] {
|
||||||
const result: number[] = [];
|
const result: number[] = [];
|
||||||
const marked = new Set<number>();
|
const marked = new Map<number, boolean>();
|
||||||
const nodeStack: number[] = [];
|
const toVisit: number[] = [];
|
||||||
this.nodes.forEach(node => {
|
this.nodes.forEach(node => {
|
||||||
if (marked.has(node.id)) {
|
if (marked.get(node.id)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nodeStack.push(node.id);
|
toVisit.push(node.id);
|
||||||
while (nodeStack.length > 0) {
|
while (toVisit.length > 0) {
|
||||||
const item = nodeStack[nodeStack.length - 1];
|
const item = toVisit[toVisit.length - 1];
|
||||||
if (marked.has(item)) {
|
if (marked.get(item)) {
|
||||||
if (!result.find(id => id === item)) {
|
if (!result.find(id => id === item)) {
|
||||||
result.push(item);
|
result.push(item);
|
||||||
}
|
}
|
||||||
nodeStack.pop();
|
toVisit.pop();
|
||||||
} else {
|
} else {
|
||||||
marked.add(item);
|
marked.set(item, true);
|
||||||
const itemNode = this.nodes.get(item);
|
const itemNode = this.nodes.get(item);
|
||||||
if (itemNode && itemNode.outputs.length > 0) {
|
if (itemNode && itemNode.outputs.length > 0) {
|
||||||
itemNode.outputs.forEach(child => {
|
itemNode.outputs.forEach(child => {
|
||||||
if (!marked.has(child)) {
|
if (!marked.get(child)) {
|
||||||
nodeStack.push(child);
|
toVisit.push(child);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,6 @@ export interface IMultiSubstitution {
|
||||||
original: IConstituenta;
|
original: IConstituenta;
|
||||||
substitution: IConstituenta;
|
substitution: IConstituenta;
|
||||||
substitution_source: ILibraryItem;
|
substitution_source: ILibraryItem;
|
||||||
is_suggestion: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,7 +213,6 @@ export enum SubstitutionErrorType {
|
||||||
typificationCycle,
|
typificationCycle,
|
||||||
baseSubstitutionNotSet,
|
baseSubstitutionNotSet,
|
||||||
unequalTypification,
|
unequalTypification,
|
||||||
unequalExpressions,
|
|
||||||
unequalArgsCount,
|
unequalArgsCount,
|
||||||
unequalArgs
|
unequalArgs
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,13 @@
|
||||||
* Module: API for OperationSystem.
|
* Module: API for OperationSystem.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { limits } from '@/utils/constants';
|
|
||||||
import { describeSubstitutionError, information } from '@/utils/labels';
|
import { describeSubstitutionError, information } from '@/utils/labels';
|
||||||
import { TextMatcher } from '@/utils/utils';
|
import { TextMatcher } from '@/utils/utils';
|
||||||
|
|
||||||
import { Graph } from './Graph';
|
import { Graph } from './Graph';
|
||||||
import { ILibraryItem, LibraryItemID } from './library';
|
import { ILibraryItem, LibraryItemID } from './library';
|
||||||
import { ICstSubstitute, IOperation, IOperationSchema, SubstitutionErrorType } from './oss';
|
import { ICstSubstitute, IOperation, IOperationSchema, SubstitutionErrorType } from './oss';
|
||||||
import { ConstituentaID, CstClass, CstType, IConstituenta, IRSForm } from './rsform';
|
import { ConstituentaID, CstType, IConstituenta, IRSForm } from './rsform';
|
||||||
import { AliasMapping, ParsingStatus } from './rslang';
|
import { AliasMapping, ParsingStatus } from './rslang';
|
||||||
import { applyAliasMapping, applyTypificationMapping, extractGlobals, isSetTypification } from './rslangAPI';
|
import { applyAliasMapping, applyTypificationMapping, extractGlobals, isSetTypification } from './rslangAPI';
|
||||||
|
|
||||||
|
@ -52,20 +51,14 @@ export function sortItemsForOSS(oss: IOperationSchema, items: ILibraryItem[]): I
|
||||||
|
|
||||||
type CrossMapping = Map<LibraryItemID, AliasMapping>;
|
type CrossMapping = Map<LibraryItemID, AliasMapping>;
|
||||||
|
|
||||||
// TODO: test validator
|
|
||||||
/**
|
/**
|
||||||
* Validator for Substitution table.
|
* Validator for Substitution table.
|
||||||
*/
|
*/
|
||||||
export class SubstitutionValidator {
|
export class SubstitutionValidator {
|
||||||
public msg: string = '';
|
public msg: string = '';
|
||||||
public suggestions: ICstSubstitute[] = [];
|
|
||||||
|
|
||||||
private schemas: IRSForm[];
|
private schemas: IRSForm[];
|
||||||
private substitutions: ICstSubstitute[];
|
private substitutions: ICstSubstitute[];
|
||||||
private constituents = new Set<ConstituentaID>();
|
|
||||||
private originals = new Set<ConstituentaID>();
|
|
||||||
private mapping: CrossMapping = new Map();
|
|
||||||
|
|
||||||
private cstByID = new Map<ConstituentaID, IConstituenta>();
|
private cstByID = new Map<ConstituentaID, IConstituenta>();
|
||||||
private schemaByID = new Map<LibraryItemID, IRSForm>();
|
private schemaByID = new Map<LibraryItemID, IRSForm>();
|
||||||
private schemaByCst = new Map<ConstituentaID, IRSForm>();
|
private schemaByCst = new Map<ConstituentaID, IRSForm>();
|
||||||
|
@ -73,36 +66,16 @@ export class SubstitutionValidator {
|
||||||
constructor(schemas: IRSForm[], substitutions: ICstSubstitute[]) {
|
constructor(schemas: IRSForm[], substitutions: ICstSubstitute[]) {
|
||||||
this.schemas = schemas;
|
this.schemas = schemas;
|
||||||
this.substitutions = substitutions;
|
this.substitutions = substitutions;
|
||||||
if (this.substitutions.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
schemas.forEach(schema => {
|
schemas.forEach(schema => {
|
||||||
this.schemaByID.set(schema.id, schema);
|
this.schemaByID.set(schema.id, schema);
|
||||||
this.mapping.set(schema.id, {});
|
|
||||||
schema.items.forEach(item => {
|
schema.items.forEach(item => {
|
||||||
this.cstByID.set(item.id, item);
|
this.cstByID.set(item.id, item);
|
||||||
this.schemaByCst.set(item.id, schema);
|
this.schemaByCst.set(item.id, schema);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
let index = limits.max_semantic_index;
|
|
||||||
substitutions.forEach(item => {
|
|
||||||
this.constituents.add(item.original);
|
|
||||||
this.constituents.add(item.substitution);
|
|
||||||
this.originals.add(item.original);
|
|
||||||
const original = this.cstByID.get(item.original);
|
|
||||||
const substitution = this.cstByID.get(item.substitution);
|
|
||||||
if (!original || !substitution) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
const newAlias = `${substitution.alias[0]}${index}`;
|
|
||||||
this.mapping.get(original.schema)![original.alias] = newAlias;
|
|
||||||
this.mapping.get(substitution.schema)![substitution.alias] = newAlias;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public validate(): boolean {
|
public validate(): boolean {
|
||||||
this.calculateSuggestions();
|
|
||||||
if (this.substitutions.length === 0) {
|
if (this.substitutions.length === 0) {
|
||||||
return this.setValid();
|
return this.setValid();
|
||||||
}
|
}
|
||||||
|
@ -112,62 +85,13 @@ export class SubstitutionValidator {
|
||||||
if (!this.checkCycles()) {
|
if (!this.checkCycles()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!this.checkSubstitutions()) {
|
if (!this.checkTypifications()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.setValid();
|
return this.setValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
private calculateSuggestions(): void {
|
|
||||||
const candidates = new Map<ConstituentaID, string>();
|
|
||||||
const minors = new Set<ConstituentaID>();
|
|
||||||
const schemaByCst = new Map<ConstituentaID, IRSForm>();
|
|
||||||
for (const schema of this.schemas) {
|
|
||||||
for (const cst of schema.items) {
|
|
||||||
if (this.originals.has(cst.id)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (cst.cst_class === CstClass.BASIC) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const inputs = schema.graph.at(cst.id)!.inputs;
|
|
||||||
if (inputs.length === 0 || inputs.some(id => !this.constituents.has(id))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (inputs.some(id => this.originals.has(id))) {
|
|
||||||
minors.add(cst.id);
|
|
||||||
}
|
|
||||||
candidates.set(cst.id, applyAliasMapping(cst.definition_formal, this.mapping.get(schema.id)!).replace(' ', ''));
|
|
||||||
schemaByCst.set(cst.id, schema);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const [key1, value1] of candidates) {
|
|
||||||
for (const [key2, value2] of candidates) {
|
|
||||||
if (key1 >= key2) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (schemaByCst.get(key1) === schemaByCst.get(key2)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (value1 != value2) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (minors.has(key2)) {
|
|
||||||
this.suggestions.push({
|
|
||||||
original: key2,
|
|
||||||
substitution: key1
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.suggestions.push({
|
|
||||||
original: key1,
|
|
||||||
substitution: key2
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private checkTypes(): boolean {
|
private checkTypes(): boolean {
|
||||||
for (const item of this.substitutions) {
|
for (const item of this.substitutions) {
|
||||||
const original = this.cstByID.get(item.original);
|
const original = this.cstByID.get(item.original);
|
||||||
|
@ -280,7 +204,7 @@ export class SubstitutionValidator {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkSubstitutions(): boolean {
|
private checkTypifications(): boolean {
|
||||||
const baseMappings = this.prepareBaseMappings();
|
const baseMappings = this.prepareBaseMappings();
|
||||||
const typeMappings = this.calculateSubstituteMappings(baseMappings);
|
const typeMappings = this.calculateSubstituteMappings(baseMappings);
|
||||||
if (typeMappings === null) {
|
if (typeMappings === null) {
|
||||||
|
@ -292,13 +216,6 @@ export class SubstitutionValidator {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const substitution = this.cstByID.get(item.substitution)!;
|
const substitution = this.cstByID.get(item.substitution)!;
|
||||||
if (original.cst_type === substitution.cst_type && original.cst_class !== CstClass.BASIC) {
|
|
||||||
if (!this.checkEqual(original, substitution)) {
|
|
||||||
this.reportError(SubstitutionErrorType.unequalExpressions, [substitution.alias, original.alias]);
|
|
||||||
// Note: do not interrupt the validation process. Only warn about the problem.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const originalType = applyTypificationMapping(
|
const originalType = applyTypificationMapping(
|
||||||
applyAliasMapping(original.parse.typification, baseMappings.get(original.schema)!),
|
applyAliasMapping(original.parse.typification, baseMappings.get(original.schema)!),
|
||||||
typeMappings
|
typeMappings
|
||||||
|
@ -370,6 +287,7 @@ export class SubstitutionValidator {
|
||||||
} else {
|
} else {
|
||||||
substitutionText = applyAliasMapping(substitution.parse.typification, baseMappings.get(substitution.schema)!);
|
substitutionText = applyAliasMapping(substitution.parse.typification, baseMappings.get(substitution.schema)!);
|
||||||
substitutionText = applyTypificationMapping(substitutionText, result);
|
substitutionText = applyTypificationMapping(substitutionText, result);
|
||||||
|
console.log(substitutionText);
|
||||||
if (!isSetTypification(substitutionText)) {
|
if (!isSetTypification(substitutionText)) {
|
||||||
this.reportError(SubstitutionErrorType.baseSubstitutionNotSet, [
|
this.reportError(SubstitutionErrorType.baseSubstitutionNotSet, [
|
||||||
substitution.alias,
|
substitution.alias,
|
||||||
|
@ -392,35 +310,13 @@ export class SubstitutionValidator {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkEqual(left: IConstituenta, right: IConstituenta): boolean {
|
|
||||||
const schema1 = this.schemaByID.get(left.schema)!;
|
|
||||||
const inputs1 = schema1.graph.at(left.id)!.inputs;
|
|
||||||
if (inputs1.some(id => !this.constituents.has(id))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const schema2 = this.schemaByID.get(right.schema)!;
|
|
||||||
const inputs2 = schema2.graph.at(right.id)!.inputs;
|
|
||||||
if (inputs2.some(id => !this.constituents.has(id))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const expression1 = applyAliasMapping(left.definition_formal, this.mapping.get(schema1.id)!);
|
|
||||||
const expression2 = applyAliasMapping(right.definition_formal, this.mapping.get(schema2.id)!);
|
|
||||||
return expression1.replace(' ', '') === expression2.replace(' ', '');
|
|
||||||
}
|
|
||||||
|
|
||||||
private setValid(): boolean {
|
private setValid(): boolean {
|
||||||
if (this.msg.length > 0) {
|
this.msg = information.substitutionsCorrect;
|
||||||
this.msg += '\n';
|
|
||||||
}
|
|
||||||
this.msg += information.substitutionsCorrect;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private reportError(errorType: SubstitutionErrorType, params: string[]): boolean {
|
private reportError(errorType: SubstitutionErrorType, params: string[]): boolean {
|
||||||
if (this.msg.length > 0) {
|
this.msg = describeSubstitutionError({
|
||||||
this.msg += '\n';
|
|
||||||
}
|
|
||||||
this.msg += describeSubstitutionError({
|
|
||||||
errorType: errorType,
|
errorType: errorType,
|
||||||
params: params
|
params: params
|
||||||
});
|
});
|
||||||
|
|
|
@ -93,7 +93,7 @@ export function inferTemplate(expression: string): boolean {
|
||||||
* - `CstClass.DERIVED` if the CstType is TERM, FUNCTION, or PREDICATE.
|
* - `CstClass.DERIVED` if the CstType is TERM, FUNCTION, or PREDICATE.
|
||||||
* - `CstClass.STATEMENT` if the CstType is AXIOM or THEOREM.
|
* - `CstClass.STATEMENT` if the CstType is AXIOM or THEOREM.
|
||||||
*/
|
*/
|
||||||
export function inferClass(type: CstType, isTemplate: boolean = false): CstClass {
|
export function inferClass(type: CstType, isTemplate: boolean): CstClass {
|
||||||
if (isTemplate) {
|
if (isTemplate) {
|
||||||
return CstClass.TEMPLATE;
|
return CstClass.TEMPLATE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { applyTypificationMapping, extractGlobals, isSimpleExpression, splitTemplateDefinition } from './rslangAPI';
|
import { extractGlobals, isSimpleExpression, splitTemplateDefinition } from './rslangAPI';
|
||||||
|
|
||||||
const globalsData = [
|
const globalsData = [
|
||||||
['', ''],
|
['', ''],
|
||||||
|
@ -47,24 +47,3 @@ describe('Testing split template', () => {
|
||||||
expect(`${result.head}||${result.body}`).toBe(expected);
|
expect(`${result.head}||${result.body}`).toBe(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const typificationMappingData = [
|
|
||||||
['', '', '', ''],
|
|
||||||
['X1', 'X2', 'X1', 'X2'],
|
|
||||||
['X1', 'X2', 'ℬ(X1)', 'ℬ(X2)'],
|
|
||||||
['X1', 'X2', 'X1×X3', 'X2×X3'],
|
|
||||||
['X1', '(X1×X1)', 'X1', 'X1×X1'],
|
|
||||||
['X1', '(X1×X1)', 'ℬ(X1)', 'ℬ(X1×X1)'],
|
|
||||||
['X1', '(X1×X1)', 'ℬ(X1×X2)', 'ℬ((X1×X1)×X2)'],
|
|
||||||
['X1', 'ℬ(X3)', 'ℬ(X1)', 'ℬℬ(X3)'],
|
|
||||||
['X1', 'ℬ(X3)', 'ℬ(X1×X1)', 'ℬ(ℬ(X3)×ℬ(X3))']
|
|
||||||
];
|
|
||||||
describe('Testing typification mapping', () => {
|
|
||||||
it.each(typificationMappingData)(
|
|
||||||
'Apply typification mapping %p',
|
|
||||||
(original: string, replacement: string, input: string, expected: string) => {
|
|
||||||
const result = applyTypificationMapping(input, { [original]: replacement });
|
|
||||||
expect(result).toBe(expected);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
|
@ -164,55 +164,13 @@ export function applyAliasMapping(target: string, mapping: AliasMapping): string
|
||||||
* Apply alias typification mapping.
|
* Apply alias typification mapping.
|
||||||
*/
|
*/
|
||||||
export function applyTypificationMapping(target: string, mapping: AliasMapping): string {
|
export function applyTypificationMapping(target: string, mapping: AliasMapping): string {
|
||||||
const modified = applyAliasMapping(target, mapping);
|
const result = applyAliasMapping(target, mapping);
|
||||||
if (modified === target) {
|
if (result === target) {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteBrackets: number[] = [];
|
// remove double parentheses
|
||||||
const positions: number[] = [];
|
// deal with ℬ(ℬ)
|
||||||
const booleans: number[] = [];
|
|
||||||
let boolCount: number = 0;
|
|
||||||
let stackSize: number = 0;
|
|
||||||
|
|
||||||
for (let i = 0; i < modified.length; i++) {
|
|
||||||
const char = modified[i];
|
|
||||||
if (char === 'ℬ') {
|
|
||||||
boolCount++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (char === '(') {
|
|
||||||
stackSize++;
|
|
||||||
positions.push(i);
|
|
||||||
booleans.push(boolCount);
|
|
||||||
}
|
|
||||||
boolCount = 0;
|
|
||||||
if (char === ')') {
|
|
||||||
if (
|
|
||||||
i < modified.length - 1 &&
|
|
||||||
modified[i + 1] === ')' &&
|
|
||||||
stackSize > 1 &&
|
|
||||||
positions[stackSize - 2] + booleans[stackSize - 1] + 1 === positions[stackSize - 1]
|
|
||||||
) {
|
|
||||||
deleteBrackets.push(i);
|
|
||||||
deleteBrackets.push(positions[stackSize - 2]);
|
|
||||||
}
|
|
||||||
if (i === modified.length - 1 && stackSize === 1 && positions[0] === 0) {
|
|
||||||
deleteBrackets.push(i);
|
|
||||||
deleteBrackets.push(positions[0]);
|
|
||||||
}
|
|
||||||
stackSize--;
|
|
||||||
positions.pop();
|
|
||||||
booleans.pop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = '';
|
|
||||||
for (let i = 0; i < modified.length; i++) {
|
|
||||||
if (!deleteBrackets.includes(i)) {
|
|
||||||
result += modified[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,17 +9,16 @@ import TopicItem from '../TopicItem';
|
||||||
|
|
||||||
function HelpMain() {
|
function HelpMain() {
|
||||||
return (
|
return (
|
||||||
<div className='text-justify'>
|
<div>
|
||||||
<h1>Портал</h1>
|
<h1>Портал</h1>
|
||||||
<p>
|
<p>
|
||||||
Портал позволяет анализировать предметные области, формально записывать системы определений и синтезировать их с
|
Портал позволяет анализировать предметные области, формально записывать системы определений и синтезировать их с
|
||||||
помощью математического аппарата <LinkTopic text='Родов структур' topic={HelpTopic.RSLANG} />
|
помощью математического аппарата <LinkTopic text='Родов структур' topic={HelpTopic.RSLANG} />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Такие системы называются <LinkTopic text='Концептуальными схемами' topic={HelpTopic.CC_SYSTEM} /> и состоят из
|
Такие системы называются <b>Концептуальными схемами</b> и состоят из отдельных{' '}
|
||||||
отдельных <LinkTopic text='Конституент' topic={HelpTopic.CC_CONSTITUENTA} />, обладающих уникальными
|
<LinkTopic text='Конституент' topic={HelpTopic.CC_CONSTITUENTA} />, обладающих уникальными обозначениями и
|
||||||
обозначениями и формальными определениями. Концептуальные схемы могут быть получены в рамках операций синтеза в{' '}
|
формальными определениями
|
||||||
<LinkTopic text='Операционной схеме синтеза' topic={HelpTopic.CC_OSS} />.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h2>Разделы Портала</h2>
|
<h2>Разделы Портала</h2>
|
||||||
|
@ -70,9 +69,8 @@ function HelpMain() {
|
||||||
Портал разрабатывается <TextURL text='Центром Концепт' href={external_urls.concept} />
|
Портал разрабатывается <TextURL text='Центром Концепт' href={external_urls.concept} />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Портал поддерживает актуальные версии браузеров Chrome, Firefox, Safari, включая мобильные устройства.
|
Портал поддерживает актуальные версии браузеров Chrome, Firefox, Safari. Убедитесь, что используете последнюю
|
||||||
Убедитесь, что используете последнюю версию браузера в случае возникновения визуальных ошибок или проблем с
|
версию браузера в случае возникновения визуальных ошибок или проблем с производительностью.
|
||||||
производительностью.
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Ваши пожелания по доработке, найденные ошибки и иные предложения можно направлять на email:{' '}
|
Ваши пожелания по доработке, найденные ошибки и иные предложения можно направлять на email:{' '}
|
||||||
|
|
|
@ -181,7 +181,7 @@ function HelpThesaurus() {
|
||||||
</li>
|
</li>
|
||||||
<li>основа данного понятия – понятие, на котором основано порождающее выражение данной конституенты;</li>
|
<li>основа данного понятия – понятие, на котором основано порождающее выражение данной конституенты;</li>
|
||||||
<li>
|
<li>
|
||||||
порожденное понятие данным понятием – понятие, определением которого является порождающим выражением,
|
порожденное понятие данным понятием – понятие, определение которого является порождающим выражением,
|
||||||
основанным на данном понятии.
|
основанным на данном понятии.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -267,7 +267,7 @@ function HelpThesaurus() {
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<IconSynthesis size='1rem' className='inline-icon' />
|
<IconSynthesis size='1rem' className='inline-icon' />
|
||||||
{'\u2009'}синтез концептуальных схем.
|
{'\u2009'}синтез концептуальных схем.ыф
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,8 @@ function HelpConceptOSS() {
|
||||||
<p>
|
<p>
|
||||||
Операция синтеза в рамках ОСС задаются набором операций-аргументов и <b>таблицей отождествлений</b> понятий из
|
Операция синтеза в рамках ОСС задаются набором операций-аргументов и <b>таблицей отождествлений</b> понятий из
|
||||||
КС, привязанных к выбранным аргументам. Таким образом{' '}
|
КС, привязанных к выбранным аргументам. Таким образом{' '}
|
||||||
<LinkTopic text='конституенты' topic={HelpTopic.CC_CONSTITUENTA} /> в каждой КС разделяются на исходные и
|
<LinkTopic text='конституенты' topic={HelpTopic.CC_CONSTITUENTA} /> в каждой КС разделяются на исходные
|
||||||
наследованные. При формировании таблицы отождествлений пользователю предлагается синтезировать производные
|
(дописанные), наследованные, отождествленные (удаляемые).
|
||||||
понятия, выражения которых совпадают после проведения заданных отождествлений.
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
После задания аргументов и таблицы отождествления необходимо единожды{' '}
|
После задания аргументов и таблицы отождествления необходимо единожды{' '}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { AnimatePresence } from 'framer-motion';
|
||||||
import { useEffect, useLayoutEffect, useMemo, useState } from 'react';
|
import { useEffect, useLayoutEffect, useMemo, useState } from 'react';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
|
|
||||||
import { IconChild, IconPredecessor, IconSave } from '@/components/Icons';
|
import { IconChild, IconParent, IconSave } from '@/components/Icons';
|
||||||
import RefsInput from '@/components/RefsInput';
|
import RefsInput from '@/components/RefsInput';
|
||||||
import MiniButton from '@/components/ui/MiniButton';
|
import MiniButton from '@/components/ui/MiniButton';
|
||||||
import Overlay from '@/components/ui/Overlay';
|
import Overlay from '@/components/ui/Overlay';
|
||||||
|
@ -128,7 +128,7 @@ function FormConstituenta({
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AnimateFade className='mx-0 md:mx-auto pt-[2rem] xs:pt-0'>
|
<AnimateFade className='mx-0 md:mx-auto'>
|
||||||
{state ? (
|
{state ? (
|
||||||
<ControlsOverlay
|
<ControlsOverlay
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
@ -161,7 +161,7 @@ function FormConstituenta({
|
||||||
{state ? (
|
{state ? (
|
||||||
<TextArea
|
<TextArea
|
||||||
id='cst_typification'
|
id='cst_typification'
|
||||||
fitContent
|
className='cc-fit-content'
|
||||||
dense
|
dense
|
||||||
noResize
|
noResize
|
||||||
noBorder
|
noBorder
|
||||||
|
@ -171,33 +171,32 @@ function FormConstituenta({
|
||||||
colors='clr-app clr-text-default'
|
colors='clr-app clr-text-default'
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{state ? (
|
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
<AnimateFade key='cst_expression_fade' hideContent={!state.definition_formal && isElementary}>
|
<AnimateFade key='cst_expression_fade' hideContent={!state || (!state?.definition_formal && isElementary)}>
|
||||||
<EditorRSExpression
|
<EditorRSExpression
|
||||||
id='cst_expression'
|
id='cst_expression'
|
||||||
label={
|
label={
|
||||||
state.cst_type === CstType.STRUCTURED
|
state?.cst_type === CstType.STRUCTURED
|
||||||
? 'Область определения'
|
? 'Область определения'
|
||||||
: isFunctional(state.cst_type)
|
: !!state && isFunctional(state.cst_type)
|
||||||
? 'Определение функции'
|
? 'Определение функции'
|
||||||
: 'Формальное определение'
|
: 'Формальное определение'
|
||||||
}
|
}
|
||||||
placeholder={
|
placeholder={
|
||||||
state.cst_type !== CstType.STRUCTURED
|
state?.cst_type !== CstType.STRUCTURED
|
||||||
? 'Родоструктурное выражение'
|
? 'Родоструктурное выражение'
|
||||||
: 'Определение множества, которому принадлежат элементы родовой структуры'
|
: 'Определение множества, которому принадлежат элементы родовой структуры'
|
||||||
}
|
}
|
||||||
value={expression}
|
value={expression}
|
||||||
activeCst={state}
|
activeCst={state}
|
||||||
disabled={disabled || state.is_inherited}
|
disabled={disabled || state?.is_inherited}
|
||||||
toggleReset={toggleReset}
|
toggleReset={toggleReset}
|
||||||
onChange={newValue => setExpression(newValue)}
|
onChange={newValue => setExpression(newValue)}
|
||||||
setTypification={setTypification}
|
setTypification={setTypification}
|
||||||
onOpenEdit={onOpenEdit}
|
onOpenEdit={onOpenEdit}
|
||||||
/>
|
/>
|
||||||
</AnimateFade>
|
</AnimateFade>
|
||||||
<AnimateFade key='cst_definition_fade' hideContent={!state.definition_raw && isElementary}>
|
<AnimateFade key='cst_definition_fade' hideContent={!state || (!state?.definition_raw && isElementary)}>
|
||||||
<RefsInput
|
<RefsInput
|
||||||
id='cst_definition'
|
id='cst_definition'
|
||||||
label='Текстовое определение'
|
label='Текстовое определение'
|
||||||
|
@ -207,22 +206,21 @@ function FormConstituenta({
|
||||||
schema={schema}
|
schema={schema}
|
||||||
onOpenEdit={onOpenEdit}
|
onOpenEdit={onOpenEdit}
|
||||||
value={textDefinition}
|
value={textDefinition}
|
||||||
initialValue={state.definition_raw}
|
initialValue={state?.definition_raw ?? ''}
|
||||||
resolved={state.definition_resolved}
|
resolved={state?.definition_resolved ?? ''}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onChange={newValue => setTextDefinition(newValue)}
|
onChange={newValue => setTextDefinition(newValue)}
|
||||||
/>
|
/>
|
||||||
</AnimateFade>
|
</AnimateFade>
|
||||||
<AnimateFade key='cst_convention_fade' hideContent={!showConvention}>
|
<AnimateFade key='cst_convention_fade' hideContent={!showConvention || !state}>
|
||||||
<TextArea
|
<TextArea
|
||||||
id='cst_convention'
|
id='cst_convention'
|
||||||
fitContent
|
className='cc-fit-content max-h-[8rem]'
|
||||||
className='max-h-[8rem]'
|
|
||||||
spellCheck
|
spellCheck
|
||||||
label={isBasic ? 'Конвенция' : 'Комментарий'}
|
label={isBasic ? 'Конвенция' : 'Комментарий'}
|
||||||
placeholder={isBasic ? 'Договоренность об интерпретации' : 'Пояснение разработчика'}
|
placeholder={isBasic ? 'Договоренность об интерпретации' : 'Пояснение разработчика'}
|
||||||
value={convention}
|
value={convention}
|
||||||
disabled={disabled || (isBasic && state.is_inherited)}
|
disabled={disabled || (isBasic && state?.is_inherited)}
|
||||||
onChange={event => setConvention(event.target.value)}
|
onChange={event => setConvention(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</AnimateFade>
|
</AnimateFade>
|
||||||
|
@ -249,16 +247,16 @@ function FormConstituenta({
|
||||||
icon={<IconSave size='1.25rem' />}
|
icon={<IconSave size='1.25rem' />}
|
||||||
/>
|
/>
|
||||||
<Overlay position='top-[0.1rem] left-[0.4rem]' className='cc-icons'>
|
<Overlay position='top-[0.1rem] left-[0.4rem]' className='cc-icons'>
|
||||||
{state.is_inherited_parent ? (
|
{state?.is_inherited_parent ? (
|
||||||
<MiniButton
|
<MiniButton
|
||||||
icon={<IconPredecessor size='1.25rem' className='clr-text-red' />}
|
icon={<IconChild size='1.25rem' className='clr-text-red' />}
|
||||||
disabled
|
disabled
|
||||||
titleHtml='Внимание!</br> Конституента имеет потомков<br/> в операционной схеме синтеза'
|
titleHtml='Внимание!</br> Конституента имеет потомков<br/> в операционной схеме синтеза'
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{state.is_inherited ? (
|
{state?.is_inherited ? (
|
||||||
<MiniButton
|
<MiniButton
|
||||||
icon={<IconChild size='1.25rem' className='clr-text-red' />}
|
icon={<IconParent size='1.25rem' className='clr-text-red' />}
|
||||||
disabled
|
disabled
|
||||||
titleHtml='Внимание!</br> Конституента является наследником<br/>'
|
titleHtml='Внимание!</br> Конституента является наследником<br/>'
|
||||||
/>
|
/>
|
||||||
|
@ -267,7 +265,6 @@ function FormConstituenta({
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
) : null}
|
|
||||||
</form>
|
</form>
|
||||||
</AnimateFade>
|
</AnimateFade>
|
||||||
);
|
);
|
||||||
|
|
|
@ -50,7 +50,7 @@ function ToolbarConstituenta({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Overlay
|
<Overlay
|
||||||
position='top-1 right-1/2 translate-x-1/2 xs:right-4 xs:translate-x-0 md:right-1/2 md:translate-x-1/2'
|
position='top-1 right-1/2 translate-x-1/2 sm:right-4 sm:translate-x-0 md:right-1/2 md:translate-x-1/2'
|
||||||
className='cc-icons outline-none transition-all duration-500'
|
className='cc-icons outline-none transition-all duration-500'
|
||||||
>
|
>
|
||||||
{controller.schema && controller.schema?.oss.length > 0 ? (
|
{controller.schema && controller.schema?.oss.length > 0 ? (
|
||||||
|
|
|
@ -28,7 +28,7 @@ import ToolbarRSExpression from './ToolbarRSExpression';
|
||||||
|
|
||||||
interface EditorRSExpressionProps {
|
interface EditorRSExpressionProps {
|
||||||
id?: string;
|
id?: string;
|
||||||
activeCst: IConstituenta;
|
activeCst?: IConstituenta;
|
||||||
value: string;
|
value: string;
|
||||||
label: string;
|
label: string;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
|
@ -70,10 +70,13 @@ function EditorRSExpression({
|
||||||
|
|
||||||
function handleChange(newValue: string) {
|
function handleChange(newValue: string) {
|
||||||
onChange(newValue);
|
onChange(newValue);
|
||||||
setIsModified(newValue !== activeCst.definition_formal);
|
setIsModified(newValue !== activeCst?.definition_formal);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCheckExpression(callback?: (parse: IExpressionParse) => void) {
|
function handleCheckExpression(callback?: (parse: IExpressionParse) => void) {
|
||||||
|
if (!activeCst) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const prefix = getDefinitionPrefix(activeCst);
|
const prefix = getDefinitionPrefix(activeCst);
|
||||||
const expression = prefix + value;
|
const expression = prefix + value;
|
||||||
parser.checkExpression(expression, activeCst, parse => {
|
parser.checkExpression(expression, activeCst, parse => {
|
||||||
|
@ -96,7 +99,7 @@ function EditorRSExpression({
|
||||||
|
|
||||||
const onShowError = useCallback(
|
const onShowError = useCallback(
|
||||||
(error: IRSErrorDescription) => {
|
(error: IRSErrorDescription) => {
|
||||||
if (!rsInput.current) {
|
if (!activeCst || !rsInput.current) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const prefix = getDefinitionPrefix(activeCst);
|
const prefix = getDefinitionPrefix(activeCst);
|
||||||
|
@ -133,7 +136,7 @@ function EditorRSExpression({
|
||||||
toast.error(errors.astFailed);
|
toast.error(errors.astFailed);
|
||||||
} else {
|
} else {
|
||||||
setSyntaxTree(parse.ast);
|
setSyntaxTree(parse.ast);
|
||||||
setExpression(getDefinitionPrefix(activeCst) + value);
|
setExpression(getDefinitionPrefix(activeCst!) + value);
|
||||||
setShowAST(true);
|
setShowAST(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -142,7 +145,7 @@ function EditorRSExpression({
|
||||||
const controls = useMemo(
|
const controls = useMemo(
|
||||||
() => (
|
() => (
|
||||||
<RSEditorControls
|
<RSEditorControls
|
||||||
isOpen={showControls && (!disabled || (model.processing && !activeCst.is_inherited))}
|
isOpen={showControls && (!disabled || (model.processing && !activeCst?.is_inherited))}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onEdit={handleEdit}
|
onEdit={handleEdit}
|
||||||
/>
|
/>
|
||||||
|
@ -169,7 +172,7 @@ function EditorRSExpression({
|
||||||
<StatusBar
|
<StatusBar
|
||||||
processing={parser.processing}
|
processing={parser.processing}
|
||||||
isModified={isModified}
|
isModified={isModified}
|
||||||
activeCst={activeCst}
|
constituenta={activeCst}
|
||||||
parseData={parser.parseData}
|
parseData={parser.parseData}
|
||||||
onAnalyze={() => handleCheckExpression()}
|
onAnalyze={() => handleCheckExpression()}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -19,11 +19,11 @@ interface StatusBarProps {
|
||||||
processing?: boolean;
|
processing?: boolean;
|
||||||
isModified?: boolean;
|
isModified?: boolean;
|
||||||
parseData?: IExpressionParse;
|
parseData?: IExpressionParse;
|
||||||
activeCst: IConstituenta;
|
constituenta?: IConstituenta;
|
||||||
onAnalyze: () => void;
|
onAnalyze: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function StatusBar({ isModified, processing, activeCst, parseData, onAnalyze }: StatusBarProps) {
|
function StatusBar({ isModified, processing, constituenta, parseData, onAnalyze }: StatusBarProps) {
|
||||||
const { colors } = useConceptOptions();
|
const { colors } = useConceptOptions();
|
||||||
const status = useMemo(() => {
|
const status = useMemo(() => {
|
||||||
if (isModified) {
|
if (isModified) {
|
||||||
|
@ -33,8 +33,8 @@ function StatusBar({ isModified, processing, activeCst, parseData, onAnalyze }:
|
||||||
const parse = parseData.parseResult ? ParsingStatus.VERIFIED : ParsingStatus.INCORRECT;
|
const parse = parseData.parseResult ? ParsingStatus.VERIFIED : ParsingStatus.INCORRECT;
|
||||||
return inferStatus(parse, parseData.valueClass);
|
return inferStatus(parse, parseData.valueClass);
|
||||||
}
|
}
|
||||||
return inferStatus(activeCst.parse.status, activeCst.parse.valueClass);
|
return inferStatus(constituenta?.parse?.status, constituenta?.parse?.valueClass);
|
||||||
}, [isModified, activeCst, parseData]);
|
}, [isModified, constituenta, parseData]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -437,14 +437,10 @@ export const RSEditState = ({
|
||||||
|
|
||||||
const createCst = useCallback(
|
const createCst = useCallback(
|
||||||
(type: CstType | undefined, skipDialog: boolean, definition?: string) => {
|
(type: CstType | undefined, skipDialog: boolean, definition?: string) => {
|
||||||
if (!model.schema) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const targetType = type ?? activeCst?.cst_type ?? CstType.BASE;
|
|
||||||
const data: ICstCreateData = {
|
const data: ICstCreateData = {
|
||||||
insert_after: activeCst?.id ?? null,
|
insert_after: activeCst?.id ?? null,
|
||||||
cst_type: targetType,
|
cst_type: type ?? activeCst?.cst_type ?? CstType.BASE,
|
||||||
alias: generateAlias(targetType, model.schema),
|
alias: '',
|
||||||
term_raw: '',
|
term_raw: '',
|
||||||
definition_formal: definition ?? '',
|
definition_formal: definition ?? '',
|
||||||
definition_raw: '',
|
definition_raw: '',
|
||||||
|
@ -458,17 +454,17 @@ export const RSEditState = ({
|
||||||
setShowCreateCst(true);
|
setShowCreateCst(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[activeCst, handleCreateCst, model.schema]
|
[activeCst, handleCreateCst]
|
||||||
);
|
);
|
||||||
|
|
||||||
const cloneCst = useCallback(() => {
|
const cloneCst = useCallback(() => {
|
||||||
if (!activeCst || !model.schema) {
|
if (!activeCst) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const data: ICstCreateData = {
|
const data: ICstCreateData = {
|
||||||
insert_after: activeCst.id,
|
insert_after: activeCst.id,
|
||||||
cst_type: activeCst.cst_type,
|
cst_type: activeCst.cst_type,
|
||||||
alias: generateAlias(activeCst.cst_type, model.schema),
|
alias: '',
|
||||||
term_raw: activeCst.term_raw,
|
term_raw: activeCst.term_raw,
|
||||||
definition_formal: activeCst.definition_formal,
|
definition_formal: activeCst.definition_formal,
|
||||||
definition_raw: activeCst.definition_raw,
|
definition_raw: activeCst.definition_raw,
|
||||||
|
@ -476,7 +472,7 @@ export const RSEditState = ({
|
||||||
term_forms: activeCst.term_forms
|
term_forms: activeCst.term_forms
|
||||||
};
|
};
|
||||||
handleCreateCst(data);
|
handleCreateCst(data);
|
||||||
}, [activeCst, handleCreateCst, model.schema]);
|
}, [activeCst, handleCreateCst]);
|
||||||
|
|
||||||
const renameCst = useCallback(() => {
|
const renameCst = useCallback(() => {
|
||||||
if (!activeCst) {
|
if (!activeCst) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ export const PARAMETER = {
|
||||||
typificationTruncate: 42, // characters - threshold for long typification - truncate
|
typificationTruncate: 42, // characters - threshold for long typification - truncate
|
||||||
|
|
||||||
ossLongLabel: 14, // characters - threshold for long labels - small font
|
ossLongLabel: 14, // characters - threshold for long labels - small font
|
||||||
ossTruncateLabel: 32, // characters - threshold for long labels - truncate
|
ossTruncateLabel: 28, // characters - threshold for long labels - truncate
|
||||||
|
|
||||||
statSmallThreshold: 3, // characters - threshold for small labels - small font
|
statSmallThreshold: 3, // characters - threshold for small labels - small font
|
||||||
|
|
||||||
|
@ -42,8 +42,7 @@ export const PARAMETER = {
|
||||||
* Numeric limitations.
|
* Numeric limitations.
|
||||||
*/
|
*/
|
||||||
export const limits = {
|
export const limits = {
|
||||||
location_len: 500,
|
location_len: 500
|
||||||
max_semantic_index: 900
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -824,8 +824,6 @@ export function describeSubstitutionError(error: ISubstitutionErrorDescription):
|
||||||
return `Ошибка ${error.params[0]} -> ${error.params[1]}: количество аргументов не совпадает`;
|
return `Ошибка ${error.params[0]} -> ${error.params[1]}: количество аргументов не совпадает`;
|
||||||
case SubstitutionErrorType.unequalArgs:
|
case SubstitutionErrorType.unequalArgs:
|
||||||
return `Ошибка ${error.params[0]} -> ${error.params[1]}: типизация аргументов не совпадает`;
|
return `Ошибка ${error.params[0]} -> ${error.params[1]}: типизация аргументов не совпадает`;
|
||||||
case SubstitutionErrorType.unequalExpressions:
|
|
||||||
return `Предупреждение ${error.params[0]} -> ${error.params[1]}: определения понятий не совпадают`;
|
|
||||||
}
|
}
|
||||||
return 'UNKNOWN ERROR';
|
return 'UNKNOWN ERROR';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
/** @type {import('tailwindcss').Config} */
|
/** @type {import('tailwindcss').Config} */
|
||||||
import defaultTheme from 'tailwindcss/defaultTheme';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
darkMode: 'class',
|
darkMode: 'class',
|
||||||
content: ['./src/**/*.{js,jsx,ts,tsx}'],
|
content: ['./src/**/*.{js,jsx,ts,tsx}'],
|
||||||
|
@ -16,10 +14,6 @@ export default {
|
||||||
modalControls: '70',
|
modalControls: '70',
|
||||||
modalTooltip: '90'
|
modalTooltip: '90'
|
||||||
},
|
},
|
||||||
screens: {
|
|
||||||
xs: '475px',
|
|
||||||
...defaultTheme.screens
|
|
||||||
},
|
|
||||||
extend: {}
|
extend: {}
|
||||||
},
|
},
|
||||||
plugins: [],
|
plugins: [],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user