#150 Feedback fixes

This commit is contained in:
Jonas Van Goolen
2017-12-19 10:41:35 +01:00
parent 8270587624
commit 4a56bd0f14
3 changed files with 38 additions and 33 deletions

View File

@@ -1,12 +1,10 @@
import {
ChangeDetectionStrategy,
Component, EventEmitter,
Input,
ViewEncapsulation,
ChangeDetectionStrategy,
OnInit,
Output, SimpleChanges, OnChanges, ChangeDetectorRef, DoCheck
Output,
ViewEncapsulation
} from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { RemoteData } from '../../core/data/remote-data';
import { PageInfo } from '../../core/shared/page-info.model';
@@ -16,6 +14,7 @@ import { PaginationComponentOptions } from '../pagination/pagination-component-o
import { SortOptions, SortDirection } from '../../core/cache/models/sort-options.model';
import { fadeIn } from '../animations/fade';
import { ListableObject } from '../object-collection/shared/listable-object.model';
import { hasValue } from '../empty.util';
@Component({
changeDetection: ChangeDetectionStrategy.Default,
@@ -26,14 +25,35 @@ import { ListableObject } from '../object-collection/shared/listable-object.mode
animations: [fadeIn]
})
export class ObjectGridComponent implements OnChanges, OnInit {
export class ObjectGridComponent {
@Input() objects: RemoteData<ListableObject[]>;
@Input() config: PaginationComponentOptions;
@Input() sortConfig: SortOptions;
@Input() hideGear = false;
@Input() hidePagerWhenSinglePage = true;
pageInfo: Observable<PageInfo>;
private _objects: RemoteData<ListableObject[]>;
pageInfo: PageInfo;
@Input() set objects(objects: RemoteData<ListableObject[]>) {
this._objects = objects;
if (hasValue(objects)) {
this.pageInfo = objects.pageInfo;
}
}
get objects() {
return this._objects;
}
/**
* An event fired when the page is changed.
* Event's payload equals to the newly selected page.
*/
@Output() change: EventEmitter<{
pagination: PaginationComponentOptions,
sort: SortOptions
}> = new EventEmitter<{
pagination: PaginationComponentOptions,
sort: SortOptions
}>();
/**
* An event fired when the page is changed.
@@ -61,26 +81,6 @@ export class ObjectGridComponent implements OnChanges, OnInit {
*/
@Output() sortFieldChange: EventEmitter<string> = new EventEmitter<string>();
data: any = {};
ngOnChanges(changes: SimpleChanges) {
if (changes.objects && !changes.objects.isFirstChange()) {
// this.pageInfo = this.objects.pageInfo;
}
}
ngOnInit(): void {
// this.pageInfo = this.objects.pageInfo;
}
/**
* @param route
* Route is a singleton service provided by Angular.
* @param router
* Router is a singleton service provided by Angular.
*/
constructor(private cdRef: ChangeDetectorRef) {
}
onPageChange(event) {
this.pageChange.emit(event);
}