From 853bc31e213a55a0fbc8782b3d01fed568829ab1 Mon Sep 17 00:00:00 2001 From: Sean Date: Wed, 13 May 2020 13:01:58 +0200 Subject: [PATCH] Change motion cr mode view behavior if the default cr mode is 'original' nothing really happens if the default cr mode is 'changed' you will stay in original view after creating cr's. That's due to the autoupdate limitation. Changing this would mean that you cannot change the view anymore if the default cd mode is 'diff' you will switch to diff view after creating a cr. It seems that the diff view has an automatic fallback to the original view if no cr exists, perhaps Tobias knows more about that. If the default cr mode if 'final' you will try to change to mod-final-version if it exists. If there is no change-reco, you will fall back to original version. --- .../motion-detail/motion-detail.component.ts | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts index d845cea7f..beda8a319 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts @@ -532,9 +532,11 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, this.configService .get('motions_default_line_numbering') .subscribe(mode => (this.lnMode = mode)); - this.configService - .get('motions_recommendation_text_mode') - .subscribe(mode => (this.crMode = this.determineCrMode(mode))); + this.configService.get('motions_recommendation_text_mode').subscribe(mode => { + if (mode) { + this.crMode = this.determineCrMode(mode); + } + }); this.configService .get('motions_show_sequential_numbers') .subscribe(shown => (this.showSequential = shown)); @@ -674,7 +676,9 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, // allChangingObjects, we set "diff" 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. - this.crMode = this.determineCrMode(this.crMode); + if (this.crMode) { + this.crMode = this.determineCrMode(this.crMode); + } this.cd.markForCheck(); } @@ -1531,13 +1535,22 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, * Tries to determine the realistic CR-Mode from a given CR mode */ private determineCrMode(mode: ChangeRecoMode): ChangeRecoMode { - if (this.motion) { - if (mode === ChangeRecoMode.Final && this.motion.modified_final_version) { + if (mode === ChangeRecoMode.Final) { + if (this.motion?.modified_final_version) { return ChangeRecoMode.ModifiedFinal; - } - if ((mode === ChangeRecoMode.Diff || mode === ChangeRecoMode.Changed) && !this.allChangingObjects.length) { + /** + * Because without change recos you cannot escape the final version anymore + */ + } else if (!this.allChangingObjects?.length) { return ChangeRecoMode.Original; } + } else if (mode === ChangeRecoMode.Changed && !this.allChangingObjects?.length) { + /** + * 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; } return mode; }