Merge pull request #3416 from FinnStutzenstein/MotionCommentsFix2

Fixing special comments fields.
This commit is contained in:
Emanuel Schütze 2017-09-22 13:54:16 +02:00 committed by GitHub
commit 88fabd10ab
7 changed files with 46 additions and 36 deletions

View File

@ -70,6 +70,11 @@ angular.module('OpenSlidesApp.core', [
console.error('The constant REALM is not set properly.'); console.error('The constant REALM is not set properly.');
} }
// Get a random retry timeout between 2000 and 5000 ms.
var getTimeoutTime = function () {
return Math.floor(Math.random() * 3000 + 2000);
};
/* The callbacks are invoked if the ws connection closed and this factory tries to /* The callbacks are invoked if the ws connection closed and this factory tries to
* reconnect after 1 second. The callbacks should return a promise. If the promise * reconnect after 1 second. The callbacks should return a promise. If the promise
* resolves, the retry-process is stopped, so the callback can indicate whether it * resolves, the retry-process is stopped, so the callback can indicate whether it
@ -81,7 +86,7 @@ angular.module('OpenSlidesApp.core', [
$q.all(callbackPromises).then(function (success) { $q.all(callbackPromises).then(function (success) {
ErrorMessage.clearConnectionError(); ErrorMessage.clearConnectionError();
}, function (error) { }, function (error) {
$timeout(runRetryConnectCallbacks, 1000); $timeout(runRetryConnectCallbacks, getTimeoutTime());
}); });
}; };
@ -101,7 +106,7 @@ angular.module('OpenSlidesApp.core', [
if (event.code !== 1000) { // 1000 is a normal close, like the close on logout if (event.code !== 1000) { // 1000 is a normal close, like the close on logout
ErrorMessage.setConnectionError(); ErrorMessage.setConnectionError();
} }
$timeout(runRetryConnectCallbacks, 1000); $timeout(runRetryConnectCallbacks, getTimeoutTime());
}; };
socket.onmessage = function (event) { socket.onmessage = function (event) {
var dataList = []; var dataList = [];

View File

@ -183,10 +183,12 @@ angular.module('OpenSlidesApp.core.projector', ['OpenSlidesApp.core'])
var setElements = function (projector) { var setElements = function (projector) {
// Get all elements, that should be projected. // Get all elements, that should be projected.
var newElements = []; var newElements = [];
var enable_clock = Config.get('projector_enable_clock');
enable_clock = enable_clock ? enable_clock.value : true;
_.forEach(slides.getElements(projector), function (element) { _.forEach(slides.getElements(projector), function (element) {
if (!element.error) { if (!element.error) {
// Exclude the clock if it should be disabled. // Exclude the clock if it should be disabled.
if (Config.get('projector_enable_clock').value || element.name !== 'core/clock') { if (enable_clock || element.name !== 'core/clock') {
newElements.push(element); newElements.push(element);
} }
} else { } else {

View File

@ -376,10 +376,9 @@ angular.module('OpenSlidesApp.motions', [
name = gettextCatalog.getString(this.state.name); name = gettextCatalog.getString(this.state.name);
if (this.state.show_state_extension_field) { if (this.state.show_state_extension_field) {
// check motion comment fields for flag 'forState' // check motion comment fields for flag 'forState'
var fields = Config.get('motions_comments').value; var commentFieldForStateId = MotionComment.getFieldIdForFlag('forState');
var index = _.findIndex(fields, ['forState', true]); if (commentFieldForStateId > -1) {
if (index > -1) { additionalName = ' ' + this.comments[commentFieldForStateId];
additionalName = ' ' + this.comments[index];
} }
} }
} }
@ -394,10 +393,9 @@ angular.module('OpenSlidesApp.motions', [
recommendation = gettextCatalog.getString(this.recommendation.recommendation_label); recommendation = gettextCatalog.getString(this.recommendation.recommendation_label);
if (this.recommendation.show_recommendation_extension_field) { if (this.recommendation.show_recommendation_extension_field) {
// check motion comment fields for flag 'forRecommendation' // check motion comment fields for flag 'forRecommendation'
var fields = Config.get('motions_comments').value; var commentFieldForRecommendationId = MotionComment.getFieldIdForFlag('forRecommendation');
var index = _.findIndex(fields, ['forRecommendation', true]); if (commentFieldForRecommendationId > -1) {
if (index > -1) { additionalName = ' ' + this.comments[commentFieldForRecommendationId];
additionalName = ' ' + this.comments[index];
} }
} }
} }

View File

@ -1194,6 +1194,7 @@ angular.module('OpenSlidesApp.motions.site', [
'$scope', '$scope',
'$http', '$http',
'$timeout', '$timeout',
'$window',
'operator', 'operator',
'ngDialog', 'ngDialog',
'gettextCatalog', 'gettextCatalog',
@ -1220,7 +1221,7 @@ angular.module('OpenSlidesApp.motions.site', [
'PersonalNoteManager', 'PersonalNoteManager',
'WebpageTitle', 'WebpageTitle',
'EditingWarning', 'EditingWarning',
function($scope, $http, $timeout, operator, ngDialog, gettextCatalog, MotionForm, function($scope, $http, $timeout, $window, 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, Editor, Projector, ProjectionDefault, MotionBlock, MotionPdfExport, MotionCommentsInlineEditing, Editor, Projector, ProjectionDefault, MotionBlock, MotionPdfExport,
@ -1259,6 +1260,10 @@ angular.module('OpenSlidesApp.motions.site', [
}, function () { }, function () {
$scope.motion = Motion.get(motionId); $scope.motion = Motion.get(motionId);
MotionComment.populateFields($scope.motion); MotionComment.populateFields($scope.motion);
if (motion.comments) {
$scope.stateExtension = $scope.motion.comments[$scope.commentFieldForStateId];
$scope.recommendationExtension = $scope.motion.comments[$scope.commentFieldForRecommendationId];
}
$scope.motion.personalNote = PersonalNoteManager.getNote($scope.motion); $scope.motion.personalNote = PersonalNoteManager.getNote($scope.motion);
var webpageTitle = gettextCatalog.getString('Motion') + ' '; var webpageTitle = gettextCatalog.getString('Motion') + ' ';
@ -1410,17 +1415,13 @@ angular.module('OpenSlidesApp.motions.site', [
}; };
// save additional state field // save additional state field
$scope.saveAdditionalStateField = function (stateExtension) { $scope.saveAdditionalStateField = function (stateExtension) {
if (stateExtension) {
motion['comment_' + $scope.commentFieldForStateId] = stateExtension; motion['comment_' + $scope.commentFieldForStateId] = stateExtension;
$scope.save(motion); $scope.save(motion);
}
}; };
// save additional recommendation field // save additional recommendation field
$scope.saveAdditionalRecommendationField = function (recommendationExtension) { $scope.saveAdditionalRecommendationField = function (recommendationExtension) {
if (recommendationExtension) {
motion['comment_' + $scope.commentFieldForRecommendationId] = recommendationExtension; motion['comment_' + $scope.commentFieldForRecommendationId] = recommendationExtension;
$scope.save(motion); $scope.save(motion);
}
}; };
// update recommendation // update recommendation
$scope.updateRecommendation = function (recommendation_id) { $scope.updateRecommendation = function (recommendation_id) {
@ -1506,6 +1507,10 @@ angular.module('OpenSlidesApp.motions.site', [
$('#personalNote').css('width', ''); $('#personalNote').css('width', '');
} }
}; };
$scope.gotoPersonalNote = function () {
var pos = $('#personalNote').offset();
$window.scrollTo(pos.left, pos.top);
};
var resizePersonalNoteContainer = function () { var resizePersonalNoteContainer = function () {
if ($scope.personalNotePinned) { if ($scope.personalNotePinned) {
var width = $('#main-column').width() - 40; // Subtract 2x20px margin var width = $('#main-column').width() - 40; // Subtract 2x20px margin

View File

@ -92,7 +92,7 @@
</div> </div>
<div class="detail" uib-collapse="isMeta"> <div class="detail" uib-collapse="isMeta">
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-sm-4">
<!-- submitters --> <!-- submitters -->
<h3 translate>Submitters</h3> <h3 translate>Submitters</h3>
<div ng-repeat="submitter in motion.submitters"> <div ng-repeat="submitter in motion.submitters">
@ -132,7 +132,7 @@
</button> </button>
</div> </div>
</div> </div>
<div class="col-md-4"> <div class="col-sm-4">
<!-- State --> <!-- State -->
<h3 ng-if="!motion.isAllowed('change_state')" class="heading" translate>State</h3> <h3 ng-if="!motion.isAllowed('change_state')" class="heading" translate>State</h3>
<div ng-if="motion.isAllowed('change_state')" class="heading"> <div ng-if="motion.isAllowed('change_state')" class="heading">
@ -161,10 +161,10 @@
</div> </div>
<div os-perms="motions.can_manage" class="input-group spacer" <div os-perms="motions.can_manage" class="input-group spacer"
ng-show="motion.state.show_state_extension_field"> ng-show="motion.state.show_state_extension_field">
<label class="sr-only" for="stateExtensionField">{{ motion.comments[commentFieldForStateId] }}</label> <label class="sr-only" for="stateExtensionField">{{ commentsFields[commentFieldForStateId].name }}</label>
<input type="text" ng-model="stateExtension" <input type="text" ng-model="stateExtension"
id="stateNameExtensionField" class="form-control input-sm" id="stateNameExtensionField" class="form-control input-sm"
placeholder="{{ motion.comments[commentFieldForStateId] }}"> placeholder="{{ commentsFields[commentFieldForStateId].name }}">
<span class="input-group-btn"> <span class="input-group-btn">
<button ng-click="saveAdditionalStateField(stateExtension)" class="btn btn-default btn-sm"> <button ng-click="saveAdditionalStateField(stateExtension)" class="btn btn-default btn-sm">
<i class="fa fa-check"></i> <i class="fa fa-check"></i>
@ -204,11 +204,11 @@
<div class="input-group spacer" <div class="input-group spacer"
ng-if="motion.recommendation.show_recommendation_extension_field"> ng-if="motion.recommendation.show_recommendation_extension_field">
<label class="sr-only" for="recommendationExtensionField"> <label class="sr-only" for="recommendationExtensionField">
{{ motion.comments[commentFieldForRecommendationId] }} {{ commentsFields[commentFieldForRecommendationId].name }}
</label> </label>
<input type="text" ng-model="recommendationExtension" <input type="text" ng-model="recommendationExtension"
id="recommendationExtensionField" class="form-control input-sm" id="recommendationExtensionField" class="form-control input-sm"
placeholder="{{ motion.comments[commentFieldForRecommendationId] }}"> placeholder="{{ commentsFields[commentFieldForRecommendationId].name }}">
<span class="input-group-btn"> <span class="input-group-btn">
<button ng-click="saveAdditionalRecommendationField(recommendationExtension)" class="btn btn-default btn-sm"> <button ng-click="saveAdditionalRecommendationField(recommendationExtension)" class="btn btn-default btn-sm">
<i class="fa fa-check"></i> <i class="fa fa-check"></i>
@ -244,7 +244,9 @@
</ul> </ul>
</span> </span>
</div> </div>
<div ng-show="motion.category">
{{ motion.category.prefix }} &ndash; {{ motion.category.name }} {{ motion.category.prefix }} &ndash; {{ motion.category.name }}
</div>
<!-- Motion block --> <!-- Motion block -->
<h3 class="heading" os-perms="!motions.can_manage" ng-show="motion.motionBlock" translate>Motion block</h3> <h3 class="heading" os-perms="!motions.can_manage" ng-show="motion.motionBlock" translate>Motion block</h3>
@ -295,7 +297,7 @@
{{ motion.origin }} {{ motion.origin }}
</div> </div>
<div class="col-md-4"> <div class="col-sm-4">
<h3 ng-if="motion.polls.length > 0" translate>Voting result</h3> <h3 ng-if="motion.polls.length > 0" translate>Voting result</h3>
<ol> <ol>
<li ng-controller="MotionPollDetailCtrl" ng-repeat="poll in motion.polls" class="spacer" <li ng-controller="MotionPollDetailCtrl" ng-repeat="poll in motion.polls" class="spacer"
@ -426,7 +428,7 @@
</button> </button>
<div class="spacer-top pull-right nobr"> <div class="spacer-top pull-right nobr">
<a href="#personalNote" translate>Personal note</a> <a href ng-click="gotoPersonalNote()" translate>Personal note</a>
<span ng-click="pinPersonalNote()" class="spacer-left pointer" title="{{ 'Pin personal note' || translate }}"> <span ng-click="pinPersonalNote()" class="spacer-left pointer" title="{{ 'Pin personal note' || translate }}">
<i class="fa fa-thumb-tack" ng-class="{'rotate-45-deg-right': !personalNotePinned}"></i> <i class="fa fa-thumb-tack" ng-class="{'rotate-45-deg-right': !personalNotePinned}"></i>
</span> </span>

View File

@ -585,7 +585,8 @@ angular.module('OpenSlidesApp.users.site', [
}, },
}; };
} }
$scope.filter.propertyList = ['first_name', 'last_name', 'title', 'number', 'comment', 'structure_level']; $scope.filter.propertyList = ['first_name', 'last_name', 'username', 'title',
'number', 'comment', 'structure_level'];
$scope.filter.propertyDict = { $scope.filter.propertyDict = {
'groups_id' : function (group_id) { 'groups_id' : function (group_id) {
return Group.get(group_id).name; return Group.get(group_id).name;

View File

@ -22,8 +22,7 @@ LOREM_IPSUM = [
commodi consequat. Quis aute iure reprehenderit in voluptate velit esse commodi consequat. Quis aute iure reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat
cupiditat non proident, sunt in culpa qui officia deserunt mollit anim cupiditat non proident, sunt in culpa qui officia deserunt mollit anim
id est laborum.</p> id est laborum.</p>""".replace('\n', ' '),
""",
"""\ """\
<p>Sed ut perspiciatis, unde omnis iste natus error sit voluptatem <p>Sed ut perspiciatis, unde omnis iste natus error sit voluptatem
@ -39,8 +38,7 @@ LOREM_IPSUM = [
aliquid ex ea commodi consequatur? Quis autem vel eum iure aliquid ex ea commodi consequatur? Quis autem vel eum iure
reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae
consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla
pariatur?</p> pariatur?</p>""".replace('\n', ' '),
""",
"""\ """\
<p>At vero eos et accusamus et iusto odio dignissimos ducimus, qui <p>At vero eos et accusamus et iusto odio dignissimos ducimus, qui
@ -55,8 +53,7 @@ LOREM_IPSUM = [
necessitatibus saepe eveniet, ut et voluptates repudiandae sint et necessitatibus saepe eveniet, ut et voluptates repudiandae sint et
molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente
delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut
perferendis doloribus asperiores repellat</p> perferendis doloribus asperiores repellat</p>""".replace('\n', ' '),
""",
] ]
DEFAULT_NUMBER = 100 DEFAULT_NUMBER = 100