Implement comment deletion and loading indicator
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -946,6 +946,9 @@ input.input-inline {
|
||||
position: absolute;
|
||||
top: -5px;
|
||||
right: 0;
|
||||
a {
|
||||
font-weight: normal;
|
||||
}
|
||||
button {
|
||||
opacity: .5;
|
||||
padding: 14px 19px;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ use OCA\Deck\Db\Acl;
|
||||
use OCP\Activity\IEvent;
|
||||
use OCP\Activity\IProvider;
|
||||
use OCP\Comments\IComment;
|
||||
use OCP\Comments\NotFoundException;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUserManager;
|
||||
|
||||
@@ -235,8 +236,11 @@ class DeckProvider implements IProvider {
|
||||
private function parseParamForComment($subjectParams, $params, IEvent $event) {
|
||||
if (array_key_exists('comment', $subjectParams)) {
|
||||
/** @var IComment $comment */
|
||||
try {
|
||||
$comment = \OC::$server->getCommentsManager()->get((int)$subjectParams['comment']);
|
||||
$event->setParsedMessage($comment->getMessage());
|
||||
} catch (NotFoundException $e) {
|
||||
}
|
||||
}
|
||||
$params['comment'] = $subjectParams['comment'];
|
||||
return $params;
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
<div class="author currentUser">admin</div>
|
||||
</div>
|
||||
<form class="newCommentForm">
|
||||
<div contenteditable="true" class="message" data-placeholder="{{ $ctrl.t('deck', 'New comment …') }}" ng-model="$ctrl.$scope.newComment"></div>
|
||||
<div contenteditable="true" class="message" data-placeholder="{{ $ctrl.t('deck', 'New comment …') }}" ng-model="$ctrl.$scope.newComment" ng-disabled="$ctrl.status.commentCreateLoading"></div>
|
||||
<input class="submit icon-confirm has-tooltip" type="submit"
|
||||
value="" title="" data-original-title="Post" ng-click="$ctrl.postComment()">
|
||||
<div class="submitLoading icon-loading-small hidden"></div>
|
||||
value="" title="" data-original-title="Post" ng-click="$ctrl.postComment()" ng-if="!$ctrl.status.commentCreateLoading">
|
||||
<div class="submitLoading icon-loading-small" ng-if="$ctrl.status.commentCreateLoading"></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user