Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix amendment detail view error #3667

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion client/src/app/domain/models/motions/motion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ export class Motion extends BaseModel<Motion> implements MotionFormattingReprese
}

public amendment_paragraph_text(paragraphNumber: number): string | null {
return this.amendment_paragraphs[paragraphNumber] ?? null;
return this.amendment_paragraphs && this.amendment_paragraphs[paragraphNumber]
? this.amendment_paragraphs[paragraphNumber]
: null;
}

public static readonly REQUESTABLE_FIELDS: (keyof Motion)[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class MotionManageTitleComponent extends BaseMotionDetailChildComponent {
}

public titleCanBeChanged(): boolean {
if (this.motion.isStatuteAmendment() || this.motion.isParagraphBasedAmendment()) {
if (this.motion.isAmendment()) {
return false;
}
return this.changeRecoMode === ChangeRecoMode.Original || this.changeRecoMode === ChangeRecoMode.Diff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,23 +324,27 @@ export class ViewMotion extends BaseProjectableViewModel<Motion> {
return !!(this.tags && this.tags.length > 0);
}

public isStatuteAmendment(): boolean {
return !!this.statute_paragraph_id;
}

/**
* Determine if the motion is in its final workflow state
*/
public isInFinalState(): boolean {
return this.state ? this.state.isFinalState : false;
}

public isAmendment(): boolean {
return this.lead_motion_id && this.lead_motion_id > 0;
}

/**
* It's a paragraph-based amendments if only one paragraph is to be changed,
* specified by -array
*/
public isParagraphBasedAmendment(): boolean {
return this.lead_motion_id && this.lead_motion_id > 0;
return this.amendment_paragraph_numbers?.length > 0;
}

public isStatuteAmendment(): boolean {
return !!this.statute_paragraph_id;
}

public override getProjectionBuildDescriptor(
Expand Down Expand Up @@ -369,7 +373,7 @@ export class ViewMotion extends BaseProjectableViewModel<Motion> {
}

public getProjectiondefault(): ProjectiondefaultValue {
if (this.isParagraphBasedAmendment()) {
if (this.isAmendment()) {
return PROJECTIONDEFAULT.amendment;
} else {
return PROJECTIONDEFAULT.motion;
Expand Down
Loading