Avoid final version to amendments

If the motion is a paragraph based amendment the user cannot create a
final version anymore
This commit is contained in:
Sean 2020-09-14 16:40:08 +02:00
parent 2759f8ce2b
commit bc333a6b51
2 changed files with 18 additions and 1 deletions

View File

@ -553,7 +553,7 @@
type="button"
mat-icon-button
matTooltip="{{ 'Create final print template' | translate }}"
*ngIf="motion.state.isFinalState && !motion.modified_final_version"
*ngIf="showCreateFinalVersionButton"
(click)="createModifiedFinalVersion()"
>
<mat-icon>file_copy</mat-icon>
@ -564,6 +564,7 @@
type="button"
mat-icon-button
*ngIf="isRecoMode(ChangeRecoMode.ModifiedFinal) && !isFinalEdit"
matTooltip="{{ 'Edit final print template' | translate }}"
(click)="editModifiedFinal()"
>
<mat-icon>edit</mat-icon>
@ -574,6 +575,7 @@
*ngIf="isRecoMode(ChangeRecoMode.ModifiedFinal) && isFinalEdit"
mat-icon-button
[disabled]="!finalVersionEdited"
matTooltip="{{ 'Save final print template' | translate }}"
(click)="onSubmitFinalVersion()"
>
<mat-icon>save</mat-icon>
@ -583,6 +585,7 @@
type="button"
*ngIf="isRecoMode(ChangeRecoMode.ModifiedFinal) && isFinalEdit"
mat-icon-button
matTooltip="{{ 'Cancel editing without saving' | translate }}"
(click)="cancelFinalVersionEdit()"
>
<mat-icon>close</mat-icon>

View File

@ -171,6 +171,17 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
return this.motion.showPreamble;
}
public get showCreateFinalVersionButton(): boolean {
if (
this.motion.isParagraphBasedAmendment() ||
!this.motion.state.isFinalState ||
this.motion.modified_final_version
) {
return false;
}
return true;
}
/**
* Saves the target motion. Accessed via the getter and setter.
*/
@ -1267,6 +1278,9 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
* Sets the modified final version to the final version.
*/
public async createModifiedFinalVersion(): Promise<void> {
if (this.motion.isParagraphBasedAmendment()) {
throw new Error('Cannot create a final version of an amendment.');
}
// Get the final version and remove line numbers
const changes: ViewUnifiedChange[] = Object.assign([], this.getChangesForFinalMode());
let finalVersion = this.repo.formatMotion(