diff --git a/app/assets/javascripts/angular/directives/components/activity-comment-directive.js b/app/assets/javascripts/angular/directives/components/activity-comment-directive.js index e6a28b0bc5..ce6d7691e0 100644 --- a/app/assets/javascripts/angular/directives/components/activity-comment-directive.js +++ b/app/assets/javascripts/angular/directives/components/activity-comment-directive.js @@ -33,14 +33,18 @@ angular.module('openproject.uiComponents') return { restrict: 'E', replace: true, + require: '^?exclusiveEdit', scope: { workPackage: '=', activities: '=' }, templateUrl: '/templates/components/activity_comment.html', - link: function(scope, element, attrs) { + link: function(scope, element, attrs, exclusiveEditController) { + exclusiveEditController.setCreator(scope); + scope.title = I18n.t('js.label_add_comment_title'); scope.buttonTitle = I18n.t('js.label_add_comment'); + scope.buttonCancel = I18n.t('js.button_cancel'); scope.canAddComment = !!scope.workPackage.links.addComment; scope.activity = { comment: '' }; @@ -52,7 +56,11 @@ angular.module('openproject.uiComponents') scope.$emit('workPackageRefreshRequired', ''); return response; }); - } + }; + + scope.clearComment = function() { + scope.activity.comment = ''; + }; } }; }]); diff --git a/app/assets/javascripts/angular/work_packages/tabs/exclusive-edit-directive.js b/app/assets/javascripts/angular/work_packages/tabs/exclusive-edit-directive.js index 049d878f83..d5c8b4765e 100644 --- a/app/assets/javascripts/angular/work_packages/tabs/exclusive-edit-directive.js +++ b/app/assets/javascripts/angular/work_packages/tabs/exclusive-edit-directive.js @@ -36,15 +36,25 @@ angular.module('openproject.workPackages.tabs') template: '
', controller: function() { var editors = []; + var creator; + this.gotEditable = function(selectedEditor) { angular.forEach(editors, function(editor) { - if (selectedEditor != editor) { - editor.inEdit = false; } - }); + editor.inEdit = selectedEditor == editor; + }); }; + this.addEditable = function(editor) { editors.push(editor); }; + + this.setCreator = function(newCreator) { + creator = newCreator; + }; + + this.setQuoted = function(text) { + creator.activity.comment = text; + }; } }; }) 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 153ee21387..10fec68ba4 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 @@ -35,18 +35,25 @@ angular.module('openproject.workPackages.tabs') require: '^?exclusiveEdit', templateUrl: '/templates/work_packages/tabs/_user_activity.html', scope: { + workPackage: '=', activity: '=', activityNo: '=', inputElementId: '=' }, link: function(scope, element, attrs, exclusiveEditController) { exclusiveEditController.addEditable(scope); + scope.$watch('inEdit', function(newVal, oldVal) { + if(newVal) { + angular.element('#edit-comment-text').focus(); + } + }) scope.I18n = I18n; scope.userPath = PathHelper.staticUserPath; scope.inEdit = false; scope.inFocus = false; scope.userCanEdit = !!scope.activity.links.update; + scope.userCanQuote = !!scope.workPackage.links.addComment; scope.activity.links.user.fetch().then(function(user) { scope.userId = user.props.id; @@ -55,7 +62,6 @@ angular.module('openproject.workPackages.tabs') }); scope.editComment = function() { - scope.inEdit = true; exclusiveEditController.gotEditable(scope); }; @@ -64,9 +70,10 @@ angular.module('openproject.workPackages.tabs') }; scope.quoteComment = function() { + exclusiveEditController.setQuoted(quotedText(scope.activity.props.rawComment)); var elem = angular.element('#' + scope.inputElementId); - elem.val(quotedText(scope.activity.props.rawComment)); $uiViewScroll(elem); + elem.focus(); }; scope.updateComment = function(comment) { diff --git a/config/locales/js-de.yml b/config/locales/js-de.yml index 8876c485b7..e18c455a95 100644 --- a/config/locales/js-de.yml +++ b/config/locales/js-de.yml @@ -32,6 +32,7 @@ de: hide: "Verbergen" loading: "Lädt ..." button_add_watcher: "Beobachter hinzufügen" + button_cancel: "Abbrechen" button_check_all: "Alles auswählen" button_copy: "Kopieren" button_delete: "Löschen" @@ -41,6 +42,7 @@ de: button_log_time: "Aufwand buchen" button_move: "Verschieben" button_quote: "Zitieren" + button_save: "Speichern" button_uncheck_all: "Alles abwählen" button_update: "Bearbeiten" description_available_columns: "Verfügbare Spalten" diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml index c0fa77eded..3f14b9bcb3 100644 --- a/config/locales/js-en.yml +++ b/config/locales/js-en.yml @@ -32,6 +32,7 @@ en: hide: "Hide" loading: "Loading ..." button_add_watcher: "Add watcher" + button_cancel: "Cancel" button_check_all: "Check all" button_copy: "Copy" button_delete: "Delete" @@ -41,6 +42,7 @@ en: button_log_time: "Log time" button_move: "Move" button_quote: "Quote" + button_save: "Save" button_uncheck_all: "Uncheck all" button_update: "Update" description_available_columns: "Available Columns" diff --git a/public/templates/components/activity_comment.html b/public/templates/components/activity_comment.html index d86fe8128d..1f0b28315a 100644 --- a/public/templates/components/activity_comment.html +++ b/public/templates/components/activity_comment.html @@ -3,12 +3,18 @@ diff --git a/public/templates/work_packages/tabs/_user_activity.html b/public/templates/work_packages/tabs/_user_activity.html index da45b4236a..0d950d1069 100644 --- a/public/templates/work_packages/tabs/_user_activity.html +++ b/public/templates/work_packages/tabs/_user_activity.html @@ -4,7 +4,9 @@