From 28f58ee5f3bf9f4fc7ac7f41868a4ddce2998b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 7 Sep 2018 15:04:42 +0200 Subject: [PATCH] Fix activity rendering in the sidebar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- css/activity.css | 14 ++++++++++ js/controller/ActivityController.js | 25 +++++++++--------- js/directive/avatar.js | 16 +++++++----- js/directive/bindHtmlCompile.js | 38 ++++++++++++++++++++++++++++ js/service/ActivityService.js | 1 + templates/part.board.sidebarView.php | 2 +- templates/part.card.activity.html | 4 +-- templates/part.card.php | 2 +- 8 files changed, 79 insertions(+), 23 deletions(-) create mode 100644 js/directive/bindHtmlCompile.js diff --git a/css/activity.css b/css/activity.css index 3cfcbd3b9..843406f4c 100644 --- a/css/activity.css +++ b/css/activity.css @@ -7,3 +7,17 @@ background-color: rgba(233, 50, 45, 0.2); text-decoration: none; } + +.activityTabView .avatardiv-container { + display: inline-block; + bottom: -3px; + margin-left: 3px; +} + +.activityTabView .avatar-name-wrapper { + font-weight: bold; +} + +.activityTabView .activitysubject a { + font-weight: bold; +} diff --git a/js/controller/ActivityController.js b/js/controller/ActivityController.js index 345ec75b1..642e3608f 100644 --- a/js/controller/ActivityController.js +++ b/js/controller/ActivityController.js @@ -48,7 +48,7 @@ class ActivityController { } parseMessage(subject, parameters) { - OCA.Activity.RichObjectStringParser._userLocalTemplate = ''; + OCA.Activity.RichObjectStringParser._userLocalTemplate = ' {{ name }}'; return OCA.Activity.RichObjectStringParser.parseMessage(subject, parameters); } @@ -57,20 +57,19 @@ class ActivityController { let dataLengthBefore = self.getData(self.element.id).length; let _executeFetch = function() { let promise = self.activityservice.fetchMoreActivities(self.type, self.element.id); - if (Promise.resolve(promise) === promise) { - promise.then(function (data) { - let dataLengthAfter = self.getData(self.element.id).length; - if (data !== null || dataLengthAfter <= dataLengthBefore || dataLengthAfter < 5) { - _executeFetch(); - } else { - self.loading = false; - self.$scope.$apply(); - } - }, function () { + promise.then(function (data) { + let dataLengthAfter = self.getData(self.element.id).length; + if (data !== null && (dataLengthAfter <= dataLengthBefore || dataLengthAfter < 5)) { + _executeFetch(); + } else { self.loading = false; self.$scope.$apply(); - }); - } + } + }, function () { + self.loading = false; + self.$scope.$apply(); + }); + }; _executeFetch(); } diff --git a/js/directive/avatar.js b/js/directive/avatar.js index 79cd41a85..8f20ab3e2 100644 --- a/js/directive/avatar.js +++ b/js/directive/avatar.js @@ -4,20 +4,20 @@ * @author Julius Härtl * * @license GNU AGPL version 3 or any later version - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * + * */ import app from '../app/App.js'; @@ -32,6 +32,10 @@ app.directive('avatar', function() { link: function(scope, element, attr){ scope.uid = attr.displayname; scope.displayname = attr.displayname; + scope.size = attr.size; + if (typeof scope.size === 'undefined') { + scope.size = 32; + } var value = attr.user; var avatardiv = $(element).find('.avatardiv'); if(typeof attr.contactsmenu !== 'undefined' && attr.contactsmenu !== 'false') { @@ -44,8 +48,8 @@ app.directive('avatar', function() { placement: 'top' }); } - avatardiv.avatar(value, 32, false, false, false, attr.displayname); + avatardiv.avatar(value, scope.size, false, false, false, attr.displayname); }, controller: function () {} }; -}); \ No newline at end of file +}); diff --git a/js/directive/bindHtmlCompile.js b/js/directive/bindHtmlCompile.js new file mode 100644 index 000000000..dbaa2d5e7 --- /dev/null +++ b/js/directive/bindHtmlCompile.js @@ -0,0 +1,38 @@ +/* + * @copyright Copyright (c) 2018 Julius Härtl + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +import app from '../app/App.js'; + +app.directive('bindHtmlCompile', function ($compile) { + 'use strict'; + + return { + restrict: 'A', + link: function (scope, element, attrs) { + scope.$watch(function () { + return scope.$eval(attrs.bindHtmlCompile); + }, function (value) { + element.html(value); + $compile(element.contents())(scope); + }); + } + }; +}); diff --git a/js/service/ActivityService.js b/js/service/ActivityService.js index 23a7538c7..514057edd 100644 --- a/js/service/ActivityService.js +++ b/js/service/ActivityService.js @@ -78,6 +78,7 @@ class ActivityService { }); self.since[type][id].oldest = response.headers('X-Activity-Last-Given'); self.running = false; + return response; }, function (error) { if (error.status === 304) { self.since[type][id].finished = true; diff --git a/templates/part.board.sidebarView.php b/templates/part.board.sidebarView.php index 891e1c6be..369e71649 100644 --- a/templates/part.board.sidebarView.php +++ b/templates/part.board.sidebarView.php @@ -150,7 +150,7 @@ -
+
diff --git a/templates/part.card.activity.html b/templates/part.card.activity.html index c3c7d0408..1c8a7198f 100644 --- a/templates/part.card.activity.html +++ b/templates/part.card.activity.html @@ -1,11 +1,11 @@ -
    +
    • + bind-html-compile="$ctrl.parseMessage(activity.subject_rich[0], activity.subject_rich[1])">
{{ activity.timestamp/1000 | relativeDateFilter }}
diff --git a/templates/part.card.php b/templates/part.card.php index 488fbe664..6358b72ad 100644 --- a/templates/part.card.php +++ b/templates/part.card.php @@ -131,7 +131,7 @@ -
+