Implement comment deletion and loading indicator
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -33,6 +33,9 @@ class ActivityController {
|
||||
this.$scope = $scope;
|
||||
this.type = '';
|
||||
this.loading = false;
|
||||
this.status = {
|
||||
commentCreateLoading: false
|
||||
};
|
||||
this.$scope.newComment = '';
|
||||
|
||||
const self = this;
|
||||
@@ -51,6 +54,7 @@ class ActivityController {
|
||||
|
||||
postComment() {
|
||||
const self = this;
|
||||
this.status.commentCreateLoading = true;
|
||||
var model = this.activityservice.commentCollection.create({
|
||||
actorId: OC.getCurrentUser().uid,
|
||||
actorDisplayName: OC.getCurrentUser().displayName,
|
||||
@@ -66,6 +70,7 @@ class ActivityController {
|
||||
console.log("SUCCESS");
|
||||
self.$scope.newComment = '';
|
||||
self.activityservice.fetchNewerActivities(self.type, self.element.id).then(function () {});
|
||||
self.status.commentCreateLoading = false;
|
||||
},
|
||||
error: function() {
|
||||
|
||||
@@ -82,8 +87,9 @@ class ActivityController {
|
||||
|
||||
}
|
||||
|
||||
deleteComment() {
|
||||
|
||||
deleteComment(item) {
|
||||
item.commentModel.destroy();
|
||||
item.deleted = true;
|
||||
}
|
||||
|
||||
getCommentDetails() {}
|
||||
@@ -125,17 +131,8 @@ class ActivityController {
|
||||
}
|
||||
|
||||
getActivityStream() {
|
||||
const self = this;
|
||||
let activities = this.activityservice.getData(this.type, this.element.id);
|
||||
this.data = [];
|
||||
for (let i in activities) {
|
||||
let activity = activities[i];
|
||||
activity.timelineType = 'activity';
|
||||
activity.timelineTimestamp = activity.timestamp;
|
||||
this.data.push(activity);
|
||||
}
|
||||
let sorted = this.data.sort((a, b) => b.timelineTimestamp - a.timelineTimestamp);
|
||||
return sorted;
|
||||
return activities;
|
||||
}
|
||||
|
||||
page() {
|
||||
|
||||
@@ -66,6 +66,14 @@ var CommentModel = OC.Backbone.Model.extend(
|
||||
};
|
||||
},
|
||||
|
||||
url: function() {
|
||||
if (typeof this.get('id') !== 'undefined') {
|
||||
return this.collection.url() + this.get('id');
|
||||
} else {
|
||||
return this.collection.url();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
export default CommentModel;
|
||||
|
||||
@@ -53,11 +53,9 @@ class ActivityService {
|
||||
let item = this.toEnhanceWithComments[index];
|
||||
item.commentModel = this.commentCollection.get(item.subject_rich[1].comment);
|
||||
if (typeof item.commentModel !== 'undefined') {
|
||||
// FIXME: not working
|
||||
this.toEnhanceWithComments.remove(item);
|
||||
this.toEnhanceWithComments = this.toEnhanceWithComments.filter(entry => entry.id !== item.id);
|
||||
}
|
||||
}
|
||||
console.log(this.toEnhanceWithComments);
|
||||
var firstUnread = this.commentCollection.findWhere({isUnread: true});
|
||||
if (typeof firstUnread !== 'undefined') {
|
||||
this.commentCollection.updateReadMarker();
|
||||
@@ -155,13 +153,15 @@ class ActivityService {
|
||||
return;
|
||||
}
|
||||
item.timestamp = new Date(item.datetime).getTime();
|
||||
|
||||
item.type = 'activity';
|
||||
if (item.subject_rich[1].comment) {
|
||||
item.type = 'comment';
|
||||
item.commentModel = this.commentCollection.get(item.subject_rich[1].comment);
|
||||
if (typeof item.commentModel === 'undefined') {
|
||||
this.toEnhanceWithComments.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
this.data[type][id].push(item);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user