From aa13e5ddd0167f48a771cedddf7258949de6c5e3 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Fri, 22 Sep 2017 10:38:41 +0200 Subject: [PATCH] Fixing special comments fields, reconnect timeout, minor things. --- openslides/core/static/js/core/base.js | 9 ++++++-- openslides/core/static/js/core/projector.js | 4 +++- openslides/motions/static/js/motions/base.js | 14 +++++------ openslides/motions/static/js/motions/site.js | 23 +++++++++++-------- .../templates/motions/motion-detail.html | 20 ++++++++-------- openslides/users/static/js/users/site.js | 3 ++- .../commands/create-example-data.py | 9 +++----- 7 files changed, 46 insertions(+), 36 deletions(-) diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js index 7f30b67c7..cc68c3100 100644 --- a/openslides/core/static/js/core/base.js +++ b/openslides/core/static/js/core/base.js @@ -70,6 +70,11 @@ angular.module('OpenSlidesApp.core', [ 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 * 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 @@ -81,7 +86,7 @@ angular.module('OpenSlidesApp.core', [ $q.all(callbackPromises).then(function (success) { ErrorMessage.clearConnectionError(); }, 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 ErrorMessage.setConnectionError(); } - $timeout(runRetryConnectCallbacks, 1000); + $timeout(runRetryConnectCallbacks, getTimeoutTime()); }; socket.onmessage = function (event) { var dataList = []; diff --git a/openslides/core/static/js/core/projector.js b/openslides/core/static/js/core/projector.js index c12b36b5e..9530f6692 100644 --- a/openslides/core/static/js/core/projector.js +++ b/openslides/core/static/js/core/projector.js @@ -183,10 +183,12 @@ angular.module('OpenSlidesApp.core.projector', ['OpenSlidesApp.core']) var setElements = function (projector) { // Get all elements, that should be projected. var newElements = []; + var enable_clock = Config.get('projector_enable_clock'); + enable_clock = enable_clock ? enable_clock.value : true; _.forEach(slides.getElements(projector), function (element) { if (!element.error) { // 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); } } else { diff --git a/openslides/motions/static/js/motions/base.js b/openslides/motions/static/js/motions/base.js index 7f67303bc..b44d452f4 100644 --- a/openslides/motions/static/js/motions/base.js +++ b/openslides/motions/static/js/motions/base.js @@ -376,10 +376,9 @@ angular.module('OpenSlidesApp.motions', [ name = gettextCatalog.getString(this.state.name); if (this.state.show_state_extension_field) { // check motion comment fields for flag 'forState' - var fields = Config.get('motions_comments').value; - var index = _.findIndex(fields, ['forState', true]); - if (index > -1) { - additionalName = ' ' + this.comments[index]; + var commentFieldForStateId = MotionComment.getFieldIdForFlag('forState'); + if (commentFieldForStateId > -1) { + additionalName = ' ' + this.comments[commentFieldForStateId]; } } } @@ -394,10 +393,9 @@ angular.module('OpenSlidesApp.motions', [ recommendation = gettextCatalog.getString(this.recommendation.recommendation_label); if (this.recommendation.show_recommendation_extension_field) { // check motion comment fields for flag 'forRecommendation' - var fields = Config.get('motions_comments').value; - var index = _.findIndex(fields, ['forRecommendation', true]); - if (index > -1) { - additionalName = ' ' + this.comments[index]; + var commentFieldForRecommendationId = MotionComment.getFieldIdForFlag('forRecommendation'); + if (commentFieldForRecommendationId > -1) { + additionalName = ' ' + this.comments[commentFieldForRecommendationId]; } } } diff --git a/openslides/motions/static/js/motions/site.js b/openslides/motions/static/js/motions/site.js index 6edfb3225..c72bf5235 100644 --- a/openslides/motions/static/js/motions/site.js +++ b/openslides/motions/static/js/motions/site.js @@ -1194,6 +1194,7 @@ angular.module('OpenSlidesApp.motions.site', [ '$scope', '$http', '$timeout', + '$window', 'operator', 'ngDialog', 'gettextCatalog', @@ -1220,7 +1221,7 @@ angular.module('OpenSlidesApp.motions.site', [ 'PersonalNoteManager', 'WebpageTitle', 'EditingWarning', - function($scope, $http, $timeout, operator, ngDialog, gettextCatalog, MotionForm, + function($scope, $http, $timeout, $window, operator, ngDialog, gettextCatalog, MotionForm, ChangeRecommmendationCreate, ChangeRecommmendationView, MotionChangeRecommendation, Motion, MotionComment, Category, Mediafile, Tag, User, Workflow, Config, motionId, MotionInlineEditing, MotionCommentsInlineEditing, Editor, Projector, ProjectionDefault, MotionBlock, MotionPdfExport, @@ -1259,6 +1260,10 @@ angular.module('OpenSlidesApp.motions.site', [ }, function () { $scope.motion = Motion.get(motionId); 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); var webpageTitle = gettextCatalog.getString('Motion') + ' '; @@ -1410,17 +1415,13 @@ angular.module('OpenSlidesApp.motions.site', [ }; // save additional state field $scope.saveAdditionalStateField = function (stateExtension) { - if (stateExtension) { - motion['comment_' + $scope.commentFieldForStateId] = stateExtension; - $scope.save(motion); - } + motion['comment_' + $scope.commentFieldForStateId] = stateExtension; + $scope.save(motion); }; // save additional recommendation field $scope.saveAdditionalRecommendationField = function (recommendationExtension) { - if (recommendationExtension) { - motion['comment_' + $scope.commentFieldForRecommendationId] = recommendationExtension; - $scope.save(motion); - } + motion['comment_' + $scope.commentFieldForRecommendationId] = recommendationExtension; + $scope.save(motion); }; // update recommendation $scope.updateRecommendation = function (recommendation_id) { @@ -1506,6 +1507,10 @@ angular.module('OpenSlidesApp.motions.site', [ $('#personalNote').css('width', ''); } }; + $scope.gotoPersonalNote = function () { + var pos = $('#personalNote').offset(); + $window.scrollTo(pos.left, pos.top); + }; var resizePersonalNoteContainer = function () { if ($scope.personalNotePinned) { var width = $('#main-column').width() - 40; // Subtract 2x20px margin diff --git a/openslides/motions/static/templates/motions/motion-detail.html b/openslides/motions/static/templates/motions/motion-detail.html index 4277b47f8..b03ae4671 100644 --- a/openslides/motions/static/templates/motions/motion-detail.html +++ b/openslides/motions/static/templates/motions/motion-detail.html @@ -92,7 +92,7 @@
-
+

Submitters

@@ -132,7 +132,7 @@
-
+

State

@@ -161,10 +161,10 @@
- + + placeholder="{{ commentsFields[commentFieldForStateId].name }}">
- {{ motion.category.prefix }} – {{ motion.category.name }} +
+ {{ motion.category.prefix }} – {{ motion.category.name }} +

Motion block

@@ -295,7 +297,7 @@ {{ motion.origin }}
-
+

Voting result

  1. - Personal note + Personal note diff --git a/openslides/users/static/js/users/site.js b/openslides/users/static/js/users/site.js index 740eb9df9..35984c853 100644 --- a/openslides/users/static/js/users/site.js +++ b/openslides/users/static/js/users/site.js @@ -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 = { 'groups_id' : function (group_id) { return Group.get(group_id).name; diff --git a/tests/example_data_generator/management/commands/create-example-data.py b/tests/example_data_generator/management/commands/create-example-data.py index b30bd1d6d..a7755cc42 100644 --- a/tests/example_data_generator/management/commands/create-example-data.py +++ b/tests/example_data_generator/management/commands/create-example-data.py @@ -22,8 +22,7 @@ LOREM_IPSUM = [ commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim - id est laborum.

    - """, + id est laborum.

    """.replace('\n', ' '), """\

    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 reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla - pariatur?

    - """, + pariatur?

    """.replace('\n', ' '), """\

    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 molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut - perferendis doloribus asperiores repellat…

    - """, + perferendis doloribus asperiores repellat…

    """.replace('\n', ' '), ] DEFAULT_NUMBER = 100