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