Use WorkPackageResource in panels

pull/4605/head
Oliver Günther 8 years ago
parent 06550750b1
commit e4f479c1b4
  1. 10
      frontend/app/components/routing/ui-router.config.ts
  2. 2
      frontend/app/components/work-packages/work-package-comment/work-package-comment.directive.js
  3. 2
      frontend/app/components/work-packages/work-package-comment/work-package-comment.directive.test.js
  4. 2
      frontend/app/components/wp-activity/activity-entry.directive.js
  5. 16
      frontend/app/components/wp-panels/activity-panel/wp-activity.service.js
  6. 17
      frontend/app/services/activity-service.js
  7. 24
      frontend/app/work_packages/activities/revision-activity-directive.js
  8. 6
      frontend/app/work_packages/activities/user-activity-directive.js

@ -34,7 +34,7 @@ const panels = {
return {
url: '/overview',
reloadOnSearch: false,
template: '<overview-panel work-package="workPackage"></overview-panel>'
template: '<overview-panel work-package="workPackageResource"></overview-panel>'
};
},
@ -42,16 +42,16 @@ const panels = {
return {
url: '/watchers',
reloadOnSearch: false,
template: '<watchers-panel ng-if="workPackage" work-package="workPackage"></watchers-panel>'
};
template: '<watchers-panel ng-if="workPackageResource" work-package="workPackageResource"></watchers-panel>'
}
},
get activity() {
return {
url: '/activity',
reloadOnSearch: false,
template: '<activity-panel ng-if="workPackage" work-package="workPackage"></activity-panel>'
};
template: '<activity-panel ng-if="workPackageResource" work-package="workPackageResource"></activity-panel>'
}
},
get activityDetails() {

@ -47,7 +47,7 @@ function workPackageComment($timeout, $location, FocusHelper, ActivityService, C
ctrl.isEditing = false;
ctrl.isRequired = true;
ctrl.canAddComment = !!ctrl.workPackage.links.addComment;
ctrl.canAddComment = !!ctrl.workPackage.addComment;
ctrl.showAbove = ConfigurationService.commentsSortedInDescendingOrder();

@ -102,7 +102,7 @@ describe('workPackageCommentDirectiveTest', function() {
describe('activity comments', function() {
describe('without comment link in work package', function() {
beforeEach(function() {
scope.workPackage.links.addComment = undefined;
scope.workPackage.addComment = undefined;
compile();
});

@ -45,7 +45,7 @@ function activityEntry(PathHelper) {
},
link: function(scope) {
var projectId = scope.workPackage.embedded.project.props.id;
var projectId = scope.workPackage.project.props.id;
scope.autocompletePath = PathHelper.workPackageJsonAutoCompletePath(projectId);
scope.activityType = scope.activity.props._type;

@ -52,26 +52,26 @@ function wpActivity($filter, $q, ConfigurationService){
var aggregated = [], promises = [];
var add = function (data) {
aggregated.push(data.embedded.elements);
aggregated.push(data.elements);
};
promises.push(workPackage.links.activities.fetch().then(add));
promises.push(workPackage.activities.$load().then(add));
if (workPackage.links.revisions) {
promises.push(workPackage.links.revisions.fetch().then(add));
if (workPackage.revisions) {
promises.push(workPackage.revisions.$load().then(add));
}
return $q.all(promises).then(function () {
activities.length = 0;
activities.push.apply(activities, $filter('orderBy')(
_.flatten(aggregated), 'props.createdAt', reverse
_.flatten(aggregated), 'createdAt', reverse
));
});
},
info: function (activity, index) {
var activityDate = function (activity) {
return $filter('date')(activity.props.createdAt, 'longDate')
return $filter('date')(activity.createdAt, 'longDate')
};
var orderedIndex = function(idx, forceReverse) {
@ -100,7 +100,7 @@ function wpActivity($filter, $q, ConfigurationService){
isInitial: function(forceReverse) {
var activityNo = this.number(forceReverse);
if (activity.props._type.indexOf('Activity') !== 0) {
if (activity._type.indexOf('Activity') !== 0) {
return false;
}
@ -110,7 +110,7 @@ function wpActivity($filter, $q, ConfigurationService){
while (--activityNo > 0) {
var idx = orderedIndex(activityNo, forceReverse) - 1;
if (activities[idx].props._type.indexOf('Activity') === 0) {
if (activities[idx]._type.indexOf('Activity') === 0) {
return false;
}
}

@ -35,12 +35,12 @@ module.exports = function(
) {
var ActivityService = {
createComment: function(workPackage, comment) {
return $http({
url: workPackage.links.addComment.url(),
method: 'POST',
data: JSON.stringify({ comment: comment }),
headers: { 'Content-Type': 'application/json; charset=UTF-8' }
});
var data = JSON.stringify({ comment: comment });
workPackage.addComment(
{ comment: comment},
{ 'Content-Type': 'application/json; charset=UTF-8' }
);
},
updateComment: function(activity, comment) {
@ -52,7 +52,10 @@ module.exports = function(
}
};
return activity.links.update.fetch(options).then(function(activity){
return activity.update(
{ comment: comment },
{ 'Content-Type': 'application/json; charset=UTF-8' }
).then(function(activity) {
NotificationsService.addSuccess(
I18n.t('js.work_packages.comment_updated')
);

@ -44,26 +44,26 @@ module.exports = function($compile,
},
link: function(scope, element) {
scope.I18n = I18n;
if (scope.activity.links.author === undefined) {
scope.userName = scope.activity.props.authorName;
if (scope.activity.author === undefined) {
scope.userName = scope.activity.authorName;
} else {
scope.userPath = PathHelper.userPath;
scope.activity.links.author.fetch().then(function(user) {
scope.userId = user.props.id;
scope.userName = user.props.name;
scope.userAvatar = user.props.avatar;
scope.activity.author.$load().then(function(user) {
scope.userId = user.id;
scope.userName = user.name;
scope.userAvatar = user.avatar;
scope.userActive = UsersHelper.isActive(user);
scope.userLabel = I18n.t('js.label_author', { user: scope.userName });
});
}
scope.project = scope.workPackage.embedded.project;
scope.revision = scope.activity.props.identifier;
scope.formattedRevision = scope.activity.props.formattedIdentifier;
scope.revisionPath = scope.activity.links.showRevision.href;
scope.message = $sce.trustAsHtml(scope.activity.props.message.html);
scope.project = scope.workPackage.project;
scope.revision = scope.activity.identifier;
scope.formattedRevision = scope.activity.formattedIdentifier;
scope.revisionPath = scope.activity.showRevision.$link.href;
scope.message = $sce.trustAsHtml(scope.activity.message.html);
var date = '<op-date-time date-time-value="activity.props.createdAt"/></op-date-time>';
var date = '<op-date-time date-time-value="activity.createdAt"/></op-date-time>';
var link = [
'<a ng-href="{{ revisionPath }}" title="{{ revision }}">',
'{{ I18n.t("js.label_committed_link", { revision_identifier: formattedRevision }) }}',

@ -71,11 +71,11 @@ module.exports = function($uiViewScroll,
scope.userPath = PathHelper.userPath;
scope.inEdit = false;
scope.inPreview = false;
scope.userCanEdit = !!scope.activity.links.update;
scope.userCanQuote = !!scope.workPackage.links.addComment;
scope.userCanEdit = !!scope.activity.update;
scope.userCanQuote = !!scope.workPackage.addComment;
scope.accessibilityModeEnabled = ConfigurationService.accessibilityModeEnabled();
var resource = UserService.getUserByResource(scope.activity.links.user);
var resource = UserService.getUserByResource(scope.activity.user);
resource.then(function(user) {
scope.userId = user.props.id;
scope.userName = user.props.name;

Loading…
Cancel
Save