Small UI fixes

This commit is contained in:
IRBorisov 2024-03-20 19:49:45 +03:00
parent feb65cfd42
commit 278b60277c
6 changed files with 34 additions and 13 deletions

View File

@ -1,12 +1,12 @@
function HelpVersions() { function HelpVersions() {
// prettier-ignore // prettier-ignore
return ( return (
<div> <div className='text-justify'>
<h1>Версионирование схем</h1> <h1>Версионирование схем</h1>
<p>Версионирование позволяет сохранить текущее состояние схемы под определенным именем (версией) и использовать ссылку на него для совместной работы. После создания версии ее содержание изменить нельзя</p> <p>Версионирование позволяет сохранить текущее состояние схемы под определенным именем (версией) и использовать ссылку на него для совместной работы. После создания версии ее содержание изменить нельзя</p>
<p><b>Владелец</b> обладает правом редактирования названий и создания новых версий</p> <p>Владелец обладает правом редактирования названий и создания новых версий</p>
<p>Управление версиями происходит в Карточке схемы</p> <p>Управление версиями происходит в Карточке схемы</p>
<p>Функция Поделиться включает текущую выбранную версию в ссылку</p> <p>Функция Поделиться включает версию в ссылку</p>
</div>); </div>);
} }

View File

@ -6,7 +6,7 @@ import { FiSave } from 'react-icons/fi';
import MiniButton from '@/components/ui/MiniButton'; import MiniButton from '@/components/ui/MiniButton';
import Overlay from '@/components/ui/Overlay'; import Overlay from '@/components/ui/Overlay';
import { prepareTooltip } from '@/utils/labels'; import { messages, prepareTooltip } from '@/utils/labels';
interface ConstituentaToolbarProps { interface ConstituentaToolbarProps {
isMutable: boolean; isMutable: boolean;
@ -55,7 +55,7 @@ function ConstituentaToolbar({
icon={<BiPlusCircle size={'1.25rem'} className='icon-green' />} icon={<BiPlusCircle size={'1.25rem'} className='icon-green' />}
/> />
<MiniButton <MiniButton
titleHtml={prepareTooltip('Клонировать конституенту', 'Alt + V')} titleHtml={isModified ? messages.unsaved : prepareTooltip('Клонировать конституенту', 'Alt + V')}
disabled={!isMutable || isModified} disabled={!isMutable || isModified}
onClick={onClone} onClick={onClone}
icon={<BiDuplicate size='1.25rem' className='icon-green' />} icon={<BiDuplicate size='1.25rem' className='icon-green' />}

View File

@ -4,25 +4,37 @@ import { LiaEdit } from 'react-icons/lia';
import MiniButton from '@/components/ui/MiniButton'; import MiniButton from '@/components/ui/MiniButton';
import Overlay from '@/components/ui/Overlay'; import Overlay from '@/components/ui/Overlay';
import { IConstituenta } from '@/models/rsform'; import { IConstituenta } from '@/models/rsform';
import { messages } from '@/utils/labels';
interface ControlsOverlayProps { interface ControlsOverlayProps {
constituenta?: IConstituenta; constituenta?: IConstituenta;
isMutable: boolean; isMutable: boolean;
isModified: boolean;
processing: boolean; processing: boolean;
onRename: () => void; onRename: () => void;
onEditTerm: () => void; onEditTerm: () => void;
} }
function ControlsOverlay({ constituenta, isMutable, processing, onRename, onEditTerm }: ControlsOverlayProps) { function ControlsOverlay({
constituenta,
isMutable,
isModified,
processing,
onRename,
onEditTerm
}: ControlsOverlayProps) {
return ( return (
<Overlay position='top-1 left-[4.1rem]' className='flex select-none'> <Overlay position='top-1 left-[4.1rem]' className='flex select-none'>
{isMutable || processing ? ( {isMutable || processing ? (
<MiniButton <MiniButton
title={`Редактировать словоформы термина: ${constituenta?.term_forms.length ?? 0}`} title={
isModified ? messages.unsaved : `Редактировать словоформы термина: ${constituenta?.term_forms.length ?? 0}`
}
noHover noHover
onClick={onEditTerm} onClick={onEditTerm}
icon={<LiaEdit size='1rem' className='icon-primary' />} icon={<LiaEdit size='1rem' className='icon-primary' />}
disabled={isModified}
/> />
) : null} ) : null}
<div <div
@ -39,9 +51,10 @@ function ControlsOverlay({ constituenta, isMutable, processing, onRename, onEdit
{isMutable || processing ? ( {isMutable || processing ? (
<MiniButton <MiniButton
noHover noHover
title='Переименовать конституенту' title={isModified ? messages.unsaved : 'Переименовать конституенту'}
onClick={onRename} onClick={onRename}
icon={<LiaEdit size='1rem' className='icon-primary' />} icon={<LiaEdit size='1rem' className='icon-primary' />}
disabled={isModified}
/> />
) : null} ) : null}
</Overlay> </Overlay>

View File

@ -115,6 +115,7 @@ function FormConstituenta({
<div> <div>
<ControlsOverlay <ControlsOverlay
isMutable={isMutable} isMutable={isMutable}
isModified={isModified}
processing={processing} processing={processing}
constituenta={constituenta} constituenta={constituenta}
onEditTerm={onEditTerm} onEditTerm={onEditTerm}

View File

@ -129,7 +129,7 @@ function FormRSForm({ id, isModified, setIsModified }: FormRSFormProps) {
/> />
<MiniButton <MiniButton
noHover noHover
title='Редактировать версии' title={schema?.versions.length === 0 ? 'Список версий пуст' : 'Редактировать версии'}
disabled={!schema || schema?.versions.length === 0} disabled={!schema || schema?.versions.length === 0}
onClick={controller.editVersions} onClick={controller.editVersions}
icon={<LuPencilLine size='1.25rem' className='icon-primary' />} icon={<LuPencilLine size='1.25rem' className='icon-primary' />}

View File

@ -62,6 +62,13 @@ export function labelConstituenta(cst: IConstituenta) {
return `${cst.alias}: ${describeConstituenta(cst)}`; return `${cst.alias}: ${describeConstituenta(cst)}`;
} }
/**
* Generate HTML wrapper for control description including hotkey.
*/
export function prepareTooltip(text: string, hotkey?: string) {
return hotkey ? `<b>[${hotkey}]</b><br/>${text}` : text;
}
/** /**
* Generates label for {@link IVersionInfo} of {@link IRSForm}. * Generates label for {@link IVersionInfo} of {@link IRSForm}.
*/ */
@ -747,8 +754,8 @@ export function describeAccessMode(mode: UserAccessMode): string {
} }
/** /**
* Generate HTML wrapper for control description including hotkey. * UI shared messages.
*/ */
export function prepareTooltip(text: string, hotkey?: string) { export const messages = {
return hotkey ? `<b>[${hotkey}]</b><br/>${text}` : text; unsaved: 'Сохраните или отмените изменения'
} };