Skip to content
Snippets Groups Projects
Commit 5e8e8966 authored by Art Lowel's avatar Art Lowel Committed by GitHub
Browse files

Merge pull request #162 from LotteHofstede/merge-fixes-and-updates-for-simple-search

This merge closes #161 
parents 62bfeb40 da881f7a
No related branches found
No related tags found
No related merge requests found
Showing
with 20 additions and 54 deletions
......@@ -6,7 +6,7 @@ import { SearchPageComponent } from './search-page.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: 'search', component: SearchPageComponent }
{ path: '', component: SearchPageComponent }
])
]
})
......
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';
......
......@@ -8,10 +8,10 @@ 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: [
......@@ -19,8 +19,7 @@ import { CommunitySearchResultListElementComponent } from '../object-list/search
CommonModule,
TranslateModule,
RouterModule,
SharedModule,
SearchModule
SharedModule
],
declarations: [
SearchPageComponent,
......@@ -29,6 +28,9 @@ import { CommunitySearchResultListElementComponent } from '../object-list/search
CollectionSearchResultListElementComponent,
CommunitySearchResultListElementComponent
],
providers: [
SearchService
],
entryComponents: [
ItemSearchResultListElementComponent,
CollectionSearchResultListElementComponent,
......
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.
......
......@@ -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[]) => {
......
......@@ -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 },
])
],
......
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> {
......
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> {
......
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> {
......
......@@ -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';
......
import { NgModule } from '@angular/core';
import { CoreModule } from '../core/core.module';
import { SearchService } from './search.service';
@NgModule({
imports: [
],
declarations: [
],
exports: [
],
providers: [
SearchService
]
})
export class SearchModule { }
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';
......@@ -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) {
......@@ -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) {
}
......@@ -75,9 +60,4 @@ export class SearchFormComponent implements OnInit, OnDestroy {
return id1 === id2;
}
ngOnDestroy(): void {
if (this.sub) {
this.sub.unsubscribe();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment