mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
44024: search page almost finished
This commit is contained in:
@@ -16,21 +16,18 @@ import { GenericConstructor } from '../../shared/generic-constructor';
|
|||||||
import { getMapsTo, getRelationMetadata, getRelationships } from './build-decorators';
|
import { getMapsTo, getRelationMetadata, getRelationships } from './build-decorators';
|
||||||
import { NormalizedObjectFactory } from '../models/normalized-object-factory';
|
import { NormalizedObjectFactory } from '../models/normalized-object-factory';
|
||||||
import { Request } from '../../data/request.models';
|
import { Request } from '../../data/request.models';
|
||||||
|
import { PageInfo } from '../../shared/page-info.model';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RemoteDataBuildService {
|
export class RemoteDataBuildService {
|
||||||
constructor(
|
constructor(protected objectCache: ObjectCacheService,
|
||||||
protected objectCache: ObjectCacheService,
|
protected responseCache: ResponseCacheService,
|
||||||
protected responseCache: ResponseCacheService,
|
protected requestService: RequestService,
|
||||||
protected requestService: RequestService,
|
protected store: Store<CoreState>,) {
|
||||||
protected store: Store<CoreState>,
|
|
||||||
) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildSingle<TNormalized extends CacheableObject, TDomain>(
|
buildSingle<TNormalized extends CacheableObject, TDomain>(href: string,
|
||||||
href: string,
|
normalizedType: GenericConstructor<TNormalized>): RemoteData<TDomain> {
|
||||||
normalizedType: GenericConstructor<TNormalized>
|
|
||||||
): RemoteData<TDomain> {
|
|
||||||
const requestHrefObs = this.objectCache.getRequestHrefBySelfLink(href);
|
const requestHrefObs = this.objectCache.getRequestHrefBySelfLink(href);
|
||||||
|
|
||||||
const requestObs = Observable.race(
|
const requestObs = Observable.race(
|
||||||
@@ -64,6 +61,13 @@ export class RemoteDataBuildService {
|
|||||||
const pageInfo = responseCacheObs
|
const pageInfo = responseCacheObs
|
||||||
.filter((entry: ResponseCacheEntry) => hasValue(entry.response) && hasValue(entry.response['pageInfo']))
|
.filter((entry: ResponseCacheEntry) => hasValue(entry.response) && hasValue(entry.response['pageInfo']))
|
||||||
.map((entry: ResponseCacheEntry) => (entry.response as SuccessResponse).pageInfo)
|
.map((entry: ResponseCacheEntry) => (entry.response as SuccessResponse).pageInfo)
|
||||||
|
.map((pInfo: PageInfo) => {
|
||||||
|
if (isNotEmpty(pageInfo) && pInfo.currentPage >= 0) {
|
||||||
|
return Object.assign({}, pInfo, {currentPage: pInfo.currentPage + 1});
|
||||||
|
} else {
|
||||||
|
return pInfo;
|
||||||
|
}
|
||||||
|
})
|
||||||
.distinctUntilChanged();
|
.distinctUntilChanged();
|
||||||
/* tslint:enable:no-string-literal */
|
/* tslint:enable:no-string-literal */
|
||||||
|
|
||||||
@@ -107,10 +111,8 @@ export class RemoteDataBuildService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
buildList<TNormalized extends CacheableObject, TDomain>(
|
buildList<TNormalized extends CacheableObject, TDomain>(href: string,
|
||||||
href: string,
|
normalizedType: GenericConstructor<TNormalized>): RemoteData<TDomain[]> {
|
||||||
normalizedType: GenericConstructor<TNormalized>
|
|
||||||
): RemoteData<TDomain[]> {
|
|
||||||
const requestObs = this.store.select<RequestEntry>('core', 'data', 'request', href)
|
const requestObs = this.store.select<RequestEntry>('core', 'data', 'request', href)
|
||||||
.filter((entry) => hasValue(entry));
|
.filter((entry) => hasValue(entry));
|
||||||
const responseCacheObs = this.responseCache.get(href).filter((entry) => hasValue(entry));
|
const responseCacheObs = this.responseCache.get(href).filter((entry) => hasValue(entry));
|
||||||
@@ -240,7 +242,7 @@ export class RemoteDataBuildService {
|
|||||||
})
|
})
|
||||||
.filter((e) => hasValue(e))
|
.filter((e) => hasValue(e))
|
||||||
.join(', ')
|
.join(', ')
|
||||||
);
|
);
|
||||||
|
|
||||||
const statusCode = Observable.combineLatest(
|
const statusCode = Observable.combineLatest(
|
||||||
...input.map((rd) => rd.statusCode),
|
...input.map((rd) => rd.statusCode),
|
||||||
@@ -252,7 +254,7 @@ export class RemoteDataBuildService {
|
|||||||
})
|
})
|
||||||
.filter((c) => hasValue(c))
|
.filter((c) => hasValue(c))
|
||||||
.join(', ')
|
.join(', ')
|
||||||
);
|
);
|
||||||
|
|
||||||
const pageInfo = Observable.of(undefined);
|
const pageInfo = Observable.of(undefined);
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<div class="search-page">
|
<div class="search-page">
|
||||||
<ds-search-form></ds-search-form>
|
<ds-search-form (formSubmit)="updateSearch($event)" [query]="query"></ds-search-form>
|
||||||
<ds-search-results [searchResults]="results"></ds-search-results>
|
<ds-search-results [searchResults]="results"></ds-search-results>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { SearchService } from '../search/search.service';
|
import { SearchService } from '../search/search.service';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { SortOptions } from '../core/cache/models/sort-options.model';
|
|
||||||
import { RemoteData } from '../core/data/remote-data';
|
import { RemoteData } from '../core/data/remote-data';
|
||||||
import { SearchResult } from '../search/search-result.model';
|
import { SearchResult } from '../search/search-result.model';
|
||||||
import { DSpaceObject } from '../core/shared/dspace-object.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';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component renders a simple item page.
|
* This component renders a simple item page.
|
||||||
@@ -13,30 +14,57 @@ import { DSpaceObject } from '../core/shared/dspace-object.model';
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-search-page',
|
selector: 'ds-search-page',
|
||||||
styleUrls: ['./search-page.component.scss'],
|
styleUrls: ['./search-page.component.scss'],
|
||||||
templateUrl: './search-page.component.html',
|
templateUrl: './search-page.component.html',
|
||||||
})
|
})
|
||||||
export class SearchPageComponent implements OnInit {
|
export class SearchPageComponent implements OnInit, OnDestroy {
|
||||||
private sub;
|
private sub;
|
||||||
results: RemoteData<Array<SearchResult<DSpaceObject>>>;
|
private query: string;
|
||||||
|
private scope: string;
|
||||||
|
private page: number;
|
||||||
|
private results: RemoteData<Array<SearchResult<DSpaceObject>>>;
|
||||||
|
private currentParams = {};
|
||||||
|
|
||||||
constructor(
|
constructor(private service: SearchService,
|
||||||
private service: SearchService,
|
private route: ActivatedRoute,
|
||||||
private route: ActivatedRoute,
|
private router: Router,) {
|
||||||
) { }
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.sub = this.route
|
this.sub = this.route
|
||||||
.queryParams
|
.queryParams
|
||||||
.subscribe((params) => {
|
.subscribe((params) => {
|
||||||
const query: string = params.query || '';
|
this.currentParams = params;
|
||||||
const scope: string = params.scope;
|
this.query = params.query || '';
|
||||||
const page: number = +params.page || 0;
|
this.scope = params.scope;
|
||||||
this.results = this.service.search(query, scope, {elementsPerPage: 10, currentPage: page, sort: new SortOptions()});
|
this.page = +params.page || 1;
|
||||||
|
const pagination: PaginationComponentOptions = new PaginationComponentOptions();
|
||||||
|
pagination.id = 'results-pagination';
|
||||||
|
pagination.currentPage = this.page;
|
||||||
|
pagination.pageSize = +params.pageSize;
|
||||||
|
this.results = this.service.search(this.query, this.scope, {
|
||||||
|
pagination: pagination,
|
||||||
|
sort: new SortOptions(params.sortField, params.sortDirection)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
ngOnDestroy() {
|
);
|
||||||
this.sub.unsubscribe();
|
}
|
||||||
}
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1 +1,2 @@
|
|||||||
<ds-object-list [objects]="searchResults"></ds-object-list>
|
<ds-object-list [config]="searchConfig.pagination" [sortConfig]="searchConfig.sort"
|
||||||
|
[objects]="searchResults" [hideGear]="false"></ds-object-list>
|
@@ -1,7 +1,10 @@
|
|||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
import { SearchResult } from '../../search/search-result.model';
|
import { SearchResult } from '../../search/search-result.model';
|
||||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||||
|
import { SortOptions, SortDirection } from '../../core/cache/models/sort-options.model';
|
||||||
|
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||||
|
import { SearchOptions } from '../../search/search-options.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component renders a simple item page.
|
* This component renders a simple item page.
|
||||||
@@ -17,8 +20,13 @@ import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
|||||||
export class SearchResultsComponent implements OnInit {
|
export class SearchResultsComponent implements OnInit {
|
||||||
@Input() searchResults: RemoteData<Array<SearchResult<DSpaceObject>>>;
|
@Input() searchResults: RemoteData<Array<SearchResult<DSpaceObject>>>;
|
||||||
|
|
||||||
ngOnInit(): void {
|
@Input() searchConfig: SearchOptions;
|
||||||
// onInit
|
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.searchConfig = new SearchOptions();
|
||||||
|
this.searchConfig.pagination = new PaginationComponentOptions();
|
||||||
|
this.searchConfig.pagination.id = 'search-results-pagination';
|
||||||
|
this.searchConfig.sort = new SortOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
7
src/app/search/search-options.model.ts
Normal file
7
src/app/search/search-options.model.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { SortOptions } from '../core/cache/models/sort-options.model';
|
||||||
|
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
|
||||||
|
|
||||||
|
export class SearchOptions {
|
||||||
|
pagination?: PaginationComponentOptions;
|
||||||
|
sort?: SortOptions;
|
||||||
|
}
|
@@ -1,7 +0,0 @@
|
|||||||
import { SortOptions } from '../core/cache/models/sort-options.model';
|
|
||||||
|
|
||||||
export class SearchOptions {
|
|
||||||
elementsPerPage?: number;
|
|
||||||
currentPage?: number;
|
|
||||||
sort?: SortOptions;
|
|
||||||
}
|
|
@@ -5,7 +5,7 @@ import { SearchResult } from './search-result.model';
|
|||||||
import { ItemDataService } from '../core/data/item-data.service';
|
import { ItemDataService } from '../core/data/item-data.service';
|
||||||
import { PageInfo } from '../core/shared/page-info.model';
|
import { PageInfo } from '../core/shared/page-info.model';
|
||||||
import { DSpaceObject } from '../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../core/shared/dspace-object.model';
|
||||||
import { SearchOptions } from './search.models';
|
import { SearchOptions } from './search-options.model';
|
||||||
import { hasValue, isNotEmpty } from '../shared/empty.util';
|
import { hasValue, isNotEmpty } from '../shared/empty.util';
|
||||||
import { Metadatum } from '../core/shared/metadatum.model';
|
import { Metadatum } from '../core/shared/metadatum.model';
|
||||||
import { Item } from '../core/shared/item.model';
|
import { Item } from '../core/shared/item.model';
|
||||||
@@ -36,19 +36,18 @@ export class SearchService {
|
|||||||
if (hasValue(scopeId)) {
|
if (hasValue(scopeId)) {
|
||||||
self += `&scope=${scopeId}`;
|
self += `&scope=${scopeId}`;
|
||||||
}
|
}
|
||||||
if (isNotEmpty(searchOptions) && hasValue(searchOptions.currentPage)) {
|
if (isNotEmpty(searchOptions) && hasValue(searchOptions.pagination.currentPage)) {
|
||||||
self += `&page=${searchOptions.currentPage}`;
|
self += `&page=${searchOptions.pagination.currentPage}`;
|
||||||
}
|
}
|
||||||
const requestPending = Observable.of(false);
|
const requestPending = Observable.of(false);
|
||||||
const responsePending = Observable.of(false);
|
const responsePending = Observable.of(false);
|
||||||
const isSuccessFul = Observable.of(true);
|
|
||||||
const errorMessage = Observable.of(undefined);
|
const errorMessage = Observable.of(undefined);
|
||||||
const statusCode = Observable.of('200');
|
const statusCode = Observable.of('200');
|
||||||
const returningPageInfo = new PageInfo();
|
const returningPageInfo = new PageInfo();
|
||||||
|
|
||||||
if (isNotEmpty(searchOptions)) {
|
if (isNotEmpty(searchOptions)) {
|
||||||
returningPageInfo.elementsPerPage = searchOptions.elementsPerPage;
|
returningPageInfo.elementsPerPage = searchOptions.pagination.pageSize;
|
||||||
returningPageInfo.currentPage = searchOptions.currentPage;
|
returningPageInfo.currentPage = searchOptions.pagination.currentPage;
|
||||||
} else {
|
} else {
|
||||||
returningPageInfo.elementsPerPage = 10;
|
returningPageInfo.elementsPerPage = 10;
|
||||||
returningPageInfo.currentPage = 1;
|
returningPageInfo.currentPage = 1;
|
||||||
@@ -82,7 +81,7 @@ export class SearchService {
|
|||||||
self,
|
self,
|
||||||
requestPending,
|
requestPending,
|
||||||
responsePending,
|
responsePending,
|
||||||
isSuccessFul,
|
itemsRD.hasSucceeded,
|
||||||
errorMessage,
|
errorMessage,
|
||||||
statusCode,
|
statusCode,
|
||||||
pageInfo,
|
pageInfo,
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div ngbDropdown #paginationControls="ngbDropdown" class="d-inline-block float-right">
|
<div ngbDropdown #paginationControls="ngbDropdown" class="d-inline-block float-right">
|
||||||
<button class="btn btn-outline-primary" id="paginationControls" (click)="$event.stopPropagation(); (paginationControls.isOpen())?paginationControls.close():paginationControls.open();"><i class="fa fa-cog" aria-hidden="true"></i></button>
|
<button class="btn btn-outline-primary" id="paginationControls" ngbDropdownToggle><i class="fa fa-cog" aria-hidden="true"></i></button>
|
||||||
<div class="dropdown-menu dropdown-menu-right" id="paginationControlsDropdownMenu" aria-labelledby="paginationControls">
|
<div class="dropdown-menu dropdown-menu-right" id="paginationControlsDropdownMenu" aria-labelledby="paginationControls" ngbDropdownMenu>
|
||||||
<h6 class="dropdown-header">{{ 'pagination.results-per-page' | translate}}</h6>
|
<h6 class="dropdown-header">{{ 'pagination.results-per-page' | translate}}</h6>
|
||||||
<button class="dropdown-item" style="padding-left: 20px" *ngFor="let item of pageSizeOptions" (click)="setPageSize(item)"><i class="fa fa-check {{(item != paginationOptions.pageSize) ? 'invisible' : ''}}" aria-hidden="true"></i> {{item}} </button>
|
<button class="dropdown-item" style="padding-left: 20px" *ngFor="let item of pageSizeOptions" (click)="setPageSize(item)"><i class="fa fa-check {{(item != paginationOptions.pageSize) ? 'invisible' : ''}}" aria-hidden="true"></i> {{item}} </button>
|
||||||
<h6 class="dropdown-header">{{ 'pagination.sort-direction' | translate}}</h6>
|
<h6 class="dropdown-header">{{ 'pagination.sort-direction' | translate}}</h6>
|
||||||
|
5
src/app/shared/pagination/pagination.component.scss
Normal file
5
src/app/shared/pagination/pagination.component.scss
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
:host {
|
||||||
|
.dropdown-toggle::after {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
@@ -30,11 +30,12 @@ import { PageInfo } from '../../core/shared/page-info.model';
|
|||||||
@Component({
|
@Component({
|
||||||
exportAs: 'paginationComponent',
|
exportAs: 'paginationComponent',
|
||||||
selector: 'ds-pagination',
|
selector: 'ds-pagination',
|
||||||
|
styleUrls: ['pagination.component.scss'],
|
||||||
templateUrl: 'pagination.component.html',
|
templateUrl: 'pagination.component.html',
|
||||||
changeDetection: ChangeDetectionStrategy.Default,
|
changeDetection: ChangeDetectionStrategy.Default,
|
||||||
encapsulation: ViewEncapsulation.Emulated
|
encapsulation: ViewEncapsulation.Emulated
|
||||||
})
|
})
|
||||||
export class PaginationComponent implements OnChanges, OnDestroy, OnInit {
|
export class PaginationComponent implements OnDestroy, OnInit {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of items in collection.
|
* Number of items in collection.
|
||||||
@@ -165,15 +166,6 @@ export class PaginationComponent implements OnChanges, OnDestroy, OnInit {
|
|||||||
total: null
|
total: null
|
||||||
};
|
};
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
|
||||||
if (changes.pageInfoState && !changes.pageInfoState.isFirstChange()) {
|
|
||||||
this.subs.push(this.pageInfoState.subscribe((pageInfo) => {
|
|
||||||
/* TODO: this is a temporary fix for the pagination start index (0 or 1) discrepancy between the rest and the frontend respectively */
|
|
||||||
this.currentPageState = pageInfo.currentPage + 1;
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method provided by Angular. Invoked after the constructor.
|
* Method provided by Angular. Invoked after the constructor.
|
||||||
*/
|
*/
|
||||||
@@ -185,13 +177,6 @@ export class PaginationComponent implements OnChanges, OnDestroy, OnInit {
|
|||||||
}));
|
}));
|
||||||
this.checkConfig(this.paginationOptions);
|
this.checkConfig(this.paginationOptions);
|
||||||
|
|
||||||
if (this.pageInfoState) {
|
|
||||||
this.subs.push(this.pageInfoState.subscribe((pageInfo) => {
|
|
||||||
/* TODO: this is a temporary fix for the pagination start index (0 or 1) discrepancy between the rest and the frontend respectively */
|
|
||||||
this.currentPageState = pageInfo.currentPage + 1;
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.id = this.paginationOptions.id || null;
|
this.id = this.paginationOptions.id || null;
|
||||||
this.pageSizeOptions = this.paginationOptions.pageSizeOptions;
|
this.pageSizeOptions = this.paginationOptions.pageSizeOptions;
|
||||||
this.subs.push(this.route.queryParams
|
this.subs.push(this.route.queryParams
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
<form [formGroup]="searchFormGroup" action="/search">
|
<form #form="ngForm" (ngSubmit)="onSubmit(form.value)">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" class="form-control" aria-label="Search input">
|
<input type="text" [ngModel]="query" name="query" class="form-control" aria-label="Search input">
|
||||||
|
|
||||||
<div class="input-group-btn" ngbDropdown>
|
<div class="input-group-btn" ngbDropdown>
|
||||||
<button type="submit" class="btn btn-secondary">Search DSpace</button>
|
<button type="submit" class="btn btn-secondary">Search DSpace</button>
|
||||||
<button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"
|
<button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"
|
||||||
@@ -9,11 +8,10 @@
|
|||||||
<span class="sr-only">Toggle Dropdown</span>
|
<span class="sr-only">Toggle Dropdown</span>
|
||||||
</button>
|
</button>
|
||||||
<div ngbDropdownMenu class="dropdown-menu dropdown-menu-right" aria-labelledby="searchDropdown">
|
<div ngbDropdownMenu class="dropdown-menu dropdown-menu-right" aria-labelledby="searchDropdown">
|
||||||
<a class="dropdown-item" href="#">Search DSpace</a>
|
<a class="dropdown-item" (click)="onSubmit(form.value)">Search DSpace</a>
|
||||||
<a class="dropdown-item" href="#">Search this Collection</a>
|
<a class="dropdown-item" (click)="onSubmit(form.value, '7669c72a-3f2a-451f-a3b9-9210e7a4c02f')">Search OR2017 - Demonstration</a>
|
||||||
<a class="dropdown-item" href="#">Search this Community</a>
|
<a class="dropdown-item" (click)="onSubmit(form.value, '9076bd16-e69a-48d6-9e41-0238cb40d863')">Search Sample Community</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit, EventEmitter, Output, Input } from '@angular/core';
|
||||||
import { FormGroup, FormControl } from '@angular/forms';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component renders a simple item page.
|
* This component renders a simple item page.
|
||||||
@@ -8,21 +7,18 @@ import { FormGroup, FormControl } from '@angular/forms';
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-search-form',
|
selector: 'ds-search-form',
|
||||||
styleUrls: ['./search-form.component.scss'],
|
styleUrls: ['./search-form.component.scss'],
|
||||||
templateUrl: './search-form.component.html',
|
templateUrl: './search-form.component.html',
|
||||||
})
|
})
|
||||||
export class SearchFormComponent implements OnInit {
|
export class SearchFormComponent implements OnInit {
|
||||||
searchFormGroup: FormGroup;
|
@Output() formSubmit: EventEmitter<any> = new EventEmitter<any>();
|
||||||
//
|
@Input() query: string;
|
||||||
// constructor() {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
ngOnInit(): void {
|
|
||||||
this.searchFormGroup = new FormGroup({
|
|
||||||
firstName: new FormControl()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ngOnInit(): void { }
|
||||||
|
|
||||||
|
onSubmit(form: any, scope?: string) {
|
||||||
|
const data: any = Object.assign({}, form, { scope: scope });
|
||||||
|
this.formSubmit.emit(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user