Allow to explicitly set the type of a change recommendation

This commit is contained in:
Tobias Hößl 2016-11-13 16:42:56 +01:00
parent 577d0bf3cc
commit 771f087ade
7 changed files with 51 additions and 8 deletions

View File

@ -470,6 +470,14 @@ angular.module('OpenSlidesApp.core.site', [
extends: 'select', extends: 'select',
templateUrl: 'static/templates/core/select-multiple.html' templateUrl: 'static/templates/core/select-multiple.html'
}); });
formlyConfig.setType({
name: 'radio-buttons',
templateUrl: 'static/templates/core/radio-buttons.html',
wrapper: ['bootstrapHasError'],
defaultOptions: {
noFormControl: false
}
});
} }
]) ])

View File

@ -0,0 +1,6 @@
<div class="btn-group" data-toggle="buttons">
<label ng-repeat="(key, option) in to.options" ng-click="model[options.key] = option.value;"
class="btn btn-default btn-sm" ng-class="{active: (model[options.key] == option.value)}">
<input type="radio" tabindex="0" ng-value="option.value" ng-model="model[options.key]">{{option.name}}
</label>
</div>

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2016-11-19 10:29
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('motions', '0008_auto_20161116_2222'),
]
operations = [
migrations.AddField(
model_name='motionchangerecommendation',
name='type',
field=models.PositiveIntegerField(default=0),
),
]

View File

@ -760,6 +760,9 @@ class MotionChangeRecommendation(RESTModelMixin, models.Model):
rejected = models.BooleanField(default=False) rejected = models.BooleanField(default=False)
"""If true, this change recommendation has been rejected""" """If true, this change recommendation has been rejected"""
type = models.PositiveIntegerField(default=0)
"""Replacement (0), Insertion (1), Deletion (2)"""
line_from = models.PositiveIntegerField() line_from = models.PositiveIntegerField()
"""The number or the first affected line""" """The number or the first affected line"""

View File

@ -251,6 +251,7 @@ class MotionChangeRecommendationSerializer(ModelSerializer):
'id', 'id',
'motion_version', 'motion_version',
'rejected', 'rejected',
'type',
'line_from', 'line_from',
'line_to', 'line_to',
'text', 'text',

View File

@ -616,14 +616,7 @@ angular.module('OpenSlidesApp.motions', [
return diffService._serializeDom(mergedFragment); return diffService._serializeDom(mergedFragment);
}, },
getType: function(original_full_html) { getType: function(original_full_html) {
var lineLength = Config.get('motions_line_length').value, return this.type;
html = lineNumberingService.insertLineNumbers(original_full_html, lineLength);
var data = diffService.extractRangeByLineNumbers(html, this.line_from, this.line_to),
oldText = data.outerContextStart + data.innerContextStart +
data.html + data.innerContextEnd + data.outerContextEnd;
return diffService.detectReplacementType(oldText, this.text);
}, },
getTitle: function(original_full_html) { getTitle: function(original_full_html) {
var title; var title;

View File

@ -346,6 +346,18 @@ angular.module('OpenSlidesApp.motions.site', [
}, },
hide: true hide: true
}, },
{
key: 'type',
type: 'radio-buttons',
templateOptions: {
name: 'type',
options: [
{name: gettextCatalog.getString('Replacement'), value: 0},
{name: gettextCatalog.getString('Insertion'), value: 1},
{name: gettextCatalog.getString('Deletion'), value: 2}
]
}
},
{ {
key: 'text', key: 'text',
type: 'editor', type: 'editor',