Merge pull request #2969 from CatoTH/Issue2961-bugfix

Solving two bugs in the diff - for #2961
This commit is contained in:
Emanuel Schütze 2017-02-16 14:59:51 +01:00 committed by GitHub
commit d595e28d09
9 changed files with 44 additions and 51 deletions

View File

@ -609,11 +609,11 @@ img {
padding-top: 5px; padding-top: 5px;
} }
.change-recommendation-overview { .change-recommendation-overview {
margin-bottom: 50px; margin-bottom: 30px;
padding: 10px; padding: 10px 15px 0 10px;
} }
.change-recommendation-overview h2 { .change-recommendation-overview h3 {
margin-top: 0; margin-top: 10px;
} }
.change-recommendation-overview ul { .change-recommendation-overview ul {
list-style: none; list-style: none;
@ -628,7 +628,7 @@ img {
} }
.change-recommendation-overview li > * { .change-recommendation-overview li > * {
display: table-cell; display: table-cell;
padding: 4px; padding: 1px;
} }
.change-recommendation-overview .status { .change-recommendation-overview .status {
color: gray; color: gray;

View File

@ -534,13 +534,9 @@ tr.elected td {
} }
.diff-box { .diff-box {
background-color: #f9f9f9; margin-left: 25px;
border: solid 1px #eee;
border-radius: 3px;
margin-bottom: 0;
margin-top: -25px;
padding-top: 0; padding-top: 0;
padding-right: 155px; margin-top: -10px;
} }
.motion-text-with-diffs .original-text { .motion-text-with-diffs .original-text {
min-height: 30px; // Spacer between .diff-box, in case .original-text is empty min-height: 30px; // Spacer between .diff-box, in case .original-text is empty
@ -554,34 +550,6 @@ tr.elected td {
.diff-box:hover { .diff-box:hover {
background-color: #f0f0f0; background-color: #f0f0f0;
} }
.diff-box .action-row {
font-size: 0.8em;
padding-top: 5px;
padding-bottom: 5px;
float: right;
width: 150px;
text-align: right;
margin-right: -150px;
opacity: 0.5;
}
.diff-box:hover .action-row {
opacity: 1;
}
.diff-box .action-row .btn-delete {
margin-left: 5px;
color: red;
}
.diff-box .action-row .btn-edit {
margin-left: 5px;
}
.diff-box .status-row {
font-style: italic;
color: gray;
}
.diff-box .status-row > *:after {
content: ':';
}
.motion-text-diff .delete { .motion-text-diff .delete {
color: red; color: red;
text-decoration: line-through; text-decoration: line-through;

View File

@ -736,8 +736,7 @@ angular.module('OpenSlidesApp.motions', [
oldText = data.outerContextStart + data.innerContextStart + oldText = data.outerContextStart + data.innerContextStart +
data.html + data.innerContextEnd + data.outerContextEnd; data.html + data.innerContextEnd + data.outerContextEnd;
var diff = diffService.diff(oldText, this.text, lineLength, this.line_from); return diffService.diff(oldText, this.text, lineLength, this.line_from);
return lineNumberingService.insertLineNumbers(diff, lineLength, highlight, null, this.line_from);
}, },
getType: function(original_full_html) { getType: function(original_full_html) {
return this.type; return this.type;

View File

@ -963,6 +963,17 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi
if (this._diffDetectBrokenDiffHtml(diffUnnormalized)) { if (this._diffDetectBrokenDiffHtml(diffUnnormalized)) {
diff = this._diffParagraphs(htmlOld, htmlNew, lineLength, firstLineNumber); diff = this._diffParagraphs(htmlOld, htmlNew, lineLength, firstLineNumber);
} else { } else {
diffUnnormalized = diffUnnormalized.replace(/<ins>.*?(\n.*?)*<\/ins>/gi, function (found) {
found = found.replace(/<(div|p|li)[^>]*>/gi, function(match) { return match + '<ins>'; });
found = found.replace(/<\/(div|p|li)[^>]*>/gi, function(match) { return '</ins>' + match; });
return found;
});
diffUnnormalized = diffUnnormalized.replace(/<del>.*?(\n.*?)*<\/del>/gi, function (found) {
found = found.replace(/<(div|p|li)[^>]*>/gi, function(match) { return match + '<del>'; });
found = found.replace(/<\/(div|p|li)[^>]*>/gi, function(match) { return '</del>' + match; });
return found;
});
var node = document.createElement('div'); var node = document.createElement('div');
node.innerHTML = diffUnnormalized; node.innerHTML = diffUnnormalized;
diff = node.innerHTML; diff = node.innerHTML;

View File

@ -378,6 +378,9 @@
<div ng-class="{'col-sm-8': (lineNumberMode != 'outside'), 'col-sm-12': (lineNumberMode == 'outside')}"> <div ng-class="{'col-sm-8': (lineNumberMode != 'outside'), 'col-sm-12': (lineNumberMode == 'outside')}">
<ng-include ng-if="viewChangeRecommendations.mode == 'diff'"
src="'static/templates/motions/motion-detail/change-summary.html'"></ng-include>
<div><p>{{ config('motions_preamble') | translate }}</p></div> <div><p>{{ config('motions_preamble') | translate }}</p></div>
<div class="motion-text-holder"> <div class="motion-text-holder">

View File

@ -1,11 +1,11 @@
<!-- A summary of all changes --> <!-- A summary of all changes -->
<section class="change-recommendation-overview"> <section class="change-recommendation-overview">
<h2> <strong>
<translate>Summary of change recommendations</translate> <translate>Summary of change recommendations</translate>:
</h2> </strong>
<ul ng-if="change_recommendations.length > 0"> <ul ng-if="change_recommendations.length > 0">
<li ng-repeat="change in (changes = (change_recommendations | filter:{motion_version_id:version}:true | orderBy: 'line_from')) " <li ng-repeat="change in (changes = (change_recommendations | filter:{motion_version_id:version}:true | orderBy: 'line_from')) ">
ng-click="viewChangeRecommendations.scrollToDiffBox(change.id)"> <a href='' ng-click="viewChangeRecommendations.scrollToDiffBox(change.id)">
<span ng-if="change.line_from >= change.line_to - 1" class="line-number"> <span ng-if="change.line_from >= change.line_to - 1" class="line-number">
<translate>Line</translate> {{ change.line_from }}: <translate>Line</translate> {{ change.line_from }}:
</span> </span>
@ -20,6 +20,7 @@
<span class="status"> <span class="status">
<translate ng-if="change.rejected">Rejected</translate> <translate ng-if="change.rejected">Rejected</translate>
</span> </span>
</a>
</li> </li>
</ul> </ul>
<div ng-if="change_recommendations.length == 0" class="no-changes"> <div ng-if="change_recommendations.length == 0" class="no-changes">

View File

@ -1,5 +1,4 @@
<div ng-if="viewChangeRecommendations.mode == 'diff'"> <div ng-if="viewChangeRecommendations.mode == 'diff'">
<ng-include src="'static/templates/motions/motion-detail/change-summary.html'"></ng-include>
<!-- The actual diff view --> <!-- The actual diff view -->
<div class="motion-text-with-diffs line-numbers-{{ lineNumberMode }}"> <div class="motion-text-with-diffs line-numbers-{{ lineNumberMode }}">

View File

@ -103,11 +103,11 @@
ng-bind-html="change.getDiff(motion, null, line) | trusted"> ng-bind-html="change.getDiff(motion, null, line) | trusted">
</div> </div>
</div> </div>
<div class="motion-text original-text line-numbers-{{ config('motions_default_line_numbering') }}"
ng-bind-html="motion.getTextRemainderAfterLastChangeRecommendation(null, changes, line) | trusted">
</div>
</div> </div>
<div class="motion-text original-text line-numbers-{{ config('motions_default_line_numbering') }}"
ng-bind-html="motion.getTextRemainderAfterLastChangeRecommendation(null, changes, line) | trusted">
</div>
</div> </div>
</div> </div>

View File

@ -351,5 +351,17 @@ describe('linenumbering', function () {
expect(diff).toBe("<P class=\"p1 delete\">Test1 Test2</P><P class=\"p2 insert\">Test1 Test2</P>"); expect(diff).toBe("<P class=\"p1 delete\">Test1 Test2</P><P class=\"p2 insert\">Test1 Test2</P>");
}); });
it('handles inserted paragraphs', function () {
var before = "<P>liebliche Stimme, aber deine Stimme ist rauh; du bist der Wolf.' Da gieng der </P>",
after = "<p>liebliche Stimme, aber deine Stimme ist rauh; du bist der Wolf.'</p>\
\
<p>Der Wolf hatte danach richtig schlechte laune, trank eine Flasche Rum,</p>\
\
<p>machte eine Weltreise und kam danach wieder um die Ziegen zu fressen. Da ging der</p>";
var diff = diffService.diff(before, after);
expect(diff).toBe("<p>liebliche Stimme, aber deine Stimme ist rauh; du bist der <del>Wolf.' </del><ins>Wolf.'</ins></p><p><ins>Der Wolf hatte danach richtig schlechte laune, trank eine Flasche Rum,</ins></p><p><ins>machte eine Weltreise und kam danach wieder um die Ziegen zu fressen. </ins>Da gi<del>e</del>ng der</p>");
});
}); });
}); });