Merge pull request #3361 from FinnStutzenstein/ReasonInlineEditing

Inline editing for motion reason
This commit is contained in:
Norman Jäckel 2017-08-28 20:53:28 +02:00 committed by GitHub
commit 1ca829f902
4 changed files with 44 additions and 7 deletions

View File

@ -36,6 +36,7 @@ Motions:
- Added config value for pagenumber alignment in PDF [#3327].
- Bugfix: Several bugfixes regarding splitting list items in
change recommendations [#3288]
- Added inline Editing for motion reason [#3361].
Users:
- User without permission to see users can now see agenda item speakers,

View File

@ -1214,7 +1214,7 @@ angular.module('OpenSlidesApp.motions.site', [
$scope.setProjectionMode($scope.projectionModes[0]);
}
if ($scope.change_recommendations.length > 0) {
$scope.inlineEditing.disable();
$scope.disableMotionInlineEditing();
}
});
$scope.$watch(function () {
@ -1313,7 +1313,7 @@ angular.module('OpenSlidesApp.motions.site', [
// open edit dialog
$scope.openDialog = function (motion) {
if ($scope.inlineEditing.active) {
$scope.inlineEditing.disable();
$scope.disableMotionInlineEditing();
}
ngDialog.open(MotionForm.getDialog(motion));
};
@ -1428,6 +1428,7 @@ angular.module('OpenSlidesApp.motions.site', [
$scope.showVersion = function (version) {
$scope.version = version.id;
$scope.inlineEditing.setVersion(motion, version.id);
$scope.reasonInlineEditing.setVersion(motion, version.id);
$scope.createChangeRecommendation.setVersion(motion, version.id);
};
// permit specific version
@ -1483,18 +1484,51 @@ angular.module('OpenSlidesApp.motions.site', [
Config.get('motions_allow_disable_versioning').value);
}
);
$scope.reasonInlineEditing = MotionInlineEditing.createInstance($scope, motion,
'reason-inline-editor', true,
function (obj) {
return motion.getReason($scope.version);
},
function (obj) {
motion.reason = obj.editor.getData();
motion.disable_versioning = (obj.trivialChange &&
Config.get('motions_allow_disable_versioning').value);
}
);
// Wrapper functions for $scope.inlineEditing, to warn other users.
var editingStoppedCallback;
$scope.enableMotionInlineEditing = function () {
editingStoppedCallback = EditingWarning.editingStarted('motion_update_' + motion.id);
if ($scope.motion.getReason($scope.version)) {
$scope.reasonInlineEditing.enable();
}
$scope.inlineEditing.enable();
};
$scope.disableMotionInlineEditing = function () {
if (editingStoppedCallback) {
editingStoppedCallback();
}
if ($scope.motion.getReason($scope.version)) {
$scope.reasonInlineEditing.disable();
}
$scope.inlineEditing.disable();
};
$scope.textReasonSaveToolbarVisible = function () {
return ($scope.inlineEditing.changed && $scope.inlineEditing.active) ||
($scope.reasonInlineEditing.changed && $scope.reasonInlineEditing.active);
};
$scope.textReasonSave = function () {
if ($scope.motion.getReason($scope.version)) {
$scope.reasonInlineEditing.save();
}
$scope.inlineEditing.save();
};
$scope.textReasonRevert = function () {
if ($scope.motion.getReason($scope.version)) {
$scope.reasonInlineEditing.revert();
}
$scope.inlineEditing.revert();
};
$scope.commentsInlineEditing = MotionCommentsInlineEditing.createInstances($scope, motion);
$scope.personalNoteInlineEditing = MotionInlineEditing.createInstance($scope, motion,
'personal-note-inline-editor', false,

View File

@ -482,7 +482,9 @@
<!-- reason -->
<div ng-if="motion.getReason(version) != ''">
<h3 translate>Reason</h3>
<div ng-bind-html="motion.getReason(version) | trusted"></div>
<div id="reason-inline-editor" ng-bind-html="motion.getReason(version) | trusted"
contenteditable="{{ reasonInlineEditing.isEditable }}">
</div>
</div>
<!-- attachments -->

View File

@ -4,12 +4,12 @@
class="motion-text motion-text-original line-numbers-{{ lineNumberMode }}"
contenteditable="{{ inlineEditing.isEditable }}">
</div>
<div class="motion-save-toolbar" ng-class="{ 'visible': (inlineEditing.changed && inlineEditing.active) }">
<div class="changed-hint" translate>The text has been changed.</div>
<button type="button" ng-click="inlineEditing.save()" class="btn btn-primary" translate>
<div class="motion-save-toolbar" ng-class="{ 'visible': textReasonSaveToolbarVisible() }">
<div class="changed-hint" translate>The text or reason have been changed.</div>
<button type="button" ng-click="textReasonSave()" class="btn btn-primary" translate>
Save
</button>
<button type="button" ng-click="inlineEditing.revert()" class="btn btn-default" translate>
<button type="button" ng-click="textReasonRevert()" class="btn btn-default" translate>
Revert
</button>
<label ng-if="motion.state.versioning && config('motions_allow_disable_versioning')">