Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,14 @@ export class PreprintStepperState {

ctx.setState(patch({ preprintFile: patch({ isLoading: true }) }));

return this.fileService
.updateFileContent(action.file, uploadedFile.links.upload)
.pipe(switchMap(() => this.fileService.renameEntry(uploadedFile.links.upload, action.file.name, 'replace')));
return this.fileService.updateFileContent(action.file, uploadedFile.links.upload).pipe(
switchMap(() => {
if (uploadedFile.name !== action.file.name) {
return this.fileService.renameEntry(uploadedFile.links.upload, action.file.name, 'replace');
}
return EMPTY;
})
);
}

@Action(FetchPreprintPrimaryFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ describe('ProjectOverviewToolbarComponent', () => {
expect(component.ResourceType).toBe(ResourceType);
});

it('should have resourceType set to Registration', () => {
expect(component.resourceType).toBe(ResourceType.Registration);
it('should have resourceType set to Project', () => {
expect(component.resourceType).toBe(ResourceType.Project);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class ProjectOverviewToolbarComponent {

isPublic = signal(false);
isBookmarked = signal(false);
resourceType = ResourceType.Registration;
resourceType = ResourceType.Project;

bookmarksCollectionId = select(BookmarksSelectors.getBookmarksCollectionId);
bookmarks = select(BookmarksSelectors.getBookmarks);
Expand Down
187 changes: 91 additions & 96 deletions src/app/shared/components/resource-card/resource-card.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,115 +4,110 @@
<p-accordion-header class="flex flex-row align-items-start gap-3 p-0">
<div osfStopPropagation class="flex flex-column align-items-start gap-2">
<p class="type py-1 px-3 font-bold">{{ cardTypeLabel() | translate }}</p>
</div>
</p-accordion-header>

<div class="flex align-items-center gap-2">
<h2>
<a
class="dark-blue-link word-break-word"
[href]="resource().absoluteUrl"
target="_blank"
rel="noopener noreferrer"
>
{{ displayTitle() | fixSpecialChar }}
</a>
</h2>
<div class="flex align-items-center gap-2">
<h2>
<a
class="dark-blue-link word-break-word"
[href]="resource().absoluteUrl"
target="_blank"
rel="noopener noreferrer"
>
{{ displayTitle() | fixSpecialChar }}
</a>
</h2>

@if (isWithdrawn()) {
<p-tag severity="secondary">{{ 'resourceCard.labels.withdrawn' | translate }}</p-tag>
}
@if (isWithdrawn()) {
<p-tag severity="secondary">{{ 'resourceCard.labels.withdrawn' | translate }}</p-tag>
}

@let orcidValues = orcids();
@if (orcidValues.length && orcidValues[0]) {
<a [href]="orcidValues[0]" class="h-1rem" target="_blank" rel="noopener noreferrer">
<img ngSrc="assets/icons/colored/orcid.svg" width="16" height="16" alt="orcid" />
</a>
}
</div>
@let orcidValues = orcids();
@if (orcidValues.length && orcidValues[0]) {
<a [href]="orcidValues[0]" class="h-1rem" target="_blank" rel="noopener noreferrer">
<img ngSrc="assets/icons/colored/orcid.svg" width="16" height="16" alt="orcid" />
</a>
}
</div>

@if (affiliatedEntities().length > 0) {
<div class="line-height-3">
@for (affiliatedEntity of affiliatedEntities().slice(0, limit); track $index) {
<a
class="word-break-word"
[href]="affiliatedEntity.absoluteUrl"
target="_blank"
rel="noopener noreferrer"
>
{{ affiliatedEntity.name }}{{ $last ? '' : ', ' }}
</a>
}
@if (resource().creators.length > limit) {
<p class="inline">
&nbsp;{{ 'resourceCard.andCountMore' | translate: { count: resource().creators.length - limit } }}
</p>
}
</div>
@if (affiliatedEntities().length > 0) {
<div class="line-height-3">
@for (affiliatedEntity of affiliatedEntities().slice(0, limit); track $index) {
<a class="word-break-word" [href]="affiliatedEntity.absoluteUrl" target="_blank" rel="noopener noreferrer">
{{ affiliatedEntity.name }}{{ $last ? '' : ', ' }}
</a>
}

@if (resource().isPartOf) {
<div class="flex flex-row gap-1 line-height-3">
<p class="white-space-nowrap">{{ 'resourceCard.labels.from' | translate }}</p>
<a
class="white-space-normal word-break-word"
[href]="resource().isPartOf!.absoluteUrl"
target="_blank"
rel="noopener noreferrer"
>
{{ resource().isPartOf!.name }}
</a>
</div>
@if (resource().creators.length > limit) {
<p class="inline">
&nbsp;{{ 'resourceCard.andCountMore' | translate: { count: resource().creators.length - limit } }}
</p>
}
</div>
}

@if (resource().isContainedBy) {
<div class="flex flex-row gap-1 line-height-3">
<p class="white-space-nowrap">{{ 'resourceCard.labels.from' | translate }}</p>
<a
class="white-space-normal"
[href]="resource().isContainedBy!.absoluteUrl"
target="_blank"
rel="noopener noreferrer"
>
{{ resource().isContainedBy!.name }}
</a>
</div>
}
@if (resource().isPartOf) {
<div class="flex flex-row gap-1 line-height-3">
<p class="white-space-nowrap">{{ 'resourceCard.labels.from' | translate }}</p>
<a
class="white-space-normal word-break-word"
[href]="resource().isPartOf!.absoluteUrl"
target="_blank"
rel="noopener noreferrer"
>
{{ resource().isPartOf!.name }}
</a>
</div>
}

@if (dateFields().length > 0) {
<div class="flex flex-column md:flex-row line-height-3">
@for (dateField of dateFields(); track $index) {
<p>{{ dateField.label | translate }}: {{ dateField.date | date: 'MMMM d, y' : 'UTC' }}</p>
@if (resource().isContainedBy) {
<div class="flex flex-row gap-1 line-height-3">
<p class="white-space-nowrap">{{ 'resourceCard.labels.from' | translate }}</p>
<a
class="white-space-normal"
[href]="resource().isContainedBy!.absoluteUrl"
target="_blank"
rel="noopener noreferrer"
>
{{ resource().isContainedBy!.name }}
</a>
</div>
}

@if (!$last && !isSmall()) {
<p class="mx-1">
{{ '|' }}
</p>
}
}
</div>
}
@if (dateFields().length > 0) {
<div class="flex flex-column md:flex-row line-height-3">
@for (dateField of dateFields(); track $index) {
<p>{{ dateField.label | translate }}: {{ dateField.date | date: 'MMMM d, y' : 'UTC' }}</p>

@if (resource().context) {
<div class="flex flex-row gap-1 line-height-3 flex-wrap">
<p [innerHTML]="`${'resourceCard.labels.context' | translate}: ${resource().context}`"></p>
</div>
@if (!$last && !isSmall()) {
<p class="mx-1">
{{ '|' }}
</p>
}
}
</div>
}

@if (
resource().resourceType === ResourceType.Registration ||
resource().resourceType === ResourceType.RegistrationComponent
) {
<osf-data-resources
class="mt-1"
[absoluteUrl]="resource().absoluteUrl"
[hasData]="!!resource().hasDataResource"
[hasAnalyticCode]="resource().hasAnalyticCodeResource"
[hasMaterials]="resource().hasMaterialsResource"
[hasPapers]="resource().hasPapersResource"
[hasSupplements]="resource().hasSupplementalResource"
/>
}
@if (resource().context) {
<div class="flex flex-row gap-1 line-height-3 flex-wrap">
<p [innerHTML]="`${'resourceCard.labels.context' | translate}: ${resource().context}`"></p>
</div>
</p-accordion-header>
}

@if (
resource().resourceType === ResourceType.Registration ||
resource().resourceType === ResourceType.RegistrationComponent
) {
<osf-data-resources
class="mt-1"
[absoluteUrl]="resource().absoluteUrl"
[hasData]="!!resource().hasDataResource"
[hasAnalyticCode]="resource().hasAnalyticCodeResource"
[hasMaterials]="resource().hasMaterialsResource"
[hasPapers]="resource().hasPapersResource"
[hasSupplements]="resource().hasSupplementalResource"
/>
}
<p-accordion-content>
<div class="flex flex-column pt-1">
<hr class="w-full break-line my-2" />
Expand Down