@topconsultnpm/sdkui-react 6.21.0-dev2.6 → 6.21.0-dev2.8

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.
@@ -5,6 +5,7 @@ interface TMBlogAttachmentsProps {
5
5
  layoutMode: "compact" | "extended";
6
6
  attachments: Array<BlogPostAttachment>;
7
7
  isSelected: boolean;
8
+ isLoading?: boolean;
8
9
  searchText: string;
9
10
  dcmtTypeDescriptors: Map<number, DcmtTypeDescriptor>;
10
11
  treeFs: FileItem | undefined;
@@ -1,10 +1,10 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { SDK_Globals } from "@topconsultnpm/sdk-ts";
3
3
  import { getAttachmentInfo, lightenColor, removeFileExtension } from "./TMBlogsPostUtils";
4
4
  import TMDcmtIcon from "../features/documents/TMDcmtIcon";
5
5
  import { IconAttachment } from "../../helper";
6
6
  const TMBlogAttachments = (props) => {
7
- const { layoutMode, attachments, isSelected, searchText, dcmtTypeDescriptors, treeFs, draftLatestInfoMap, archivedDocumentMap, handleAttachmentFocus, openDcmtForm } = props;
7
+ const { layoutMode, attachments, isSelected, isLoading = false, searchText, dcmtTypeDescriptors, treeFs, draftLatestInfoMap, archivedDocumentMap, handleAttachmentFocus, openDcmtForm } = props;
8
8
  const handleMouseEnter = (e, blogPostAttachment, name, fileExt) => {
9
9
  e.currentTarget.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.15)';
10
10
  e.currentTarget.style.backgroundColor = isSelected ? lightenColor("#135596", 40) : '#cfcfcf';
@@ -24,7 +24,7 @@ const TMBlogAttachments = (props) => {
24
24
  };
25
25
  return _jsx("div", { style: { width: "100%", marginTop: "5px", overflow: "hidden" }, children: attachments.map((blogPostAttachment, index) => {
26
26
  const { name, nameElement, tooltipContent, fileExt, archivedDocumentsExist, draftExist } = getAttachmentInfo(blogPostAttachment, treeFs, draftLatestInfoMap, archivedDocumentMap, dcmtTypeDescriptors, isSelected, searchText);
27
- return _jsx("div", { onDoubleClick: (e) => onDoubleClick(e, blogPostAttachment, name, fileExt), onMouseEnter: (e) => handleMouseEnter(e, blogPostAttachment, name, fileExt), onMouseLeave: (e) => handleMouseLeave(e), style: {
27
+ return _jsx("div", { onDoubleClick: (e) => !isLoading && onDoubleClick(e, blogPostAttachment, name, fileExt), onMouseEnter: (e) => !isLoading && handleMouseEnter(e, blogPostAttachment, name, fileExt), onMouseLeave: (e) => !isLoading && handleMouseLeave(e), style: {
28
28
  display: layoutMode === "extended" ? "inline-flex" : "flex",
29
29
  padding: '4px 8px',
30
30
  margin: '4px',
@@ -32,17 +32,43 @@ const TMBlogAttachments = (props) => {
32
32
  borderRadius: '8px',
33
33
  boxShadow: '0 2px 4px rgba(0, 0, 0, 0.1)',
34
34
  backgroundColor: isSelected ? "#135596" : "#ffffff",
35
- cursor: "pointer",
35
+ cursor: isLoading ? "default" : "pointer",
36
36
  fontSize: '0.9rem',
37
37
  color: isSelected ? "#ffffff" : "#000000",
38
- }, children: _jsxs("div", { style: { alignItems: 'center', display: 'flex', minWidth: 0 }, children: [(!archivedDocumentsExist && !draftExist) ?
39
- _jsx(IconAttachment, { style: { marginRight: "5px", flexShrink: 0 } }) :
40
- _jsx("div", { style: { marginRight: "10px", flexShrink: 0 }, children: _jsx(TMDcmtIcon, { tid: blogPostAttachment.tid, did: blogPostAttachment.did, fileExtension: fileExt, downloadMode: 'openInNewWindow', tooltipContent: tooltipContent }) }), _jsx("span", { title: layoutMode === 'compact' ? name + " (DID: " + blogPostAttachment.did + ")" : undefined, style: {
41
- whiteSpace: 'nowrap',
42
- overflow: 'hidden',
43
- textOverflow: 'ellipsis',
44
- minWidth: 0,
45
- }, children: nameElement })] }) }, blogPostAttachment.did + "_" + index);
38
+ }, children: _jsx("div", { style: { alignItems: 'center', display: 'flex', minWidth: 0 }, children: isLoading ? (_jsxs(_Fragment, { children: [_jsx("div", { style: {
39
+ width: '16px',
40
+ height: '16px',
41
+ marginRight: '8px',
42
+ border: '2px solid #ddd',
43
+ borderTop: `2px solid ${isSelected ? '#fff' : '#135596'}`,
44
+ borderRadius: '50%',
45
+ animation: 'spin 1s linear infinite',
46
+ flexShrink: 0,
47
+ } }), _jsx("span", { style: {
48
+ background: isSelected ? 'rgba(255,255,255,0.3)' : 'linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%)',
49
+ backgroundSize: '200% 100%',
50
+ animation: 'shimmer 1.5s infinite',
51
+ borderRadius: '4px',
52
+ width: '120px',
53
+ height: '14px',
54
+ display: 'inline-block',
55
+ } }), _jsx("style", { children: `
56
+ @keyframes spin {
57
+ 0% { transform: rotate(0deg); }
58
+ 100% { transform: rotate(360deg); }
59
+ }
60
+ @keyframes shimmer {
61
+ 0% { background-position: -200% 0; }
62
+ 100% { background-position: 200% 0; }
63
+ }
64
+ ` })] })) : (_jsxs(_Fragment, { children: [(!archivedDocumentsExist && !draftExist) ?
65
+ _jsx(IconAttachment, { style: { marginRight: "5px", flexShrink: 0 } }) :
66
+ _jsx("div", { style: { marginRight: "10px", flexShrink: 0 }, children: _jsx(TMDcmtIcon, { tid: blogPostAttachment.tid, did: blogPostAttachment.did, fileExtension: fileExt, downloadMode: 'openInNewWindow', tooltipContent: tooltipContent }) }), _jsx("span", { title: layoutMode === 'compact' ? name + " (DID: " + blogPostAttachment.did + ")" : undefined, style: {
67
+ whiteSpace: 'nowrap',
68
+ overflow: 'hidden',
69
+ textOverflow: 'ellipsis',
70
+ minWidth: 0,
71
+ }, children: nameElement })] })) }) }, blogPostAttachment.did + "_" + index);
46
72
  }) });
47
73
  };
48
74
  export default TMBlogAttachments;
@@ -48,6 +48,7 @@ const TMBlogsPost = (props) => {
48
48
  const [firstUnreadPost, setFirstUnreadPost] = useState(undefined);
49
49
  // State to manage the focused file
50
50
  const [dcmtTypeDescriptors, setDcmtTypeDescriptors] = useState(new Map());
51
+ const [descriptorsLoaded, setDescriptorsLoaded] = useState(false);
51
52
  const [currentHeader, setCurrentHeader] = useState(header);
52
53
  const [isHeaderHidden, setIsHeaderHidden] = useState(isHeaderFullyHidden(currentHeader));
53
54
  const [localShowId, setLocalShowId] = useState(false);
@@ -147,8 +148,13 @@ const TMBlogsPost = (props) => {
147
148
  useEffect(() => {
148
149
  (async () => {
149
150
  if (showExtendedAttachments) {
151
+ setDescriptorsLoaded(false);
150
152
  const descriptors = await getDcmtTypeDescriptor(posts);
151
153
  setDcmtTypeDescriptors(descriptors);
154
+ setDescriptorsLoaded(true);
155
+ }
156
+ else {
157
+ setDescriptorsLoaded(true);
152
158
  }
153
159
  const publishedBlogssLength = posts.filter(newsFeed => newsFeed.isSys !== 1 && newsFeed.isDel !== 1).length;
154
160
  const systemBlogsLength = posts.filter(newsFeed => newsFeed.isSys === 1).length;
@@ -679,7 +685,7 @@ const TMBlogsPost = (props) => {
679
685
  textDecoration: blogPost.isDel ? 'line-through' : 'none',
680
686
  boxShadow: isFocused ? "0 4px 12px rgba(19, 85, 150, 0.6)" : "none",
681
687
  cursor: 'pointer',
682
- }, children: [_jsx(BlogPostTitle, { displayMode: displayMode, layoutMode: layoutMode, blogPost: blogPost, isSelected: isSelected, isOwnComment: isOwnComment, searchText: searchText, isSys: isSys, isHomeBlogPost: isHomeBlogPost, showId: localShowId, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }), isNew && _jsx(NewBadge, { layoutMode: layoutMode }), _jsx("div", { style: { fontSize: '1rem', color: "#000", marginTop: "10px", overflow: "hidden" }, children: _jsx(TMHtmlContentDisplay, { markup: blogPost.description ?? '-', searchText: searchText, isSelected: isSelected }) }), showExtendedAttachments && blogPost.attachments && blogPost.attachments.length > 0 && (_jsx(TMBlogAttachments, { attachments: blogPost.attachments, layoutMode: layoutMode, isSelected: isSelected, searchText: searchText, dcmtTypeDescriptors: dcmtTypeDescriptors, treeFs: treeFs, draftLatestInfoMap: draftLatestInfoMap, archivedDocumentMap: archivedDocumentMap, handleAttachmentFocus: handleFocusedAttachment, openDcmtForm: openDcmtForm }))] }, `${id}-blogpost-${blogPost.id}`) })] }, "blog-post-wrapper-" + id + "-" + blogPost.id);
688
+ }, children: [_jsx(BlogPostTitle, { displayMode: displayMode, layoutMode: layoutMode, blogPost: blogPost, isSelected: isSelected, isOwnComment: isOwnComment, searchText: searchText, isSys: isSys, isHomeBlogPost: isHomeBlogPost, showId: localShowId, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers }), isNew && _jsx(NewBadge, { layoutMode: layoutMode }), _jsx("div", { style: { fontSize: '1rem', color: "#000", marginTop: "10px", overflow: "hidden" }, children: _jsx(TMHtmlContentDisplay, { markup: blogPost.description ?? '-', searchText: searchText, isSelected: isSelected }) }), showExtendedAttachments && blogPost.attachments && blogPost.attachments.length > 0 && (_jsx(TMBlogAttachments, { attachments: blogPost.attachments, layoutMode: layoutMode, isSelected: isSelected, isLoading: !descriptorsLoaded, searchText: searchText, dcmtTypeDescriptors: dcmtTypeDescriptors, treeFs: treeFs, draftLatestInfoMap: draftLatestInfoMap, archivedDocumentMap: archivedDocumentMap, handleAttachmentFocus: handleFocusedAttachment, openDcmtForm: openDcmtForm }))] }, `${id}-blogpost-${blogPost.id}`) })] }, "blog-post-wrapper-" + id + "-" + blogPost.id);
683
689
  }), _jsx("div", { ref: bottomRef })] }), _jsx(TMContextMenu, { items: menuItems, target: `#${id}-blogs-wrapper`, externalControl: {
684
690
  visible: menuVisible,
685
691
  position: menuPosition,
@@ -142,27 +142,21 @@ export const getAttachmentInfo = (attachment, treeFs, draftLatestInfoMap, archiv
142
142
  return { name, nameElement, tooltipContent, folderId, fileExt, draftExist, archivedDocumentsExist };
143
143
  };
144
144
  export const getDcmtTypeDescriptor = async (blogPosts) => {
145
- // Create a Map to store tid as key and DcmtTypeDescriptor as value
146
145
  const dcmtTypeMap = new Map();
147
- // Collect unique tids first to avoid duplicate HTTP calls
148
- const uniqueTids = new Set();
149
- for (const blogPost of blogPosts) {
150
- if (blogPost.attachments) {
151
- for (const attachment of blogPost.attachments) {
152
- if (attachment.tid) {
153
- uniqueTids.add(attachment.tid);
154
- }
155
- }
146
+ // Collect unique tid-did pairs to avoid duplicate HTTP calls
147
+ const tidDidMap = new Map();
148
+ for (const { tid, did } of blogPosts.flatMap(bp => bp.attachments ?? [])) {
149
+ if (tid !== undefined && !tidDidMap.has(tid)) {
150
+ tidDidMap.set(tid, did);
156
151
  }
157
152
  }
158
- // Fetch all descriptors in parallel instead of sequentially
159
- const promises = Array.from(uniqueTids).map(async (tid) => {
160
- const dcmtTypeDescriptor = await DcmtTypeListCacheService.GetAsync(tid, true);
161
- if (dcmtTypeDescriptor) {
162
- dcmtTypeMap.set(tid, dcmtTypeDescriptor);
153
+ // Fetch all descriptors in parallel
154
+ await Promise.all(Array.from(tidDidMap.entries()).map(async ([tid, did]) => {
155
+ const descriptor = await DcmtTypeListCacheService.GetWithNotGrantedAsync(tid, did);
156
+ if (descriptor) {
157
+ dcmtTypeMap.set(tid, descriptor);
163
158
  }
164
- });
165
- await Promise.all(promises);
159
+ }));
166
160
  return dcmtTypeMap;
167
161
  };
168
162
  export const BlogPostHomeHeader = (header, classId, isSelected, searchText, headerClickCallback) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.21.0-dev2.6",
3
+ "version": "6.21.0-dev2.8",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",