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
5 changes: 3 additions & 2 deletions src/app/features/files/mappers/file-custom-metadata.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { ApiData } from '@osf/shared/models/common/json-api.model';
import { replaceBadEncodedChars } from '@shared/helpers/format-bad-encoding.helper';

import { FileCustomMetadata, OsfFileCustomMetadata } from '../models';

export function MapFileCustomMetadata(data: ApiData<FileCustomMetadata, null, null, null>): OsfFileCustomMetadata {
return {
id: data.id,
description: data.attributes.description,
description: replaceBadEncodedChars(data.attributes.description),
language: data.attributes.language,
resourceTypeGeneral: data.attributes.resource_type_general,
title: data.attributes.title,
title: replaceBadEncodedChars(data.attributes.title),
};
}
5 changes: 3 additions & 2 deletions src/app/features/files/mappers/resource-metadata.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { IdentifiersMapper } from '@osf/shared/mappers/identifiers.mapper';
import { ResourceMetadata } from '@osf/shared/models/resource-metadata.model';
import { replaceBadEncodedChars } from '@shared/helpers/format-bad-encoding.helper';

import { GetResourceCustomMetadataResponse } from '../models/get-resource-custom-metadata-response.model';
import { GetResourceShortInfoResponse } from '../models/get-resource-short-info-response.model';
Expand All @@ -9,8 +10,8 @@ export function MapResourceMetadata(
customMetadata: GetResourceCustomMetadataResponse
): ResourceMetadata {
return {
title: shortInfo.data.attributes.title,
description: shortInfo.data.attributes.description,
title: replaceBadEncodedChars(shortInfo.data.attributes.title),
description: replaceBadEncodedChars(shortInfo.data.attributes.description),
dateCreated: new Date(shortInfo.data.attributes.date_created),
dateModified: new Date(shortInfo.data.attributes.date_modified),
funders:
Expand Down
3 changes: 2 additions & 1 deletion src/app/features/meetings/mappers/meetings.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ResponseJsonApi } from '@osf/shared/models/common/json-api.model';
import { replaceBadEncodedChars } from '@shared/helpers/format-bad-encoding.helper';

import {
MeetingGetResponseJsonApi,
Expand Down Expand Up @@ -28,7 +29,7 @@ export class MeetingsMapper {
return {
data: response.data.map((item) => ({
id: item.id,
title: item.attributes.title,
title: replaceBadEncodedChars(item.attributes.title),
dateCreated: item.attributes.date_created,
authorName: item.attributes.author_name,
downloadCount: item.attributes.download_count || 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ <h2>{{ 'project.overview.metadata.description' | translate }}</h2>
</div>

<p data-test-display-node-description class="mt-4">
{{ (description() | fixSpecialChar) || ('project.overview.metadata.noDescription' | translate) }}
{{ description() || ('project.overview.metadata.noDescription' | translate) }}
</p>
</p-card>
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import { Card } from 'primeng/card';

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

import { FixSpecialCharPipe } from '@osf/shared/pipes/fix-special-char.pipe';

@Component({
selector: 'osf-metadata-description',
imports: [Card, Button, FixSpecialCharPipe, TranslatePipe],
imports: [Card, Button, TranslatePipe],
templateUrl: './metadata-description.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ <h2>{{ 'common.labels.title' | translate }}</h2>
</div>

<p data-test-display-node-title class="mt-4 word-break-word">
{{ title() | fixSpecialChar }}
{{ title() }}
</p>
</p-card>
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import { Card } from 'primeng/card';

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

import { FixSpecialCharPipe } from '@osf/shared/pipes/fix-special-char.pipe';

@Component({
selector: 'osf-metadata-title',
imports: [Card, Button, FixSpecialCharPipe, TranslatePipe],
imports: [Card, Button, TranslatePipe],
templateUrl: './metadata-title.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
Expand Down
5 changes: 3 additions & 2 deletions src/app/features/metadata/mappers/metadata.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { IdentifiersMapper } from '@osf/shared/mappers/identifiers.mapper';
import { LicensesMapper } from '@osf/shared/mappers/licenses.mapper';
import { replaceBadEncodedChars } from '@shared/helpers/format-bad-encoding.helper';

import { CustomItemMetadataRecord, CustomMetadataJsonApi, MetadataJsonApi, MetadataModel } from '../models';

export class MetadataMapper {
static fromMetadataApiResponse(response: MetadataJsonApi): MetadataModel {
return {
id: response.id,
title: response.attributes.title,
description: response.attributes.description,
title: replaceBadEncodedChars(response.attributes.title),
description: replaceBadEncodedChars(response.attributes.description),
tags: response.attributes.tags,
dateCreated: response.attributes.date_created,
dateModified: response.attributes.date_modified,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { UserMapper } from '@osf/shared/mappers/user';
import { ResponseJsonApi } from '@osf/shared/models/common/json-api.model';
import { PaginatedData } from '@osf/shared/models/paginated-data.model';
import { replaceBadEncodedChars } from '@shared/helpers/format-bad-encoding.helper';

import {
PreprintProviderModerationInfo,
Expand Down Expand Up @@ -64,7 +65,7 @@ export class PreprintModerationMapper {
return {
data: response.data.map((x) => ({
id: x.id,
title: x.attributes.title,
title: replaceBadEncodedChars(x.attributes.title),
public: x.attributes.public,
reviewsState: x.attributes.reviews_state,
actions: [],
Expand All @@ -86,7 +87,7 @@ export class PreprintModerationMapper {
return {
data: response.data.map((x) => ({
id: x.id,
title: x.embeds.target.data.attributes.title,
title: replaceBadEncodedChars(x.embeds.target.data.attributes.title),
preprintId: x.embeds.target.data.id,
actions: [],
contributors: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { UserMapper } from '@osf/shared/mappers/user';
import { PaginatedData } from '@osf/shared/models/paginated-data.model';
import { replaceBadEncodedChars } from '@shared/helpers/format-bad-encoding.helper';

import {
RegistryDataJsonApi,
Expand All @@ -13,7 +14,7 @@ export class RegistryModerationMapper {
static fromResponse(response: RegistryDataJsonApi): RegistryModeration {
return {
id: response.id,
title: response.attributes.title,
title: replaceBadEncodedChars(response.attributes.title),
reviewsState: response.attributes.reviews_state,
revisionStatus: response.attributes.revision_state,
public: response.attributes.public,
Expand Down
9 changes: 5 additions & 4 deletions src/app/features/preprints/mappers/preprints.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { StringOrNull } from '@osf/shared/helpers/types.helper';
import { IdentifiersMapper } from '@osf/shared/mappers/identifiers.mapper';
import { LicensesMapper } from '@osf/shared/mappers/licenses.mapper';
import { ApiData, JsonApiResponseWithMeta, ResponseJsonApi } from '@osf/shared/models/common/json-api.model';
import { replaceBadEncodedChars } from '@shared/helpers/format-bad-encoding.helper';

import {
PreprintAttributesJsonApi,
Expand All @@ -18,7 +19,7 @@ export class PreprintsMapper {
return {
data: {
attributes: {
title: title,
title: replaceBadEncodedChars(title),
description: abstract,
},
relationships: {
Expand All @@ -44,7 +45,7 @@ export class PreprintsMapper {
dateWithdrawn: response.attributes.date_withdrawn,
datePublished: response.attributes.date_published,
dateLastTransitioned: response.attributes.date_last_transitioned,
title: response.attributes.title,
title: replaceBadEncodedChars(response.attributes.title),
description: response.attributes.description,
reviewsState: response.attributes.reviews_state,
preprintDoiCreated: response.attributes.preprint_doi_created,
Expand Down Expand Up @@ -102,7 +103,7 @@ export class PreprintsMapper {
dateWithdrawn: data.attributes.date_withdrawn,
datePublished: data.attributes.date_published,
dateLastTransitioned: data.attributes.date_last_transitioned,
title: data.attributes.title,
title: replaceBadEncodedChars(data.attributes.title),
description: data.attributes.description,
reviewsState: data.attributes.reviews_state,
preprintDoiCreated: data.attributes.preprint_doi_created,
Expand Down Expand Up @@ -172,7 +173,7 @@ export class PreprintsMapper {
data: response.data.map((preprintData) => {
return {
id: preprintData.id,
title: preprintData.attributes.title,
title: replaceBadEncodedChars(preprintData.attributes.title),
dateModified: preprintData.attributes.date_modified,
contributors: preprintData.embeds.bibliographic_contributors.data.map((contrData) => {
return {
Expand Down
5 changes: 3 additions & 2 deletions src/app/features/project/settings/mappers/settings.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { UserPermissions } from '@osf/shared/enums/user-permissions.enum';
import { InstitutionsMapper } from '@osf/shared/mappers/institutions';
import { RegionsMapper } from '@osf/shared/mappers/regions';
import { replaceBadEncodedChars } from '@shared/helpers/format-bad-encoding.helper';
import { BaseNodeDataJsonApi } from '@shared/models/nodes/base-node-data-json-api.model';

import {
Expand Down Expand Up @@ -30,8 +31,8 @@ export class SettingsMapper {
static fromNodeResponse(data: BaseNodeDataJsonApi): NodeDetailsModel {
return {
id: data.id,
title: data.attributes.title,
description: data.attributes.description,
title: replaceBadEncodedChars(data.attributes.title),
description: replaceBadEncodedChars(data.attributes.description),
isPublic: data.attributes.public,
region: data.embeds?.region ? RegionsMapper.getRegion(data?.embeds?.region?.data) : null,
affiliatedInstitutions: data.embeds?.affiliated_institutions
Expand Down
5 changes: 3 additions & 2 deletions src/app/features/registry/mappers/linked-nodes.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { ContributorsMapper } from '@osf/shared/mappers/contributors';
import { replaceBadEncodedChars } from '@shared/helpers/format-bad-encoding.helper';

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,
title: replaceBadEncodedChars(apiNode.attributes.title),
description: replaceBadEncodedChars(apiNode.attributes.description),
category: apiNode.attributes.category,
dateCreated: apiNode.attributes.date_created,
dateModified: apiNode.attributes.date_modified,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { ContributorsMapper } from '@osf/shared/mappers/contributors';
import { replaceBadEncodedChars } from '@shared/helpers/format-bad-encoding.helper';

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,
title: replaceBadEncodedChars(apiRegistration.attributes.title),
description: replaceBadEncodedChars(apiRegistration.attributes.description),
category: apiRegistration.attributes.category,
dateCreated: apiRegistration.attributes.date_created,
dateModified: apiRegistration.attributes.date_modified,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { ContributorsMapper } from '@osf/shared/mappers/contributors';
import { replaceBadEncodedChars } from '@shared/helpers/format-bad-encoding.helper';

import { RegistryComponentJsonApi, RegistryComponentModel } from '../models';

export class RegistryComponentsMapper {
static fromApiResponse(apiComponent: RegistryComponentJsonApi): RegistryComponentModel {
return {
id: apiComponent.id,
title: apiComponent.attributes.title,
description: apiComponent.attributes.description,
title: replaceBadEncodedChars(apiComponent.attributes.title),
description: replaceBadEncodedChars(apiComponent.attributes.description),
category: apiComponent.attributes.category,
dateCreated: apiComponent.attributes.date_created,
dateModified: apiComponent.attributes.date_modified,
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/helpers/format-bad-encoding.helper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export function replaceBadEncodedChars(text: string) {
if (!text) return '';
return text.replace(/&amp;/gi, '&').replace(/&lt;/gi, '<').replace(/&gt;/gi, '>');
}
16 changes: 9 additions & 7 deletions src/app/shared/mappers/activity-logs.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { replaceBadEncodedChars } from '@shared/helpers/format-bad-encoding.helper';

import { DEFAULT_TABLE_PARAMS } from '../constants/default-table-params.constants';
import { ActivityLog, LogContributor } from '../models/activity-logs/activity-logs.model';
import { ActivityLogJsonApi, LogContributorJsonApi } from '../models/activity-logs/activity-logs-json-api.model';
Expand All @@ -24,22 +26,22 @@ export class ActivityLogsMapper {
paramsNode: params.params_node
? {
id: params.params_node.id,
title: params.params_node.title,
title: replaceBadEncodedChars(params.params_node.title),
}
: { id: '', title: '' },
paramsProject: params.params_project,
template_node: params.template_node
? {
id: params.template_node.id,
url: params.template_node.url,
title: params.template_node.title,
title: replaceBadEncodedChars(params.template_node.title),
}
: null,
pointer: params.pointer
? {
category: params.pointer.category,
id: params.pointer.id,
title: params.pointer.title,
title: replaceBadEncodedChars(params.pointer.title),
url: params.pointer.url,
}
: null,
Expand Down Expand Up @@ -72,8 +74,8 @@ export class ActivityLogsMapper {
? {
id: log.embeds.original_node.data.id,
type: log.embeds.original_node.data.type,
title: log.embeds.original_node.data.attributes.title,
description: log.embeds.original_node.data.attributes.description,
title: replaceBadEncodedChars(log.embeds.original_node.data.attributes.title),
description: replaceBadEncodedChars(log.embeds.original_node.data.attributes.description),
category: log.embeds.original_node.data.attributes.category,
customCitation: log.embeds.original_node.data.attributes.custom_citation,
dateCreated: log.embeds.original_node.data.attributes.date_created,
Expand Down Expand Up @@ -119,8 +121,8 @@ export class ActivityLogsMapper {
? {
id: log.embeds.linked_node.data.id,
type: log.embeds.linked_node.data.type,
title: log.embeds.linked_node.data.attributes.title,
description: log.embeds.linked_node.data.attributes.description,
title: replaceBadEncodedChars(log.embeds.linked_node.data.attributes.title),
description: replaceBadEncodedChars(log.embeds.linked_node.data.attributes.description),
category: log.embeds.linked_node.data.attributes.category,
customCitation: log.embeds.linked_node.data.attributes.custom_citation,
dateCreated: log.embeds.linked_node.data.attributes.date_created,
Expand Down
19 changes: 10 additions & 9 deletions src/app/shared/mappers/collections/collections.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
import { ResponseJsonApi } from '@osf/shared/models/common/json-api.model';
import { ContributorModel } from '@osf/shared/models/contributors/contributor.model';
import { PaginatedData } from '@osf/shared/models/paginated-data.model';
import { replaceBadEncodedChars } from '@shared/helpers/format-bad-encoding.helper';

import { UserMapper } from '../user';

Expand All @@ -28,8 +29,8 @@ export class CollectionsMapper {
return {
id: response.id,
type: response.type,
name: response.attributes.name,
description: response.attributes.description,
name: replaceBadEncodedChars(response.attributes.name),
description: replaceBadEncodedChars(response.attributes.description),
advisoryBoard: response.attributes.advisory_board,
example: response.attributes.example,
domain: response.attributes.domain,
Expand Down Expand Up @@ -58,7 +59,7 @@ export class CollectionsMapper {
brand: response.embeds.brand.data
? {
id: response.embeds.brand.data.id,
name: response.embeds.brand.data.attributes.name,
name: replaceBadEncodedChars(response.embeds.brand.data.attributes.name),
heroLogoImageUrl: response.embeds.brand.data.attributes.hero_logo_image,
topNavLogoImageUrl: response.embeds.brand.data.attributes.topnav_logo_image,
heroBackgroundImageUrl: response.embeds.brand.data.attributes.hero_background_image,
Expand All @@ -74,7 +75,7 @@ export class CollectionsMapper {
return {
id: response.id,
type: response.type,
title: response.attributes.title,
title: replaceBadEncodedChars(response.attributes.title),
dateCreated: response.attributes.date_created,
dateModified: response.attributes.date_modified,
bookmarks: response.attributes.bookmarks,
Expand Down Expand Up @@ -110,7 +111,7 @@ export class CollectionsMapper {
dataType: submission.attributes.data_type,
disease: submission.attributes.disease,
gradeLevels: submission.attributes.grade_levels,
collectionTitle: submission.embeds.collection.data.attributes.title,
collectionTitle: replaceBadEncodedChars(submission.embeds.collection.data.attributes.title),
collectionId: submission.embeds.collection.data.relationships.provider.data.id,
};
}
Expand All @@ -127,8 +128,8 @@ export class CollectionsMapper {
type: submission.type,
nodeId: submission.embeds.guid.data.id,
nodeUrl: submission.embeds.guid.data.links.html,
title: submission.embeds.guid.data.attributes.title,
description: submission.embeds.guid.data.attributes.description,
title: replaceBadEncodedChars(submission.embeds.guid.data.attributes.title),
description: replaceBadEncodedChars(submission.embeds.guid.data.attributes.description),
category: submission.embeds.guid.data.attributes.category,
dateCreated: submission.embeds.guid.data.attributes.date_created,
dateModified: submission.embeds.guid.data.attributes.date_modified,
Expand Down Expand Up @@ -183,8 +184,8 @@ export class CollectionsMapper {
type: submission.type,
nodeId: submission.embeds.guid.data.id,
nodeUrl: submission.embeds.guid.data.links.html,
title: submission.embeds.guid.data.attributes.title,
description: submission.embeds.guid.data.attributes.description,
title: replaceBadEncodedChars(submission.embeds.guid.data.attributes.title),
description: replaceBadEncodedChars(submission.embeds.guid.data.attributes.description),
category: submission.embeds.guid.data.attributes.category,
dateCreated: submission.embeds.guid.data.attributes.date_created,
dateModified: submission.embeds.guid.data.attributes.date_modified,
Expand Down
Loading