Overhaul change recommendation statuses

This commit is contained in:
Tobias Hößl 2016-11-13 13:19:16 +01:00
parent e8bf67b185
commit 32d3d804b1
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')
"""The motion version to which the change recommendation belongs."""
status = models.PositiveIntegerField(default=0)
"""Proposed (0), Accepted (1), Rejected (2)"""
rejected = models.BooleanField(default=False)
"""If true, this change recommendation has been rejected"""
line_from = models.PositiveIntegerField()
"""The number or the first affected line"""

View File

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

View File

@ -239,15 +239,14 @@ angular.module('OpenSlidesApp.motions', [
return html;
},
getTextWithChangeRecommendations: function (versionId, statusCompareCb) {
_getTextWithChangeRecommendations: function (versionId, statusCompareCb) {
var lineLength = Config.get('motions_line_length').value,
html = this.getVersion(versionId).text,
changes = this.getChangeRecommendations(versionId, 'DESC'),
fragment;
changes = this.getChangeRecommendations(versionId, 'DESC');
for (var i = 0; i < changes.length; i++) {
var change = changes[i];
if (statusCompareCb === undefined || statusCompareCb(change.status)) {
if (statusCompareCb === undefined || statusCompareCb(change.rejected)) {
html = lineNumberingService.insertLineNumbers(html, lineLength);
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);
},
getTextWithAcceptedChangeRecommendations: function (versionId) {
return this.getTextWithChangeRecommendations(versionId, function(status) {
return (status == 1);
getTextWithAllChangeRecommendations: function (versionId) {
return this._getTextWithChangeRecommendations(versionId, function() {
return true;
});
},
getTextWithoutRejectedChangeRecommendations: function (versionId) {
return this._getTextWithChangeRecommendations(versionId, function(rejected) {
return !rejected;
});
},
getTextByMode: function(mode, versionId) {
@ -280,10 +284,10 @@ angular.module('OpenSlidesApp.motions', [
text += this.getTextRemainderAfterLastChangeRecommendation(versionId, changes);
break;
case 'changed':
text = this.getTextWithChangeRecommendations(versionId);
text = this.getTextWithAllChangeRecommendations(versionId);
break;
case 'agreed':
text = this.getTextWithAcceptedChangeRecommendations(versionId);
text = this.getTextWithoutRejectedChangeRecommendations(versionId);
break;
}
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')) {
throw 'No permission to update motion';
}
var newHtml = (
includeProposed ?
motion.getTextWithoutRejectedChangeRecommendations(version) :
motion.getTextWithAcceptedChangeRecommendations(version)
);
var newHtml = motion.getTextByMode('agreed');
motion.setTextStrippingLineBreaks(newHtml);
Motion.inject(motion);

View File

@ -345,7 +345,7 @@
<!-- Changed View -->
<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>
<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 -->
<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>
<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>
</span>
<span class="status">
<translate ng-if="change.status == 0">Suggested</translate>
<translate ng-if="change.status == 1">Accepted</translate>
<translate ng-if="change.status == 2">Rejected</translate>
<translate ng-if="change.rejected">Rejected</translate>
</span>
</li>
</ul>

View File

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