Minor UI improvements

This commit is contained in:
IRBorisov 2023-10-26 11:50:18 +03:00
parent f1ac63b61a
commit 3b423b33ff
4 changed files with 84 additions and 74 deletions

View File

@ -4,6 +4,7 @@ import { toast } from 'react-toastify';
import Checkbox from '../../components/Common/Checkbox'; import Checkbox from '../../components/Common/Checkbox';
import ConceptTooltip from '../../components/Common/ConceptTooltip'; import ConceptTooltip from '../../components/Common/ConceptTooltip';
import Divider from '../../components/Common/Divider';
import MiniButton from '../../components/Common/MiniButton'; import MiniButton from '../../components/Common/MiniButton';
import SubmitButton from '../../components/Common/SubmitButton'; import SubmitButton from '../../components/Common/SubmitButton';
import TextArea from '../../components/Common/TextArea'; import TextArea from '../../components/Common/TextArea';
@ -15,6 +16,7 @@ import { useRSForm } from '../../context/RSFormContext';
import { useUsers } from '../../context/UsersContext'; import { useUsers } from '../../context/UsersContext';
import { LibraryItemType } from '../../models/library'; import { LibraryItemType } from '../../models/library';
import { IRSFormCreateData } from '../../models/rsform'; import { IRSFormCreateData } from '../../models/rsform';
import RSFormStats from './elements/RSFormStats';
interface EditorRSFormProps { interface EditorRSFormProps {
onDestroy: () => void onDestroy: () => void
@ -81,9 +83,9 @@ function EditorRSForm({ onDestroy, onClaim, onShare, isModified, setIsModified,
}; };
return ( return (
<form onSubmit={handleSubmit} className='flex-grow max-w-[40rem] min-w-[30rem] px-4 py-2 mt-4 border'> <div>
<div className='relative w-full'> <div className='relative flex items-start justify-center w-full'>
<div className='absolute top-0 right-0 flex'> <div className='absolute flex mt-1'>
<MiniButton <MiniButton
tooltip='Поделиться схемой' tooltip='Поделиться схемой'
icon={<ShareIcon size={5} color='text-primary'/>} icon={<ShareIcon size={5} color='text-primary'/>}
@ -114,74 +116,81 @@ function EditorRSForm({ onDestroy, onClaim, onShare, isModified, setIsModified,
</ConceptTooltip> </ConceptTooltip>
</div> </div>
</div> </div>
<div className='flex flex-col gap-3 mt-2'> <div className='flex w-full'>
<TextInput id='title' label='Полное название' type='text' <form onSubmit={handleSubmit} className='flex-grow max-w-[40rem] min-w-[30rem] px-4 py-2'>
required <div className='flex flex-col gap-3 mt-2'>
value={title} <TextInput id='title' label='Полное название' type='text'
disabled={!isEditable} required
onChange={event => setTitle(event.target.value)} value={title}
/> disabled={!isEditable}
<TextInput id='alias' label='Сокращение' type='text' onChange={event => setTitle(event.target.value)}
required />
value={alias} <TextInput id='alias' label='Сокращение' type='text'
disabled={!isEditable} required
dimensions='max-w-sm' value={alias}
onChange={event => setAlias(event.target.value)} disabled={!isEditable}
/> dense
<TextArea id='comment' label='Комментарий' dimensions='w-full'
value={comment} onChange={event => setAlias(event.target.value)}
disabled={!isEditable} />
onChange={event => setComment(event.target.value)} <TextArea id='comment' label='Комментарий'
/> value={comment}
<div className='flex justify-between whitespace-nowrap'> disabled={!isEditable}
<Checkbox id='common' label='Общедоступная схема' onChange={event => setComment(event.target.value)}
value={common} />
dimensions='w-fit' <div className='flex justify-between whitespace-nowrap'>
disabled={!isEditable} <Checkbox id='common' label='Общедоступная схема'
setValue={value => setCommon(value)} tooltip='Общедоступные схемы видны всем пользователям и могут быть изменены'
/> value={common}
<Checkbox id='canonical' label='Неизменная схема' dimensions='w-fit'
dimensions='w-fit' disabled={!isEditable}
value={canonical} setValue={value => setCommon(value)}
tooltip='Только администраторы могут присваивать схемам неизменный статус' />
disabled={!isEditable || !isForceAdmin} <Checkbox id='canonical' label='Неизменная схема'
setValue={value => setCanonical(value)} dimensions='w-fit'
/> value={canonical}
</div> tooltip='Только администраторы могут присваивать схемам неизменный статус'
disabled={!isEditable || !isForceAdmin}
setValue={value => setCanonical(value)}
/>
</div>
<SubmitButton <SubmitButton
text='Сохранить изменения' text='Сохранить изменения'
loading={processing} loading={processing}
disabled={!isModified || !isEditable} disabled={!isModified || !isEditable}
icon={<SaveIcon size={6} />} icon={<SaveIcon size={6} />}
dimensions='my-2 w-fit' dimensions='my-2 w-fit'
/> />
<div className='flex flex-col gap-1'> <div className='flex flex-col gap-1'>
<div className='flex justify-start'> <div className='flex justify-start'>
<label className='font-semibold'>Владелец:</label> <label className='font-semibold'>Владелец:</label>
<span className='min-w-[200px] ml-2 overflow-ellipsis overflow-hidden whitespace-nowrap'> <span className='min-w-[200px] ml-2 overflow-ellipsis overflow-hidden whitespace-nowrap'>
{getUserLabel(schema?.owner ?? null)} {getUserLabel(schema?.owner ?? null)}
</span> </span>
</div>
<div className='flex justify-start'>
<label className='font-semibold'>Отслеживают:</label>
<span id='subscriber-count' className='ml-2'>
{ schema?.subscribers.length ?? 0 }
</span>
</div>
<div className='flex justify-start'>
<label className='font-semibold'>Дата обновления:</label>
<span className='ml-2'>{schema && new Date(schema?.time_update).toLocaleString(intl.locale)}</span>
</div>
<div className='flex justify-start'>
<label className='font-semibold'>Дата создания:</label>
<span className='ml-8'>{schema && new Date(schema?.time_create).toLocaleString(intl.locale)}</span>
</div>
</div>
</div> </div>
<div className='flex justify-start'> </form>
<label className='font-semibold'>Отслеживают:</label> {schema && <Divider vertical />}
<span id='subscriber-count' className='ml-2'> <RSFormStats stats={schema?.stats}/>
{ schema?.subscribers.length ?? 0 }
</span>
</div>
<div className='flex justify-start'>
<label className='font-semibold'>Дата обновления:</label>
<span className='ml-2'>{schema && new Date(schema?.time_update).toLocaleString(intl.locale)}</span>
</div>
<div className='flex justify-start'>
<label className='font-semibold'>Дата создания:</label>
<span className='ml-8'>{schema && new Date(schema?.time_create).toLocaleString(intl.locale)}</span>
</div>
</div>
</div> </div>
</form> </div>);
);
} }
export default EditorRSForm; export default EditorRSForm;

View File

@ -30,7 +30,6 @@ import EditorConstituenta from './EditorConstituenta';
import EditorItems from './EditorItems'; import EditorItems from './EditorItems';
import EditorRSForm from './EditorRSForm'; import EditorRSForm from './EditorRSForm';
import EditorTermGraph from './EditorTermGraph'; import EditorTermGraph from './EditorTermGraph';
import RSFormStats from './elements/RSFormStats';
import RSTabsMenu from './elements/RSTabsMenu'; import RSTabsMenu from './elements/RSTabsMenu';
export enum RSTabID { export enum RSTabID {
@ -420,7 +419,7 @@ function RSTabs() {
</TabList> </TabList>
<div className='overflow-y-auto' style={{ maxHeight: panelHeight}}> <div className='overflow-y-auto' style={{ maxHeight: panelHeight}}>
<TabPanel className='flex gap-4 w-fit'> <TabPanel>
<EditorRSForm <EditorRSForm
isModified={isModified} isModified={isModified}
setIsModified={setIsModified} setIsModified={setIsModified}
@ -429,7 +428,6 @@ function RSTabs() {
onClaim={onClaimSchema} onClaim={onClaimSchema}
onShare={onShareSchema} onShare={onShareSchema}
/> />
{schema.stats && <RSFormStats stats={schema.stats}/>}
</TabPanel> </TabPanel>
<TabPanel> <TabPanel>

View File

@ -3,12 +3,15 @@ import LabeledText from '../../../components/Common/LabeledText';
import { type IRSFormStats } from '../../../models/rsform'; import { type IRSFormStats } from '../../../models/rsform';
interface RSFormStatsProps { interface RSFormStatsProps {
stats: IRSFormStats stats?: IRSFormStats
} }
function RSFormStats({ stats }: RSFormStatsProps) { function RSFormStats({ stats }: RSFormStatsProps) {
if (!stats) {
return null;
}
return ( return (
<div className='flex flex-col gap-1 px-4 py-2 mt-4 border min-w-[16rem]'> <div className='flex flex-col gap-1 px-4 py-2 mt-7 min-w-[16rem]'>
<LabeledText id='count_all' <LabeledText id='count_all'
label='Всего конституент ' label='Всего конституент '
text={stats.count_all} text={stats.count_all}

View File

@ -56,7 +56,7 @@ function RegisterPage() {
return ( return (
<div className='flex justify-center w-full py-2'> <div className='flex justify-center w-full py-2'>
{ user && { user &&
<b>{`Вы вошли в систему как ${user.username}. Если хотите зарегистрировать нового пользователя, выйдите из системы (меню в правом верхнем углу экрана)`}</b>} <b>{`Вы вошли в систему как ${user.username}`}</b>}
{ !user && { !user &&
<Form <Form
title='Регистрация' title='Регистрация'