Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<div
class="flex justify-content-between align-items-center mb-2 w-full border-bottom-1 border-gray-300 gap-2 flex-column sm:flex-row sm:gap-4"
>
<div class="flex align-items-center gap-2 cursor-pointer w-full sm:w-5">
<div class="flex align-items-center gap-2 w-full sm:w-5">
<p-button
[icon]="expanded() ? 'fas fa-minus' : 'fas fa-plus'"
variant="text"
severity="contrast"
[ariaLabel]="title() || ('common.accessibility.toggleTreeNode' | translate)"
[attr.aria-expanded]="expanded()"
(onClick)="toggle()"
></p-button>

<span class="font-medium text-color">{{ title() }}</span>
<span class="font-medium">{{ title() }}</span>
</div>

@if (rightControls()) {
<div class="flex flex-wrap gap-2 align-items-center w-full sm:gap-4 sm:w-7">
@for (control of rightControls(); let index = $index; track index) {
<div class="flex align-items-center gap-2">
@if (control.label) {
<span class="font-medium text-color">
<span class="font-medium">
{{ control.label | translate }}
</span>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,10 @@ describe('ProjectDetailSettingAccordionComponent', () => {

fixture = TestBed.createComponent(ProjectDetailSettingAccordionComponent);
component = fixture.componentInstance;
fixture.componentRef.setInput('rightControls', []);
});

it('should create', () => {
expect(component).toBeTruthy();
});

it('should initialize with expanded set to false', () => {
expect(component.expanded()).toBe(false);
});

it('should toggle expanded state when toggle() is called', () => {
it('should toggle expanded state', () => {
expect(component.expanded()).toBe(false);

component.toggle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@ import { TranslatePipe } from '@ngx-translate/core';
import { Button } from 'primeng/button';

import { ChangeDetectionStrategy, Component, input, output, signal } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { SelectComponent } from '@osf/shared/components/select/select.component';

import { RightControl } from '../../models';
import { RightControl, RightControlValueChange } from '../../models';

@Component({
selector: 'osf-project-detail-setting-accordion',
imports: [FormsModule, Button, SelectComponent, TranslatePipe],
imports: [Button, SelectComponent, TranslatePipe],
templateUrl: './project-detail-setting-accordion.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ProjectDetailSettingAccordionComponent {
emitValueChange = output<{ index: number; value: boolean | string }>();
emitValueChange = output<RightControlValueChange>();
title = input<string>();
rightControls = input.required<RightControl[] | undefined>();
disabledRightControls = input(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SubscriptionEvent } from '@osf/shared/enums/subscriptions/subscription-
import { SubscriptionFrequency } from '@osf/shared/enums/subscriptions/subscription-frequency.enum';
import { NotificationSubscription } from '@osf/shared/models/notifications/notification-subscription.model';

import { RightControl } from '../../models';
import { RightControl, RightControlValueChange } from '../../models';
import { NotificationDescriptionPipe } from '../../pipes';
import { ProjectDetailSettingAccordionComponent } from '../project-detail-setting-accordion/project-detail-setting-accordion.component';

Expand Down Expand Up @@ -52,7 +52,7 @@ export class ProjectSettingNotificationsComponent {
});
}

changeEmittedValue(emittedValue: { index: number; value: boolean | string }): void {
changeEmittedValue(emittedValue: RightControlValueChange): void {
if (this.allAccordionData) {
this.notificationEmitValue.emit({
id: this.notifications()[0].id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { FormsModule } from '@angular/forms';

import { UserSelectors } from '@osf/core/store/user/user.selectors';

import { RightControl } from '../../models';
import { RightControl, RightControlValueChange } from '../../models';
import { ProjectDetailSettingAccordionComponent } from '../project-detail-setting-accordion/project-detail-setting-accordion.component';

@Component({
Expand Down Expand Up @@ -51,7 +51,7 @@ export class SettingsWikiCardComponent {
});
}

changeEmittedValue(emittedValue: { index: number; value: boolean | string }): void {
changeEmittedValue(emittedValue: RightControlValueChange): void {
if (typeof emittedValue.value === 'boolean') {
this.anyoneCanEditWikiEmitValue.emit(emittedValue.value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ export interface RightControl {
options: SelectOption[];
event?: SubscriptionEvent;
}

export interface RightControlValueChange {
index: number;
value: boolean | string;
}
Loading