mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
This commit is contained in:
parent
38766f3588
commit
95f833d97d
|
@ -18,10 +18,11 @@ import { SelectorCstType } from '@/utils/selectors';
|
|||
|
||||
interface DlgRenameCstProps extends Pick<ModalProps, 'hideWindow'> {
|
||||
initial: ICstRenameData;
|
||||
allowChangeType: boolean;
|
||||
onRename: (data: ICstRenameData) => void;
|
||||
}
|
||||
|
||||
function DlgRenameCst({ hideWindow, initial, onRename }: DlgRenameCstProps) {
|
||||
function DlgRenameCst({ hideWindow, initial, allowChangeType, onRename }: DlgRenameCstProps) {
|
||||
const { schema } = useRSForm();
|
||||
const [validated, setValidated] = useState(false);
|
||||
const [cstData, updateData] = usePartialUpdate(initial);
|
||||
|
@ -52,6 +53,7 @@ function DlgRenameCst({ hideWindow, initial, onRename }: DlgRenameCstProps) {
|
|||
id='dlg_cst_type'
|
||||
placeholder='Выберите тип'
|
||||
className='min-w-[16rem] self-center'
|
||||
isDisabled={!allowChangeType}
|
||||
options={SelectorCstType}
|
||||
value={{
|
||||
value: cstData.cst_type,
|
||||
|
|
|
@ -255,7 +255,20 @@ export function isFunctional(type: CstType): boolean {
|
|||
* Validate new alias against {@link CstType} and {@link IRSForm}.
|
||||
*/
|
||||
export function validateNewAlias(alias: string, type: CstType, schema: IRSForm): boolean {
|
||||
return alias.length >= 2 && alias.startsWith(getCstTypePrefix(type)) && !schema.cstByAlias.has(alias);
|
||||
if (alias.length < 2) {
|
||||
return false;
|
||||
}
|
||||
const prefix = getCstTypePrefix(type);
|
||||
if (!alias.startsWith(prefix)) {
|
||||
return false;
|
||||
}
|
||||
if (schema.cstByAlias.has(alias)) {
|
||||
return false;
|
||||
}
|
||||
if (!/^\d+$/.exec(alias.substring(prefix.length))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -689,10 +689,11 @@ export const RSEditState = ({
|
|||
initial={createInitialData}
|
||||
/>
|
||||
) : null}
|
||||
{showRenameCst && renameInitialData ? (
|
||||
{activeCst && showRenameCst && renameInitialData ? (
|
||||
<DlgRenameCst
|
||||
hideWindow={() => setShowRenameCst(false)}
|
||||
onRename={handleRenameCst}
|
||||
allowChangeType={!activeCst.is_inherited}
|
||||
initial={renameInitialData}
|
||||
/>
|
||||
) : null}
|
||||
|
|
Loading…
Reference in New Issue
Block a user