Fix changed amendment in slides

This commit is contained in:
Tobias Hößl 2020-09-16 19:51:07 +02:00
parent 04477d9ebd
commit 1a0e017f80
No known key found for this signature in database
GPG Key ID: 1D780C7599C2D2A2
4 changed files with 101 additions and 14 deletions

View File

@ -1121,4 +1121,20 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo
} }
}); });
} }
public changeHasCollissions(change: ViewUnifiedChange, changes: ViewUnifiedChange[]): boolean {
return (
changes.filter((otherChange: ViewUnifiedChange) => {
return (
otherChange.getChangeId() !== change.getChangeId() &&
((otherChange.getLineFrom() >= change.getLineFrom() &&
otherChange.getLineFrom() < change.getLineTo()) ||
(otherChange.getLineTo() > change.getLineFrom() &&
otherChange.getLineTo() <= change.getLineTo()) ||
(otherChange.getLineFrom() < change.getLineFrom() &&
otherChange.getLineTo() > change.getLineTo()))
);
}).length > 0
);
}
} }

View File

@ -155,19 +155,7 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte
* @param {ViewUnifiedChange[]} changes * @param {ViewUnifiedChange[]} changes
*/ */
public hasCollissions(change: ViewUnifiedChange, changes: ViewUnifiedChange[]): boolean { public hasCollissions(change: ViewUnifiedChange, changes: ViewUnifiedChange[]): boolean {
return ( return this.motionRepo.changeHasCollissions(change, changes);
changes.filter((otherChange: ViewUnifiedChange) => {
return (
otherChange.getChangeId() !== change.getChangeId() &&
((otherChange.getLineFrom() >= change.getLineFrom() &&
otherChange.getLineFrom() < change.getLineTo()) ||
(otherChange.getLineTo() > change.getLineFrom() &&
otherChange.getLineTo() <= change.getLineTo()) ||
(otherChange.getLineFrom() < change.getLineFrom() &&
otherChange.getLineTo() > change.getLineTo()))
);
}).length > 0
);
} }
/** /**

View File

@ -105,7 +105,7 @@
></div> ></div>
<!-- Amendment text --> <!-- Amendment text -->
<section class="text-holder" *ngIf="isParagraphBasedAmendment()"> <section class="text-holder" *ngIf="isParagraphBasedAmendment() && crMode !== 'diff'">
<div class="alert alert-info" *ngIf="getAmendedParagraphs().length === 0"> <div class="alert alert-info" *ngIf="getAmendedParagraphs().length === 0">
<span>{{ 'No changes at the text.' | translate }}</span> <span>{{ 'No changes at the text.' | translate }}</span>
</div> </div>
@ -127,6 +127,51 @@
</div> </div>
</section> </section>
<!-- The actual diff view of an amendment. This logic is based on the os-motion-detail-diff component -->
<section class="text-holder" *ngIf="isParagraphBasedAmendment() && crMode === 'diff'">
<div *ngIf="getTitleChangingObject() as changedTitle">
<div class="diff-box diff-box-{{ changedTitle.getChangeId() }} clearfix">
<div class="status-row" *ngIf="changedTitle.isRejected()">
<i class="grey">{{ 'Rejected' | translate }}</i>
</div>
<div
class="motion-text motion-text-diff"
[class.line-numbers-none]="isLineNumberingNone()"
[class.line-numbers-inline]="isLineNumberingInline()"
[class.line-numbers-outside]="isLineNumberingOutside()"
[attr.data-change-id]="changedTitle.getChangeId()"
>
<div class="bold">{{ 'Changed title' | translate }}:</div>
<div [innerHTML]="getFormattedTitleDiff() | trust: 'html'"></div>
</div>
</div>
</div>
<div *ngFor="let change of getAllTextChangingObjects(); let i = index">
<div
class="diff-box diff-box-{{ change.getChangeId() }} clearfix"
[class.collides]="hasCollissions(change, getAllTextChangingObjects())"
>
<div class="status-row" *ngIf="isChangeRecommendation(change) && change.isRejected()">
<i class="grey">{{ 'Rejected' | translate }}</i>
</div>
<div class="status-row" *ngIf="isAmendment(change) && showAllAmendments">
<i class="grey">{{ change.amendment.identifier }} - {{ change.amendment.state.name | translate }}</i>
</div>
<div
class="motion-text motion-text-diff"
[class.line-numbers-none]="isLineNumberingNone()"
[class.line-numbers-inline]="isLineNumberingInline()"
[class.line-numbers-outside]="isLineNumberingOutside()"
[attr.data-change-id]="change.getChangeId()"
[innerHTML]="getAmendmentDiff(change) | trust: 'html'"
></div>
</div>
</div>
</section>
<!-- Reason --> <!-- Reason -->
<div *ngIf="data.data.reason"> <div *ngIf="data.data.reason">
<h3>{{ 'Reason' | translate }}</h3> <h3>{{ 'Reason' | translate }}</h3>

View File

@ -446,4 +446,42 @@ export class MotionSlideComponent extends BaseMotionSlideComponent<MotionSlideDa
const diffHtml = this.diff.diff(this.data.data.base_statute.text, this.data.data.text); const diffHtml = this.diff.diff(this.data.data.base_statute.text, this.data.data.text);
return this.lineNumbering.insertLineBreaksWithoutNumbers(diffHtml, this.lineLength, true); return this.lineNumbering.insertLineBreaksWithoutNumbers(diffHtml, this.lineLength, true);
} }
/**
* Returns true if this change is colliding with another change
* @param {ViewUnifiedChange} change
* @param {ViewUnifiedChange[]} changes
*/
public hasCollissions(change: ViewUnifiedChange, changes: ViewUnifiedChange[]): boolean {
return this.motionRepo.changeHasCollissions(change, changes);
}
/**
* Returns true if the change is an Amendment
*
* @param {ViewUnifiedChange} change
*/
public isAmendment(change: ViewUnifiedChange): boolean {
return change.getChangeType() === ViewUnifiedChangeType.TYPE_AMENDMENT;
}
/**
* Returns true if the change is a Change Recommendation
*
* @param {ViewUnifiedChange} change
*/
public isChangeRecommendation(change: ViewUnifiedChange): boolean {
return change.getChangeType() === ViewUnifiedChangeType.TYPE_CHANGE_RECOMMENDATION;
}
/**
* Returns the diff string from the motion to the change
* @param {ViewUnifiedChange} change
*/
public getAmendmentDiff(change: ViewUnifiedChange): string {
const motion = this.data.data;
const baseHtml = this.lineNumbering.insertLineNumbers(motion.base_motion?.text, this.lineLength);
return this.diff.getChangeDiff(baseHtml, change, this.lineLength, this.highlightedLine);
}
} }