mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
Fix Create from template
This commit is contained in:
parent
cb717cf492
commit
3391affb72
|
@ -12,7 +12,7 @@ import AnimateFade from '@/components/wrap/AnimateFade';
|
||||||
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';
|
||||||
import { generateAlias } from '@/models/rsformAPI';
|
import { generateAlias, validateNewAlias } from '@/models/rsformAPI';
|
||||||
import { inferTemplatedType, substituteTemplateArgs } from '@/models/rslangAPI';
|
import { inferTemplatedType, substituteTemplateArgs } from '@/models/rslangAPI';
|
||||||
|
|
||||||
import FormCreateCst from '../DlgCreateCst/FormCreateCst';
|
import FormCreateCst from '../DlgCreateCst/FormCreateCst';
|
||||||
|
@ -101,6 +101,10 @@ function DlgConstituentaTemplate({ hideWindow, schema, onCreate, insertAfter }:
|
||||||
});
|
});
|
||||||
}, [substitutes.arguments, template.prototype, updateConstituenta, updateSubstitutes]);
|
}, [substitutes.arguments, template.prototype, updateConstituenta, updateSubstitutes]);
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
setValidated(!!template.prototype && validateNewAlias(constituenta.alias, constituenta.cst_type, schema));
|
||||||
|
}, [constituenta.alias, constituenta.cst_type, schema, template.prototype]);
|
||||||
|
|
||||||
const templatePanel = useMemo(
|
const templatePanel = useMemo(
|
||||||
() => (
|
() => (
|
||||||
<TabPanel>
|
<TabPanel>
|
||||||
|
@ -123,12 +127,7 @@ function DlgConstituentaTemplate({ hideWindow, schema, onCreate, insertAfter }:
|
||||||
() => (
|
() => (
|
||||||
<TabPanel>
|
<TabPanel>
|
||||||
<AnimateFade className='cc-column'>
|
<AnimateFade className='cc-column'>
|
||||||
<FormCreateCst
|
<FormCreateCst state={constituenta} partialUpdate={updateConstituenta} schema={schema} />
|
||||||
state={constituenta}
|
|
||||||
partialUpdate={updateConstituenta}
|
|
||||||
schema={schema}
|
|
||||||
setValidated={setValidated}
|
|
||||||
/>
|
|
||||||
</AnimateFade>
|
</AnimateFade>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
),
|
),
|
||||||
|
|
|
@ -20,7 +20,7 @@ interface FormCreateCstProps {
|
||||||
state: ICstCreateData;
|
state: ICstCreateData;
|
||||||
|
|
||||||
partialUpdate: React.Dispatch<Partial<ICstCreateData>>;
|
partialUpdate: React.Dispatch<Partial<ICstCreateData>>;
|
||||||
setValidated: React.Dispatch<React.SetStateAction<boolean>>;
|
setValidated?: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function FormCreateCst({ schema, state, partialUpdate, setValidated }: FormCreateCstProps) {
|
function FormCreateCst({ schema, state, partialUpdate, setValidated }: FormCreateCstProps) {
|
||||||
|
@ -36,7 +36,9 @@ function FormCreateCst({ schema, state, partialUpdate, setValidated }: FormCreat
|
||||||
}, [state.cst_type, partialUpdate, schema]);
|
}, [state.cst_type, partialUpdate, schema]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
setValidated(validateNewAlias(state.alias, state.cst_type, schema));
|
if (setValidated) {
|
||||||
|
setValidated(validateNewAlias(state.alias, state.cst_type, schema));
|
||||||
|
}
|
||||||
}, [state.alias, state.cst_type, schema, setValidated]);
|
}, [state.alias, state.cst_type, schema, setValidated]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user