DriveComment.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. DriveComment = function(file, id, content, modifiedDate, createdDate, isResolved, user, pCommentId)
  2. {
  3. DrawioComment.call(this, file, id, content, modifiedDate, createdDate, isResolved, user);
  4. this.pCommentId = pCommentId; //a reply
  5. };
  6. //Extends DrawioComment
  7. mxUtils.extend(DriveComment, DrawioComment);
  8. DriveComment.prototype.addReply = function(reply, success, error, doResolve, doReopen)
  9. {
  10. var body = {'content': reply.content};
  11. if (doResolve)
  12. {
  13. body.verb = 'resolve';
  14. }
  15. else if (doReopen)
  16. {
  17. body.verb = 'reopen';
  18. }
  19. this.file.ui.drive.executeRequest(
  20. {
  21. url: '/files/' + this.file.getId() + '/comments/' + this.id + '/replies',
  22. params: body,
  23. method: 'POST'
  24. },
  25. mxUtils.bind(this, function(resp)
  26. {
  27. success(resp.replyId); //pass comment id
  28. }), error);
  29. };
  30. DriveComment.prototype.editComment = function(newContent, success, error)
  31. {
  32. this.content = newContent;
  33. var body = {'content': newContent};
  34. this.file.ui.drive.executeRequest(
  35. this.pCommentId?
  36. {
  37. url: '/files/' + this.file.getId() + '/comments/' + this.pCommentId + '/replies/' + this.id,
  38. params: body,
  39. method: 'PATCH'
  40. } :
  41. {
  42. url: '/files/' + this.file.getId() + '/comments/' + this.id,
  43. params: body,
  44. method: 'PATCH'
  45. },
  46. success, error);
  47. };
  48. DriveComment.prototype.deleteComment = function(success, error)
  49. {
  50. this.file.ui.drive.executeRequest(
  51. this.pCommentId?
  52. {
  53. url: '/files/' + this.file.getId() + '/comments/' + this.pCommentId + '/replies/' + this.id,
  54. method: 'DELETE'
  55. }:
  56. {
  57. url: '/files/' + this.file.getId() + '/comments/' + this.id,
  58. method: 'DELETE'
  59. },
  60. success, error);
  61. };