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
1 change: 1 addition & 0 deletions src/app/features/registry/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './registration-links-card/registration-links-card.component';
export * from './registry-revisions/registry-revisions.component';
export * from './registry-statuses/registry-statuses.component';
export * from './withdraw-dialog/withdraw-dialog.component';
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<p-card>
@if (registrationData()) {
<div class="flex gap-3 flex-column">
<div class="flex flex-wrap gap-2 w-full">
@if (registrationData().isPublic) {
<i class="osf-icon-padlock-unlock"></i>
} @else {
<i class="osf-icon-padlock"></i>
}
<h2 class="align-self-center">
{{ registrationData().title || 'project.registrations.card.noTitle' | translate }}
</h2>
</div>
<div class="flex flex-wrap flex-column lg:flex-nowrap lg:flex-row justify-content-between gap-5">
<div class="flex gap-3 flex-column w-full">
<div class="flex gap-2 align-items-baseline">
<strong>{{ 'project.registrations.card.registered' | translate }}</strong>
<span>{{ registrationData().dateCreated | date: 'medium' }}</span>
</div>

<div class="flex gap-2 align-items-baseline">
<strong>{{ 'project.registrations.card.lastUpdated' | translate }}</strong>
<span>{{ registrationData().dateModified | date: 'medium' }}</span>
</div>

<div class="flex gap-2 align-items-baseline">
<strong>{{ 'project.overview.metadata.contributors' | translate }}:</strong>
<span class="contributors">
@for (contributor of registrationData().contributors; track contributor.id) {
<a [href]="">{{ contributor.fullName }}</a>
@if (!$last) {
<span>, </span>
}
}
</span>
</div>

<div class="flex gap-2 align-items-baseline">
<strong>{{ 'project.registrations.card.description' | translate }}</strong>

<osf-truncated-text
[maxVisibleLines]="2"
[text]="registrationData().description || 'project.registrations.card.noDescription' | translate"
/>
</div>

@if (isRegistrationData()) {
@if (registrationDataTyped()?.registrationSupplement) {
<div class="flex gap-2">
<strong>{{ 'project.registrations.card.registrationSupplement' | translate }}:</strong>
<span>{{ registrationDataTyped()?.registrationSupplement }}</span>
</div>
}

@if (registrationDataTyped()?.withdrawn) {
<div class="flex gap-2">
<strong>{{ 'project.registrations.card.withdrawn' | translate }}:</strong>
<span>{{ 'common.labels.yes' | translate }}</span>
</div>
}

@if (registrationDataTyped()?.embargoed) {
<div class="flex gap-2">
<strong>{{ 'project.registrations.card.embargoed' | translate }}:</strong>
<span>{{ 'common.labels.yes' | translate }}</span>
</div>
}
}

<div class="flex gap-2 mt-1">
<p-button
severity="primary"
[label]="'common.buttons.review' | translate"
(click)="reviewEmitRegistrationData.emit(registrationData()!.id)"
></p-button>

@if (
registrationDataTyped() &&
registrationDataTyped()?.currentUserPermissions &&
registrationDataTyped()!.currentUserPermissions.length > 1
) {
<p-button
severity="secondary"
(click)="updateEmitRegistrationData.emit(registrationData().id)"
[label]="'common.buttons.update' | translate"
></p-button>
}
</div>
</div>

@if (hasResources()) {
<div class="flex flex-column min-w-max">
<h3 class="mb-1">{{ 'shared.resources.title' | translate }}</h3>
<osf-data-resources
[vertical]="true"
[resourceId]="registrationData().id"
[hasData]="registrationDataTyped()?.hasData"
[hasAnalyticCode]="registrationDataTyped()?.hasAnalyticCode"
[hasMaterials]="registrationDataTyped()?.hasMaterials"
[hasPapers]="registrationDataTyped()?.hasPapers"
[hasSupplements]="registrationDataTyped()?.hasSupplements"
></osf-data-resources>
</div>
}
</div>
</div>
}
</p-card>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { RegistrationLinksCardComponent } from './registration-links-card.component';

