summaryrefslogtreecommitdiffstats
path: root/apps/comments/src/commentsummarymodel.js
blob: b1eea97c9755e3cae16c565568eae7630047e2b0 (plain)
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
69
70
/*
 * Copyright (c) 2016
 *
 * This file is licensed under the Affero General Public License version 3
 * or later.
 *
 * See the COPYING-README file.
 *
 */

(function(OC, OCA) {

	_.extend(OC.Files.Client, {
		PROPERTY_READMARKER: '{' + OC.Files.Client.NS_OWNCLOUD + '}readMarker',
	})

	/**
	 * @class OCA.Comments.CommentSummaryModel
	 * @classdesc
	 *
	 * Model containing summary information related to comments
	 * like the read marker.
	 *
	 */
	const CommentSummaryModel = OC.Backbone.Model.extend(
		/** @lends OCA.Comments.CommentSummaryModel.prototype */ {
			sync: OC.Backbone.davSync,

			/**
		 * Object type
		 *
		 * @type string
		 */
			_objectType: 'files',

			/**
		 * Object id
		 *
		 * @type string
		 */
			_objectId: null,

			davProperties: {
				readMarker: OC.Files.Client.PROPERTY_READMARKER,
			},

			/**
			 * Initializes the summary model
			 *
			 * @param {any} [attrs] ignored
			 * @param {Object} [options] destructuring object
			 * @param {string} [options.objectType] object type
			 * @param {string} [options.objectId] object id
			 */
			initialize(attrs, options) {
				options = options || {}
				if (options.objectType) {
					this._objectType = options.objectType
				}
			},

			url() {
				return OC.linkToRemote('dav') + '/comments/'
				+ encodeURIComponent(this._objectType) + '/'
				+ encodeURIComponent(this.id) + '/'
			},
		})

	OCA.Comments.CommentSummaryModel = CommentSummaryModel
})(OC, OCA)