Toggle to show all amendments in diff view

This commit is contained in:
Tobias Hößl 2020-05-02 17:23:52 +02:00
parent ea830f53b0
commit 25839ea709
No known key found for this signature in database
GPG Key ID: 1D780C7599C2D2A2
5 changed files with 81 additions and 7 deletions

View File

@ -15,7 +15,7 @@ export class ViewMotionAmendedParagraph implements ViewUnifiedChange {
}
public constructor(
private amendment: ViewMotion,
public amendment: ViewMotion,
private paragraphNo: number,
private newText: string,
private lineRange: LineRange

View File

@ -26,10 +26,10 @@
-->
</span>
<span class="status">
<ng-container *ngIf="change.isRejected()">
<ng-container *ngIf="change.isRejected() && !isAmendment(change)">
<span>{{ 'Rejected' | translate }}</span></ng-container
>
<ng-container *ngIf="change.isAccepted() && isAmendment(change)">
<ng-container *ngIf="(change.isAccepted() || isAmendment(change)) && change.stateName">
{{ change.stateName | translate }}</ng-container
>
</span>
@ -104,6 +104,15 @@
>
<mat-icon>more_horiz</mat-icon>
</button>
<button
mat-icon-button
*ngIf="isAmendment(change)"
type="button"
[matMenuTriggerFor]="amendmentMenu"
[matMenuTriggerData]="{ change: change }"
>
<mat-icon>more_horiz</mat-icon>
</button>
<!--
<a ng-if="change.type == 'amendment'" ui-sref="motions.motion.detail({id: change.original.id})"
@ -114,10 +123,18 @@
</a>
-->
</div>
<div class="status-row" *ngIf="change.isRejected()">
<div class="status-row" *ngIf="isChangeRecommendation(change) && change.isRejected()">
<i class="grey">{{ 'Rejected' | translate }}</i>
</div>
<!-- If it's an amendment, only accepted ones will be passed to this component
by default (== !showAllAmendments). In this case, don't show the prefix.
However, if showAllAmendments === true, the prefix should be shown alwayes,
even if it's accepted -->
<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()"
@ -143,12 +160,46 @@
</div>
</div>
<mat-menu #amendmentMenu="matMenu">
<ng-template matMenuContent let-change="change">
<button
type="button"
mat-menu-item
[routerLink]="change.amendment.getDetailStateURL()" [state]="{ back: 'true' }"
>
<mat-icon>visibility_on</mat-icon>
<span>{{ 'Show amendment' | translate }}</span>
</button>
<mat-divider *ngIf="change.amendment.state.next_states.length > 0"></mat-divider>
<button *ngFor="let state of change.amendment.state.next_states" mat-menu-item (click)="setAmendmentState(change, state.id)">
{{ state.name | translate }} <span *ngIf="state.show_state_extension_field">&nbsp;...</span>
</button>
<mat-divider *ngIf="change.amendment.state.next_states.length > 0"></mat-divider>
<button
*ngFor="let state of change.amendment.state.previous_states"
mat-menu-item
(click)="setAmendmentState(change, state.id)"
>
<mat-icon>arrow_back</mat-icon>
{{ state.name | translate }}
<span *ngIf="state.show_state_extension_field">&nbsp;...</span>
</button>
<button mat-menu-item (click)="setAmendmentState(change, null)">
<mat-icon>replay</mat-icon>
{{ 'Reset state' | translate }}
</button>
<!-- perms.isAllowed('change_state', motion) -->
</ng-template>
</mat-menu>
<mat-menu #changeRecommendationMenu="matMenu">
<ng-template matMenuContent let-change="change">
<button
type="button"
mat-menu-item
[disabled]="hasCollissions(change, changes)"
(click)="setAcceptanceValue(change, 'accepted')"
>
<mat-icon>thumb_up</mat-icon>
@ -158,7 +209,6 @@
<button
type="button"
mat-menu-item
[disabled]="hasCollissions(change, changes)"
(click)="setAcceptanceValue(change, 'rejected')"
>
<mat-icon>thumb_down</mat-icon>

View File

@ -26,6 +26,7 @@ import {
MotionTitleChangeRecommendationDialogComponent,
MotionTitleChangeRecommendationDialogComponentData
} from '../motion-title-change-recommendation-dialog/motion-title-change-recommendation-dialog.component';
import { ViewMotionAmendedParagraph } from '../../../../models/view-motion-amended-paragraph';
/**
* This component displays the original motion text with the change blocks inside.
@ -45,6 +46,7 @@ import {
* [scrollToChange]="change"
* [highlightedLine]="highlightedLine"
* [lineNumberingMode]="lnMode"
* [showAllAmendments]="showAllAmendments"
* (createChangeRecommendation)="createChangeRecommendation($event)"
* ></os-motion-detail-diff>
* ```
@ -70,6 +72,8 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte
public highlightedLine: number;
@Input()
public lineNumberingMode: LineNumberingMode;
@Input()
public showAllAmendments: boolean;
@Output()
public createChangeRecommendation: EventEmitter<LineRange> = new EventEmitter<LineRange>();
@ -364,6 +368,10 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte
});
}
public setAmendmentState(change: ViewUnifiedChange, state: number): void {
this.motionRepo.setState((change as ViewMotionAmendedParagraph).amendment, state).catch(this.raiseError);
}
/**
* Scrolls to the native element specified by [scrollToChange]
*/

View File

@ -463,6 +463,11 @@
<span *ngIf="amendments.length === 1">{{ 'Amendment' | translate }}</span>
<span *ngIf="amendments.length > 1">{{ 'Amendments' | translate }}</span>
</a>
<br>
<mat-checkbox [(ngModel)]="showAllAmendments" *ngIf="isRecoMode(ChangeRecoMode.Diff)">
{{ 'Temporarily show all in text' | translate }}
</mat-checkbox>
</div>
<!-- motion polls -->
@ -681,6 +686,7 @@
[changes]="getChangesForDiffMode()"
[scrollToChange]="scrollToChange"
[highlightedLine]="highlightedLine"
[showAllAmendments]="showAllAmendments"
[lineNumberingMode]="lnMode"
(createChangeRecommendation)="createChangeRecommendation($event)"
></os-motion-detail-diff>
@ -904,6 +910,7 @@
[changes]="getChangesForDiffMode()"
[scrollToChange]="scrollToChange"
[highlightedLine]="highlightedLine"
[showAllAmendments]="showAllAmendments"
[lineNumberingMode]="lnMode"
(createChangeRecommendation)="createChangeRecommendation($event)"
></os-motion-detail-diff>

View File

@ -327,6 +327,11 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
*/
private amendmentTextMode: string;
/**
* Show all amendments in the text, not only the ones with the apropriate state
*/
public showAllAmendments = false;
/**
* For using the enum constants from the template
*/
@ -1005,7 +1010,11 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
public getChangesForDiffMode(): ViewUnifiedChange[] {
return this.allChangingObjects.filter(change => {
return change.showInDiffView();
if (this.showAllAmendments) {
return true;
} else {
return change.showInDiffView();
}
});
}