Merge pull request #1680 from opf/fix/edit-comments-styling-and-validation

pull/1697/head
Hagen Schink 10 years ago
commit 3b1928edca
  1. 12
      app/assets/javascripts/angular/directives/components/activity-comment-directive.js
  2. 14
      app/assets/javascripts/angular/work_packages/tabs/exclusive-edit-directive.js
  3. 11
      app/assets/javascripts/angular/work_packages/tabs/user-activity-directive.js
  4. 2
      config/locales/js-de.yml
  5. 2
      config/locales/js-en.yml
  6. 10
      public/templates/components/activity_comment.html
  7. 19
      public/templates/work_packages/tabs/_user_activity.html
  8. 7
      public/templates/work_packages/tabs/activity.html
  9. 5
      public/templates/work_packages/tabs/overview.html

@ -33,14 +33,18 @@ angular.module('openproject.uiComponents')
return { return {
restrict: 'E', restrict: 'E',
replace: true, replace: true,
require: '^?exclusiveEdit',
scope: { scope: {
workPackage: '=', workPackage: '=',
activities: '=' activities: '='
}, },
templateUrl: '/templates/components/activity_comment.html', 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.title = I18n.t('js.label_add_comment_title');
scope.buttonTitle = I18n.t('js.label_add_comment'); scope.buttonTitle = I18n.t('js.label_add_comment');
scope.buttonCancel = I18n.t('js.button_cancel');
scope.canAddComment = !!scope.workPackage.links.addComment; scope.canAddComment = !!scope.workPackage.links.addComment;
scope.activity = { comment: '' }; scope.activity = { comment: '' };
@ -52,7 +56,11 @@ angular.module('openproject.uiComponents')
scope.$emit('workPackageRefreshRequired', ''); scope.$emit('workPackageRefreshRequired', '');
return response; return response;
}); });
} };
scope.clearComment = function() {
scope.activity.comment = '';
};
} }
}; };
}]); }]);

@ -36,15 +36,25 @@ angular.module('openproject.workPackages.tabs')
template: '<div class="exclusive-edit" ng-transclude></div>', template: '<div class="exclusive-edit" ng-transclude></div>',
controller: function() { controller: function() {
var editors = []; var editors = [];
var creator;
this.gotEditable = function(selectedEditor) { this.gotEditable = function(selectedEditor) {
angular.forEach(editors, function(editor) { angular.forEach(editors, function(editor) {
if (selectedEditor != editor) { editor.inEdit = selectedEditor == editor;
editor.inEdit = false; }
}); });
}; };
this.addEditable = function(editor) { this.addEditable = function(editor) {
editors.push(editor); editors.push(editor);
}; };
this.setCreator = function(newCreator) {
creator = newCreator;
};
this.setQuoted = function(text) {
creator.activity.comment = text;
};
} }
}; };
}) })

