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;
|
position: absolute;
|
||||||
top: -5px;
|
top: -5px;
|
||||||
right: 0;
|
right: 0;
|
||||||
|
a {
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
button {
|
button {
|
||||||
opacity: .5;
|
opacity: .5;
|
||||||
padding: 14px 19px;
|
padding: 14px 19px;
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ class ActivityController {
|
|||||||
this.$scope = $scope;
|
this.$scope = $scope;
|
||||||
this.type = '';
|
this.type = '';
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
this.status = {
|
||||||
|
commentCreateLoading: false
|
||||||
|
};
|
||||||
this.$scope.newComment = '';
|
this.$scope.newComment = '';
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
@@ -51,6 +54,7 @@ class ActivityController {
|
|||||||
|
|
||||||
postComment() {
|
postComment() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
this.status.commentCreateLoading = true;
|
||||||
var model = this.activityservice.commentCollection.create({
|
var model = this.activityservice.commentCollection.create({
|
||||||
actorId: OC.getCurrentUser().uid,
|
actorId: OC.getCurrentUser().uid,
|
||||||
actorDisplayName: OC.getCurrentUser().displayName,
|
actorDisplayName: OC.getCurrentUser().displayName,
|
||||||
@@ -66,6 +70,7 @@ class ActivityController {
|
|||||||
console.log("SUCCESS");
|
console.log("SUCCESS");
|
||||||
self.$scope.newComment = '';
|
self.$scope.newComment = '';
|
||||||
self.activityservice.fetchNewerActivities(self.type, self.element.id).then(function () {});
|
self.activityservice.fetchNewerActivities(self.type, self.element.id).then(function () {});
|
||||||
|
self.status.commentCreateLoading = false;
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
|
|
||||||
@@ -82,8 +87,9 @@ class ActivityController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteComment() {
|
deleteComment(item) {
|
||||||
|
item.commentModel.destroy();
|
||||||
|
item.deleted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
getCommentDetails() {}
|
getCommentDetails() {}
|
||||||
@@ -125,17 +131,8 @@ class ActivityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getActivityStream() {
|
getActivityStream() {
|
||||||
const self = this;
|
|
||||||
let activities = this.activityservice.getData(this.type, this.element.id);
|
let activities = this.activityservice.getData(this.type, this.element.id);
|
||||||
this.data = [];
|
return activities;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
page() {
|
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;
|
export default CommentModel;
|
||||||
|
|||||||
@@ -53,11 +53,9 @@ class ActivityService {
|
|||||||
let item = this.toEnhanceWithComments[index];
|
let item = this.toEnhanceWithComments[index];
|
||||||
item.commentModel = this.commentCollection.get(item.subject_rich[1].comment);
|
item.commentModel = this.commentCollection.get(item.subject_rich[1].comment);
|
||||||
if (typeof item.commentModel !== 'undefined') {
|
if (typeof item.commentModel !== 'undefined') {
|
||||||
// FIXME: not working
|
this.toEnhanceWithComments = this.toEnhanceWithComments.filter(entry => entry.id !== item.id);
|
||||||
this.toEnhanceWithComments.remove(item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(this.toEnhanceWithComments);
|
|
||||||
var firstUnread = this.commentCollection.findWhere({isUnread: true});
|
var firstUnread = this.commentCollection.findWhere({isUnread: true});
|
||||||
if (typeof firstUnread !== 'undefined') {
|
if (typeof firstUnread !== 'undefined') {
|
||||||
this.commentCollection.updateReadMarker();
|
this.commentCollection.updateReadMarker();
|
||||||
@@ -155,13 +153,15 @@ class ActivityService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
item.timestamp = new Date(item.datetime).getTime();
|
item.timestamp = new Date(item.datetime).getTime();
|
||||||
|
item.type = 'activity';
|
||||||
if (item.subject_rich[1].comment) {
|
if (item.subject_rich[1].comment) {
|
||||||
|
item.type = 'comment';
|
||||||
item.commentModel = this.commentCollection.get(item.subject_rich[1].comment);
|
item.commentModel = this.commentCollection.get(item.subject_rich[1].comment);
|
||||||
if (typeof item.commentModel === 'undefined') {
|
if (typeof item.commentModel === 'undefined') {
|
||||||
this.toEnhanceWithComments.push(item);
|
this.toEnhanceWithComments.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.data[type][id].push(item);
|
this.data[type][id].push(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ use OCA\Deck\Db\Acl;
|
|||||||
use OCP\Activity\IEvent;
|
use OCP\Activity\IEvent;
|
||||||
use OCP\Activity\IProvider;
|
use OCP\Activity\IProvider;
|
||||||
use OCP\Comments\IComment;
|
use OCP\Comments\IComment;
|
||||||
|
use OCP\Comments\NotFoundException;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
|
|
||||||
@@ -235,8 +236,11 @@ class DeckProvider implements IProvider {
|
|||||||
private function parseParamForComment($subjectParams, $params, IEvent $event) {
|
private function parseParamForComment($subjectParams, $params, IEvent $event) {
|
||||||
if (array_key_exists('comment', $subjectParams)) {
|
if (array_key_exists('comment', $subjectParams)) {
|
||||||
/** @var IComment $comment */
|
/** @var IComment $comment */
|
||||||
$comment = \OC::$server->getCommentsManager()->get((int) $subjectParams['comment']);
|
try {
|
||||||
$event->setParsedMessage($comment->getMessage());
|
$comment = \OC::$server->getCommentsManager()->get((int)$subjectParams['comment']);
|
||||||
|
$event->setParsedMessage($comment->getMessage());
|
||||||
|
} catch (NotFoundException $e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$params['comment'] = $subjectParams['comment'];
|
$params['comment'] = $subjectParams['comment'];
|
||||||
return $params;
|
return $params;
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
<div class="author currentUser">admin</div>
|
<div class="author currentUser">admin</div>
|
||||||
</div>
|
</div>
|
||||||
<form class="newCommentForm">
|
<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"
|
<input class="submit icon-confirm has-tooltip" type="submit"
|
||||||
value="" title="" data-original-title="Post" ng-click="$ctrl.postComment()">
|
value="" title="" data-original-title="Post" ng-click="$ctrl.postComment()" ng-if="!$ctrl.status.commentCreateLoading">
|
||||||
<div class="submitLoading icon-loading-small hidden"></div>
|
<div class="submitLoading icon-loading-small" ng-if="$ctrl.status.commentCreateLoading"></div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user