@topconsultnpm/sdkui-react-beta 6.12.152 → 6.12.153

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.
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { BlogPost, HomeBlogPost, IDCount, UserDescriptor, WorkingGroupDescriptor } from "@topconsultnpm/sdk-ts-beta";
3
3
  import { FileItem } from '../base/TMFileManager';
4
+ import { DcmtInfo } from '../../ts';
4
5
  interface TMBlogsProps {
5
6
  /** Component Identifier */
6
7
  id: string;
@@ -66,6 +67,7 @@ interface TMBlogsProps {
66
67
  isDownloadAttachmentEnabled: boolean;
67
68
  isViewEditMetadata: boolean;
68
69
  isDeleteEnabled: boolean;
70
+ isCopyToClipboardEnabled: boolean;
69
71
  isRestoreEnabled: boolean;
70
72
  isRefreshEnabled: boolean;
71
73
  isCreateContextualTask: boolean;
@@ -81,6 +83,8 @@ interface TMBlogsProps {
81
83
  showTaskFormCallback?: () => void;
82
84
  /** Optional Whether to enable the context menu */
83
85
  showContextMenu?: boolean;
86
+ /** Optional handle attachment focus functon */
87
+ handleAttachmentFocus?: (attachment: DcmtInfo | undefined) => void;
84
88
  }
85
89
  declare const TMBlogs: (props: TMBlogsProps) => import("react/jsx-runtime").JSX.Element;
86
90
  export default TMBlogs;
@@ -26,10 +26,11 @@ const TMBlogs = (props) => {
26
26
  isDownloadAttachmentEnabled: false,
27
27
  isViewEditMetadata: false,
28
28
  isDeleteEnabled: false,
29
+ isCopyToClipboardEnabled: false,
29
30
  isRestoreEnabled: false,
30
31
  isRefreshEnabled: false,
31
32
  isCreateContextualTask: false,
32
- }, refreshCallback, newPosts = [], showCommentFormCallback, showTaskFormCallback, showContextMenu = true } = props;
33
+ }, refreshCallback, newPosts = [], showCommentFormCallback, showTaskFormCallback, showContextMenu = true, handleAttachmentFocus } = props;
33
34
  // Get the current device type (e.g., mobile, tablet, desktop) using a custom hook.
34
35
  const deviceType = useDeviceType();
35
36
  const { abortController, showWaitPanel, waitPanelTitle, showPrimary, waitPanelTextPrimary, waitPanelValuePrimary, waitPanelMaxValuePrimary, showSecondary, waitPanelTextSecondary, waitPanelValueSecondary, waitPanelMaxValueSecondary, downloadDcmtsAsync } = useDcmtOperations();
@@ -152,10 +153,14 @@ const TMBlogs = (props) => {
152
153
  };
153
154
  const handleFocusedAttachment = (attachment) => {
154
155
  setFocusedAttachment(attachment);
156
+ if (handleAttachmentFocus)
157
+ handleAttachmentFocus(attachment);
155
158
  };
156
159
  const handleFocusedBlog = (blog) => {
157
160
  setFocusedBlog(blog);
158
161
  setFocusedAttachment(undefined);
162
+ if (handleAttachmentFocus)
163
+ handleAttachmentFocus(undefined);
159
164
  };
160
165
  const refresh = () => {
161
166
  if (refreshCallback)
@@ -167,6 +172,24 @@ const TMBlogs = (props) => {
167
172
  if (downloadDcmtsAsync)
168
173
  downloadDcmtsAsync([{ TID: focusedAttachment.TID, DID: focusedAttachment.DID, fileName: focusedAttachment.fileName }], DownloadTypes.Dcmt);
169
174
  };
175
+ const copyInClipboard = (blog) => {
176
+ if (blog === undefined)
177
+ return;
178
+ const { id, ownerName, creationTime, description } = blog;
179
+ const cleanDescription = description ? description.replace(/<[^>]*>/g, '') : '';
180
+ const formattedText = `${ownerName} (${Globalization.getDateTimeDisplayValue(creationTime)}):\n${cleanDescription}`;
181
+ let result = [];
182
+ window.navigator.clipboard.writeText(formattedText)
183
+ .then(() => {
184
+ result = [{ rowIndex: id ?? 1, id1: id ?? 1, id2: id ?? 1, description: SDKUI_Localizator.UpdateCompletedSuccessfully, resultType: ResultTypes.SUCCESS }];
185
+ })
186
+ .catch(err => {
187
+ result = [{ rowIndex: id ?? 1, id1: id ?? 1, id2: id ?? 1, resultType: ResultTypes.ERROR, description: getExceptionMessage(err) }];
188
+ })
189
+ .finally(() => {
190
+ TMResultManager.show(result, SDKUI_Localizator.CopyToClipboard, "ID", undefined);
191
+ });
192
+ };
170
193
  // ContexMenuItems array contains a list of context menu items for a blog
171
194
  const contextMenuItems = useMemo(() => {
172
195
  let menuItemsElements = [
@@ -200,6 +223,13 @@ const TMBlogs = (props) => {
200
223
  disabled: focusedBlog?.ownerID !== SDK_Globals.tmSession?.SessionDescr?.userID || focusedBlog === undefined || (focusedBlog && (focusedBlog.isDel !== undefined && focusedBlog.isDel !== 0)),
201
224
  beginGroup: true
202
225
  },
226
+ {
227
+ text: SDKUI_Localizator.CopyToClipboard,
228
+ visible: contextMenuParams.isCopyToClipboardEnabled,
229
+ icon: 'copy',
230
+ disabled: focusedBlog === undefined,
231
+ onClick: () => { copyInClipboard(focusedBlog); }
232
+ },
203
233
  {
204
234
  icon: "undo",
205
235
  text: SDKUI_Localizator.Restore,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.12.152",
3
+ "version": "6.12.153",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",