@ -35,18 +35,25 @@ angular.module('openproject.workPackages.tabs')
require: '^?exclusiveEdit', require: '^?exclusiveEdit',
templateUrl: '/templates/work_packages/tabs/_user_activity.html', templateUrl: '/templates/work_packages/tabs/_user_activity.html',
scope: { scope: {
workPackage: '=',
activity: '=', activity: '=',
activityNo: '=', activityNo: '=',
inputElementId: '=' inputElementId: '='
}, },
link: function(scope, element, attrs, exclusiveEditController) { link: function(scope, element, attrs, exclusiveEditController) {
exclusiveEditController.addEditable(scope); exclusiveEditController.addEditable(scope);
scope.$watch('inEdit', function(newVal, oldVal) {
if(newVal) {
angular.element('#edit-comment-text').focus();
}
})
scope.I18n = I18n; scope.I18n = I18n;
scope.userPath = PathHelper.staticUserPath; scope.userPath = PathHelper.staticUserPath;
scope.inEdit = false; scope.inEdit = false;
scope.inFocus = false; scope.inFocus = false;
scope.userCanEdit = !!scope.activity.links.update; scope.userCanEdit = !!scope.activity.links.update;
scope.userCanQuote = !!scope.workPackage.links.addComment;
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;
@ -55,7 +62,6 @@ angular.module('openproject.workPackages.tabs')
}); });
scope.editComment = function() { scope.editComment = function() {
scope.inEdit = true;
exclusiveEditController.gotEditable(scope); exclusiveEditController.gotEditable(scope);
}; };
@ -64,9 +70,10 @@ angular.module('openproject.workPackages.tabs')
}; };
scope.quoteComment = function() { scope.quoteComment = function() {
exclusiveEditController.setQuoted(quotedText(scope.activity.props.rawComment));
var elem = angular.element('#' + scope.inputElementId); var elem = angular.element('#' + scope.inputElementId);
elem.val(quotedText(scope.activity.props.rawComment));
$uiViewScroll(elem); $uiViewScroll(elem);
elem.focus();
}; };
scope.updateComment = function(comment) { scope.updateComment = function(comment) {

@ -32,6 +32,7 @@ de:
hide: "Verbergen" hide: "Verbergen"
loading: "Lädt ..." loading: "Lädt ..."
button_add_watcher: "Beobachter hinzufügen" button_add_watcher: "Beobachter hinzufügen"
button_cancel: "Abbrechen"
button_check_all: "Alles auswählen" button_check_all: "Alles auswählen"
button_copy: "Kopieren" button_copy: "Kopieren"
button_delete: "Löschen" button_delete: "Löschen"
@ -41,6 +42,7 @@ de:
button_log_time: "Aufwand buchen" button_log_time: "Aufwand buchen"
button_move: "Verschieben" button_move: "Verschieben"
button_quote: "Zitieren" button_quote: "Zitieren"
button_save: "Speichern"
button_uncheck_all: "Alles abwählen" button_uncheck_all: "Alles abwählen"
button_update: "Bearbeiten" button_update: "Bearbeiten"
description_available_columns: "Verfügbare Spalten" description_available_columns: "Verfügbare Spalten"

@ -32,6 +32,7 @@ en:
hide: "Hide" hide: "Hide"
loading: "Loading ..." loading: "Loading ..."
button_add_watcher: "Add watcher" button_add_watcher: "Add watcher"
button_cancel: "Cancel"
button_check_all: "Check all" button_check_all: "Check all"
button_copy: "Copy" button_copy: "Copy"
button_delete: "Delete" button_delete: "Delete"
@ -41,6 +42,7 @@ en:
button_log_time: "Log time" button_log_time: "Log time"
button_move: "Move" button_move: "Move"
button_quote: "Quote" button_quote: "Quote"
button_save: "Save"
button_uncheck_all: "Uncheck all" button_uncheck_all: "Uncheck all"
button_update: "Update" button_update: "Update"
description_available_columns: "Available Columns" description_available_columns: "Available Columns"

@ -3,12 +3,18 @@
<label> <label>
<h3>{{ title }}</h3> <h3>{{ title }}</h3>
<textarea id="add-comment-text" <textarea id="add-comment-text"
class="add-comment-text"
name="add_comment_text" name="add_comment_text"
ng-model="activity.comment" ng-model="activity.comment"
required></textarea> required
placeholder="Add your comments here">
</textarea>
<button class="button" <button class="button"
ng-click="createComment()" ng-click="createComment()"
ng-disabled="commentForm.$invalid">{{ buttonTitle }}</button> ng-disabled="commentForm.$invalid"><i class="icon-yes icon-left"></i>{{ buttonTitle }}
</button>
<button class="button" ng-disabled="commentForm.$invalid" ng-click="clearComment()">
<i class="icon-close icon-left"></i>{{ buttonCancel }}</button>
</label> </label>
</form> </form>
</div> </div>

@ -4,7 +4,9 @@
<div class="comments-number"><a ng-href="#{{ currentAnchor }}" ng-bind="'#' + activityNo"></a> <div class="comments-number"><a ng-href="#{{ currentAnchor }}" ng-bind="'#' + activityNo"></a>
<div class="comments-icons" <div class="comments-icons"
ng-show="activity.props._type == 'Activity::Comment' && inFocus"> ng-show="activity.props._type == 'Activity::Comment' && inFocus">
<i class="icon-quote action-icon" ng-click="quoteComment()"></i> <i class="icon-quote action-icon"
ng-if="userCanQuote"
ng-click="quoteComment()"></i>
<i class="icon-edit action-icon" <i class="icon-edit action-icon"
ng-if="userCanEdit" ng-if="userCanEdit"
ng-click="editComment()"></i> ng-click="editComment()"></i>
@ -15,15 +17,24 @@
<span class="date">{{ I18n.t('js.label_commented_on') }} <date-time date-time-value="activity.props.createdAt"/></date-time> <span class="date">{{ I18n.t('js.label_commented_on') }} <date-time date-time-value="activity.props.createdAt"/></date-time>
<span class="comment wiki"> <span class="comment wiki">
<div ng-if="inEdit"> <div ng-if="inEdit">
<form name="editCommentForm">
<div> <div>
<textarea id="edit-comment-text" <textarea id="edit-comment-text"
name="edit_comment_text"
class="add-comment-text"
ng-model="activity.props.rawComment"
ng-bind-html="activity.props.rawComment" ng-bind-html="activity.props.rawComment"
rows="5"></textarea> rows="4"
required></textarea>
</div> </div>
<div> <div>
<button class="button" ng-click="updateComment()">{{ I18n.t('js.button_update') }}</button> <button class="button"
<span><a href="" ng-click="cancelEdit()">cancel</a></span> ng-click="updateComment()"
ng-disabled="editCommentForm.$invalid"><i class="icon-yes icon-left"></i>{{ I18n.t('js.button_save') }}
</button>
<button class="button" ng-disabled="commentForm.$invalid" ng-click="cancelEdit()"><i class="icon-close icon-left"></i>{{ I18n.t('js.button_cancel') }}</button>
</div> </div>
</form>
</div> </div>
<span ng-if="!inEdit" <span ng-if="!inEdit"
class="message" class="message"

@ -1,6 +1,6 @@
<div class="detail-panel-content" > <div class="detail-panel-content" >
<div class="detail-activity">
<exclusive-edit> <exclusive-edit>
<div class="detail-activity">
<ul class="work-package-details-activities-list"> <ul class="work-package-details-activities-list">
<li ng-repeat="activity in activities" <li ng-repeat="activity in activities"
class="work-package-details-activities-activity" class="work-package-details-activities-activity"
@ -10,15 +10,16 @@
<h3 class="activity-date" <h3 class="activity-date"
ng-if="currentDate !== (activities[$index-1].props.createdAt | date:'longDate')" ng-if="currentDate !== (activities[$index-1].props.createdAt | date:'longDate')"
ng-bind="currentDate"/> ng-bind="currentDate"/>
<user-activity activity="activity" <user-activity work-package="workPackage"
activity="activity"
activity-no="activityNo" activity-no="activityNo"
input-element-id="'add-comment-text'"> input-element-id="'add-comment-text'">
</user-activity> </user-activity>
</li> </li>
</ul> </ul>
</exclusive-edit>
</div> </div>
<activity-comment work-package="workPackage" <activity-comment work-package="workPackage"
activities="activities"> activities="activities">
</activity-comment> </activity-comment>
</exclusive-edit>
</div> </div>

@ -43,13 +43,14 @@
class="work-package-details-activities-activity" class="work-package-details-activities-activity"
ng-init="currentAnchor = 'note-' + ($index+1); ng-init="currentAnchor = 'note-' + ($index+1);
activityNo = activities.length - $index;"> activityNo = activities.length - $index;">
<user-activity activity="activity" <user-activity work-package="workPackage"
activity="activity"
activity-no="activityNo" activity-no="activityNo"
input-element-id="'add-comment-text'"> input-element-id="'add-comment-text'">
</li> </li>
</ul> </ul>
</exclusive-edit>
<activity-comment work-package="workPackage" <activity-comment work-package="workPackage"
activities="activities"> activities="activities">
</activity-comment> </activity-comment>
</exclusive-edit>
</div> </div>

Loading…
Cancel
Save