summaryrefslogtreecommitdiffstats
path: root/apps/comments/js/commentcollection.js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-01-27 18:28:55 +0100
committerVincent Petry <pvince81@owncloud.com>2016-02-02 18:01:15 +0100
commitcca33942aa01542c7b9920c80c66e3becd3a0d9c (patch)
treeb1eea7483ea67a445815e579032dedfa23b2d3c5 /apps/comments/js/commentcollection.js
parent0e95b9f2d560f5fc177e672162e995341cfba025 (diff)
downloadnextcloud-server-cca33942aa01542c7b9920c80c66e3becd3a0d9c.tar.gz
nextcloud-server-cca33942aa01542c7b9920c80c66e3becd3a0d9c.zip
Comments GUI
Diffstat (limited to 'apps/comments/js/commentcollection.js')
-rw-r--r--apps/comments/js/commentcollection.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/apps/comments/js/commentcollection.js b/apps/comments/js/commentcollection.js
new file mode 100644
index 00000000000..61b5adb7da7
--- /dev/null
+++ b/apps/comments/js/commentcollection.js
@@ -0,0 +1,82 @@
+/*
+ * 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) {
+
+ function filterFunction(model, term) {
+ return model.get('name').substr(0, term.length) === term;
+ }
+
+ /**
+ * @class OCA.Comments.CommentsCollection
+ * @classdesc
+ *
+ * Collection of comments assigned to a file
+ *
+ */
+ var CommentsCollection = OC.Backbone.Collection.extend(
+ /** @lends OCA.Comments.CommentsCollection.prototype */ {
+
+ sync: OC.Backbone.davSync,
+
+ model: OCA.Comments.CommentModel,
+
+ _objectType: 'files',
+ _objectId: null,
+
+ _endReached: false,
+ _currentIndex: 0,
+
+ initialize: function(models, options) {
+ options = options || {};
+ if (options.objectType) {
+ this._objectType = options.objectType;
+ }
+ if (options.objectId) {
+ this._objectId = options.objectId;
+ }
+ },
+
+ url: function() {
+ return OC.linkToRemote('dav') + '/comments/' +
+ encodeURIComponent(this._objectType) + '/' +
+ encodeURIComponent(this._objectId) + '/';
+ },
+
+ setObjectId: function(objectId) {
+ this._objectId = objectId;
+ },
+
+ hasMoreResults: function() {
+ return !this._endReached;
+ },
+
+ /**
+ * Fetch the next set of results
+ */
+ fetchNext: function() {
+ if (!this.hasMoreResults()) {
+ return null;
+ }
+ if (this._currentIndex === 0) {
+ return this.fetch();
+ }
+ return this.fetch({remove: false});
+ },
+
+ reset: function() {
+ this._currentIndex = 0;
+ OC.Backbone.Collection.prototype.reset.apply(this, arguments);
+ }
+ });
+
+ OCA.Comments.CommentsCollection = CommentsCollection;
+})(OC, OCA);
+