diff --git a/apps/comments/appinfo/app.php b/apps/comments/appinfo/app.php index c6f36567c5..a1eb4f6899 100644 --- a/apps/comments/appinfo/app.php +++ b/apps/comments/appinfo/app.php @@ -27,6 +27,7 @@ $eventDispatcher->addListener( \OCP\Util::addScript('comments', 'app'); \OCP\Util::addScript('comments', 'commentmodel'); \OCP\Util::addScript('comments', 'commentcollection'); + \OCP\Util::addScript('comments', 'commentsummarymodel'); \OCP\Util::addScript('comments', 'commentstabview'); \OCP\Util::addScript('comments', 'filesplugin'); \OCP\Util::addStyle('comments', 'comments'); diff --git a/apps/comments/css/comments.css b/apps/comments/css/comments.css index c1624dcc57..5e247aaeb7 100644 --- a/apps/comments/css/comments.css +++ b/apps/comments/css/comments.css @@ -49,3 +49,7 @@ position: absolute; right: 0; } + +.app-files .action-comment>img { + margin-right: 5px; +} diff --git a/apps/comments/js/commentcollection.js b/apps/comments/js/commentcollection.js index d10e5e0086..a15039cf48 100644 --- a/apps/comments/js/commentcollection.js +++ b/apps/comments/js/commentcollection.js @@ -10,8 +10,6 @@ (function(OC, OCA) { - var NS_OWNCLOUD = 'http://owncloud.org/ns'; - /** * @class OCA.Comments.CommentCollection * @classdesc @@ -26,12 +24,40 @@ model: OCA.Comments.CommentModel, + /** + * Object type + * + * @type string + */ _objectType: 'files', + + /** + * Object id + * + * @type string + */ _objectId: null, + /** + * True if there are no more page results left to fetch + * + * @type bool + */ _endReached: false, + + /** + * Number of comments to fetch per page + * + * @type int + */ _limit : 20, + /** + * Initializes the collection + * + * @param {string} [options.objectType] object type + * @param {string} [options.objectId] object id + */ initialize: function(models, options) { options = options || {}; if (options.objectType) { @@ -58,6 +84,7 @@ reset: function() { this._endReached = false; + this._summaryModel = null; return OC.Backbone.Collection.prototype.reset.apply(this, arguments); }, @@ -81,6 +108,7 @@ var success = options.success; options = _.extend({ remove: false, + parse: true, data: body, davProperties: CommentCollection.prototype.model.prototype.davProperties, success: function(resp) { @@ -102,6 +130,35 @@ }, options); return this.sync('REPORT', this, options); + }, + + /** + * Returns the matching summary model + * + * @return {OCA.Comments.CommentSummaryModel} summary model + */ + getSummaryModel: function() { + if (!this._summaryModel) { + this._summaryModel = new OCA.Comments.CommentSummaryModel({ + id: this._objectId, + objectType: this._objectType + }); + } + return this._summaryModel; + }, + + /** + * Updates the read marker for this comment thread + * + * @param {Date} [date] optional date, defaults to now + * @param {Object} [options] backbone options + */ + updateReadMarker: function(date, options) { + options = options || {}; + + return this.getSummaryModel().save({ + readMarker: (date || new Date()).toUTCString() + }, options); } }); diff --git a/apps/comments/js/commentmodel.js b/apps/comments/js/commentmodel.js index b945f71fdd..ba04fd61de 100644 --- a/apps/comments/js/commentmodel.js +++ b/apps/comments/js/commentmodel.js @@ -34,11 +34,12 @@ 'actorDisplayName': '{' + NS_OWNCLOUD + '}actorDisplayName', 'creationDateTime': '{' + NS_OWNCLOUD + '}creationDateTime', 'objectType': '{' + NS_OWNCLOUD + '}objectType', - 'objectId': '{' + NS_OWNCLOUD + '}objectId' + 'objectId': '{' + NS_OWNCLOUD + '}objectId', + 'isUnread': '{' + NS_OWNCLOUD + '}isUnread' }, parse: function(data) { - // TODO: parse non-string values + data.isUnread = (data.isUnread === 'true'); return data; } }); diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index 463ac2d76e..188d8c5943 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -31,7 +31,7 @@ '
'; var COMMENT_TEMPLATE = - '