From 5532907a12e22adf8d5058c7bd230adfbb8686b2 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 29 Jul 2014 10:27:59 +0200 Subject: [PATCH 1/5] WIP styling comments buttons but broken quoting. --- .../components/activity-comment-directive.js | 6 ++++- .../components/activity_comment.html | 10 +++++-- .../work_packages/tabs/_user_activity.html | 27 ++++++++++++------- 3 files changed, 31 insertions(+), 12 deletions(-) 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..5b8163707f 100644 --- a/app/assets/javascripts/angular/directives/components/activity-comment-directive.js +++ b/app/assets/javascripts/angular/directives/components/activity-comment-directive.js @@ -52,7 +52,11 @@ angular.module('openproject.uiComponents') scope.$emit('workPackageRefreshRequired', ''); return response; }); - } + }; + + scope.clearComment = function() { + scope.activity.comment = ''; + }; } }; }]); diff --git a/public/templates/components/activity_comment.html b/public/templates/components/activity_comment.html index d86fe8128d..fcaf8ad3d2 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..b5868970ab 100644 --- a/public/templates/work_packages/tabs/_user_activity.html +++ b/public/templates/work_packages/tabs/_user_activity.html @@ -15,15 +15,24 @@ {{ I18n.t('js.label_commented_on') }}
-
- -
-
- - cancel -
+
+
+ +
+
+ + +
+
Date: Tue, 29 Jul 2014 10:56:01 +0200 Subject: [PATCH 2/5] Show/hide add/cancel buttons on comment validation. --- .../components/activity-comment-directive.js | 5 ++++- .../work_packages/tabs/exclusive-edit-directive.js | 11 +++++++++++ .../work_packages/tabs/user-activity-directive.js | 2 +- config/locales/js-de.yml | 1 + config/locales/js-en.yml | 1 + public/templates/components/activity_comment.html | 2 +- .../work_packages/tabs/_user_activity.html | 2 +- public/templates/work_packages/tabs/activity.html | 14 +++++++------- public/templates/work_packages/tabs/overview.html | 6 +++--- 9 files changed, 30 insertions(+), 14 deletions(-) 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 5b8163707f..ff2fb7e6c6 100644 --- a/app/assets/javascripts/angular/directives/components/activity-comment-directive.js +++ b/app/assets/javascripts/angular/directives/components/activity-comment-directive.js @@ -33,12 +33,15 @@ 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.canAddComment = !!scope.workPackage.links.addComment; 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..7a49a62cf6 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,26 @@ 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; } }); }; + 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..c3470959f6 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 @@ -64,8 +64,8 @@ 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); }; diff --git a/config/locales/js-de.yml b/config/locales/js-de.yml index 8876c485b7..20c193c60b 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" diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml index c0fa77eded..c46a2a3bfd 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" diff --git a/public/templates/components/activity_comment.html b/public/templates/components/activity_comment.html index fcaf8ad3d2..1a601a25f9 100644 --- a/public/templates/components/activity_comment.html +++ b/public/templates/components/activity_comment.html @@ -14,7 +14,7 @@ ng-disabled="commentForm.$invalid">{{ buttonTitle }} + {{ I18n.t('js.button_cancel') }} diff --git a/public/templates/work_packages/tabs/_user_activity.html b/public/templates/work_packages/tabs/_user_activity.html index b5868970ab..03a999fd6e 100644 --- a/public/templates/work_packages/tabs/_user_activity.html +++ b/public/templates/work_packages/tabs/_user_activity.html @@ -30,7 +30,7 @@ ng-click="updateComment()" ng-disabled="editCommentForm.$invalid">{{ I18n.t('js.button_update') }} - + diff --git a/public/templates/work_packages/tabs/activity.html b/public/templates/work_packages/tabs/activity.html index 777209996d..4c99ee5235 100644 --- a/public/templates/work_packages/tabs/activity.html +++ b/public/templates/work_packages/tabs/activity.html @@ -1,6 +1,6 @@
-
- + +
- -
- - +
+ + +
diff --git a/public/templates/work_packages/tabs/overview.html b/public/templates/work_packages/tabs/overview.html index d11923d82c..384b046666 100644 --- a/public/templates/work_packages/tabs/overview.html +++ b/public/templates/work_packages/tabs/overview.html @@ -48,8 +48,8 @@ input-element-id="'add-comment-text'"> + + - - From abebb88f249b458efcdb538d71b74b6d3f30a720 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 29 Jul 2014 11:08:34 +0200 Subject: [PATCH 3/5] Clean up locales for comments templates. --- .../angular/directives/components/activity-comment-directive.js | 1 + config/locales/js-de.yml | 1 + config/locales/js-en.yml | 1 + public/templates/components/activity_comment.html | 2 +- public/templates/work_packages/tabs/_user_activity.html | 2 +- 5 files changed, 5 insertions(+), 2 deletions(-) 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 ff2fb7e6c6..ce6d7691e0 100644 --- a/app/assets/javascripts/angular/directives/components/activity-comment-directive.js +++ b/app/assets/javascripts/angular/directives/components/activity-comment-directive.js @@ -44,6 +44,7 @@ angular.module('openproject.uiComponents') 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: '' }; diff --git a/config/locales/js-de.yml b/config/locales/js-de.yml index 20c193c60b..e18c455a95 100644 --- a/config/locales/js-de.yml +++ b/config/locales/js-de.yml @@ -42,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 c46a2a3bfd..3f14b9bcb3 100644 --- a/config/locales/js-en.yml +++ b/config/locales/js-en.yml @@ -42,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 1a601a25f9..1f0b28315a 100644 --- a/public/templates/components/activity_comment.html +++ b/public/templates/components/activity_comment.html @@ -14,7 +14,7 @@ ng-disabled="commentForm.$invalid">{{ buttonTitle }} + {{ buttonCancel }} diff --git a/public/templates/work_packages/tabs/_user_activity.html b/public/templates/work_packages/tabs/_user_activity.html index 03a999fd6e..b5c0ed4fc0 100644 --- a/public/templates/work_packages/tabs/_user_activity.html +++ b/public/templates/work_packages/tabs/_user_activity.html @@ -28,7 +28,7 @@
From 674671bd53e1ff291ab89aad9f15d486360432c7 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 29 Jul 2014 11:14:55 +0200 Subject: [PATCH 4/5] Hovering quote icon only appears with add comment privilege. --- .../angular/work_packages/tabs/user-activity-directive.js | 2 ++ public/templates/work_packages/tabs/_user_activity.html | 4 +++- public/templates/work_packages/tabs/activity.html | 3 ++- public/templates/work_packages/tabs/overview.html | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) 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 c3470959f6..122ca33a35 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,6 +35,7 @@ angular.module('openproject.workPackages.tabs') require: '^?exclusiveEdit', templateUrl: '/templates/work_packages/tabs/_user_activity.html', scope: { + workPackage: '=', activity: '=', activityNo: '=', inputElementId: '=' @@ -47,6 +48,7 @@ angular.module('openproject.workPackages.tabs') 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; diff --git a/public/templates/work_packages/tabs/_user_activity.html b/public/templates/work_packages/tabs/_user_activity.html index b5c0ed4fc0..0d950d1069 100644 --- a/public/templates/work_packages/tabs/_user_activity.html +++ b/public/templates/work_packages/tabs/_user_activity.html @@ -4,7 +4,9 @@
- + diff --git a/public/templates/work_packages/tabs/activity.html b/public/templates/work_packages/tabs/activity.html index 4c99ee5235..6cf39cd959 100644 --- a/public/templates/work_packages/tabs/activity.html +++ b/public/templates/work_packages/tabs/activity.html @@ -10,7 +10,8 @@

- diff --git a/public/templates/work_packages/tabs/overview.html b/public/templates/work_packages/tabs/overview.html index 384b046666..4c3a418b97 100644 --- a/public/templates/work_packages/tabs/overview.html +++ b/public/templates/work_packages/tabs/overview.html @@ -43,7 +43,8 @@ class="work-package-details-activities-activity" ng-init="currentAnchor = 'note-' + ($index+1); activityNo = activities.length - $index;"> - From 9d35d742b2bf92858e46e8b41d6e14d7e1a4a893 Mon Sep 17 00:00:00 2001 From: Richard Date: Wed, 30 Jul 2014 14:06:16 +0200 Subject: [PATCH 5/5] Focus on text areas on edit/quote comments. --- .../angular/work_packages/tabs/exclusive-edit-directive.js | 5 ++--- .../angular/work_packages/tabs/user-activity-directive.js | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) 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 7a49a62cf6..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 @@ -40,9 +40,8 @@ angular.module('openproject.workPackages.tabs') this.gotEditable = function(selectedEditor) { angular.forEach(editors, function(editor) { - if (selectedEditor != editor) { - editor.inEdit = false; } - }); + editor.inEdit = selectedEditor == editor; + }); }; this.addEditable = function(editor) { 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 122ca33a35..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 @@ -42,6 +42,11 @@ angular.module('openproject.workPackages.tabs') }, 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; @@ -57,7 +62,6 @@ angular.module('openproject.workPackages.tabs') }); scope.editComment = function() { - scope.inEdit = true; exclusiveEditController.gotEditable(scope); }; @@ -69,6 +73,7 @@ angular.module('openproject.workPackages.tabs') exclusiveEditController.setQuoted(quotedText(scope.activity.props.rawComment)); var elem = angular.element('#' + scope.inputElementId); $uiViewScroll(elem); + elem.focus(); }; scope.updateComment = function(comment) {