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
Expand Up @@ -11,6 +11,7 @@ import { RouterLink } from '@angular/router';
import { PreprintProviderDetails } from '@osf/features/preprints/models';
import { CustomDialogService } from '@osf/shared/services';
import { SearchInputComponent } from '@shared/components';
import { normalizeQuotes } from '@shared/helpers';
import { DecodeHtmlPipe } from '@shared/pipes';

import { PreprintsHelpDialogComponent } from '../preprints-help-dialog/preprints-help-dialog.component';
Expand All @@ -31,7 +32,7 @@ export class PreprintProviderHeroComponent {
triggerSearch = output<string>();

onTriggerSearch(value: string) {
this.triggerSearch.emit(value);
this.triggerSearch.emit(normalizeQuotes(value)!);
}

openHelpDialog() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
} from '@osf/features/preprints/store/preprint-providers';
import { SearchInputComponent } from '@shared/components';
import { ResourceType } from '@shared/enums';
import { normalizeQuotes } from '@shared/helpers';
import { BrandService } from '@shared/services';

@Component({
Expand Down Expand Up @@ -87,7 +88,7 @@ export class PreprintsLandingComponent implements OnInit, OnDestroy {
}

redirectToSearchPageWithValue() {
const searchValue = this.searchControl.value;
const searchValue = normalizeQuotes(this.searchControl.value);

this.router.navigate(['/search'], {
queryParams: { search: searchValue, tab: ResourceType.Preprint },
Expand Down
8 changes: 5 additions & 3 deletions src/app/features/profile/profile.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
@if (user()) {
<osf-profile-information [currentUser]="user()" [showEdit]="isMyProfile()" (editProfile)="toProfileSettings()" />

<div class="mt-6">
<osf-global-search [resourceTabOptions]="resourceTabOptions" />
</div>
@if (defaultSearchFiltersInitialized()) {
<div class="mt-6">
<osf-global-search [resourceTabOptions]="resourceTabOptions" />
</div>
}
}
}
7 changes: 5 additions & 2 deletions src/app/features/profile/profile.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createDispatchMap, select } from '@ngxs/store';

import { ChangeDetectionStrategy, Component, computed, DestroyRef, inject, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component, computed, DestroyRef, inject, OnInit, signal } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ActivatedRoute, Router } from '@angular/router';

Expand Down Expand Up @@ -39,6 +39,7 @@ export class ProfileComponent implements OnInit {

isMyProfile = computed(() => !this.route.snapshot.params['id']);
user = computed(() => (this.isMyProfile() ? this.loggedInUser() : this.userProfile()));
defaultSearchFiltersInitialized = signal<boolean>(false);

ngOnInit(): void {
const userId = this.route.snapshot.params['id'];
Expand All @@ -65,14 +66,16 @@ export class ProfileComponent implements OnInit {
private setupMyProfile(user: UserModel): void {
this.actions.setUserProfile(user);
if (user?.iri) {
this.defaultSearchFiltersInitialized.set(true);
this.actions.setDefaultFilterValue('creator,isContainedBy.creator', user.iri);
}
}

private setSearchFilter(): void {
const currentUser = this.user();
if (currentUser?.iri) {
this.actions.setDefaultFilterValue('creator', currentUser.iri);
this.defaultSearchFiltersInitialized.set(true);
this.actions.setDefaultFilterValue('creator,isContainedBy.creator', currentUser.iri);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
GetRegistryProvider,
RegistrationProviderSelectors,
} from '@osf/shared/stores/registration-provider';
import { normalizeQuotes } from '@shared/helpers';

import { RegistryServicesComponent } from '../../components';
import { GetRegistries, RegistriesSelectors } from '../../store';
Expand Down Expand Up @@ -73,7 +74,7 @@ export class RegistriesLandingComponent implements OnInit, OnDestroy {
}

redirectToSearchPageWithValue(): void {
const searchValue = this.searchControl.value;
const searchValue = normalizeQuotes(this.searchControl.value);

this.router.navigate(['/search'], { queryParams: { search: searchValue, tab: ResourceType.Registration } });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,11 @@ export class GlobalSearchComponent implements OnInit, OnDestroy {
.subscribe({
next: (newValue) => {
if (!newValue) newValue = null;
this.actions.setSearchText(normalizeQuotes(newValue));
const normalizedValue = normalizeQuotes(newValue);
this.actions.setSearchText(normalizedValue);
this.router.navigate([], {
relativeTo: this.route,
queryParams: { search: newValue },
queryParams: { search: normalizedValue },
queryParamsHandling: 'merge',
});
this.actions.fetchResources();
Expand Down
6 changes: 4 additions & 2 deletions src/app/shared/helpers/normalize-quotes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export function normalizeQuotes(text: string) {
return text.replace(/[\u201C\u201D]/g, '"');
import { StringOrNull } from '@shared/helpers/types.helper';

export function normalizeQuotes(text: StringOrNull): StringOrNull {
return text?.replace(/[\u201C\u201D]/g, '"') ?? null;
}
Loading