mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-12 12:33:07 +00:00
44024: simple search finalisation
This commit is contained in:
@@ -20,4 +20,6 @@ html {
|
||||
|
||||
.main-content {
|
||||
flex: 1 0 auto;
|
||||
margin-top: $content-spacing;
|
||||
margin-bottom: $content-spacing;
|
||||
}
|
||||
|
@@ -3,6 +3,8 @@
|
||||
display: block;
|
||||
margin-right: ($grid-gutter-width / -2);
|
||||
margin-left: ($grid-gutter-width / -2);
|
||||
margin-top: -$content-spacing;
|
||||
margin-bottom: -$content-spacing;
|
||||
}
|
||||
|
||||
.dspace-logo-container {
|
||||
|
@@ -1,2 +1,3 @@
|
||||
<ds-home-news></ds-home-news>
|
||||
<ds-search-form></ds-search-form>
|
||||
<ds-top-level-community-list></ds-top-level-community-list>
|
||||
|
@@ -7,7 +7,7 @@ import { Collection } from '../../../core/shared/collection.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-collection-search-result-list-element',
|
||||
styleUrls: ['collection-search-result-list-element.component.scss'],
|
||||
styleUrls: ['../search-result-list-element.component.scss', 'collection-search-result-list-element.component.scss'],
|
||||
templateUrl: 'collection-search-result-list-element.component.html'
|
||||
})
|
||||
|
||||
|
@@ -7,7 +7,7 @@ import { Community } from '../../../core/shared/community.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-community-search-result-list-element',
|
||||
styleUrls: ['community-search-result-list-element.component.scss'],
|
||||
styleUrls: ['../search-result-list-element.component.scss', 'community-search-result-list-element.component.scss'],
|
||||
templateUrl: 'community-search-result-list-element.component.html'
|
||||
})
|
||||
|
||||
|
@@ -7,7 +7,7 @@ import { Item } from '../../../core/shared/item.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-item-search-result-list-element',
|
||||
styleUrls: ['item-search-result-list-element.component.scss'],
|
||||
styleUrls: ['../search-result-list-element.component.scss', 'item-search-result-list-element.component.scss'],
|
||||
templateUrl: 'item-search-result-list-element.component.html'
|
||||
})
|
||||
|
||||
|
@@ -0,0 +1,7 @@
|
||||
@import '../../../styles/shared_imports.scss';
|
||||
:host {
|
||||
/deep/ em {
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
<div class="search-page">
|
||||
<ds-search-form (formSubmit)="updateSearch($event)" [query]="query"></ds-search-form>
|
||||
<ds-search-form [query]="query" [scope]="(scopeObject?.payload | async)" [currentParams]="currentParams"></ds-search-form>
|
||||
<ds-search-results [searchResults]="results" [searchConfig]="searchOptions"></ds-search-results>
|
||||
</div>
|
@@ -7,6 +7,8 @@ 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 { CommunityDataService } from '../core/data/community-data.service';
|
||||
import { hasValue } from '../shared/empty.util';
|
||||
|
||||
/**
|
||||
* This component renders a simple item page.
|
||||
@@ -23,6 +25,7 @@ export class SearchPageComponent implements OnInit, OnDestroy {
|
||||
private sub;
|
||||
query: string;
|
||||
private scope: string;
|
||||
scopeObject: RemoteData<DSpaceObject>;
|
||||
private page: number;
|
||||
results: RemoteData<Array<SearchResult<DSpaceObject>>>;
|
||||
private currentParams = {};
|
||||
@@ -30,7 +33,8 @@ export class SearchPageComponent implements OnInit, OnDestroy {
|
||||
|
||||
constructor(private service: SearchService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,) {
|
||||
private communityService: CommunityDataService,
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -48,6 +52,11 @@ export class SearchPageComponent implements OnInit, OnDestroy {
|
||||
const sort: SortOptions = new SortOptions(params.sortField, params.sortDirection);
|
||||
this.searchOptions = {pagination: pagination, sort: sort};
|
||||
this.results = this.service.search(this.query, this.scope, this.searchOptions);
|
||||
if (hasValue(this.scope)) {
|
||||
this.scopeObject = this.communityService.findById(this.scope);
|
||||
} else {
|
||||
this.scopeObject = undefined;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -55,17 +64,4 @@ export class SearchPageComponent implements OnInit, OnDestroy {
|
||||
ngOnDestroy() {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
|
||||
updateSearch(data: any) {
|
||||
this.router.navigate([], {
|
||||
queryParams: Object.assign({}, this.currentParams,
|
||||
{
|
||||
query: data.query,
|
||||
scope: data.scope,
|
||||
page: data.page || 1
|
||||
}
|
||||
)
|
||||
})
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,6 @@ import { CommunitySearchResultListElementComponent } from '../object-list/search
|
||||
],
|
||||
declarations: [
|
||||
SearchPageComponent,
|
||||
SearchFormComponent,
|
||||
SearchResultsComponent,
|
||||
ItemSearchResultListElementComponent,
|
||||
CollectionSearchResultListElementComponent,
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<form #form="ngForm" (ngSubmit)="onSubmit(form.value)">
|
||||
<form #form="ngForm" (ngSubmit)="onSubmit(form.value, scope?.id)">
|
||||
<div class="form-group input-group">
|
||||
<input type="text" [ngModel]="query" name="query" class="form-control" aria-label="Search input">
|
||||
<div class="input-group-btn" ngbDropdown>
|
||||
<button type="submit" class="btn btn-secondary">{{ 'search.form.search_dspace' | translate }}</button>
|
||||
<button type="submit" class="search-button btn btn-secondary">{{ scope ? scope.name : ('search.form.search_dspace' | translate) }}</button>
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"
|
||||
aria-haspopup="true" aria-expanded="false" id="searchDropdown" ngbDropdownToggle>
|
||||
<span class="sr-only">Toggle Dropdown</span>
|
||||
|
@@ -1,4 +1,6 @@
|
||||
import { Component, OnInit, EventEmitter, Output, Input } from '@angular/core';
|
||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
|
||||
/**
|
||||
* This component renders a simple item page.
|
||||
@@ -12,11 +14,31 @@ import { Component, OnInit, EventEmitter, Output, Input } from '@angular/core';
|
||||
templateUrl: './search-form.component.html',
|
||||
})
|
||||
export class SearchFormComponent {
|
||||
@Output() formSubmit: EventEmitter<any> = new EventEmitter<any>();
|
||||
@Input() query: string;
|
||||
@Input() scope: DSpaceObject;
|
||||
|
||||
// Optional existing search parameters
|
||||
@Input() currentParams: {};
|
||||
|
||||
constructor(private router: Router) {
|
||||
}
|
||||
|
||||
onSubmit(form: any, scope ?: string) {
|
||||
const data: any = Object.assign({}, form, { scope: scope });
|
||||
this.formSubmit.emit(data);
|
||||
this.updateSearch(data);
|
||||
|
||||
}
|
||||
|
||||
updateSearch(data: any) {
|
||||
this.router.navigate(['/search'], {
|
||||
queryParams: Object.assign({}, this.currentParams,
|
||||
{
|
||||
query: data.query,
|
||||
scope: data.scope,
|
||||
page: data.page || 1
|
||||
}
|
||||
)
|
||||
})
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import { CollectionListElementComponent } from '../object-list/collection-list-e
|
||||
import { TruncatePipe } from './utils/truncate.pipe';
|
||||
import { WrapperListElementComponent } from '../object-list/wrapper-list-element/wrapper-list-element.component';
|
||||
import { SearchResultListElementComponent } from '../object-list/search-result-list-element/search-result-list-element.component';
|
||||
import { SearchFormComponent } from './search-form/search-form.component';
|
||||
|
||||
const MODULES = [
|
||||
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
||||
@@ -55,7 +56,8 @@ const COMPONENTS = [
|
||||
ComcolPageLogoComponent,
|
||||
ObjectListComponent,
|
||||
ObjectListElementComponent,
|
||||
WrapperListElementComponent
|
||||
WrapperListElementComponent,
|
||||
SearchFormComponent
|
||||
];
|
||||
|
||||
const ENTRY_COMPONENTS = [
|
||||
|
@@ -28,3 +28,4 @@ $theme-colors: (
|
||||
) !default;
|
||||
/* Fonts */
|
||||
$link-color: map-get($theme-colors, info) !default;
|
||||
|
1
src/styles/_custom_variables.scss
Normal file
1
src/styles/_custom_variables.scss
Normal file
@@ -0,0 +1 @@
|
||||
$content-spacing: $spacer * 1.5;
|
@@ -1,4 +1,5 @@
|
||||
@import 'variables.scss';
|
||||
@import 'bootstrap_variables.scss';
|
||||
@import '../../node_modules/bootstrap/scss/bootstrap.scss';
|
||||
@import "../../node_modules/font-awesome/scss/font-awesome.scss";
|
||||
@import 'mixins.scss';
|
||||
@import 'custom_variables.scss';
|
Reference in New Issue
Block a user