Small UI improvements

This commit is contained in:
IRBorisov 2023-12-13 15:24:10 +03:00
parent 9c16c3fdb7
commit 64d0dcd59b
5 changed files with 28 additions and 16 deletions

View File

@ -18,7 +18,7 @@ import { useLibrary } from '@/context/LibraryContext';
import { useConceptNavigation } from '@/context/NagivationContext'; import { useConceptNavigation } from '@/context/NagivationContext';
import { LibraryItemType } from '@/models/library'; import { LibraryItemType } from '@/models/library';
import { IRSFormCreateData } from '@/models/rsform'; import { IRSFormCreateData } from '@/models/rsform';
import { EXTEOR_TRS_FILE } from '@/utils/constants'; import { EXTEOR_TRS_FILE, limits, patterns } from '@/utils/constants';
function CreateRSFormPage() { function CreateRSFormPage() {
const router = useConceptNavigation(); const router = useConceptNavigation();
@ -97,17 +97,18 @@ function CreateRSFormPage() {
</Overlay> </Overlay>
{fileName ? <Label text={`Загружен файл: ${fileName}`} /> : null} {fileName ? <Label text={`Загружен файл: ${fileName}`} /> : null}
<TextInput <TextInput required={!file}
label='Полное название' label='Полное название'
placeholder={file && 'Загрузить из файла'} placeholder={file && 'Загрузить из файла'}
required={!file}
value={title} value={title}
onChange={event => setTitle(event.target.value)} onChange={event => setTitle(event.target.value)}
/> />
<TextInput dense <TextInput required={!file}
label='Сокращение' label='Сокращение'
placeholder={file && 'Загрузить из файла'} placeholder={file && 'Загрузить из файла'}
required={!file} dimensions='w-[14rem]'
pattern={patterns.alias}
tooltip={`не более ${limits.alias_len} символов`}
value={alias} value={alias}
onChange={event => setAlias(event.target.value)} onChange={event => setAlias(event.target.value)}
/> />

View File

@ -11,6 +11,7 @@ import { SaveIcon } from '@/components/Icons';
import { useRSForm } from '@/context/RSFormContext'; import { useRSForm } from '@/context/RSFormContext';
import { LibraryItemType } from '@/models/library'; import { LibraryItemType } from '@/models/library';
import { IRSFormCreateData } from '@/models/rsform'; import { IRSFormCreateData } from '@/models/rsform';
import { limits, patterns } from '@/utils/constants';
interface FormRSFormProps { interface FormRSFormProps {
id?: string id?: string
@ -87,9 +88,11 @@ function FormRSForm({
disabled={!isMutable} disabled={!isMutable}
onChange={event => setTitle(event.target.value)} onChange={event => setTitle(event.target.value)}
/> />
<TextInput required dense <TextInput required
label='Сокращение' label='Сокращение'
dimensions='w-full' dimensions='w-[14rem]'
pattern={patterns.alias}
tooltip={`не более ${limits.alias_len} символов`}
disabled={!isMutable} disabled={!isMutable}
value={alias} value={alias}
onChange={event => setAlias(event.target.value)} onChange={event => setAlias(event.target.value)}

View File

@ -101,13 +101,13 @@ function RSTabs() {
useLayoutEffect(() => { useLayoutEffect(() => {
if (schema) { if (schema) {
const oldTitle = document.title const oldTitle = document.title;
document.title = schema.title document.title = schema.title;
return () => { return () => {
document.title = oldTitle document.title = oldTitle;
} }
} }
}, [schema]); }, [schema, schema?.title]);
useLayoutEffect(() => { useLayoutEffect(() => {
setActiveTab(tabQuery); setActiveTab(tabQuery);

View File

@ -22,12 +22,12 @@ import {
IRSFormCreateData, IRSFormData, IRSFormUploadData} from '@/models/rsform'; IRSFormCreateData, IRSFormData, IRSFormUploadData} from '@/models/rsform';
import { IExpressionParse, IRSExpression } from '@/models/rslang'; import { IExpressionParse, IRSExpression } from '@/models/rslang';
import { buidConstants } from './constants'; import { buildConstants } from './constants';
const defaultOptions = { const defaultOptions = {
xsrfCookieName: 'csrftoken', xsrfCookieName: 'csrftoken',
xsrfHeaderName: 'x-csrftoken', xsrfHeaderName: 'x-csrftoken',
baseURL: `${buidConstants.backend}`, baseURL: `${buildConstants.backend}`,
withCredentials: true withCredentials: true
} }

View File

@ -5,7 +5,7 @@
/** /**
* Variable constants depending on build type. * Variable constants depending on build type.
*/ */
export const buidConstants = { export const buildConstants = {
backend: import.meta.env.VITE_PORTAL_BACKEND as string backend: import.meta.env.VITE_PORTAL_BACKEND as string
}; };
@ -33,11 +33,19 @@ export const resources = {
logo: '/logo_full.svg' logo: '/logo_full.svg'
}; };
/**
* Numeric limitations.
*/
export const limits = {
alias_len: 12,
}
/** /**
* Regex patterns for data validation. * Regex patterns for data validation.
*/ */
export const patterns = { export const patterns = {
login: '^[a-zA-Z][a-zA-Z0-9_\\-]{1,}[a-zA-Z0-9]$' login: '^[a-zA-Z][a-zA-Z0-9_\\-]{1,}[a-zA-Z0-9]$',
alias: `.{1,${limits.alias_len}}`
} }
/** /**