tycho-components 0.21.18 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configs/Localization.js +12 -0
- package/dist/features/Comments/HeaderNotifications/HeaderNotifications.js +1 -1
- package/dist/features/DocumentDrawer/Actions/Actions.d.ts +12 -0
- package/dist/features/DocumentDrawer/Actions/Actions.js +77 -0
- package/dist/features/DocumentDrawer/Actions/index.d.ts +2 -0
- package/dist/features/DocumentDrawer/Actions/index.js +2 -0
- package/dist/features/DocumentDrawer/Actions/style.scss +6 -0
- package/dist/features/DocumentDrawer/AutomaticParser/AutomaticParser.d.ts +8 -0
- package/dist/features/DocumentDrawer/AutomaticParser/AutomaticParser.js +96 -0
- package/dist/features/DocumentDrawer/AutomaticParser/index.d.ts +2 -0
- package/dist/features/DocumentDrawer/AutomaticParser/index.js +2 -0
- package/dist/features/DocumentDrawer/AutomaticParser/style.scss +10 -0
- package/dist/features/DocumentDrawer/DocumentDrawer.d.ts +14 -0
- package/dist/features/DocumentDrawer/DocumentDrawer.js +111 -0
- package/dist/features/DocumentDrawer/DocumentEdit/DocumentEdit.d.ts +35 -0
- package/dist/features/DocumentDrawer/DocumentEdit/DocumentEdit.js +207 -0
- package/dist/features/DocumentDrawer/DocumentEdit/index.d.ts +2 -0
- package/dist/features/DocumentDrawer/DocumentEdit/index.js +1 -0
- package/dist/features/DocumentDrawer/DocumentExport/DocumentExport.d.ts +7 -0
- package/dist/features/DocumentDrawer/DocumentExport/DocumentExport.js +71 -0
- package/dist/features/DocumentDrawer/DocumentExport/ExportInvalidSentences.d.ts +7 -0
- package/dist/features/DocumentDrawer/DocumentExport/ExportInvalidSentences.js +12 -0
- package/dist/features/DocumentDrawer/DocumentExport/index.d.ts +2 -0
- package/dist/features/DocumentDrawer/DocumentExport/index.js +2 -0
- package/dist/features/DocumentDrawer/DocumentExport/style.scss +31 -0
- package/dist/features/DocumentDrawer/DocumentLexicon/DocumentLexicon.d.ts +7 -0
- package/dist/features/DocumentDrawer/DocumentLexicon/DocumentLexicon.js +22 -0
- package/dist/features/DocumentDrawer/DocumentLexicon/index.d.ts +2 -0
- package/dist/features/DocumentDrawer/DocumentLexicon/index.js +2 -0
- package/dist/features/DocumentDrawer/DocumentLexicon/style.scss +38 -0
- package/dist/features/DocumentDrawer/DocumentRemove/DocumentRemove.d.ts +12 -0
- package/dist/features/DocumentDrawer/DocumentRemove/DocumentRemove.js +28 -0
- package/dist/features/DocumentDrawer/DocumentRemove/index.d.ts +2 -0
- package/dist/features/DocumentDrawer/DocumentRemove/index.js +2 -0
- package/dist/features/DocumentDrawer/DocumentRemove/style.scss +0 -0
- package/dist/features/DocumentDrawer/Github/Github.d.ts +8 -0
- package/dist/features/DocumentDrawer/Github/Github.js +11 -0
- package/dist/features/DocumentDrawer/Github/GithubCommit.d.ts +8 -0
- package/dist/features/DocumentDrawer/Github/GithubCommit.js +86 -0
- package/dist/features/DocumentDrawer/Github/index.d.ts +2 -0
- package/dist/features/DocumentDrawer/Github/index.js +2 -0
- package/dist/features/DocumentDrawer/Github/style.scss +31 -0
- package/dist/features/DocumentDrawer/ImageGallery/GalleryImage.d.ts +8 -0
- package/dist/features/DocumentDrawer/ImageGallery/GalleryImage.js +5 -0
- package/dist/features/DocumentDrawer/ImageGallery/GalleryRemoval.d.ts +9 -0
- package/dist/features/DocumentDrawer/ImageGallery/GalleryRemoval.js +14 -0
- package/dist/features/DocumentDrawer/ImageGallery/ImageGallery.d.ts +9 -0
- package/dist/features/DocumentDrawer/ImageGallery/ImageGallery.js +45 -0
- package/dist/features/DocumentDrawer/ImageGallery/index.d.ts +2 -0
- package/dist/features/DocumentDrawer/ImageGallery/index.js +2 -0
- package/dist/features/DocumentDrawer/ImageGallery/style.scss +41 -0
- package/dist/features/DocumentDrawer/Info/Info.d.ts +10 -0
- package/dist/features/DocumentDrawer/Info/Info.js +16 -0
- package/dist/features/DocumentDrawer/Info/index.d.ts +2 -0
- package/dist/features/DocumentDrawer/Info/index.js +2 -0
- package/dist/features/DocumentDrawer/Info/style.scss +24 -0
- package/dist/features/DocumentDrawer/Metadata/DocumentMetadata/DocumentMetadata.d.ts +8 -0
- package/dist/features/DocumentDrawer/Metadata/DocumentMetadata/DocumentMetadata.js +60 -0
- package/dist/features/DocumentDrawer/Metadata/DocumentMetadata/index.d.ts +2 -0
- package/dist/features/DocumentDrawer/Metadata/DocumentMetadata/index.js +2 -0
- package/dist/features/DocumentDrawer/Metadata/DocumentMetadata/style.scss +7 -0
- package/dist/features/DocumentDrawer/Metadata/DocumentMetadataEdit/DocumentMetadataEdit.d.ts +11 -0
- package/dist/features/DocumentDrawer/Metadata/DocumentMetadataEdit/DocumentMetadataEdit.js +195 -0
- package/dist/features/DocumentDrawer/Metadata/DocumentMetadataEdit/index.d.ts +2 -0
- package/dist/features/DocumentDrawer/Metadata/DocumentMetadataEdit/index.js +2 -0
- package/dist/features/DocumentDrawer/Metadata/DocumentMetadataEdit/style.scss +58 -0
- package/dist/features/DocumentDrawer/PageStatusComponent/PageStatusComponent.d.ts +9 -0
- package/dist/features/DocumentDrawer/PageStatusComponent/PageStatusComponent.js +30 -0
- package/dist/features/DocumentDrawer/PageStatusComponent/index.d.ts +2 -0
- package/dist/features/DocumentDrawer/PageStatusComponent/index.js +2 -0
- package/dist/features/DocumentDrawer/PageStatusComponent/style.scss +19 -0
- package/dist/features/DocumentDrawer/Pages/BoxRemoval.d.ts +9 -0
- package/dist/features/DocumentDrawer/Pages/BoxRemoval.js +14 -0
- package/dist/features/DocumentDrawer/Pages/Boxes.d.ts +9 -0
- package/dist/features/DocumentDrawer/Pages/Boxes.js +63 -0
- package/dist/features/DocumentDrawer/Pages/PageRemoval.d.ts +9 -0
- package/dist/features/DocumentDrawer/Pages/PageRemoval.js +15 -0
- package/dist/features/DocumentDrawer/Pages/Pages.d.ts +10 -0
- package/dist/features/DocumentDrawer/Pages/Pages.js +72 -0
- package/dist/features/DocumentDrawer/Pages/style.scss +48 -0
- package/dist/features/DocumentDrawer/deps.d.ts +28 -0
- package/dist/features/DocumentDrawer/deps.js +20 -0
- package/dist/features/DocumentDrawer/functions/FileUtils.d.ts +4 -0
- package/dist/features/DocumentDrawer/functions/FileUtils.js +8 -0
- package/dist/features/DocumentDrawer/functions/MetadataUtils.d.ts +41 -0
- package/dist/features/DocumentDrawer/functions/MetadataUtils.js +192 -0
- package/dist/features/DocumentDrawer/index.d.ts +5 -0
- package/dist/features/DocumentDrawer/index.js +3 -0
- package/dist/features/DocumentDrawer/localization/ActionsTexts.d.ts +77 -0
- package/dist/features/DocumentDrawer/localization/ActionsTexts.js +77 -0
- package/dist/features/DocumentDrawer/localization/DocumentTexts.d.ts +140 -0
- package/dist/features/DocumentDrawer/localization/DocumentTexts.js +140 -0
- package/dist/features/DocumentDrawer/localization/ExportTexts.d.ts +59 -0
- package/dist/features/DocumentDrawer/localization/ExportTexts.js +59 -0
- package/dist/features/DocumentDrawer/localization/GithubTexts.d.ts +35 -0
- package/dist/features/DocumentDrawer/localization/GithubTexts.js +35 -0
- package/dist/features/DocumentDrawer/localization/PageTexts.d.ts +45 -0
- package/dist/features/DocumentDrawer/localization/PageTexts.js +45 -0
- package/dist/features/DocumentDrawer/localization/ParserTexts.d.ts +30 -0
- package/dist/features/DocumentDrawer/localization/ParserTexts.js +30 -0
- package/dist/features/DocumentDrawer/services/AutomaticParserService.d.ts +8 -0
- package/dist/features/DocumentDrawer/services/AutomaticParserService.js +9 -0
- package/dist/features/DocumentDrawer/services/BoundingBoxService.d.ts +11 -0
- package/dist/features/DocumentDrawer/services/BoundingBoxService.js +20 -0
- package/dist/features/DocumentDrawer/services/DocumentService.d.ts +13 -0
- package/dist/features/DocumentDrawer/services/DocumentService.js +20 -0
- package/dist/features/DocumentDrawer/services/ExportService.d.ts +11 -0
- package/dist/features/DocumentDrawer/services/ExportService.js +16 -0
- package/dist/features/DocumentDrawer/services/GithubService.d.ts +8 -0
- package/dist/features/DocumentDrawer/services/GithubService.js +12 -0
- package/dist/features/DocumentDrawer/services/ImageService.d.ts +8 -0
- package/dist/features/DocumentDrawer/services/ImageService.js +12 -0
- package/dist/features/DocumentDrawer/services/LexiconService.d.ts +10 -0
- package/dist/features/DocumentDrawer/services/LexiconService.js +9 -0
- package/dist/features/DocumentDrawer/services/MetadataService.d.ts +15 -0
- package/dist/features/DocumentDrawer/services/MetadataService.js +26 -0
- package/dist/features/DocumentDrawer/services/PageService.d.ts +11 -0
- package/dist/features/DocumentDrawer/services/PageService.js +16 -0
- package/dist/features/DocumentDrawer/services/SentenceService.d.ts +6 -0
- package/dist/features/DocumentDrawer/services/SentenceService.js +6 -0
- package/dist/features/DocumentDrawer/style.scss +171 -0
- package/dist/features/DocumentDrawer/types/BoundingBox.d.ts +8 -0
- package/dist/features/DocumentDrawer/types/BoundingBox.js +1 -0
- package/dist/features/DocumentDrawer/types/CatalogSearchFilter.d.ts +15 -0
- package/dist/features/DocumentDrawer/types/CatalogSearchFilter.js +16 -0
- package/dist/features/DocumentDrawer/types/Category.d.ts +16 -0
- package/dist/features/DocumentDrawer/types/Category.js +5 -0
- package/dist/features/DocumentDrawer/types/DocumentStatus.d.ts +7 -0
- package/dist/features/DocumentDrawer/types/DocumentStatus.js +6 -0
- package/dist/features/DocumentDrawer/types/DocumentUpdateRequest.d.ts +13 -0
- package/dist/features/DocumentDrawer/types/DocumentUpdateRequest.js +1 -0
- package/dist/features/DocumentDrawer/types/Export.d.ts +25 -0
- package/dist/features/DocumentDrawer/types/Export.js +36 -0
- package/dist/features/DocumentDrawer/types/Lexicon.d.ts +6 -0
- package/dist/features/DocumentDrawer/types/Lexicon.js +1 -0
- package/dist/features/DocumentDrawer/types/LexiconResponse.d.ts +6 -0
- package/dist/features/DocumentDrawer/types/LexiconResponse.js +1 -0
- package/dist/features/DocumentDrawer/types/Metadata.d.ts +22 -0
- package/dist/features/DocumentDrawer/types/Metadata.js +8 -0
- package/dist/features/DocumentDrawer/types/Page.d.ts +10 -0
- package/dist/features/DocumentDrawer/types/Page.js +1 -0
- package/dist/features/DocumentDrawer/types/PageStatus.d.ts +9 -0
- package/dist/features/DocumentDrawer/types/PageStatus.js +8 -0
- package/dist/features/DocumentDrawer/types/Parser.d.ts +18 -0
- package/dist/features/DocumentDrawer/types/Parser.js +21 -0
- package/dist/features/DocumentDrawer/types/Query.d.ts +6 -0
- package/dist/features/DocumentDrawer/types/Query.js +1 -0
- package/dist/features/DocumentDrawer/types/Sentence.d.ts +4 -0
- package/dist/features/DocumentDrawer/types/Sentence.js +1 -0
- package/dist/features/index.d.ts +4 -0
- package/dist/features/index.js +2 -0
- package/dist/shell/Header/HeaderApps/HeaderApps.js +2 -1
- package/dist/shell/Header/HelpButton/HelpModal.js +2 -1
- package/package.json +1 -1
|
@@ -14,6 +14,12 @@ import { SentenceTexts } from './localization/SentenceTexts';
|
|
|
14
14
|
import { TreeTexts } from './localization/TreeTexts';
|
|
15
15
|
import { ParametersTexts } from './localization/ParametersTexts';
|
|
16
16
|
import { SentenceSplitTexts } from '../features/SentenceSplit/localization/SentenceSplitTexts';
|
|
17
|
+
import { DocumentTexts } from '../features/DocumentDrawer/localization/DocumentTexts';
|
|
18
|
+
import { ActionsTexts } from '../features/DocumentDrawer/localization/ActionsTexts';
|
|
19
|
+
import PageTexts from '../features/DocumentDrawer/localization/PageTexts';
|
|
20
|
+
import { ExportTexts } from '../features/DocumentDrawer/localization/ExportTexts';
|
|
21
|
+
import { GithubTexts } from '../features/DocumentDrawer/localization/GithubTexts';
|
|
22
|
+
import ParserTexts from '../features/DocumentDrawer/localization/ParserTexts';
|
|
17
23
|
function buildResources(namespaces) {
|
|
18
24
|
return {
|
|
19
25
|
en: Object.fromEntries(Object.entries(namespaces).map(([key, texts]) => [key, texts.en])),
|
|
@@ -37,6 +43,12 @@ const FEATURE_NAMESPACES = {
|
|
|
37
43
|
sentence: SentenceTexts,
|
|
38
44
|
parameters: ParametersTexts,
|
|
39
45
|
sentenceSplit: SentenceSplitTexts,
|
|
46
|
+
document: DocumentTexts,
|
|
47
|
+
actions: ActionsTexts,
|
|
48
|
+
page: PageTexts,
|
|
49
|
+
export: ExportTexts,
|
|
50
|
+
github: GithubTexts,
|
|
51
|
+
parser: ParserTexts,
|
|
40
52
|
};
|
|
41
53
|
export const commonResources = buildResources(CORE_NAMESPACES);
|
|
42
54
|
export const featureResources = buildResources(FEATURE_NAMESPACES);
|
|
@@ -33,7 +33,7 @@ export default function HeaderNotifications({ uid, mode, mobile }) {
|
|
|
33
33
|
useEffect(() => {
|
|
34
34
|
load();
|
|
35
35
|
}, [uid, tab]);
|
|
36
|
-
return (_jsxs("div", { className: "ds-dropdown-container notifications-container", children: [_jsx(IconButton, { name: "notifications_active", className: comments && comments.length > 0 ? 'shake' : '', size: "medium", onClick: () => setOpen(!open), mode: mobile ? 'outlined' : 'filled' }), open && (_jsx("div", { className: "ds-dropdown-list", children: _jsxs("div", { className: "notifications-panel", children: [_jsxs("div", { className: "header", children: [_jsx("span", { children: t('notification.title') }), _jsx(IconButton, { name: "close", size: "
|
|
36
|
+
return (_jsxs("div", { className: "ds-dropdown-container notifications-container", children: [_jsx(IconButton, { name: "notifications_active", className: comments && comments.length > 0 ? 'shake' : '', size: "medium", onClick: () => setOpen(!open), mode: mobile ? 'outlined' : 'filled' }), open && (_jsx("div", { className: "ds-dropdown-list", children: _jsxs("div", { className: "notifications-panel", children: [_jsxs("div", { className: "header", children: [_jsx("span", { children: t('notification.title') }), _jsx(IconButton, { name: "close", size: "small", mode: "ghost", onClick: () => setOpen(false) })] }), _jsxs("div", { className: "tabs", children: [_jsxs("button", { className: tab === 'unread' ? 'active-tab' : '', onClick: () => setTab('unread'), children: [t('notification.unread'), " (", comments?.length || 0, ")"] }), _jsx("button", { className: tab === 'read' ? 'active-tab' : '', onClick: () => setTab('read'), children: t('notification.all') })] }), _jsxs("div", { className: "content", children: [notifications &&
|
|
37
37
|
notifications.map((not, idx) => (_jsxs("div", { className: "item", onClick: () => handleOpen(not), children: [_jsx(Avatar, { src: not.picture, size: "small" }), _jsxs("div", { className: "message", children: [_jsx("span", { className: "text", children: _jsx(Trans, { t: t, i18nKey: "notification.text", values: {
|
|
38
38
|
user: not.name,
|
|
39
39
|
} }) }), _jsx("span", { className: "date", children: DateUtils.formatDateTime(not.edited ? not.edited : not.date, 'MM/dd/yyyy - HH:mm') })] })] }, idx.valueOf()))), notifications && notifications.length === 0 && (_jsx("div", { className: "empty-notifications", children: t('notification.empty') }))] })] }) }))] }));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import CatalogSearchFilter from '../types/CatalogSearchFilter';
|
|
2
|
+
import { Document } from '../deps';
|
|
3
|
+
import './style.scss';
|
|
4
|
+
type Props = {
|
|
5
|
+
document: Document;
|
|
6
|
+
setOpenFile: (b: boolean) => void;
|
|
7
|
+
setFilter: (p: CatalogSearchFilter) => void;
|
|
8
|
+
handleClickDocument: (uid: string) => void;
|
|
9
|
+
useGrid: boolean;
|
|
10
|
+
};
|
|
11
|
+
export default function Actions({ document, setOpenFile, setFilter, handleClickDocument, useGrid, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import AutomaticParser from '../AutomaticParser';
|
|
3
|
+
import DocumentRemove from '../DocumentRemove';
|
|
4
|
+
import DocumentService from '../services/DocumentService';
|
|
5
|
+
import SentenceService from '../services/SentenceService';
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
8
|
+
import { ToolsUtils, useMessageUtils } from '../deps';
|
|
9
|
+
import { Icon } from 'tycho-storybook';
|
|
10
|
+
import './style.scss';
|
|
11
|
+
export default function Actions({ document, setOpenFile, setFilter, handleClickDocument, useGrid, }) {
|
|
12
|
+
const { t } = useTranslation(['actions', 'main']);
|
|
13
|
+
const [openRemove, setOpenRemove] = useState(false);
|
|
14
|
+
const { dispatchError, dispatchMessage } = useMessageUtils();
|
|
15
|
+
const [openAutomatic, setOpenAutomatic] = useState(false);
|
|
16
|
+
const handleResume = () => {
|
|
17
|
+
SentenceService.resume(document.uid).then((r) => {
|
|
18
|
+
if (!r.data) {
|
|
19
|
+
dispatchError({ err: 'warning.syntactic.review', t });
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
window.open(`${import.meta.env.VITE_APP_REVISION_WEB_URL}/tree/${r.data.uid}`);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const handleReview = () => {
|
|
26
|
+
const baseUrl = import.meta.env.VITE_APP_REVISION_WEB_URL;
|
|
27
|
+
const url = document.defaultTool === 'DESIGN'
|
|
28
|
+
? `${baseUrl}/box/${document.uid}`
|
|
29
|
+
: `${baseUrl}/${document.uid}`;
|
|
30
|
+
window.open(url);
|
|
31
|
+
};
|
|
32
|
+
const handleSyncSearch = () => {
|
|
33
|
+
DocumentService.syncSearch(document.uid)
|
|
34
|
+
.then(() => dispatchMessage({ key: 'sync.search.success', t }))
|
|
35
|
+
.catch(() => dispatchError({ err: 'error.unknown', t }));
|
|
36
|
+
};
|
|
37
|
+
const actionOptions = [
|
|
38
|
+
{
|
|
39
|
+
iconName: ToolsUtils.getIcon(document.defaultTool),
|
|
40
|
+
title: t('label.edition.title'),
|
|
41
|
+
description: t('label.edition.description'),
|
|
42
|
+
onClick: () => handleClickDocument(document.uid),
|
|
43
|
+
buttonClassName: document.defaultTool === 'DESIGN' ? 'action-design' : undefined,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
iconName: 'graph_4',
|
|
47
|
+
title: t('label.syntactic.title'),
|
|
48
|
+
description: t('label.syntactic.description'),
|
|
49
|
+
onClick: handleReview,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
iconName: 'play_arrow',
|
|
53
|
+
title: t('label.resume.title'),
|
|
54
|
+
description: t('label.resume.description'),
|
|
55
|
+
onClick: handleResume,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
iconName: 'settings_timelapse',
|
|
59
|
+
title: t('label.automatic.title'),
|
|
60
|
+
description: t('label.automatic.description'),
|
|
61
|
+
onClick: () => setOpenAutomatic(true),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
iconName: 'sync',
|
|
65
|
+
title: t('label.sync.title'),
|
|
66
|
+
description: t('label.sync.description'),
|
|
67
|
+
onClick: handleSyncSearch,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
iconName: 'delete',
|
|
71
|
+
title: t('actions.label.remove'),
|
|
72
|
+
description: t('actions.label.remove.description'),
|
|
73
|
+
onClick: () => setOpenRemove(true),
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
return (_jsxs("div", { className: "file-actions-container", children: [_jsx("div", { className: "header", children: _jsx("div", { className: "title", children: t('actions.label.title') }) }), _jsx("div", { className: "body", children: actionOptions.map(({ iconName, title, description, onClick, buttonClassName }) => (_jsxs("div", { className: "action-line", onClick: onClick, children: [_jsx("div", { className: `action-button${buttonClassName ? ` ${buttonClassName}` : ''}`, children: _jsx(Icon, { name: iconName, size: "medium" }) }), _jsxs("div", { className: "action-desc", children: [_jsx("span", { className: "title", children: title }), _jsx("span", { children: description })] })] }, iconName))) }), openRemove && (_jsx(DocumentRemove, { document: document, setFilter: setFilter, onClose: () => setOpenRemove(false), useGrid: useGrid, setOpenFile: setOpenFile })), openAutomatic && (_jsx(AutomaticParser, { document: document, onClose: () => setOpenAutomatic(false) }))] }));
|
|
77
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import AutomaticParserService from '../services/AutomaticParserService';
|
|
3
|
+
import { EMPTY_PARSER_REQUEST } from '../types/Parser';
|
|
4
|
+
import { Box, FormControlLabel, LinearProgress, Switch, Typography, } from '@mui/material';
|
|
5
|
+
import { useEffect, useRef, useState } from 'react';
|
|
6
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
7
|
+
import { AppLoading, AppModal, useMessageUtils, } from '../deps';
|
|
8
|
+
import './style.scss';
|
|
9
|
+
const timingCheck = 5000;
|
|
10
|
+
export default function AutomaticParser({ document, onClose }) {
|
|
11
|
+
const { t } = useTranslation('parser');
|
|
12
|
+
const { dispatchMessage, dispatchError } = useMessageUtils();
|
|
13
|
+
const [checking, setChecking] = useState(true);
|
|
14
|
+
const [loading, setLoading] = useState(false);
|
|
15
|
+
const [completed, setCompleted] = useState(false);
|
|
16
|
+
const [percentage, setPercentage] = useState(0);
|
|
17
|
+
const [request, setRequest] = useState(EMPTY_PARSER_REQUEST);
|
|
18
|
+
const intervalCheckRef = useRef(null);
|
|
19
|
+
const handleChange = (field) => (event) => {
|
|
20
|
+
setRequest((prev) => ({ ...prev, [field]: event.target.checked }));
|
|
21
|
+
};
|
|
22
|
+
const calculatePercentage = (parsed, total, errors) => {
|
|
23
|
+
if (!total)
|
|
24
|
+
return 0;
|
|
25
|
+
const processed = parsed + errors;
|
|
26
|
+
return Math.min(100, (processed / total) * 100) || 0;
|
|
27
|
+
};
|
|
28
|
+
const check = () => {
|
|
29
|
+
AutomaticParserService.checkParsingStatus(document.uid)
|
|
30
|
+
.then((res) => {
|
|
31
|
+
const { parsed = 0, total = 0, completed, errors = 0, } = res?.data ?? {};
|
|
32
|
+
setChecking(false);
|
|
33
|
+
setPercentage(calculatePercentage(parsed, total, errors));
|
|
34
|
+
if (completed) {
|
|
35
|
+
setLoading(false);
|
|
36
|
+
if (intervalCheckRef.current) {
|
|
37
|
+
clearInterval(intervalCheckRef.current);
|
|
38
|
+
intervalCheckRef.current = null;
|
|
39
|
+
}
|
|
40
|
+
setCompleted(true);
|
|
41
|
+
dispatchMessage({
|
|
42
|
+
key: 'msg.parser.completed',
|
|
43
|
+
t,
|
|
44
|
+
ns: 'parser',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
.catch(() => setChecking(false));
|
|
49
|
+
};
|
|
50
|
+
const handleCheck = () => {
|
|
51
|
+
if (!document)
|
|
52
|
+
return;
|
|
53
|
+
setChecking(true);
|
|
54
|
+
AutomaticParserService.checkParsingStatus(document.uid)
|
|
55
|
+
.then((res) => {
|
|
56
|
+
const { completed } = res?.data ?? {};
|
|
57
|
+
setChecking(false);
|
|
58
|
+
if (!completed) {
|
|
59
|
+
setLoading(true);
|
|
60
|
+
intervalCheckRef.current = setInterval(check, timingCheck);
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
.catch(() => setChecking(false));
|
|
64
|
+
};
|
|
65
|
+
const handleConfirm = () => {
|
|
66
|
+
if (loading)
|
|
67
|
+
return;
|
|
68
|
+
setLoading(true);
|
|
69
|
+
AutomaticParserService.executeAutomaticParsing(document.uid, request)
|
|
70
|
+
.then(() => {
|
|
71
|
+
if (!intervalCheckRef.current) {
|
|
72
|
+
intervalCheckRef.current = setInterval(check, timingCheck);
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
.catch((err) => {
|
|
76
|
+
setLoading(false);
|
|
77
|
+
const message = err?.response?.data?.message || err?.message;
|
|
78
|
+
dispatchError({
|
|
79
|
+
err: message ?? 'error.start',
|
|
80
|
+
key: message ? 'message' : 'parser',
|
|
81
|
+
t,
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
setPercentage(0);
|
|
87
|
+
handleCheck();
|
|
88
|
+
return () => {
|
|
89
|
+
if (intervalCheckRef.current) {
|
|
90
|
+
clearInterval(intervalCheckRef.current);
|
|
91
|
+
intervalCheckRef.current = null;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}, []);
|
|
95
|
+
return (_jsx(AppModal, { title: t('modal.automatic.title'), className: "modal-automatic-parser", close: onClose, confirm: completed ? onClose : handleConfirm, confirmLabel: completed ? t('modal.automatic.finish') : undefined, disableCancel: completed, disableConfirm: !completed && loading, children: checking ? (_jsx(AppLoading, {})) : (_jsxs(_Fragment, { children: [_jsx("p", { children: _jsx(Trans, { t: t, i18nKey: "modal.automatic.desc", components: { bold: _jsx("b", {}) } }) }), _jsx(FormControlLabel, { control: _jsx(Switch, { checked: request.reprocess, onChange: handleChange('reprocess') }), label: t('modal.automatic.reprocess') }), _jsx(FormControlLabel, { control: _jsx(Switch, { checked: request.resetTags, onChange: handleChange('resetTags') }), label: t('modal.automatic.reset') }), (loading || percentage > 0) && (_jsx(Box, { sx: { mt: 3 }, children: _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', mb: 1 }, children: [_jsx(Box, { sx: { width: '100%', mr: 1 }, children: _jsx(LinearProgress, { variant: "determinate", value: percentage }) }), _jsx(Box, { sx: { minWidth: 60 }, children: _jsx(Typography, { variant: "body2", color: "text.secondary", children: `${percentage.toFixed(2)}%` }) })] }) }))] })) }));
|
|
96
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import CatalogSearchFilter from './types/CatalogSearchFilter';
|
|
2
|
+
import Category from './types/Category';
|
|
3
|
+
import { Document } from './deps';
|
|
4
|
+
import './style.scss';
|
|
5
|
+
export type DocumentDrawerProps = {
|
|
6
|
+
uid: string;
|
|
7
|
+
setOpenFile: (b: boolean) => void;
|
|
8
|
+
setFilter: (p: CatalogSearchFilter) => void;
|
|
9
|
+
handleChange: (document: Document) => void;
|
|
10
|
+
handleClickDocument: (uid: string) => void;
|
|
11
|
+
useGrid: boolean;
|
|
12
|
+
categoriesHierarchy: Category[];
|
|
13
|
+
};
|
|
14
|
+
export default function DocumentDrawer({ uid, setOpenFile, setFilter, handleChange, handleClickDocument, useGrid, categoriesHierarchy, }: DocumentDrawerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import documenService from './services/DocumentService';
|
|
3
|
+
import { Drawer, Tab, Tabs } from '@mui/material';
|
|
4
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { Participants, useCorpusUtils } from './deps';
|
|
7
|
+
import { Icon } from 'tycho-storybook';
|
|
8
|
+
import DocumentMetadata from './Metadata/DocumentMetadata';
|
|
9
|
+
import Actions from './Actions';
|
|
10
|
+
import DocumentExport from './DocumentExport';
|
|
11
|
+
import DocumentLexicon from './DocumentLexicon';
|
|
12
|
+
import Github from './Github';
|
|
13
|
+
import ImageGallery from './ImageGallery';
|
|
14
|
+
import Info from './Info';
|
|
15
|
+
import Boxes from './Pages/Boxes';
|
|
16
|
+
import Pages from './Pages/Pages';
|
|
17
|
+
import './style.scss';
|
|
18
|
+
export default function DocumentDrawer({ uid, setOpenFile, setFilter, handleChange, handleClickDocument, useGrid, categoriesHierarchy, }) {
|
|
19
|
+
const { t } = useTranslation('document');
|
|
20
|
+
const { getCorpus, hasParameter } = useCorpusUtils();
|
|
21
|
+
const [document, setDocument] = useState();
|
|
22
|
+
const [activeKey, setActiveKey] = useState('actions');
|
|
23
|
+
const hasParticipants = (document?.participants?.length ?? 0) > 0;
|
|
24
|
+
const fileItems = useMemo(() => {
|
|
25
|
+
if (!document)
|
|
26
|
+
return [];
|
|
27
|
+
let items = hasParticipants
|
|
28
|
+
? baseFileItems
|
|
29
|
+
: baseFileItems.filter((item) => item.eventKey !== 'participants');
|
|
30
|
+
if (document.github) {
|
|
31
|
+
items = [...items, githubFileItem];
|
|
32
|
+
}
|
|
33
|
+
return items;
|
|
34
|
+
}, [document, hasParticipants]);
|
|
35
|
+
const handleTabChange = (_event, newValue) => {
|
|
36
|
+
setActiveKey(newValue);
|
|
37
|
+
};
|
|
38
|
+
const renderPages = () => {
|
|
39
|
+
if (!document)
|
|
40
|
+
return null;
|
|
41
|
+
if (document.defaultTool && document.defaultTool === 'DESIGN')
|
|
42
|
+
return (_jsx(Boxes, { document: document, setDocument: setDocument, setOpenFile: setOpenFile }));
|
|
43
|
+
return (_jsx(Pages, { document: document, setDocument: setDocument, setOpenFile: setOpenFile, handleChange: handleChange }));
|
|
44
|
+
};
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
documenService.get(uid).then((response) => {
|
|
47
|
+
setDocument(response.data);
|
|
48
|
+
});
|
|
49
|
+
}, [uid]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (!hasParticipants && activeKey === 'participants') {
|
|
52
|
+
setActiveKey('actions');
|
|
53
|
+
}
|
|
54
|
+
}, [activeKey, hasParticipants]);
|
|
55
|
+
if (!document)
|
|
56
|
+
return null;
|
|
57
|
+
return (_jsx(Drawer, { anchor: "left", open: true, onClose: () => setOpenFile(false), className: "offcanvas-file", children: _jsxs("div", { className: "drawer-container", children: [_jsxs("div", { className: "tabs-col", children: [_jsxs("div", { className: "nav-item-close", onClick: () => setOpenFile(false), children: [_jsx("span", { className: "nav-link-icon", children: _jsx(Icon, { name: "arrow_circle_left" }) }), _jsx("span", { className: "title", children: t('menu.label.close') })] }), _jsx(Tabs, { orientation: "vertical", value: activeKey, onChange: handleTabChange, className: "nav", children: fileItems.map((item, idx) => (_jsx(Tab, { value: item.eventKey, label: _jsxs(_Fragment, { children: [_jsx("span", { className: "nav-link-icon", children: _jsx(Icon, { name: item.icon, filled: true }) }), _jsx("span", { className: "title", children: t(item.title) })] }) }, idx.valueOf()))) })] }), _jsxs("div", { className: "info-col", children: [activeKey === 'home' && (_jsx(Info, { document: document, categoriesHierarchy: categoriesHierarchy, handleChange: (updated) => {
|
|
58
|
+
handleChange(updated);
|
|
59
|
+
setDocument(updated);
|
|
60
|
+
} })), activeKey === 'metadata' && (_jsx(DocumentMetadata, { document: document, onDocumentChange: (updated) => {
|
|
61
|
+
handleChange(updated);
|
|
62
|
+
setDocument(updated);
|
|
63
|
+
} })), activeKey === 'lexicon' && _jsx(DocumentLexicon, { document: document }), activeKey === 'export' && _jsx(DocumentExport, { doc: document }), activeKey === 'actions' && (_jsx(Actions, { document: document, setOpenFile: setOpenFile, setFilter: setFilter, handleClickDocument: handleClickDocument, useGrid: useGrid })), activeKey === 'pages' && renderPages(), activeKey === 'gallery' && (_jsx(ImageGallery, { document: document, setDocument: setDocument, handleChange: handleChange })), activeKey === 'participants' && (_jsx(Participants, { document: document.uid, participants: document.participants || [], onChange: (r) => setDocument({ ...document, participants: r }), useChat: hasParameter(getCorpus(), 'useParticipantChat') })), activeKey === 'github' && (_jsx(Github, { document: document, setOpenFile: setOpenFile }))] })] }) }));
|
|
64
|
+
}
|
|
65
|
+
const baseFileItems = [
|
|
66
|
+
{
|
|
67
|
+
eventKey: 'home',
|
|
68
|
+
icon: 'home',
|
|
69
|
+
title: 'menu.label.home',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
eventKey: 'actions',
|
|
73
|
+
icon: 'manufacturing',
|
|
74
|
+
title: 'menu.label.actions',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
eventKey: 'pages',
|
|
78
|
+
icon: 'article',
|
|
79
|
+
title: 'menu.label.pages',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
eventKey: 'gallery',
|
|
83
|
+
icon: 'photo_library',
|
|
84
|
+
title: 'menu.label.images',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
eventKey: 'metadata',
|
|
88
|
+
icon: 'bookmark',
|
|
89
|
+
title: 'menu.label.metadata',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
eventKey: 'lexicon',
|
|
93
|
+
icon: 'sort_by_alpha',
|
|
94
|
+
title: 'menu.label.lexicon',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
eventKey: 'export',
|
|
98
|
+
icon: 'file_export',
|
|
99
|
+
title: 'menu.label.export',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
eventKey: 'participants',
|
|
103
|
+
icon: 'group',
|
|
104
|
+
title: 'menu.label.participants',
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
const githubFileItem = {
|
|
108
|
+
eventKey: 'github',
|
|
109
|
+
icon: 'code',
|
|
110
|
+
title: 'menu.label.github',
|
|
111
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DocumentStatus } from '../../../configs/types/Document';
|
|
2
|
+
import Category from '../types/Category';
|
|
3
|
+
import { TFunction } from 'i18next';
|
|
4
|
+
import { AppFormField, Document, PlatformTools, yup } from '../deps';
|
|
5
|
+
declare const baseFormSchema: yup.ObjectSchema<{
|
|
6
|
+
name: string;
|
|
7
|
+
translated: string;
|
|
8
|
+
author: string;
|
|
9
|
+
reference: string;
|
|
10
|
+
description: string;
|
|
11
|
+
category: string;
|
|
12
|
+
status: NonNullable<DocumentStatus | undefined>;
|
|
13
|
+
visible: NonNullable<boolean | undefined>;
|
|
14
|
+
defaultTool: NonNullable<PlatformTools | undefined>;
|
|
15
|
+
}, yup.AnyObject, {
|
|
16
|
+
name: undefined;
|
|
17
|
+
translated: "";
|
|
18
|
+
author: "";
|
|
19
|
+
reference: "";
|
|
20
|
+
description: "";
|
|
21
|
+
category: "";
|
|
22
|
+
status: undefined;
|
|
23
|
+
visible: undefined;
|
|
24
|
+
defaultTool: undefined;
|
|
25
|
+
}, "">;
|
|
26
|
+
export type DocumentEditFormValues = yup.InferType<typeof baseFormSchema>;
|
|
27
|
+
type Props = {
|
|
28
|
+
document: Document;
|
|
29
|
+
categoriesHierarchy: Category[];
|
|
30
|
+
onClose: () => void;
|
|
31
|
+
onSave: (document: Document) => void;
|
|
32
|
+
};
|
|
33
|
+
export default function DocumentEdit({ document, categoriesHierarchy, onClose, onSave, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export declare const getDocumentFields: (categories: Category[], t: TFunction) => AppFormField[];
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import documentService from '../services/DocumentService';
|
|
3
|
+
import { DocumentStatusNames, } from '../../../configs/types/Document';
|
|
4
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
5
|
+
import { useForm } from 'react-hook-form';
|
|
6
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
7
|
+
import { AppForm, AppModal, AppModalConfirm, DateUtils, EDITION_TOOLS, FormUtils, ToolsUtils, UsabilityUtils, useCorpusUtils, useMessageUtils, yupResolver, yup, } from '../deps';
|
|
8
|
+
const baseFormSchema = yup.object({
|
|
9
|
+
name: yup.string().trim().required(),
|
|
10
|
+
translated: yup.string().default(''),
|
|
11
|
+
author: yup.string().default(''),
|
|
12
|
+
reference: yup.string().default(''),
|
|
13
|
+
description: yup.string().default(''),
|
|
14
|
+
category: yup.string().default(''),
|
|
15
|
+
status: yup
|
|
16
|
+
.mixed()
|
|
17
|
+
.oneOf(['EDITING', 'EDITED', 'SYNTACTIC', 'COMPLETED'])
|
|
18
|
+
.required(),
|
|
19
|
+
visible: yup.boolean().required(),
|
|
20
|
+
defaultTool: yup.mixed().required(),
|
|
21
|
+
});
|
|
22
|
+
export default function DocumentEdit({ document, categoriesHierarchy, onClose, onSave, }) {
|
|
23
|
+
const { t } = useTranslation(['document', 'actions']);
|
|
24
|
+
const { dispatchMessage, dispatchError, dispatchLoading, isLoading } = useMessageUtils();
|
|
25
|
+
const { getCorpus, hasParameter } = useCorpusUtils();
|
|
26
|
+
const [openToolWarning, setOpenToolWarning] = useState(false);
|
|
27
|
+
const [pendingValues, setPendingValues] = useState(null);
|
|
28
|
+
const enabledToolNames = useMemo(() => {
|
|
29
|
+
const corpus = getCorpus();
|
|
30
|
+
if (!corpus)
|
|
31
|
+
return [];
|
|
32
|
+
const names = EDITION_TOOLS.filter((tool) => hasParameter(corpus, tool.parameter)).map((tool) => tool.name);
|
|
33
|
+
if (document.defaultTool && !names.includes(document.defaultTool)) {
|
|
34
|
+
return [...names, document.defaultTool];
|
|
35
|
+
}
|
|
36
|
+
return names;
|
|
37
|
+
}, [document.defaultTool, getCorpus, hasParameter]);
|
|
38
|
+
const formSchema = useMemo(() => baseFormSchema.shape({
|
|
39
|
+
defaultTool: yup
|
|
40
|
+
.mixed()
|
|
41
|
+
.oneOf(enabledToolNames)
|
|
42
|
+
.required(),
|
|
43
|
+
}), [enabledToolNames]);
|
|
44
|
+
const form = useForm({
|
|
45
|
+
resolver: yupResolver(formSchema),
|
|
46
|
+
mode: 'onChange',
|
|
47
|
+
defaultValues: {
|
|
48
|
+
name: document.name ?? '',
|
|
49
|
+
translated: document.translated ?? '',
|
|
50
|
+
author: document.author ?? '',
|
|
51
|
+
reference: document.reference ?? '',
|
|
52
|
+
description: document.description ?? '',
|
|
53
|
+
category: document.category ?? '',
|
|
54
|
+
status: document.status,
|
|
55
|
+
visible: document.visible ?? false,
|
|
56
|
+
defaultTool: document.defaultTool ?? 'EDICTOR',
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
const { formState } = form;
|
|
60
|
+
const isBusy = isLoading();
|
|
61
|
+
const performUpdate = (values) => {
|
|
62
|
+
const payload = { ...values };
|
|
63
|
+
const toolChanged = values.defaultTool !== document.defaultTool;
|
|
64
|
+
dispatchLoading(true);
|
|
65
|
+
documentService
|
|
66
|
+
.update(document.uid, payload)
|
|
67
|
+
.then(() => {
|
|
68
|
+
dispatchMessage({ key: 'update.success', t });
|
|
69
|
+
if (toolChanged) {
|
|
70
|
+
return documentService.get(document.uid).then((r) => r.data);
|
|
71
|
+
}
|
|
72
|
+
return { ...document, ...values };
|
|
73
|
+
})
|
|
74
|
+
.then((updated) => {
|
|
75
|
+
onSave(updated);
|
|
76
|
+
onClose();
|
|
77
|
+
})
|
|
78
|
+
.catch((err) => {
|
|
79
|
+
dispatchError({ err, t });
|
|
80
|
+
})
|
|
81
|
+
.finally(() => {
|
|
82
|
+
dispatchLoading(false);
|
|
83
|
+
setOpenToolWarning(false);
|
|
84
|
+
setPendingValues(null);
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
const onSubmit = (values) => {
|
|
88
|
+
if (isBusy)
|
|
89
|
+
return;
|
|
90
|
+
if (document.defaultTool === 'DESIGN' &&
|
|
91
|
+
values.defaultTool !== 'DESIGN') {
|
|
92
|
+
setPendingValues(values);
|
|
93
|
+
setOpenToolWarning(true);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
performUpdate(values);
|
|
97
|
+
};
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
UsabilityUtils.attachCloseToEscape(onClose);
|
|
100
|
+
}, [onClose]);
|
|
101
|
+
const defaultToolField = useMemo(() => {
|
|
102
|
+
if (enabledToolNames.length === 0)
|
|
103
|
+
return undefined;
|
|
104
|
+
const options = EDITION_TOOLS.filter((tool) => enabledToolNames.includes(tool.name)).map((tool) => ({
|
|
105
|
+
value: tool.name,
|
|
106
|
+
label: t(tool.title),
|
|
107
|
+
}));
|
|
108
|
+
return {
|
|
109
|
+
attr: 'defaultTool',
|
|
110
|
+
name: t('document.field.defaultTool'),
|
|
111
|
+
type: 'select',
|
|
112
|
+
required: false,
|
|
113
|
+
options,
|
|
114
|
+
};
|
|
115
|
+
}, [enabledToolNames, t]);
|
|
116
|
+
const { mainFields, categoryField } = useMemo(() => {
|
|
117
|
+
const all = getDocumentFields(categoriesHierarchy, t);
|
|
118
|
+
const hasCategories = (categoriesHierarchy?.length ?? 0) > 0;
|
|
119
|
+
const filtered = all.filter((field) => field.attr !== 'id' &&
|
|
120
|
+
field.attr !== 'category' &&
|
|
121
|
+
field.attr !== 'defaultTool');
|
|
122
|
+
const fields = [...filtered];
|
|
123
|
+
if (defaultToolField) {
|
|
124
|
+
const visibleIdx = fields.findIndex((f) => f.attr === 'visible');
|
|
125
|
+
const insertAt = visibleIdx >= 0 ? visibleIdx + 1 : fields.length;
|
|
126
|
+
fields.splice(insertAt, 0, defaultToolField);
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
mainFields: fields,
|
|
130
|
+
categoryField: hasCategories
|
|
131
|
+
? all.find((field) => field.attr === 'category')
|
|
132
|
+
: undefined,
|
|
133
|
+
};
|
|
134
|
+
}, [categoriesHierarchy, t, defaultToolField]);
|
|
135
|
+
return (_jsxs(_Fragment, { children: [_jsx(AppModal, { title: t('document.modal.edit.title'), className: "modal-document-edit", close: onClose, confirm: form.handleSubmit(onSubmit), disableConfirm: !formState.isValid || isBusy, children: _jsxs("div", { style: {
|
|
136
|
+
display: 'flex',
|
|
137
|
+
flexDirection: 'column',
|
|
138
|
+
gap: 16,
|
|
139
|
+
}, children: [_jsx(AppForm, { fields: mainFields, form: form, twoColumns: true }), categoryField && (_jsx("div", { className: "document-edit-category-full-width", children: _jsx(AppForm, { fields: [categoryField], form: form }) }))] }) }), openToolWarning && (_jsx(AppModalConfirm, { title: t('modal.title.design', { ns: 'actions' }), subtitle: _jsx(Trans, { t: t, ns: "actions", i18nKey: "modal.description.design", components: { bold: _jsx("b", { className: "bold" }) } }), onClose: () => {
|
|
140
|
+
setOpenToolWarning(false);
|
|
141
|
+
setPendingValues(null);
|
|
142
|
+
}, onConfirm: () => pendingValues && performUpdate(pendingValues) }))] }));
|
|
143
|
+
}
|
|
144
|
+
export const getDocumentFields = (categories, t) => [
|
|
145
|
+
{
|
|
146
|
+
attr: 'name',
|
|
147
|
+
name: t('document.field.name'),
|
|
148
|
+
type: 'text',
|
|
149
|
+
required: false,
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
attr: 'translated',
|
|
153
|
+
name: t('document.field.translated'),
|
|
154
|
+
type: 'text',
|
|
155
|
+
required: false,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
attr: 'author',
|
|
159
|
+
name: t('document.field.author'),
|
|
160
|
+
type: 'text',
|
|
161
|
+
required: false,
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
attr: 'reference',
|
|
165
|
+
name: t('document.field.reference'),
|
|
166
|
+
type: 'text',
|
|
167
|
+
required: false,
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
attr: 'category',
|
|
171
|
+
name: t('document.field.category'),
|
|
172
|
+
type: 'select',
|
|
173
|
+
required: false,
|
|
174
|
+
options: FormUtils.convertList(categories, 'name', 'uid'),
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
attr: 'status',
|
|
178
|
+
name: t('document.field.status'),
|
|
179
|
+
type: 'select',
|
|
180
|
+
required: false,
|
|
181
|
+
options: FormUtils.convertEnum(DocumentStatusNames, t, 'common'),
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
attr: 'visible',
|
|
185
|
+
name: t('document.field.visible'),
|
|
186
|
+
type: 'switch',
|
|
187
|
+
required: false,
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
attr: 'description',
|
|
191
|
+
name: t('document.field.description'),
|
|
192
|
+
type: 'textarea',
|
|
193
|
+
required: false,
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
attr: 'defaultTool',
|
|
197
|
+
name: t('document.field.defaultTool'),
|
|
198
|
+
type: 'function',
|
|
199
|
+
fn: (tool) => t(ToolsUtils.getTitle(tool)),
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
attr: 'id',
|
|
203
|
+
name: t('document.field.inc'),
|
|
204
|
+
type: 'function',
|
|
205
|
+
fn: (id) => DateUtils.extractDateFromMongoId(id, true),
|
|
206
|
+
},
|
|
207
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './DocumentEdit';
|