Don't show diff view on slides if no change recos exist

This commit is contained in:
Tobias Hößl 2021-03-06 19:16:22 +01:00
parent a11682a708
commit bef322d0a4
No known key found for this signature in database
GPG Key ID: 1D780C7599C2D2A2
3 changed files with 58 additions and 37 deletions

View File

@ -1186,4 +1186,40 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo
}).length > 0
);
}
/**
* Tries to determine the realistic CR-Mode from a given CR mode
*/
public determineCrMode(
mode: ChangeRecoMode,
hasChangingObjects: boolean,
isModifiedFinalVersion: boolean,
isParagraphBasedAmendment: boolean,
hasChangeRecommendations: boolean
): ChangeRecoMode {
if (mode === ChangeRecoMode.Final) {
if (isModifiedFinalVersion) {
return ChangeRecoMode.ModifiedFinal;
/**
* Because without change recos you cannot escape the final version anymore
*/
} else if (!hasChangingObjects) {
return ChangeRecoMode.Original;
}
} else if (mode === ChangeRecoMode.Changed && !hasChangingObjects) {
/**
* Because without change recos you cannot escape the changed version view
* You will not be able to automatically change to the Changed view after creating
* a change reco. The autoupdate has to come "after" this routine
*/
return ChangeRecoMode.Original;
} else if (mode === ChangeRecoMode.Diff && !hasChangeRecommendations && isParagraphBasedAmendment) {
/**
* The Diff view for paragraph-based amendments is only relevant for change recommendations;
* the regular amendment changes are shown in the "original" view.
*/
return ChangeRecoMode.Original;
}
return mode;
}
}

View File

@ -643,7 +643,13 @@ export class MotionDetailComponent extends BaseViewComponentDirective implements
}
private resetCrMode(): void {
this.crMode = this.determineCrMode(this.defaultCrMode);
this.crMode = this.repo.determineCrMode(
this.defaultCrMode,
this.hasChangingObjects(),
!!this.motion?.modified_final_version,
this.motion?.isParagraphBasedAmendment(),
this.changeRecommendations?.length > 0
);
}
/**
@ -720,7 +726,13 @@ export class MotionDetailComponent extends BaseViewComponentDirective implements
// first in this case (in the config-listener) and perform the actual check if "diff" is possible now.
// Test: "diff" as default view. Open a motion, create an amendment. "Original" should be set automatically.
if (this.crMode) {
this.crMode = this.determineCrMode(this.crMode);
this.crMode = this.repo.determineCrMode(
this.crMode,
this.hasChangingObjects(),
!!this.motion?.modified_final_version,
this.motion?.isParagraphBasedAmendment(),
this.changeRecommendations?.length > 0
);
}
this.cd.markForCheck();
@ -1624,40 +1636,6 @@ export class MotionDetailComponent extends BaseViewComponentDirective implements
}
}
/**
* Tries to determine the realistic CR-Mode from a given CR mode
*/
private determineCrMode(mode: ChangeRecoMode): ChangeRecoMode {
if (mode === ChangeRecoMode.Final) {
if (this.motion?.modified_final_version) {
return ChangeRecoMode.ModifiedFinal;
/**
* Because without change recos you cannot escape the final version anymore
*/
} else if (!this.hasChangingObjects()) {
return ChangeRecoMode.Original;
}
} else if (mode === ChangeRecoMode.Changed && !this.hasChangingObjects()) {
/**
* Because without change recos you cannot escape the changed version view
* You will not be able to automatically change to the Changed view after creating
* a change reco. The autoupdate has to come "after" this routine
*/
return ChangeRecoMode.Original;
} else if (
mode === ChangeRecoMode.Diff &&
!this.changeRecommendations?.length &&
this.motion?.isParagraphBasedAmendment()
) {
/**
* The Diff view for paragraph-based amendments is only relevant for change recommendations;
* the regular amendment changes are shown in the "original" view.
*/
return ChangeRecoMode.Original;
}
return mode;
}
/**
* Function to listen to notifications if the user edits this motion.
* Handles the notification messages.

View File

@ -69,7 +69,6 @@ export class MotionSlideComponent
this.lnMode = value.data.line_numbering_mode;
this.lineLength = value.data.line_length;
this.preamble = value.data.preamble;
this.crMode = value.element.mode || 'original';
this.textDivStyles.width = value.data.show_meta_box ? 'calc(100% - 250px)' : '100%';
@ -80,6 +79,14 @@ export class MotionSlideComponent
}
this.recalcUnifiedChanges();
this.crMode = this.motionRepo.determineCrMode(
value.element.mode || 'original',
this.allChangingObjects.length > 0,
!!this.data.data.modified_final_version,
this.isParagraphBasedAmendment(),
this.data.data.change_recommendations.length > 0
);
}
public get data(): SlideData<MotionSlideData> {