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 { HelpTopic } from '@/models/miscellaneous';
|
||||
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 FormCreateCst from '../DlgCreateCst/FormCreateCst';
|
||||
|
@ -101,6 +101,10 @@ function DlgConstituentaTemplate({ hideWindow, schema, onCreate, insertAfter }:
|
|||
});
|
||||
}, [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(
|
||||
() => (
|
||||
<TabPanel>
|
||||
|
@ -123,12 +127,7 @@ function DlgConstituentaTemplate({ hideWindow, schema, onCreate, insertAfter }:
|
|||
() => (
|
||||
<TabPanel>
|
||||
<AnimateFade className='cc-column'>
|
||||
<FormCreateCst
|
||||
state={constituenta}
|
||||
partialUpdate={updateConstituenta}
|
||||
schema={schema}
|
||||
setValidated={setValidated}
|
||||
/>
|
||||
<FormCreateCst state={constituenta} partialUpdate={updateConstituenta} schema={schema} />
|
||||
</AnimateFade>
|
||||
</TabPanel>
|
||||
),
|
||||
|
|
|
@ -20,7 +20,7 @@ interface FormCreateCstProps {
|
|||
state: 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) {
|
||||
|
@ -36,7 +36,9 @@ function FormCreateCst({ schema, state, partialUpdate, setValidated }: FormCreat
|
|||
}, [state.cst_type, partialUpdate, schema]);
|
||||
|
||||
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]);
|
||||
|
||||
return (
|
||||
|
|
Loading…
Reference in New Issue
Block a user