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.');
}
// 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 = [];

View File

@ -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 {

View File

@ -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];
}
}
}

View File

@ -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);
}
};
// save additional recommendation field
$scope.saveAdditionalRecommendationField = function (recommendationExtension) {
if (recommendationExtension) {
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

View File

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

View File

@ -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.</p>
""",
id est laborum.</p>""".replace('\n', ' '),
"""\
<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
reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae
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
@ -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</p>
""",
perferendis doloribus asperiores repellat</p>""".replace('\n', ' '),
]
DEFAULT_NUMBER = 100