extract activity-link to directive and reuse it for all activities

pull/3563/merge
Jens Ulferts 9 years ago committed by Oliver Günther
parent 233ce258f9
commit 760edcd414
  1. 5
      frontend/app/templates/work_packages/activities/_link.html
  2. 9
      frontend/app/templates/work_packages/activities/_revision.html
  3. 10
      frontend/app/templates/work_packages/activities/_user.html
  4. 16
      frontend/app/work_packages/activities/activity-link-directive.js
  5. 3
      frontend/app/work_packages/activities/index.js
  6. 1
      frontend/app/work_packages/activities/user-activity-directive.js

@ -0,0 +1,5 @@
<a id ="{{ activityHtmlId }}"
ng-bind="'#' + activityNo"
ng-focus="onFocus()"
ng-blur="onBlur()"
ui-sref="work-packages.show.activity({ workPackageId: workPackageId, '#': activityHtmlId})"></a>

@ -1,10 +1,9 @@
<div class="work-package-details-activities-activity-contents"> <div class="work-package-details-activities-activity-contents">
<div class="comments-number"> <div class="comments-number">
<span ui-sref="work-packages.list.details.activity.details({ activity_no: activityNo })"> <activity-link work-package="workPackage"
<a name="{{ activityNo }}" activity-no="activityNo"
ng-bind="'#' + activityNo" on-focus="focus()",
ng-href="#{{ activityNo }}"></a> on-blur="blur()"></activity-link>
</span>
</div> </div>
<div ng-if="userAvatar"> <div ng-if="userAvatar">
<img class="avatar" ng-src="{{ userAvatar }}" alt="Avatar" title="{{userName}}" /> <img class="avatar" ng-src="{{ userAvatar }}" alt="Avatar" title="{{userName}}" />

@ -2,12 +2,10 @@
ng-mouseover="focus()" ng-mouseover="focus()"
ng-mouseout="blur()"> ng-mouseout="blur()">
<div class="comments-number"> <div class="comments-number">
<a name="{{ activityNo }}" <activity-link work-package="workPackage"
ng-bind="'#' + activityNo" activity-no="activityNo"
ng-focus="focus()" on-focus="focus()",
ng-blur="blur()" on-blur="blur()"></activity-link>
id="activity-{{ activityNo }}"
ui-sref="work-packages.show.activity({ workPackageId: workPackageId, '#': 'activity-' + activityNo })"></a>
<div class="comments-icons" <div class="comments-icons"
ng-focus="focus()" ng-focus="focus()"
ng-blur="blur()" ng-blur="blur()"

@ -0,0 +1,16 @@
module.exports = function() {
return {
restrict: 'E',
templateUrl: '/templates/work_packages/activities/_link.html',
scope: {
workPackage: '=',
activityNo: '=',
onBlur: '&',
onFocus: '&'
},
link: function(scope) {
scope.workPackageId = scope.workPackage.props.id;
scope.activityHtmlId = 'activity-' + scope.activityNo;
}
};
};

@ -54,4 +54,7 @@ angular.module('openproject.workPackages.activities')
'UsersHelper', 'UsersHelper',
require('./revision-activity-directive') require('./revision-activity-directive')
]) ])
.directive('activityLink', [
require('./activity-link-directive')
])
; ;

@ -73,7 +73,6 @@ module.exports = function($uiViewScroll,
scope.userCanEdit = !!scope.activity.links.update; scope.userCanEdit = !!scope.activity.links.update;
scope.userCanQuote = !!scope.workPackage.links.addComment; scope.userCanQuote = !!scope.workPackage.links.addComment;
scope.accessibilityModeEnabled = ConfigurationService.accessibilityModeEnabled(); scope.accessibilityModeEnabled = ConfigurationService.accessibilityModeEnabled();
scope.workPackageId = scope.workPackage.props.id;
scope.activity.links.user.fetch().then(function(user) { scope.activity.links.user.fetch().then(function(user) {
scope.userId = user.props.id; scope.userId = user.props.id;

Loading…
Cancel
Save