mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 21:10:38 +03:00
Implement InlineSynthesis fronted + backend
This commit is contained in:
parent
8bae771e29
commit
f6cb4d7859
|
@ -16,7 +16,9 @@ import {
|
||||||
ICstSubstituteData,
|
ICstSubstituteData,
|
||||||
ICstTarget,
|
ICstTarget,
|
||||||
ICstUpdateData,
|
ICstUpdateData,
|
||||||
|
IInlineSynthesisData,
|
||||||
IRSForm,
|
IRSForm,
|
||||||
|
IRSFormData,
|
||||||
IRSFormUploadData
|
IRSFormUploadData
|
||||||
} from '@/models/rsform';
|
} from '@/models/rsform';
|
||||||
import {
|
import {
|
||||||
|
@ -26,6 +28,7 @@ import {
|
||||||
getTRSFile,
|
getTRSFile,
|
||||||
patchConstituenta,
|
patchConstituenta,
|
||||||
patchDeleteConstituenta,
|
patchDeleteConstituenta,
|
||||||
|
patchInlineSynthesis,
|
||||||
patchLibraryItem,
|
patchLibraryItem,
|
||||||
patchMoveConstituenta,
|
patchMoveConstituenta,
|
||||||
patchProduceStructure,
|
patchProduceStructure,
|
||||||
|
@ -65,6 +68,7 @@ interface IRSFormContext {
|
||||||
|
|
||||||
resetAliases: (callback: () => void) => void;
|
resetAliases: (callback: () => void) => void;
|
||||||
produceStructure: (data: ICstTarget, callback?: DataCallback<ConstituentaID[]>) => void;
|
produceStructure: (data: ICstTarget, callback?: DataCallback<ConstituentaID[]>) => void;
|
||||||
|
inlineSynthesis: (data: IInlineSynthesisData, callback?: DataCallback<IRSFormData>) => void;
|
||||||
|
|
||||||
cstCreate: (data: ICstCreateData, callback?: DataCallback<IConstituentaMeta>) => void;
|
cstCreate: (data: ICstCreateData, callback?: DataCallback<IConstituentaMeta>) => void;
|
||||||
cstRename: (data: ICstRenameData, callback?: DataCallback<IConstituentaMeta>) => void;
|
cstRename: (data: ICstRenameData, callback?: DataCallback<IConstituentaMeta>) => void;
|
||||||
|
@ -464,6 +468,24 @@ export const RSFormState = ({ schemaID, versionID, children }: RSFormStateProps)
|
||||||
[setError, schema, setSchema]
|
[setError, schema, setSchema]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const inlineSynthesis = useCallback(
|
||||||
|
(data: IInlineSynthesisData, callback?: DataCallback<IRSFormData>) => {
|
||||||
|
setError(undefined);
|
||||||
|
patchInlineSynthesis({
|
||||||
|
data: data,
|
||||||
|
showError: true,
|
||||||
|
setLoading: setProcessing,
|
||||||
|
onError: setError,
|
||||||
|
onSuccess: newData => {
|
||||||
|
setSchema(newData);
|
||||||
|
library.localUpdateTimestamp(Number(schemaID));
|
||||||
|
if (callback) callback(newData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[setError, library, schemaID, setSchema]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RSFormContext.Provider
|
<RSFormContext.Provider
|
||||||
value={{
|
value={{
|
||||||
|
@ -482,6 +504,7 @@ export const RSFormState = ({ schemaID, versionID, children }: RSFormStateProps)
|
||||||
claim,
|
claim,
|
||||||
resetAliases,
|
resetAliases,
|
||||||
produceStructure,
|
produceStructure,
|
||||||
|
inlineSynthesis,
|
||||||
subscribe,
|
subscribe,
|
||||||
unsubscribe,
|
unsubscribe,
|
||||||
cstUpdate,
|
cstUpdate,
|
||||||
|
|
|
@ -8,7 +8,7 @@ import Modal, { ModalProps } from '@/components/ui/Modal';
|
||||||
import TabLabel from '@/components/ui/TabLabel';
|
import TabLabel from '@/components/ui/TabLabel';
|
||||||
import useRSFormDetails from '@/hooks/useRSFormDetails';
|
import useRSFormDetails from '@/hooks/useRSFormDetails';
|
||||||
import { LibraryItemID } from '@/models/library';
|
import { LibraryItemID } from '@/models/library';
|
||||||
import { IRSForm, IRSFormInlineData, ISubstitution } from '@/models/rsform';
|
import { IInlineSynthesisData, IRSForm, ISubstitution } from '@/models/rsform';
|
||||||
|
|
||||||
import ConstituentsTab from './ConstituentsTab';
|
import ConstituentsTab from './ConstituentsTab';
|
||||||
import SchemaTab from './SchemaTab';
|
import SchemaTab from './SchemaTab';
|
||||||
|
@ -16,7 +16,7 @@ import SubstitutionsTab from './SubstitutionsTab';
|
||||||
|
|
||||||
interface DlgInlineSynthesisProps extends Pick<ModalProps, 'hideWindow'> {
|
interface DlgInlineSynthesisProps extends Pick<ModalProps, 'hideWindow'> {
|
||||||
receiver: IRSForm;
|
receiver: IRSForm;
|
||||||
onInlineSynthesis: (data: IRSFormInlineData) => void;
|
onInlineSynthesis: (data: IInlineSynthesisData) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum TabID {
|
export enum TabID {
|
||||||
|
@ -40,7 +40,7 @@ function DlgInlineSynthesis({ hideWindow, receiver, onInlineSynthesis }: DlgInli
|
||||||
if (!source.schema) {
|
if (!source.schema) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const data: IRSFormInlineData = {
|
const data: IInlineSynthesisData = {
|
||||||
source: source.schema?.id,
|
source: source.schema?.id,
|
||||||
receiver: receiver.id,
|
receiver: receiver.id,
|
||||||
items: selected,
|
items: selected,
|
||||||
|
|
|
@ -247,7 +247,7 @@ export interface IVersionCreatedResponse {
|
||||||
/**
|
/**
|
||||||
* Represents input data for inline synthesis.
|
* Represents input data for inline synthesis.
|
||||||
*/
|
*/
|
||||||
export interface IRSFormInlineData {
|
export interface IInlineSynthesisData {
|
||||||
receiver: LibraryItemID;
|
receiver: LibraryItemID;
|
||||||
source: LibraryItemID;
|
source: LibraryItemID;
|
||||||
items: ConstituentaID[];
|
items: ConstituentaID[];
|
||||||
|
|
|
@ -38,6 +38,7 @@ import {
|
||||||
ICstSubstituteData,
|
ICstSubstituteData,
|
||||||
ICstTarget,
|
ICstTarget,
|
||||||
ICstUpdateData,
|
ICstUpdateData,
|
||||||
|
IInlineSynthesisData,
|
||||||
IRSForm,
|
IRSForm,
|
||||||
TermForm
|
TermForm
|
||||||
} from '@/models/rsform';
|
} from '@/models/rsform';
|
||||||
|
@ -263,6 +264,19 @@ export const RSEditState = ({
|
||||||
[model]
|
[model]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleInlineSynthesis = useCallback(
|
||||||
|
(data: IInlineSynthesisData) => {
|
||||||
|
if (!model.schema) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const oldCount = model.schema.items.length;
|
||||||
|
model.inlineSynthesis(data, newSchema =>
|
||||||
|
toast.success(`Конституенты добавлены: ${newSchema['items'].length - oldCount}`)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
[model]
|
||||||
|
);
|
||||||
|
|
||||||
const moveUp = useCallback(() => {
|
const moveUp = useCallback(() => {
|
||||||
if (!model.schema?.items || selected.length === 0) {
|
if (!model.schema?.items || selected.length === 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -557,7 +571,7 @@ export const RSEditState = ({
|
||||||
<DlgInlineSynthesis
|
<DlgInlineSynthesis
|
||||||
receiver={model.schema}
|
receiver={model.schema}
|
||||||
hideWindow={() => setShowInlineSynthesis(false)}
|
hideWindow={() => setShowInlineSynthesis(false)}
|
||||||
onInlineSynthesis={() => toast('Testing')}
|
onInlineSynthesis={handleInlineSynthesis}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
|
|
|
@ -215,7 +215,7 @@ function RSTabsMenu({ onDestroy }: RSTabsMenuProps) {
|
||||||
onClick={handleTemplates}
|
onClick={handleTemplates}
|
||||||
/>
|
/>
|
||||||
<DropdownButton
|
<DropdownButton
|
||||||
disabled={!controller.isContentEditable || !user.is_staff}
|
disabled={!controller.isContentEditable}
|
||||||
text='Применить конструкт'
|
text='Применить конструкт'
|
||||||
title='Импортировать совокупность конституент из другой схемы'
|
title='Импортировать совокупность конституент из другой схемы'
|
||||||
icon={<LuBookCopy size='1rem' className='icon-green' />}
|
icon={<LuBookCopy size='1rem' className='icon-green' />}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import {
|
||||||
ICstSubstituteData,
|
ICstSubstituteData,
|
||||||
ICstTarget,
|
ICstTarget,
|
||||||
ICstUpdateData,
|
ICstUpdateData,
|
||||||
|
IInlineSynthesisData,
|
||||||
IProduceStructureResponse,
|
IProduceStructureResponse,
|
||||||
IRSFormCreateData,
|
IRSFormCreateData,
|
||||||
IRSFormData,
|
IRSFormData,
|
||||||
|
@ -379,6 +380,13 @@ export function patchUploadTRS(target: string, request: FrontExchange<IRSFormUpl
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
export function patchInlineSynthesis(request: FrontExchange<IInlineSynthesisData, IRSFormData>) {
|
||||||
|
AxiosPatch({
|
||||||
|
title: 'Processing inline synthesis',
|
||||||
|
endpoint: `/api/operations/inline-synthesis`,
|
||||||
|
request: request
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function postResolveText(schema: string, request: FrontExchange<ITextRequest, IResolutionData>) {
|
export function postResolveText(schema: string, request: FrontExchange<ITextRequest, IResolutionData>) {
|
||||||
AxiosPost({
|
AxiosPost({
|
||||||
|
|
Loading…
Reference in New Issue
Block a user