Merge pull request #3261 from FinnStutzenstein/NotifyWithInlineEditing

Also notify users when they inline edit a motion
This commit is contained in:
Norman Jäckel 2017-05-19 13:49:08 +02:00 committed by GitHub
commit 76918c47a4
4 changed files with 26 additions and 12 deletions

View File

@ -422,7 +422,7 @@ img {
color: black; color: black;
text-align: center; text-align: center;
padding: 5px; padding: 5px;
z-index: 10000; z-index: 1000001;
display: none; display: none;
border: 1px solid #d3d3d3; border: 1px solid #d3d3d3;
margin-left: -150px; margin-left: -150px;

View File

@ -583,10 +583,10 @@ angular.module('OpenSlidesApp.core.site', [
/* This Factory could be used in any dialog, if the user should be warned, if another user /* This Factory could be used in any dialog, if the user should be warned, if another user
* also has this dialog open. Use it like in this example in any dialog controller: * also has this dialog open. Use it like in this example in any dialog controller:
var dialogClosedCallback = DialogEditingWarning.dialogOpened('dialog_name' + item.id); var editingStoppedCallback = EditingWarning.editingStarted('editing_name' + item.id);
$scope.$on('$destroy', dialogClosedCallback); $scope.$on('$destroy', editingStoppedCallback);
*/ */
.factory('DialogEditingWarning', [ .factory('EditingWarning', [
'operator', 'operator',
'gettextCatalog', 'gettextCatalog',
'Notify', 'Notify',
@ -595,7 +595,7 @@ angular.module('OpenSlidesApp.core.site', [
return { return {
// This returns the callback function that the controller should call, if // This returns the callback function that the controller should call, if
// the dialog got closed by the user. Provide a unique dialog name. // the dialog got closed by the user. Provide a unique dialog name.
dialogOpened: function (dialogName) { editingStarted: function (dialogName) {
// List of active editors // List of active editors
var editorNames = []; var editorNames = [];
var messagingId = dialogName + 'EditingWarning'; var messagingId = dialogName + 'EditingWarning';

View File

@ -1191,10 +1191,12 @@ angular.module('OpenSlidesApp.motions.site', [
'ProjectionDefault', 'ProjectionDefault',
'MotionBlock', 'MotionBlock',
'MotionPdfExport', 'MotionPdfExport',
'EditingWarning',
function($scope, $http, $timeout, operator, ngDialog, gettextCatalog, MotionForm, function($scope, $http, $timeout, operator, ngDialog, gettextCatalog, MotionForm,
ChangeRecommmendationCreate, ChangeRecommmendationView, MotionChangeRecommendation, ChangeRecommmendationCreate, ChangeRecommmendationView, MotionChangeRecommendation,
Motion, MotionComment, Category, Mediafile, Tag, User, Workflow, Config, motionId, MotionInlineEditing, Motion, MotionComment, Category, Mediafile, Tag, User, Workflow, Config, motionId, MotionInlineEditing,
MotionCommentsInlineEditing, Projector, ProjectionDefault, MotionBlock, MotionPdfExport) { MotionCommentsInlineEditing, Projector, ProjectionDefault, MotionBlock, MotionPdfExport,
EditingWarning) {
var motion = Motion.get(motionId); var motion = Motion.get(motionId);
Category.bindAll({}, $scope, 'categories'); Category.bindAll({}, $scope, 'categories');
Mediafile.bindAll({}, $scope, 'mediafiles'); Mediafile.bindAll({}, $scope, 'mediafiles');
@ -1490,6 +1492,18 @@ angular.module('OpenSlidesApp.motions.site', [
Config.get('motions_allow_disable_versioning').value); 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);
$scope.inlineEditing.enable();
};
$scope.disableMotionInlineEditing = function () {
if (editingStoppedCallback) {
editingStoppedCallback();
}
$scope.inlineEditing.disable();
};
$scope.commentsInlineEditing = MotionCommentsInlineEditing.createInstances($scope, motion); $scope.commentsInlineEditing = MotionCommentsInlineEditing.createInstances($scope, motion);
$scope.personalNoteInlineEditing = MotionInlineEditing.createInstance($scope, motion, $scope.personalNoteInlineEditing = MotionInlineEditing.createInstance($scope, motion,
'personal-note-inline-editor', false, 'personal-note-inline-editor', false,
@ -1693,9 +1707,9 @@ angular.module('OpenSlidesApp.motions.site', [
'AgendaUpdate', 'AgendaUpdate',
'motionId', 'motionId',
'ErrorMessage', 'ErrorMessage',
'DialogEditingWarning', 'EditingWarning',
function($scope, $state, Motion, Category, Config, Mediafile, MotionForm, function($scope, $state, Motion, Category, Config, Mediafile, MotionForm,
Tag, User, Workflow, Agenda, AgendaUpdate, motionId, ErrorMessage, DialogEditingWarning) { Tag, User, Workflow, Agenda, AgendaUpdate, motionId, ErrorMessage, EditingWarning) {
Category.bindAll({}, $scope, 'categories'); Category.bindAll({}, $scope, 'categories');
Mediafile.bindAll({}, $scope, 'mediafiles'); Mediafile.bindAll({}, $scope, 'mediafiles');
Tag.bindAll({}, $scope, 'tags'); Tag.bindAll({}, $scope, 'tags');
@ -1751,8 +1765,8 @@ angular.module('OpenSlidesApp.motions.site', [
} }
// Displaying a warning, if other users edit this motion too // Displaying a warning, if other users edit this motion too
var dialogClosedCallback = DialogEditingWarning.dialogOpened('motion_update_dialog_' + motionId); var editingStoppedCallback = EditingWarning.editingStarted('motion_update_' + motionId);
$scope.$on('$destroy', dialogClosedCallback); $scope.$on('$destroy', editingStoppedCallback);
// Save motion // Save motion
$scope.save = function (motion, gotoDetailView) { $scope.save = function (motion, gotoDetailView) {

View File

@ -2,12 +2,12 @@
<!-- inline editing --> <!-- inline editing -->
<div class="pull-right inline-editing-activator" <div class="pull-right inline-editing-activator"
ng-if="motion.isAllowed('update') && version == motion.getVersion(-1).id && viewChangeRecommendations.mode == 'original'"> ng-if="motion.isAllowed('update') && version == motion.getVersion(-1).id && viewChangeRecommendations.mode == 'original'">
<button ng-if="!inlineEditing.active && change_recommendations.length == 0" ng-click="inlineEditing.enable()" <button ng-if="!inlineEditing.active && change_recommendations.length == 0" ng-click="enableMotionInlineEditing()"
class="btn btn-sm btn-default"> class="btn btn-sm btn-default">
<i class="fa fa-pencil-square-o"></i> <i class="fa fa-pencil-square-o"></i>
<translate>Inline editing</translate> <translate>Inline editing</translate>
</button> </button>
<button ng-if="inlineEditing.active && change_recommendations.length == 0" ng-click="inlineEditing.disable()" <button ng-if="inlineEditing.active && change_recommendations.length == 0" ng-click="disableMotionInlineEditing()"
class="btn btn-sm btn-default"> class="btn btn-sm btn-default">
<i class="fa fa-times-circle"></i> <i class="fa fa-times-circle"></i>
<translate>Inline editing</translate> <translate>Inline editing</translate>