directual-web-components-v2 3.11.323 → 3.11.324

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.
@@ -1824,7 +1824,9 @@ const dict = {
1824
1824
  assignedToMe: "Assigned to me",
1825
1825
  assignedTo: "Assigned to",
1826
1826
  taskResolved: "Task is resolved",
1827
- resolveTask: "Resolve task"
1827
+ resolveTask: "Resolve task",
1828
+ edit: "Edit",
1829
+ save: "Save"
1828
1830
  },
1829
1831
  sortField: 'Sort field',
1830
1832
  error: 'Error',
@@ -2317,7 +2319,9 @@ const dict = {
2317
2319
  assignedToMe: "Назначено на меня",
2318
2320
  assignedTo: "Назначено на",
2319
2321
  taskResolved: "Задача закрыта",
2320
- resolveTask: "Закрыть задачу"
2322
+ resolveTask: "Закрыть задачу",
2323
+ edit: "Редактировать",
2324
+ save: "Сохранить"
2321
2325
  },
2322
2326
  success: 'Успех',
2323
2327
  "auth": {
@@ -26323,6 +26327,7 @@ function Comments(props) {
26323
26327
  }
26324
26328
  const allowAttachment = _$1.includes(data.writeFields, _$1.get(data, "params._fileField"));
26325
26329
  const allowSend = _$1.includes(data.writeFields, _$1.get(data, "params._textField"));
26330
+ const allowEdit = _$1.get(data, "params.general.allowEdit");
26326
26331
  return /*#__PURE__*/React.createElement("div", {
26327
26332
  className: styles$N.comments + " FPS_COMMENTS"
26328
26333
  }, /*#__PURE__*/React.createElement(CommentsHeader, _extends({
@@ -26343,6 +26348,7 @@ function Comments(props) {
26343
26348
  sendComment: sendComment,
26344
26349
  lang: lang,
26345
26350
  allowSend: allowSend,
26351
+ allowEdit: allowEdit,
26346
26352
  loading: loading,
26347
26353
  allowAttachment: allowAttachment,
26348
26354
  comments: comments,
@@ -26359,9 +26365,16 @@ function Comment(props) {
26359
26365
  comments,
26360
26366
  parent,
26361
26367
  allowSend,
26368
+ allowEdit,
26362
26369
  sendComment
26363
26370
  } = props;
26364
26371
  const [addReply, setAddReply] = useState(false);
26372
+ const [isEditing, setIsEditing] = useState(false);
26373
+ const [editText, setEditText] = useState("");
26374
+ useEffect(() => {
26375
+ const commentText = _$1.get(comment, _$1.get(data, "params._textField"));
26376
+ setEditText(commentText || "");
26377
+ }, [_$1.get(comment, _$1.get(data, "params._textField"))]);
26365
26378
  const formatDate = (value, formatOptions) => {
26366
26379
  if (!value) {
26367
26380
  return null;
@@ -26395,6 +26408,7 @@ function Comment(props) {
26395
26408
  }
26396
26409
  const isTask = !!_$1.get(comment, _$1.get(data, "params.assignmentOn_assignee"));
26397
26410
  const isAssignedToMe = (_$1.get(auth, "user") == _$1.get(comment, _$1.get(data, "params.assignmentOn_assignee")) || _$1.get(auth, "user") == _$1.get(comment, _$1.get(data, "params.assignmentOn_assignee") + ".id")) && _$1.get(auth, "isAuth");
26411
+ const isAuthor = (_$1.get(auth, "user") == _$1.get(comment, _$1.get(data, "params._userField")) || _$1.get(auth, "user") == _$1.get(comment, _$1.get(data, "params._userField") + ".id")) && _$1.get(auth, "isAuth");
26398
26412
  const assigneName = isTask ? _$1.get(comment, _$1.get(data, "params.assignmentOn_assignee") + ".firstName") ? _$1.get(comment, _$1.get(data, "params.assignmentOn_assignee") + ".firstName") + ' ' + _$1.get(comment, _$1.get(data, "params.assignmentOn_assignee") + ".lastName") : _$1.get(comment, _$1.get(data, "params.assignmentOn_assignee") + ".id") || _$1.get(comment, _$1.get(data, "params.assignmentOn_assignee")) : '';
26399
26413
  const isResoled = isTask && _$1.get(comment, _$1.get(data, "params.assignmentOn_bool"));
26400
26414
  const resolvedDate = _$1.get(comment, _$1.get(data, "params.assignmentOn_dateClosed"));
@@ -26411,6 +26425,22 @@ function Comment(props) {
26411
26425
  _$1.get(data, "params.assignmentOn_dateClosed") && _$1.set(payload, _$1.get(data, "params.assignmentOn_dateClosed"), moment().toISOString());
26412
26426
  sendComment(payload, () => setLocalLoading(false), true);
26413
26427
  };
26428
+ const saveEdit = () => {
26429
+ if (!comment.id) return;
26430
+ setLocalLoading(true);
26431
+ let payload = {
26432
+ id: comment.id
26433
+ };
26434
+ _$1.set(payload, _$1.get(data, "params._textField"), editText);
26435
+ sendComment(payload, () => {
26436
+ setLocalLoading(false);
26437
+ setIsEditing(false);
26438
+ }, true);
26439
+ };
26440
+ const cancelEdit = () => {
26441
+ setEditText(commentText);
26442
+ setIsEditing(false);
26443
+ };
26414
26444
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
26415
26445
  className: styles$N.commentWrapper + " FPS_COMMENT_WRAPPER"
26416
26446
  }, isTask && /*#__PURE__*/React.createElement("div", {
@@ -26442,7 +26472,31 @@ function Comment(props) {
26442
26472
  }
26443
26473
  }, dict[lang].comments.anon), /*#__PURE__*/React.createElement("div", {
26444
26474
  className: styles$N.commentBodyHeaderDate
26445
- }, formatDate(commentDate, formatCommentDate))), /*#__PURE__*/React.createElement("div", {
26475
+ }, formatDate(commentDate, formatCommentDate))), isEditing ? /*#__PURE__*/React.createElement("div", {
26476
+ className: styles$N.commentBodyText
26477
+ }, /*#__PURE__*/React.createElement(Input, {
26478
+ type: "textarea",
26479
+ defaultValue: editText,
26480
+ onChange: setEditText,
26481
+ rows: "auto"
26482
+ }), /*#__PURE__*/React.createElement("div", {
26483
+ style: {
26484
+ marginTop: '8px',
26485
+ display: 'flex',
26486
+ gap: '8px'
26487
+ }
26488
+ }, /*#__PURE__*/React.createElement(Button, {
26489
+ loading: localLoading,
26490
+ onClick: saveEdit,
26491
+ small: true,
26492
+ height: 32,
26493
+ accent: true,
26494
+ disabled: !editText
26495
+ }, dict[lang].comments.save), /*#__PURE__*/React.createElement(Button, {
26496
+ onClick: cancelEdit,
26497
+ small: true,
26498
+ height: 32
26499
+ }, dict[lang].comments.cancel))) : /*#__PURE__*/React.createElement("div", {
26446
26500
  className: styles$N.commentBodyText
26447
26501
  }, commentText), commentAttachment && commentAttachment.length > 0 && commentAttachment.map(file => {
26448
26502
  const fileName = file.split("/")[file.split("/").length - 1];
@@ -26453,12 +26507,15 @@ function Comment(props) {
26453
26507
  href: file,
26454
26508
  className: "icon icon-clip small " + styles$N.commentFileLink
26455
26509
  }, fileName));
26456
- }), _$1.includes(data.writeFields, _$1.get(data, "params._replyField")) && allowSend && /*#__PURE__*/React.createElement("div", {
26510
+ }), !isEditing && (_$1.includes(data.writeFields, _$1.get(data, "params._replyField")) && allowSend || allowEdit && isAuthor) && /*#__PURE__*/React.createElement("div", {
26457
26511
  className: styles$N.commentBodyFooter
26458
- }, /*#__PURE__*/React.createElement("div", {
26512
+ }, _$1.includes(data.writeFields, _$1.get(data, "params._replyField")) && allowSend && /*#__PURE__*/React.createElement("div", {
26459
26513
  onClick: e => setAddReply(true),
26460
26514
  className: "icon icon-bubble small " + styles$N.commentReplyButton
26461
- }, dict[lang].comments.reply)))), addReply && /*#__PURE__*/React.createElement("div", {
26515
+ }, dict[lang].comments.reply), allowEdit && isAuthor && /*#__PURE__*/React.createElement("div", {
26516
+ onClick: e => setIsEditing(true),
26517
+ className: "icon icon-edit small " + styles$N.commentReplyButton
26518
+ }, dict[lang].comments.edit)))), addReply && /*#__PURE__*/React.createElement("div", {
26462
26519
  className: styles$N.childComments
26463
26520
  }, /*#__PURE__*/React.createElement(AddComment, _extends({}, props, {
26464
26521
  parentID: commentID,