Merge pull request #2982 from emanuelschuetze/recommendation-config

Added new config for default change recommendation view.
This commit is contained in:
Norman Jäckel 2017-02-17 16:33:36 +01:00 committed by GitHub
commit 56420aa0f5
5 changed files with 34 additions and 9 deletions

View File

@ -108,6 +108,20 @@ def get_config_variables():
subgroup='General', subgroup='General',
translatable=True) translatable=True)
yield ConfigVariable(
name='motions_recommendation_text_mode',
default_value='original',
input_type='choice',
label='Default text version for change recommendations',
choices=(
{'value': 'original', 'display_name': 'Original version'},
{'value': 'changed', 'display_name': 'Changed version'},
{'value': 'diff', 'display_name': 'Diff version'},
{'value': 'agreed', 'display_name': 'Final version'}),
weight=333,
group='Motions',
subgroup='General')
# Amendments # Amendments
yield ConfigVariable( yield ConfigVariable(
name='motions_amendments_enabled', name='motions_amendments_enabled',

View File

@ -532,7 +532,7 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
} }
}; };
// returns the pure content of the motion, parseable by makepdf // returns the pure content of the motion, parseable by pdfmake
var getContent = function() { var getContent = function() {
var motionContent = []; var motionContent = [];
angular.forEach(allMotions, function(motion, key) { angular.forEach(allMotions, function(motion, key) {

View File

@ -640,11 +640,13 @@ angular.module('OpenSlidesApp.motions.site', [
'MotionForm', 'MotionForm',
'Motion', 'Motion',
'Category', 'Category',
'Config',
'Tag', 'Tag',
'Workflow', 'Workflow',
'User', 'User',
'Agenda', 'Agenda',
'MotionBlock', 'MotionBlock',
'MotionChangeRecommendation',
'MotionCsvExport', 'MotionCsvExport',
'MotionDocxExport', 'MotionDocxExport',
'MotionContentProvider', 'MotionContentProvider',
@ -658,9 +660,10 @@ angular.module('OpenSlidesApp.motions.site', [
'osTableSort', 'osTableSort',
'PdfCreate', 'PdfCreate',
function($scope, $state, $http, gettext, gettextCatalog, ngDialog, MotionForm, Motion, function($scope, $state, $http, gettext, gettextCatalog, ngDialog, MotionForm, Motion,
Category, Tag, Workflow, User, Agenda, MotionBlock, MotionCsvExport, MotionDocxExport, Category, Config, Tag, Workflow, User, Agenda, MotionBlock, MotionChangeRecommendation,
MotionContentProvider, MotionCatalogContentProvider, PdfMakeConverter, PdfMakeDocumentProvider, MotionCsvExport, MotionDocxExport, MotionContentProvider, MotionCatalogContentProvider,
HTMLValidizer, Projector, ProjectionDefault, osTableFilter, osTableSort, PdfCreate) { PdfMakeConverter, PdfMakeDocumentProvider, HTMLValidizer, Projector, ProjectionDefault,
osTableFilter, osTableSort, PdfCreate) {
Motion.bindAll({}, $scope, 'motions'); Motion.bindAll({}, $scope, 'motions');
Category.bindAll({}, $scope, 'categories'); Category.bindAll({}, $scope, 'categories');
MotionBlock.bindAll({}, $scope, 'motionBlocks'); MotionBlock.bindAll({}, $scope, 'motionBlocks');
@ -864,10 +867,17 @@ angular.module('OpenSlidesApp.motions.site', [
$scope.pdfExport = function() { $scope.pdfExport = function() {
var filename = gettextCatalog.getString("Motions") + ".pdf"; var filename = gettextCatalog.getString("Motions") + ".pdf";
var image_sources = []; var image_sources = [];
$scope.viewChangeRecommendations = {};
$scope.viewChangeRecommendations.mode = Config.get('motions_recommendation_text_mode').value;
$scope.lineNumberMode = Config.get('motions_default_line_numbering').value;
//save the arrays of the filtered motions to an array //save the arrays of the filtered motions to an array
angular.forEach($scope.motionsFiltered, function (motion) { angular.forEach($scope.motionsFiltered, function (motion) {
var content = HTMLValidizer.validize(motion.getText($scope.version)) + HTMLValidizer.validize(motion.getReason($scope.version)); $scope.change_recommendations = MotionChangeRecommendation.filter({
'where': {'motion_version_id': {'==': motion.active_version}}
});
var text = motion.getTextByMode($scope.viewChangeRecommendations.mode, null);
var content = HTMLValidizer.validize(text) + HTMLValidizer.validize(motion.getReason());
var map = Function.prototype.call.bind([].map); var map = Function.prototype.call.bind([].map);
var tmp_image_sources = map($(content).find("img"), function(element) { var tmp_image_sources = map($(content).find("img"), function(element) {
return element.getAttribute("src"); return element.getAttribute("src");
@ -1025,7 +1035,7 @@ angular.module('OpenSlidesApp.motions.site', [
{mode: 'diff', {mode: 'diff',
label: 'Diff version'}, label: 'Diff version'},
{mode: 'agreed', {mode: 'agreed',
label: 'Resolution'}, label: 'Final version'},
]; ];
$scope.projectionMode = $scope.projectionModes[0]; $scope.projectionMode = $scope.projectionModes[0];
if (motion.isProjected().length) { if (motion.isProjected().length) {
@ -1248,7 +1258,7 @@ angular.module('OpenSlidesApp.motions.site', [
// Change recommendation viewing // Change recommendation viewing
$scope.viewChangeRecommendations = ChangeRecommmendationView; $scope.viewChangeRecommendations = ChangeRecommmendationView;
$scope.viewChangeRecommendations.init($scope, 'original'); $scope.viewChangeRecommendations.init($scope, Config.get('motions_recommendation_text_mode').value);
// PDF creating functions // PDF creating functions
$scope.pdfExport = MotionPDFExport; $scope.pdfExport = MotionPDFExport;
@ -1906,6 +1916,7 @@ angular.module('OpenSlidesApp.motions.site', [
gettext('Stop submitting new motions by non-staff users'); gettext('Stop submitting new motions by non-staff users');
gettext('Allow to disable versioning'); gettext('Allow to disable versioning');
gettext('Name of recommender'); gettext('Name of recommender');
gettext('Default text version for change recommendations');
gettext('Will be displayed as label before selected recommendation. Use an empty value to disable the recommendation system.'); gettext('Will be displayed as label before selected recommendation. Use an empty value to disable the recommendation system.');
// subgroup Amendments // subgroup Amendments

View File

@ -33,7 +33,7 @@
<a href="" ng-click="setProjectionMode(mode); $event.stopPropagation();"> <a href="" ng-click="setProjectionMode(mode); $event.stopPropagation();">
<i class="fa" ng-class="mode.mode == $parent.projectionMode.mode ? 'fa-check-square-o' : 'fa-square-o'"></i> <i class="fa" ng-class="mode.mode == $parent.projectionMode.mode ? 'fa-check-square-o' : 'fa-square-o'"></i>
<span ng-if="mode.mode!='agreed'">{{ mode.label | translate }}</span> <span ng-if="mode.mode!='agreed'">{{ mode.label | translate }}</span>
<span ng-if="mode.mode=='agreed'"><translate translate-context="decision making">Resolution</translate></span> <span ng-if="mode.mode=='agreed'"><translate translate-context="resolution">Final version</translate></span>
</a> </a>
</li> </li>
<li class="divider" ng-show="projectors.length > 1 && change_recommendations.length > 0"></li> <li class="divider" ng-show="projectors.length > 1 && change_recommendations.length > 0"></li>

View File

@ -108,7 +108,7 @@
<input type="radio" name="viewChangeRecommendations.mode" value="agreed" <input type="radio" name="viewChangeRecommendations.mode" value="agreed"
ng-model="viewChangeRecommendations.mode" ng-model="viewChangeRecommendations.mode"
ng-checked="viewChangeRecommendations.mode == 'agreed'"> ng-checked="viewChangeRecommendations.mode == 'agreed'">
<translate translate-context="decision making">Resolution</translate> <translate translate-context="resolution">Final version</translate>
</label> </label>
</div> </div>
</div> </div>