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

View File

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

View File

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

View File

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

View File

@ -62,6 +62,13 @@ export function labelConstituenta(cst: IConstituenta) {
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}.
*/
@ -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) {
return hotkey ? `<b>[${hotkey}]</b><br/>${text}` : text;
}
export const messages = {
unsaved: 'Сохраните или отмените изменения'
};