Skip to content

Commit

Permalink
refactor(team): Use team parentObj and ancestorObjs virtuals where ap…
Browse files Browse the repository at this point in the history
…propriate
  • Loading branch information
jrassa committed Nov 25, 2024
1 parent 674ee17 commit 1f4846e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/app/core/teams/team.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export class Team {
requiresExternalRoles: string[] = [];
requiresExternalTeams: string[] = [];
parent?: Team;
parentObj: Team;
ancestors: string[] = [];
ancestorObjs: Team[] = [];

constructor(model?: unknown) {
this.setFromModel(model);
Expand All @@ -23,8 +26,9 @@ export class Team {
this.requiresExternalTeams ??= [];

// Replace raw objects (from Object.assign) with class instances
if (this.parent) {
this.parent = new Team(this.parent);
if (this.parentObj) {
this.parentObj = new Team(this.parentObj);
}
this.ancestorObjs = this.ancestorObjs.map((team) => new Team(team));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,13 @@ <h2>Details</h2>
<div>{{ team().created | utcDate: 'yyyy-MM-dd' }}</div>
</div>
</div>
@if (team().parent) {
@if (team().parentObj) {
<div class="form-inline-edit-item">
<div class="col col-form-label">Parent</div>
<div class="col col-form-readonly-value">
<div>
<a
[routerLink]="[
'/team',
team().parent?._id || team().parent
]"
>
{{ team().parent?.name ?? 'Unknown' }}
<a [routerLink]="['/team', team().parentObj._id]">
{{ team().parentObj.name ?? 'Unknown' }}
</a>
</div>
</div>
Expand Down

0 comments on commit 1f4846e

Please sign in to comment.