Skip to content

Commit

Permalink
Hide children section for milestones
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Jun 24, 2024
1 parent 4961d38 commit 6cbc316
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ import { PathHelperService } from 'core-app/core/path-helper/path-helper.service
import {
WorkPackageRelationsHierarchyService,
} from 'core-app/features/work-packages/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.service';
import { take } from 'rxjs/operators';
import { take, withLatestFrom } from 'rxjs/operators';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import {
WorkPackageIsolatedQuerySpaceDirective,
} from 'core-app/features/work-packages/directives/query-space/wp-isolated-query-space.directive';
import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service';

@Component({
selector: 'wp-relations-hierarchy',
Expand All @@ -54,18 +55,21 @@ export class WorkPackageRelationsHierarchyComponent extends UntilDestroyedMixin

public workPackagePath:string;

public canHaveChildren:boolean;
public canHaveChildren = false;

public canModifyHierarchy:boolean;

public canAddRelation:boolean;

public childrenQueryProps:any;

constructor(protected wpRelationsHierarchyService:WorkPackageRelationsHierarchyService,
protected apiV3Service:ApiV3Service,
protected PathHelper:PathHelperService,
readonly I18n:I18nService) {
constructor(
readonly wpRelationsHierarchyService:WorkPackageRelationsHierarchyService,
readonly apiV3Service:ApiV3Service,
readonly PathHelper:PathHelperService,
readonly I18n:I18nService,
readonly schemaCache:SchemaCacheService,
) {
super();
}

Expand All @@ -91,10 +95,12 @@ export class WorkPackageRelationsHierarchyComponent extends UntilDestroyedMixin
.id(this.workPackage)
.requireAndStream()
.pipe(
withLatestFrom(this.schemaCache.requireAndStream(this.workPackage.href as string)),
this.untilDestroyed(),
)
.subscribe((wp:WorkPackageResource) => {
.subscribe(([wp, schema]) => {
this.workPackage = wp;
this.canHaveChildren = !schema.isMilestone as boolean;

Check failure on line 103 in frontend/src/app/features/work-packages/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.directive.ts

View workflow job for this annotation

GitHub Actions / eslint

[eslint] frontend/src/app/features/work-packages/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.directive.ts#L103 <@typescript-eslint/no-unnecessary-type-assertion>(https://typescript-eslint.io/rules/no-unnecessary-type-assertion)

This assertion is unnecessary since it does not change the type of the expression.
Raw output
{"ruleId":"@typescript-eslint/no-unnecessary-type-assertion","severity":2,"message":"This assertion is unnecessary since it does not change the type of the expression.","line":103,"column":32,"nodeType":"TSAsExpression","messageId":"unnecessaryAssertion","endLine":103,"endColumn":62,"fix":{"range":[3987,3998],"text":""}}

const parentId = this.workPackage.parent?.id?.toString();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<div class="wp-relations-hierarchy-section wp-relations--children">
<div
*ngIf="canHaveChildren"
class="wp-relations-hierarchy-section wp-relations--children">
<div class="attributes-group--header">
<div class="attributes-group--header-container">
<h3 class="attributes-group--header-text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@
expect(page).to have_no_text("Create new child")
expect(page).to have_no_css("wp-inline-create--add-link")
end

expect(page).to have_no_text("Children")
end
end

0 comments on commit 6cbc316

Please sign in to comment.