Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
8f5c860
fix(meetings): fixed meetings small issues
nsemets Aug 26, 2025
8de9aef
fix(tooltips): added tooltips
nsemets Aug 27, 2025
516655f
Merge remote-tracking branch 'origin/main' into fix/tooltips
nsemets Aug 27, 2025
193a0b5
fix(table): updated sorting
nsemets Aug 28, 2025
35212d5
fix(settings): fixed update project
nsemets Aug 28, 2025
1cf324e
fix(bookmarks): updated bookmarks
nsemets Aug 28, 2025
6d76abc
fix(my-registrations): fixed my registrations
nsemets Aug 28, 2025
fc5c303
fix(developer-apps): fixed developer apps
nsemets Aug 28, 2025
2bf55dd
fix(settings): updated tokens and notifications
nsemets Aug 28, 2025
78a26e2
fix(translation): removed dot
nsemets Aug 28, 2025
3d65a7e
Merge remote-tracking branch 'origin/main' into fix/table-sorting
nsemets Aug 28, 2025
4112bea
fix(info-icon): updated info icon translate
nsemets Aug 28, 2025
72d5703
fix(profile-settings): fixed profile settings
nsemets Aug 28, 2025
72ac75d
fix(test): updated tests
nsemets Aug 28, 2025
7324a40
Merge branch 'fix/table-sorting' into fix/improvements
nsemets Aug 28, 2025
6392c7b
fix(settings): updated settings
nsemets Aug 31, 2025
269a864
fix(user-emails): updated adding emails to user account
nsemets Sep 1, 2025
924baa0
fix(tests): updated tests
nsemets Sep 1, 2025
b8aac51
Merge remote-tracking branch 'origin/main' into fix/improvements
nsemets Sep 1, 2025
bf23db4
fix(clean-up): clean up
Nazar690 Sep 1, 2025
cd7ab91
Merge remote-tracking branch 'origin/main' into fix/improvements
nsemets Sep 1, 2025
64f92f4
Merge remote-tracking branch 'origin/fix/clean-up' into fix/improvements
nsemets Sep 1, 2025
569f5d7
fix(models): updated models
nsemets Sep 1, 2025
1929104
fix(models): updated region and license models
nsemets Sep 1, 2025
a62b376
Merge remote-tracking branch 'origin/main' into fix/improvements
nsemets Sep 2, 2025
ff31520
fix(styles): moved styles from assets
nsemets Sep 2, 2025
0da2aac
Merge remote-tracking branch 'origin/main' into fix/improvements
nsemets Sep 2, 2025
e93ff98
fix(test): fixed institution loading and test for view only link
nsemets Sep 2, 2025
4022bf1
fix(analytics): added check if is public
nsemets Sep 2, 2025
5b0ca69
fix(analytics): updated analytics feature
nsemets Sep 2, 2025
95087c7
fix(analytics): show message when data loaded
nsemets Sep 2, 2025
9570fe9
Merge remote-tracking branch 'origin/main' into fix/improvements
nsemets Sep 2, 2025
41be7e3
fix(view-only-links): updated view only links
nsemets Sep 3, 2025
392080a
fix(view only links): added shared components
nsemets Sep 3, 2025
bfa79bb
fix(tests): fixed tests
nsemets Sep 3, 2025
fa56c65
fix(unit-tests): updated jest config
nsemets Sep 3, 2025
c0d5938
Merge remote-tracking branch 'origin/main' into fix/improvements
nsemets Sep 3, 2025
fffd1ab
fix(view-only-links): update view only links for components
nsemets Sep 3, 2025
3dd4150
Merge remote-tracking branch 'origin/main' into fix/improvements
nsemets Sep 4, 2025
87b3cbb
fix(create-view-link): added logic for uncheck
nsemets Sep 4, 2025
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
@@ -0,0 +1,22 @@
<div class="flex gap-1" [class.disabled]="item().disabled">
<p-checkbox
variant="filled"
binary="true"
[(ngModel)]="item().checked"
[disabled]="item().disabled"
(onChange)="onCheckboxChange()"
></p-checkbox>

