Merge pull request #2631 from CatoTH/change-change-recommendation-views

Overhaul change recommendation statuses
This commit is contained in:
Norman Jäckel 2016-11-18 10:49:38 +01:00 committed by GitHub
commit 9375727f1f
8 changed files with 55 additions and 42 deletions

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.1 on 2016-11-16 21:22
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('motions', '0007_auto_20161027_1406'),
]
operations = [
migrations.RemoveField(
model_name='motionchangerecommendation',
name='status',
),
migrations.AddField(
model_name='motionchangerecommendation',
name='rejected',
field=models.BooleanField(default=False),
),
]

View File

@ -757,8 +757,8 @@ class MotionChangeRecommendation(RESTModelMixin, models.Model):
related_name='change_recommendations') related_name='change_recommendations')
"""The motion version to which the change recommendation belongs.""" """The motion version to which the change recommendation belongs."""
status = models.PositiveIntegerField(default=0) rejected = models.BooleanField(default=False)
"""Proposed (0), Accepted (1), Rejected (2)""" """If true, this change recommendation has been rejected"""
line_from = models.PositiveIntegerField() line_from = models.PositiveIntegerField()
"""The number or the first affected line""" """The number or the first affected line"""

View File

@ -250,7 +250,7 @@ class MotionChangeRecommendationSerializer(ModelSerializer):
fields = ( fields = (
'id', 'id',
'motion_version', 'motion_version',
'status', 'rejected',
'line_from', 'line_from',
'line_to', 'line_to',
'text', 'text',

View File

@ -239,15 +239,14 @@ angular.module('OpenSlidesApp.motions', [
return html; return html;
}, },
getTextWithChangeRecommendations: function (versionId, statusCompareCb) { _getTextWithChangeRecommendations: function (versionId, statusCompareCb) {
var lineLength = Config.get('motions_line_length').value, var lineLength = Config.get('motions_line_length').value,
html = this.getVersion(versionId).text, html = this.getVersion(versionId).text,
changes = this.getChangeRecommendations(versionId, 'DESC'), changes = this.getChangeRecommendations(versionId, 'DESC');
fragment;
for (var i = 0; i < changes.length; i++) { for (var i = 0; i < changes.length; i++) {
var change = changes[i]; var change = changes[i];
if (statusCompareCb === undefined || statusCompareCb(change.status)) { if (statusCompareCb === undefined || statusCompareCb(change.rejected)) {
html = lineNumberingService.insertLineNumbers(html, lineLength); html = lineNumberingService.insertLineNumbers(html, lineLength);
html = diffService.replaceLines(html, change.text, change.line_from, change.line_to); html = diffService.replaceLines(html, change.text, change.line_from, change.line_to);
} }
@ -255,9 +254,14 @@ angular.module('OpenSlidesApp.motions', [
return lineNumberingService.insertLineNumbers(html, lineLength); return lineNumberingService.insertLineNumbers(html, lineLength);
}, },
getTextWithAcceptedChangeRecommendations: function (versionId) { getTextWithAllChangeRecommendations: function (versionId) {
return this.getTextWithChangeRecommendations(versionId, function(status) { return this._getTextWithChangeRecommendations(versionId, function() {
return (status == 1); return true;
});
},
getTextWithoutRejectedChangeRecommendations: function (versionId) {
return this._getTextWithChangeRecommendations(versionId, function(rejected) {
return !rejected;
}); });
}, },
getTextByMode: function(mode, versionId) { getTextByMode: function(mode, versionId) {
@ -280,10 +284,10 @@ angular.module('OpenSlidesApp.motions', [
text += this.getTextRemainderAfterLastChangeRecommendation(versionId, changes); text += this.getTextRemainderAfterLastChangeRecommendation(versionId, changes);
break; break;
case 'changed': case 'changed':
text = this.getTextWithChangeRecommendations(versionId); text = this.getTextWithAllChangeRecommendations(versionId);
break; break;
case 'agreed': case 'agreed':
text = this.getTextWithAcceptedChangeRecommendations(versionId); text = this.getTextWithoutRejectedChangeRecommendations(versionId);
break; break;
} }
return text; return text;

View File

@ -411,17 +411,12 @@ angular.module('OpenSlidesApp.motions.motionservices', ['OpenSlidesApp.motions',
}); });
}; };
obj.newVersionIncludingChanges = function (motion, version, includeProposed) { obj.newVersionIncludingChanges = function (motion, version) {
if (!motion.isAllowed('update')) { if (!motion.isAllowed('update')) {
throw 'No permission to update motion'; throw 'No permission to update motion';
} }
var newHtml = ( var newHtml = motion.getTextByMode('agreed');
includeProposed ?
motion.getTextWithoutRejectedChangeRecommendations(version) :
motion.getTextWithAcceptedChangeRecommendations(version)
);
motion.setTextStrippingLineBreaks(newHtml); motion.setTextStrippingLineBreaks(newHtml);
Motion.inject(motion); Motion.inject(motion);

View File

@ -345,7 +345,7 @@
<!-- Changed View --> <!-- Changed View -->
<div ng-if="viewChangeRecommendations.mode == 'changed'"> <div ng-if="viewChangeRecommendations.mode == 'changed'">
<div ng-bind-html="motion.getTextWithChangeRecommendations(version) | trusted" <div ng-bind-html="motion.getTextByMode('changed', version) | trusted"
class="motion-text motion-text-changed line-numbers-{{ lineNumberMode }}"></div> class="motion-text motion-text-changed line-numbers-{{ lineNumberMode }}"></div>
<div style="text-align: right;" ng-if="motion.state.versioning && (change_recommendations | filter:{motion_version_id:version}:true).length > 0"> <div style="text-align: right;" ng-if="motion.state.versioning && (change_recommendations | filter:{motion_version_id:version}:true).length > 0">
@ -360,7 +360,7 @@
<!-- Agreed View --> <!-- Agreed View -->
<div ng-if="viewChangeRecommendations.mode == 'agreed'"> <div ng-if="viewChangeRecommendations.mode == 'agreed'">
<div ng-bind-html="motion.getTextWithAcceptedChangeRecommendations(version) | trusted" <div ng-bind-html="motion.getTextByMode('agreed', version) | trusted"
class="motion-text motion-text-changed line-numbers-{{ lineNumberMode }}"></div> class="motion-text motion-text-changed line-numbers-{{ lineNumberMode }}"></div>
<div style="text-align: right;" ng-if="motion.state.versioning && (change_recommendations | filter:{motion_version_id:version}:true).length > 0"> <div style="text-align: right;" ng-if="motion.state.versioning && (change_recommendations | filter:{motion_version_id:version}:true).length > 0">

View File

@ -18,9 +18,7 @@
<translate ng-if="change.getType(motion.getVersion(version).text) == 2">Deletion</translate> <translate ng-if="change.getType(motion.getVersion(version).text) == 2">Deletion</translate>
</span> </span>
<span class="status"> <span class="status">
<translate ng-if="change.status == 0">Suggested</translate> <translate ng-if="change.rejected">Rejected</translate>
<translate ng-if="change.status == 1">Accepted</translate>
<translate ng-if="change.status == 2">Rejected</translate>
</span> </span>
</li> </li>
</ul> </ul>

View File

@ -10,22 +10,16 @@
<div class="diff-box diff-box-{{ change.id }} clearfix"> <div class="diff-box diff-box-{{ change.id }} clearfix">
<div class="action-row" ng-if="motion.isAllowed('can_manage')"> <div class="action-row" ng-if="motion.isAllowed('can_manage')">
<div class="btn-group" data-toggle="buttons"> <div class="btn-group" data-toggle="buttons">
<label class="btn btn-sm btn-default" ng-class="{active: (change.status == 0)}" <label class="btn btn-sm btn-default" ng-class="{active: !change.rejected}"
title="{{ 'Suggested' | translate }}" ng-click="change.status = 0; change.saveStatus();"> title="{{ 'Not rejected' | translate }}" ng-click="change.rejected = false; change.saveStatus();">
<input type="radio" name="changeRecommendationStatus[{{ change.id }}]" value="0" <input type="radio" name="changeRecommendationRejected[{{ change.id }}]" value="0"
ng-change="change.saveStatus()" ng-model="change.status" ng-checked="change.status == 0"> ng-change="change.saveStatus()" ng-model="change.rejected" ng-checked="change.rejected == false">
<i class="fa fa-question"></i>
</label>
<label class="btn btn-sm btn-default" ng-class="{active: (change.status == 1)}"
title="{{ 'Accepted' | translate }}" ng-click="change.status = 1; change.saveStatus();">
<input type="radio" name="changeRecommendationStatus[{{ change.id }}]" value="1"
ng-change="change.saveStatus()" ng-model="change.status" ng-checked="change.status == 1">
<i class="fa fa-thumbs-up"></i> <i class="fa fa-thumbs-up"></i>
</label> </label>
<label class="btn btn-sm btn-default" ng-class="{active: (change.status == 2)}" <label class="btn btn-sm btn-default" ng-class="{active: change.rejected}"
title="{{ 'Rejected' | translate }}" ng-click="change.status = 2; change.saveStatus();"> title="{{ 'Rejected' | translate }}" ng-click="change.rejected = true; change.saveStatus();">
<input type="radio" name="changeRecommendationStatus[{{ change.id }}]" value="2" <input type="radio" name="changeRecommendationRejected[{{ change.id }}]" value="1"
ng-change="change.saveStatus()" ng-model="change.status" ng-checked="change.status == 2"> ng-change="change.saveStatus()" ng-model="change.rejected" ng-checked="change.rejected == true">
<i class="fa fa-thumbs-down"></i> <i class="fa fa-thumbs-down"></i>
</label> </label>
</div> </div>
@ -37,10 +31,8 @@
<i class="fa fa-trash"></i> <i class="fa fa-trash"></i>
</button> </button>
</div> </div>
<div class="status-row" ng-if="!motion.isAllowed('can_manage')"> <div class="status-row" ng-if="!motion.isAllowed('can_manage') && change.rejected">
<span ng-if="change.status == 0"><translate>Suggested</translate></span> <translate>Rejected</translate>
<span ng-if="change.status == 1"><translate>Accepted</translate></span>
<span ng-if="change.status == 2"><translate>Rejected</translate></span>
</div> </div>
<div class="motion-text motion-text-diff line-numbers-{{ lineNumberMode }}" <div class="motion-text motion-text-diff line-numbers-{{ lineNumberMode }}"