Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple Search fixes for merge related issues #162

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SearchPageComponent } from './search-page.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: 'search', component: SearchPageComponent }
{ path: '', component: SearchPageComponent }
])
]
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { SearchService } from '../search/search.service';
import { SearchService } from './search.service';
import { ActivatedRoute, Router } from '@angular/router';
import { RemoteData } from '../core/data/remote-data';
import { SearchResult } from '../search/search-result.model';
import { SearchResult } from './search-result.model';
import { DSpaceObject } from '../core/shared/dspace-object.model';
import { SortOptions } from '../core/cache/models/sort-options.model';
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
import { SearchOptions } from '../search/search-options.model';
import { SearchOptions } from './search-options.model';
import { CommunityDataService } from '../core/data/community-data.service';
import { isNotEmpty } from '../shared/empty.util';
import { Community } from '../core/shared/community.model';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ import { SharedModule } from '../shared/shared.module';
import { SearchPageRoutingModule } from './search-page-routing.module';
import { SearchPageComponent } from './search-page.component';
import { SearchResultsComponent } from './search-results/search-results.compontent';
import { SearchModule } from '../search/search.module';
import { ItemSearchResultListElementComponent } from '../object-list/search-result-list-element/item-search-result/item-search-result-list-element.component';
import { CollectionSearchResultListElementComponent } from '../object-list/search-result-list-element/collection-search-result/collection-search-result-list-element.component';
import { CommunitySearchResultListElementComponent } from '../object-list/search-result-list-element/community-search-result/community-search-result-list-element.component';
import { SearchService } from './search.service';

@NgModule({
imports: [
SearchPageRoutingModule,
CommonModule,
TranslateModule,
RouterModule,
SharedModule,
SearchModule
SharedModule
],
declarations: [
SearchPageComponent,
Expand All @@ -29,6 +28,9 @@ import { CommunitySearchResultListElementComponent } from '../object-list/search
CollectionSearchResultListElementComponent,
CommunitySearchResultListElementComponent
],
providers: [
SearchService
],
entryComponents: [
ItemSearchResultListElementComponent,
CollectionSearchResultListElementComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component, Input } from '@angular/core';
import { RemoteData } from '../../core/data/remote-data';
import { SearchResult } from '../../search/search-result.model';
import { SearchResult } from '../search-result.model';
import { DSpaceObject } from '../../core/shared/dspace-object.model';
import { SearchOptions } from '../../search/search-options.model';
import { SearchOptions } from '../search-options.model';

/**
* This component renders a simple item page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ export class SearchService {
});

const pageInfo = itemsRD.pageInfo.map((info: PageInfo) => {
info.totalElements = info.totalElements > 20 ? 20 : info.totalElements;
return info;
const totalElements = info.totalElements > 20 ? 20 : info.totalElements;
return Object.assign({}, info, {totalElements: totalElements});
});

const payload = itemsRD.payload.map((items: Item[]) => {
Expand Down
1 change: 1 addition & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { PageNotFoundComponent } from './pagenotfound/pagenotfound.component';
{ path: 'communities', loadChildren: './+community-page/community-page.module#CommunityPageModule' },
{ path: 'collections', loadChildren: './+collection-page/collection-page.module#CollectionPageModule' },
{ path: 'items', loadChildren: './+item-page/item-page.module#ItemPageModule' },
{ path: 'search', loadChildren: './+search-page/search-page.module#SearchPageModule' },
{ path: '**', pathMatch: 'full', component: PageNotFoundComponent },
])
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SearchResult } from '../../../search/search-result.model';
import { SearchResult } from '../../../+search-page/search-result.model';
import { Collection } from '../../../core/shared/collection.model';

export class CollectionSearchResult extends SearchResult<Collection> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SearchResult } from '../../../search/search-result.model';
import { SearchResult } from '../../../+search-page/search-result.model';
import { Community } from '../../../core/shared/community.model';

export class CommunitySearchResult extends SearchResult<Community> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SearchResult } from '../../../search/search-result.model';
import { SearchResult } from '../../../+search-page/search-result.model';
import { Item } from '../../../core/shared/item.model';

export class ItemSearchResult extends SearchResult<Item> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Inject } from '@angular/core';

import { ObjectListElementComponent } from '../object-list-element/object-list-element.component';
import { ListableObject } from '../listable-object/listable-object.model';
import { SearchResult } from '../../search/search-result.model';
import { SearchResult } from '../../+search-page/search-result.model';
import { DSpaceObject } from '../../core/shared/dspace-object.model';
import { Metadatum } from '../../core/shared/metadatum.model';
import { isEmpty, hasNoValue } from '../../shared/empty.util';
Expand Down
17 changes: 0 additions & 17 deletions src/app/search/search.module.ts

This file was deleted.

24 changes: 2 additions & 22 deletions src/app/shared/search-form/search-form.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { Component, Input } from '@angular/core';
import { DSpaceObject } from '../../core/shared/dspace-object.model';
import { Router } from '@angular/router';
import { isNotEmpty, hasValue, isEmpty } from '../empty.util';
Expand All @@ -15,14 +15,12 @@ import { Observable } from 'rxjs/Observable';
styleUrls: ['./search-form.component.scss'],
templateUrl: './search-form.component.html',
})
export class SearchFormComponent implements OnInit, OnDestroy {
export class SearchFormComponent {
@Input() query: string;
selectedId = '';
// Optional existing search parameters
@Input() currentParams: {};
@Input() scopes: Observable<DSpaceObject[]>;
scopeOptions: string[] = [];
sub;

@Input()
set scope(dso: DSpaceObject) {
Expand All @@ -31,19 +29,6 @@ export class SearchFormComponent implements OnInit, OnDestroy {
}
}

ngOnInit(): void {
if (this.scopes) {
this.sub =
this.scopes
.filter((scopes: DSpaceObject[]) => isEmpty(scopes))
.subscribe((scopes: DSpaceObject[]) => {
this.scopeOptions = scopes
.map((scope: DSpaceObject) => scope.id);
}
);
}
}

constructor(private router: Router) {
}

Expand Down Expand Up @@ -75,9 +60,4 @@ export class SearchFormComponent implements OnInit, OnDestroy {
return id1 === id2;
}

ngOnDestroy(): void {
if (this.sub) {
this.sub.unsubscribe();
}
}
}