describe('RegistrationLinksCardComponent', () => {
let component: RegistrationLinksCardComponent;
let fixture: ComponentFixture<RegistrationLinksCardComponent>;

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

fixture = TestBed.createComponent(RegistrationLinksCardComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

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

import { Button } from 'primeng/button';
import { Card } from 'primeng/card';

import { DatePipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core';

import { LinkedNode, LinkedRegistration } from '@osf/features/registry/models';
import { DataResourcesComponent, TruncatedTextComponent } from '@shared/components';
import { RevisionReviewStates } from '@shared/enums';

@Component({
selector: 'osf-registration-links-card',
imports: [Card, Button, TranslatePipe, DatePipe, DataResourcesComponent, TruncatedTextComponent],
templateUrl: './registration-links-card.component.html',
styleUrl: './registration-links-card.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class RegistrationLinksCardComponent {
readonly registrationData = input.required<LinkedRegistration | LinkedNode>();
readonly updateEmitRegistrationData = output<string>();
readonly reviewEmitRegistrationData = output<string>();

protected readonly RevisionReviewStates = RevisionReviewStates;

protected readonly isRegistrationData = computed(() => {
const data = this.registrationData();
return 'reviewsState' in data;
});

protected readonly registrationDataTyped = computed(() => {
const data = this.registrationData();
return this.isRegistrationData() ? (data as LinkedRegistration) : null;
});

protected readonly hasResources = computed(() => {
const regData = this.registrationDataTyped();
if (!regData) return false;
return (
regData.hasData || regData.hasAnalyticCode || regData.hasMaterials || regData.hasPapers || regData.hasSupplements
);
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { BibliographicContributorJsonApi, NodeBibliographicContributor } from '../models';

export class BibliographicContributorsMapper {
static fromApiResponse(contributor: BibliographicContributorJsonApi): NodeBibliographicContributor {
const userData = contributor.embeds.users.data;

return {
id: contributor.id,
userId: userData.id,
fullName: userData.attributes.full_name,
givenName: userData.attributes.given_name,
middleNames: userData.attributes.middle_names,
familyName: userData.attributes.family_name,
suffix: userData.attributes.suffix,
dateRegistered: userData.attributes.date_registered,
isActive: userData.attributes.active,
timezone: userData.attributes.timezone,
locale: userData.attributes.locale,
profileImage: userData.links.profile_image,
profileUrl: userData.links.html,
permission: contributor.attributes.permission,
isBibliographic: contributor.attributes.bibliographic,
isCurator: contributor.attributes.is_curator,
};
}

static fromApiResponseArray(contributors: BibliographicContributorJsonApi[]): NodeBibliographicContributor[] {
return contributors.map(this.fromApiResponse);
}
}
3 changes: 3 additions & 0 deletions src/app/features/registry/mappers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export * from './bibliographic-contributors.mapper';
export * from './cedar-form.mapper';
export * from './linked-nodes.mapper';
export * from './linked-registrations.mapper';
export * from './registry-metadata.mapper';
export * from './registry-overview.mapper';
export * from './registry-schema-block.mapper';
18 changes: 18 additions & 0 deletions src/app/features/registry/mappers/linked-nodes.mapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { LinkedNode, LinkedNodeJsonApi } from '../models';

export class LinkedNodesMapper {
static fromApiResponse(apiNode: LinkedNodeJsonApi): LinkedNode {
return {
id: apiNode.id,
title: apiNode.attributes.title,
description: apiNode.attributes.description,
category: apiNode.attributes.category,
dateCreated: apiNode.attributes.date_created,
dateModified: apiNode.attributes.date_modified,
tags: apiNode.attributes.tags || [],
isPublic: apiNode.attributes.public,
htmlUrl: apiNode.links.html,
apiUrl: apiNode.links.self,
};
}
}
30 changes: 30 additions & 0 deletions src/app/features/registry/mappers/linked-registrations.mapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { LinkedRegistration, LinkedRegistrationJsonApi } from '../models';

export class LinkedRegistrationsMapper {
static fromApiResponse(apiRegistration: LinkedRegistrationJsonApi): LinkedRegistration {
return {
id: apiRegistration.id,
title: apiRegistration.attributes.title,
description: apiRegistration.attributes.description,
category: apiRegistration.attributes.category,
dateCreated: apiRegistration.attributes.date_created,
dateModified: apiRegistration.attributes.date_modified,
dateRegistered: apiRegistration.attributes.date_registered,
tags: apiRegistration.attributes.tags || [],
isPublic: apiRegistration.attributes.public,
reviewsState: apiRegistration.attributes.reviews_state,
hasData: apiRegistration.attributes.has_data,
hasAnalyticCode: apiRegistration.attributes.has_analytic_code,
hasMaterials: apiRegistration.attributes.has_materials,
hasPapers: apiRegistration.attributes.has_papers,
hasSupplements: apiRegistration.attributes.has_supplements,
withdrawn: apiRegistration.attributes.withdrawn,
embargoed: apiRegistration.attributes.embargoed,
pendingWithdrawal: apiRegistration.attributes.pending_withdrawal,
pendingRegistrationApproval: apiRegistration.attributes.pending_registration_approval,
registrationSupplement: apiRegistration.attributes.registration_supplement,
subjects: apiRegistration.attributes.subjects,
currentUserPermissions: apiRegistration.attributes.current_user_permissions,
};
}
}
101 changes: 101 additions & 0 deletions src/app/features/registry/models/bibliographic-contributors.models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { InstitutionUsersLinksJsonApi } from '@osf/features/admin-institutions/models';

export interface BibliographicContributorJsonApi {
id: string;
type: 'contributors';
attributes: {
index: number;
bibliographic: boolean;
permission: string;
unregistered_contributor: string | null;
is_curator: boolean;
};
relationships: {
users: {
links: {
related: {
href: string;
meta: Record<string, unknown>;
};
};
data: {
id: string;
type: 'users';
};
};
node: {
links: {
related: {
href: string;
meta: Record<string, unknown>;
};
};
data: {
id: string;
type: 'nodes';
};
};
};
embeds: {
users: {
data: {
id: string;
type: 'users';
attributes: {
full_name: string;
given_name: string;
middle_names: string;
family_name: string;
suffix: string;
date_registered: string;
active: boolean;
timezone: string;
locale: string;
social: Record<string, unknown>;
employment: unknown[];
education: unknown[];
};
relationships: Record<string, unknown>;
links: {
html: string;
profile_image: string;
self: string;
iri: string;
};
};
};
};
links: {
self: string;
};
}

export interface BibliographicContributorsResponse {
data: BibliographicContributorJsonApi[];
meta: {
total: number;
per_page: number;
total_bibliographic: number;
version: string;
};
links: InstitutionUsersLinksJsonApi;
}

export interface NodeBibliographicContributor {
id: string;
userId: string;
fullName: string;
givenName: string;
middleNames: string;
familyName: string;
suffix: string;
dateRegistered: string;
isActive: boolean;
timezone: string;
locale: string;
profileImage: string;
profileUrl: string;
permission: string;
isBibliographic: boolean;
isCurator: boolean;
}
5 changes: 5 additions & 0 deletions src/app/features/registry/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
export * from './bibliographic-contributors.models';
export * from './get-registry-institutions-json-api.model';
export * from './get-registry-overview-json-api.model';
export * from './get-registry-schema-block-json-api.model';
export * from './get-resource-subjects-json-api.model';
export * from './linked-nodes.models';
export * from './linked-nodes-json-api.model';
export * from './linked-registrations-json-api.model';
export * from './linked-response.models';
export * from './registry-contributor-json-api.model';
export * from './registry-institution.model';
export * from './registry-institutions-json-api.model';
Expand Down
Loading