diff --git a/app/assets/javascripts/angular/directives/components/authoring-directive.js b/app/assets/javascripts/angular/directives/components/authoring-directive.js index ce97bc4e69..a1a6fc55b9 100644 --- a/app/assets/javascripts/angular/directives/components/authoring-directive.js +++ b/app/assets/javascripts/angular/directives/components/authoring-directive.js @@ -46,7 +46,7 @@ angular.module('openproject.uiComponents') scope.authorLink = '' + scope.author.name + ''; if (scope.activity) { - scope.timestamp = '' + timeago + ''; + scope.timestamp = '' + timeago + ''; } else { scope.timestamp = ' '; } diff --git a/app/assets/javascripts/angular/helpers/components/path-helper.js b/app/assets/javascripts/angular/helpers/components/path-helper.js index 9fbc860017..f38df84374 100644 --- a/app/assets/javascripts/angular/helpers/components/path-helper.js +++ b/app/assets/javascripts/angular/helpers/components/path-helper.js @@ -36,7 +36,19 @@ angular.module('openproject.helpers') apiV3: '/api/v3', staticBase: window.appBasePath ? window.appBasePath : '', - activityPath: function(projectIdentifier, from) { + activityPath: function(activityId) { + return 'activities/' + activityId; + }, + activitiesPath: function(workPackageId) { + var path = ''; + if(workPackageId) { + path = '/work_packages/' + workPackageId; + } + path = path + '/activities'; + + return path; + }, + activityFromPath: function(projectIdentifier, from) { var link = '/activity'; if (projectIdentifier) { diff --git a/app/assets/javascripts/angular/services/activity-service.js b/app/assets/javascripts/angular/services/activity-service.js index 065f1bbbf4..ddb2318765 100644 --- a/app/assets/javascripts/angular/services/activity-service.js +++ b/app/assets/javascripts/angular/services/activity-service.js @@ -34,7 +34,7 @@ angular.module('openproject.services') var ActivityService = { createComment: function(workPackageId, activities, descending, comment) { - var resource = HALAPIResource.setup("work_packages/" + workPackageId + "/activities"); + var resource = HALAPIResource.setup(PathHelper.activitiesPath(workPackageId)); var options = { ajax: { method: "POST", @@ -53,6 +53,23 @@ angular.module('openproject.services') return activity; } }); + }, + + updateComment: function(activityId, comment) { + var resource = HALAPIResource.setup(PathHelper.activityPath(activityId)); + var options = { + ajax: { + method: "PUT", + data: { comment: comment } + } + }; + + return resource.fetch(options).then(function(activity){ + // We are unable to add to the work package's embedded activities directly + if(activity) { + // Might have to just reload the work package here ala Till + } + }); } } diff --git a/app/assets/javascripts/angular/work_packages/tabs/editable-comment-directive.js b/app/assets/javascripts/angular/work_packages/tabs/editable-comment-directive.js new file mode 100644 index 0000000000..feb805ce1b --- /dev/null +++ b/app/assets/javascripts/angular/work_packages/tabs/editable-comment-directive.js @@ -0,0 +1,43 @@ +//-- copyright +// OpenProject is a project management system. +// Copyright (C) 2012-2014 the OpenProject Foundation (OPF) +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License version 3. +// +// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +// Copyright (C) 2006-2013 Jean-Philippe Lang +// Copyright (C) 2010-2013 the ChiliProject Team +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See doc/COPYRIGHT.rdoc for more details. +//++ + +angular.module('openproject.workPackages.directives') + +.directive('editableComment', [function(){ + return { + restrict: 'A', + scope: { + activity: '=', + commentInEdit: '=' + }, + templateUrl: '/templates/work_packages/tabs/_editable_comment.html', + link: function(scope){ + + } + }; +}]); diff --git a/app/assets/javascripts/angular/work_packages/tabs/user-activity-directive.js b/app/assets/javascripts/angular/work_packages/tabs/user-activity-directive.js index 8bf72bd381..c87faf4f1b 100644 --- a/app/assets/javascripts/angular/work_packages/tabs/user-activity-directive.js +++ b/app/assets/javascripts/angular/work_packages/tabs/user-activity-directive.js @@ -28,7 +28,7 @@ angular.module('openproject.workPackages.tabs') -.directive('userActivity', ['I18n', 'PathHelper', function(I18n, PathHelper) { +.directive('userActivity', ['I18n', 'PathHelper', 'ActivityService', function(I18n, PathHelper, ActivityService) { return { restrict: 'E', replace: true, @@ -36,17 +36,45 @@ angular.module('openproject.workPackages.tabs') scope: { activity: '=', currentAnchor: '=', - activityNo: '=' + activityNo: '=', + inputElementId: '=' }, - link: function(scope) { + link: function(scope, element) { scope.I18n = I18n; scope.userPath = PathHelper.staticUserPath; + scope.inEdit = false; scope.activity.links.user.fetch().then(function(user) { scope.userId = user.props.id; scope.userName = user.props.name; scope.userAvatar = user.props.avatar; }); + + scope.editComment = function() { + scope.inEdit = true; + }; + + scope.cancelEdit = function() { + scope.inEdit = false; + }; + + scope.quoteComment = function() { + angular.element('#' + scope.inputElementId).val(quotedText(scope.activity.props.rawComment)); + }; + + scope.updateComment = function(comment) { + ActivityService.updateComment(scope.activity.props.id, comment).then(function(activity){ + + }); + }; + + // TODO RS: Move this into WorkPackageDetailsHepler once it has been merge in from attachments branch + function quotedText(rawComment) { + quoted = rawComment.split("\n") + .map(function(line){ return "\n> " + line; }) + .join(''); + return scope.userName + " wrote:" + quoted; + } } }; }]); diff --git a/public/templates/work_packages/tabs/_editable_comment.html b/public/templates/work_packages/tabs/_editable_comment.html new file mode 100644 index 0000000000..e1bd04e4d3 --- /dev/null +++ b/public/templates/work_packages/tabs/_editable_comment.html @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/public/templates/work_packages/tabs/_user_activity.html b/public/templates/work_packages/tabs/_user_activity.html index c8bdffd208..f009aa334c 100644 --- a/public/templates/work_packages/tabs/_user_activity.html +++ b/public/templates/work_packages/tabs/_user_activity.html @@ -1,13 +1,21 @@