<p class="item-title">
{{ item().title }}
@if (item().isCurrentResource) {
<span>
{{ 'myProjects.settings.viewOnlyLinkCurrentProject' | translate }}
</span>
}
</p>

@if (item().disabled && !item().isCurrentResource) {
<osf-info-icon [tooltipText]="'myProjects.settings.parentsNeedToBeChecked' | translate"></osf-info-icon>
}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.disabled .item-title {
opacity: 0.5;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ComponentCheckboxItemComponent } from './component-checkbox-item.component';

describe.skip('ComponentCheckboxItemComponent', () => {
let component: ComponentCheckboxItemComponent;
let fixture: ComponentFixture<ComponentCheckboxItemComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ComponentCheckboxItemComponent],
}).compileComponents();

fixture = TestBed.createComponent(ComponentCheckboxItemComponent);
component = fixture.componentInstance;
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { TranslatePipe } from '@ngx-translate/core';

import { Checkbox } from 'primeng/checkbox';

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

import { InfoIconComponent } from '@osf/shared/components';

import { ViewOnlyLinkComponentItem } from '../../models';

@Component({
selector: 'osf-component-checkbox-item',
imports: [Checkbox, FormsModule, InfoIconComponent, TranslatePipe],
templateUrl: './component-checkbox-item.component.html',
styleUrl: './component-checkbox-item.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ComponentCheckboxItemComponent {
item = input.required<ViewOnlyLinkComponentItem>();
checkboxChange = output<void>();

onCheckboxChange(): void {
this.checkboxChange.emit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,42 +33,8 @@
<osf-loading-spinner />
} @else {
<div class="flex flex-column gap-2">
@for (item of allComponents; track item.id) {
<div class="flex gap-1">
<p-checkbox
variant="filled"
binary="true"
[class.pl-4]="!item.isCurrentResource"
[ngModel]="selectedComponents()[item.id]"
(ngModelChange)="onCheckboxToggle(item.id, $event)"
[disabled]="item.isCurrentResource"
>
</p-checkbox>
<p>
{{ item.title }}
@if (item.isCurrentResource) {
<span>
{{ 'myProjects.settings.viewOnlyLinkCurrentProject' | translate }}
</span>
}
</p>
</div>
}
@if (allComponents.length > 1) {
<div class="flex gap-2 justify-content-end">
<p-button
severity="secondary"
size="small"
[label]="'myProjects.createProject.affiliation.selectAll' | translate"
(click)="selectAllComponents()"
/>
<p-button
severity="secondary"
size="small"
[label]="'myProjects.createProject.affiliation.removeAll' | translate"
(click)="deselectAllComponents()"
/>
</div>
@for (item of componentsList(); track item.id) {
<osf-component-checkbox-item [item]="item" (checkboxChange)="onCheckboxChange(item)" />
}
</div>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import { Button } from 'primeng/button';
import { Checkbox } from 'primeng/checkbox';
import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';

import { ChangeDetectionStrategy, Component, effect, inject, OnInit, signal } from '@angular/core';
import { ChangeDetectionStrategy, Component, effect, inject, OnInit, signal, WritableSignal } from '@angular/core';
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';

import { LoadingSpinnerComponent, TextInputComponent } from '@osf/shared/components';
import { InputLimits } from '@osf/shared/constants';
import { CustomValidators } from '@osf/shared/helpers';
import { CurrentResourceSelectors, GetResourceChildren } from '@osf/shared/stores';
import { ViewOnlyLinkChildren } from '@shared/models';
import { CurrentResourceSelectors, GetResourceWithChildren } from '@osf/shared/stores';

import { ResourceInfoModel } from '../../models';
import { ResourceInfoModel, ViewOnlyLinkComponentItem } from '../../models';
import { ComponentCheckboxItemComponent } from '../component-checkbox-item/component-checkbox-item.component';

@Component({
selector: 'osf-create-view-link-dialog',
Expand All @@ -27,6 +27,7 @@ import { ResourceInfoModel } from '../../models';
Checkbox,
TextInputComponent,
LoadingSpinnerComponent,
ComponentCheckboxItemComponent,
],
templateUrl: './create-view-link-dialog.component.html',
styleUrl: './create-view-link-dialog.component.scss',
Expand All @@ -38,122 +39,126 @@ export class CreateViewLinkDialogComponent implements OnInit {
readonly inputLimits = InputLimits;

linkName = new FormControl('', { nonNullable: true, validators: [CustomValidators.requiredTrimmed()] });

anonymous = signal(true);
selectedComponents = signal<Record<string, boolean>>({});
components = select(CurrentResourceSelectors.getResourceChildren);
isLoading = select(CurrentResourceSelectors.isResourceChildrenLoading);

actions = createDispatchMap({ getComponents: GetResourceChildren });

get currentResource() {
return this.config.data as ResourceInfoModel;
}

get allComponents(): ViewOnlyLinkChildren[] {
const currentResourceData = this.currentResource;
const components = this.components();

const result: ViewOnlyLinkChildren[] = [];
readonly components = select(CurrentResourceSelectors.getResourceWithChildren);
readonly isLoading = select(CurrentResourceSelectors.isResourceWithChildrenLoading);
readonly actions = createDispatchMap({ getComponents: GetResourceWithChildren });

if (currentResourceData) {
result.push({
id: currentResourceData.id,
title: currentResourceData.title,
isCurrentResource: true,
});
}

components.forEach((comp) => {
result.push({
id: comp.id,
title: comp.title,
isCurrentResource: false,
});
});

return result;
}
componentsList: WritableSignal<ViewOnlyLinkComponentItem[]> = signal([]);

constructor() {
effect(() => {
const components = this.allComponents;
if (components.length) {
this.initializeSelection();
}
const currentResource = this.config.data as ResourceInfoModel;
const components = this.components();

const items: ViewOnlyLinkComponentItem[] = components.map((item) => ({
id: item.id,
title: item.title,
isCurrentResource: currentResource.id === item.id,
parentId: item.parentId,
checked: currentResource.id === item.id,
disabled: currentResource.id === item.id,
}));

const updatedItems = items.map((item) => ({
...item,
disabled: item.isCurrentResource ? item.disabled : !this.isParentChecked(item, items),
}));

this.componentsList.set(updatedItems);
});
}

ngOnInit(): void {
const projectId = this.currentResource.id;
const currentResource = this.config.data as ResourceInfoModel;
const { id, type } = currentResource;

if (projectId) {
this.actions.getComponents(projectId, this.currentResource.type);
} else {
this.initializeSelection();
if (id) {
this.actions.getComponents(id, type);
}
}

private initializeSelection(): void {
const initialState: Record<string, boolean> = {};
onCheckboxChange(changedItem: ViewOnlyLinkComponentItem): void {
this.componentsList.update((items) => {
let updatedItems = [...items];

this.allComponents.forEach((component) => {
initialState[component.id] = component.isCurrentResource;
});
if (!changedItem.checked) {
updatedItems = this.uncheckChildren(changedItem.id, updatedItems);
}

this.selectedComponents.set(initialState);
return updatedItems.map((item) => ({
...item,
disabled: item.isCurrentResource ? item.disabled : !this.isParentChecked(item, updatedItems),
}));
});
}

addLink(): void {
if (this.linkName.invalid) return;

const selectedIds = Object.entries(this.selectedComponents())
.filter(([, checked]) => checked)
.map(([id]) => id);
const currentResource = this.config.data as ResourceInfoModel;
const selectedIds = this.componentsList()
.filter((x) => x.checked)
.map((x) => x.id);

const rootProjectId = this.currentResource.id;
const rootProject = selectedIds.includes(rootProjectId) ? [{ id: rootProjectId, type: 'nodes' }] : [];
const data = this.buildLinkData(selectedIds, currentResource.id, this.linkName.value, this.anonymous());

this.dialogRef.close(data);
}

private isParentChecked(item: ViewOnlyLinkComponentItem, items: ViewOnlyLinkComponentItem[]): boolean {
if (!item.parentId) {
return true;
}

const parent = items.find((x) => x.id === item.parentId);

return parent?.checked ?? true;
}

private uncheckChildren(parentId: string, items: ViewOnlyLinkComponentItem[]): ViewOnlyLinkComponentItem[] {
let updatedItems = items.map((item) => {
if (item.parentId === parentId) {
return { ...item, checked: false };
}
return item;
});

const directChildren = updatedItems.filter((item) => item.parentId === parentId);

for (const child of directChildren) {
updatedItems = this.uncheckChildren(child.id, updatedItems);
}

return updatedItems;
}

private buildLinkData(
selectedIds: string[],
rootProjectId: string,
linkName: string,
isAnonymous: boolean
): Record<string, unknown> {
const rootProject = selectedIds.includes(rootProjectId) ? [{ id: rootProjectId, type: 'nodes' }] : [];
const relationshipComponents = selectedIds
.filter((id) => id !== rootProjectId)
.map((id) => ({ id, type: 'nodes' }));

const data: Record<string, unknown> = {
attributes: {
name: this.linkName.value,
anonymous: this.anonymous(),
name: linkName,
anonymous: isAnonymous,
},
nodes: rootProject,
};

if (relationshipComponents.length) {
data['relationships'] = {
nodes: {
data: relationshipComponents,
},
nodes: { data: relationshipComponents },
};
}

this.dialogRef.close(data);
}

onCheckboxToggle(id: string, checked: boolean): void {
this.selectedComponents.update((prev) => ({ ...prev, [id]: checked }));
}

selectAllComponents(): void {
const allIds: Record<string, boolean> = {};
this.allComponents.forEach((component) => {
allIds[component.id] = true;
});
this.selectedComponents.set(allIds);
}

deselectAllComponents(): void {
const allIds: Record<string, boolean> = {};
this.allComponents.forEach((component) => {
allIds[component.id] = component.isCurrentResource;
});
this.selectedComponents.set(allIds);
return data;
}
}
1 change: 1 addition & 0 deletions src/app/features/project/contributors/components/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { ComponentCheckboxItemComponent } from './component-checkbox-item/component-checkbox-item.component';
export { CreateViewLinkDialogComponent } from './create-view-link-dialog/create-view-link-dialog.component';
1 change: 1 addition & 0 deletions src/app/features/project/contributors/models/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './resource-info.model';
export * from './view-only-components.models';
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface ViewOnlyLinkComponentItem {
id: string;
title: string;
isCurrentResource?: boolean;
disabled: boolean;
checked: boolean;
parentId?: string | null;
}
10 changes: 9 additions & 1 deletion src/app/shared/mappers/nodes/base-node.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { BaseNodeDataJsonApi, BaseNodeModel } from '@osf/shared/models';
import { BaseNodeDataJsonApi, BaseNodeModel, NodeShortInfoModel } from '@osf/shared/models';

export class BaseNodeMapper {
static getNodesData(data: BaseNodeDataJsonApi[]): BaseNodeModel[] {
return data.map((item) => this.getNodeData(item));
}

static getNodesWithChildren(data: BaseNodeDataJsonApi[]): NodeShortInfoModel[] {
return data.map((item) => ({
id: item.id,
title: item.attributes.title,
parentId: item.relationships.parent?.data?.id,
}));
}

static getNodeData(data: BaseNodeDataJsonApi): BaseNodeModel {
return {
id: data.id,
Expand Down
Loading
Loading