angular/projects/researchdatabox/portal-ng-common/src/lib/header-sort.component.ts
selector | header-sort |
templateUrl | ./header-sort.component.html |
Properties |
|
Methods |
|
Inputs |
Outputs |
constructor(loggerService: LoggerService)
|
||||||
Parameters :
|
sort | |
Type : string
|
|
Default value : ''
|
|
step | |
Type : string
|
|
Default value : ''
|
|
title | |
Type : string
|
|
Default value : ''
|
|
variable | |
Type : string
|
|
Default value : ''
|
|
headerSortChanged | |
Type : EventEmitter
|
|
headerSortClicked |
headerSortClicked()
|
Returns :
boolean
|
Protected Async initComponent |
initComponent()
|
Inherited from
BaseComponent
|
Defined in
BaseComponent:24
|
Returns :
Promise<void>
|
getInitSubject |
getInitSubject()
|
Inherited from
BaseComponent
|
Defined in
BaseComponent:71
|
For those interested in the init from RXJS-land. Note that it returns a BehaviorSubject instance, and will have an initial value of false, so process the return value as needed.
Returns :
Subject<any>
|
isInitializing |
isInitializing()
|
Inherited from
BaseComponent
|
Defined in
BaseComponent:95
|
Main flag to indicate the init status
Returns :
boolean
|
ngOnInit |
ngOnInit()
|
Inherited from
BaseComponent
|
Defined in
BaseComponent:50
|
Returns :
void
|
Async waitForDeps |
waitForDeps()
|
Inherited from
BaseComponent
|
Defined in
BaseComponent:78
|
Wait for dependencies to initialise
Returns :
Promise<any>
|
Async waitForInit |
waitForInit()
|
Inherited from
BaseComponent
|
Defined in
BaseComponent:89
|
For those interested in the init from the Promise-land
Returns :
Promise<any>
|
Protected brandingAndPortalUrl |
Type : string
|
Default value : ''
|
Inherited from
BaseComponent
|
Defined in
BaseComponent:42
|
Private filterFn |
Default value : function(initStat: boolean) { return initStat; }
|
Inherited from
BaseComponent
|
Defined in
BaseComponent:40
|
Protected initDependencies |
Type : Initable[]
|
Default value : []
|
Inherited from
BaseComponent
|
Defined in
BaseComponent:39
|
Protected initSubject |
Type : BehaviorSubject<any>
|
Default value : new BehaviorSubject(false)
|
Inherited from
BaseComponent
|
Defined in
BaseComponent:38
|
Protected isReady |
Type : boolean
|
Default value : false
|
Inherited from
BaseComponent
|
Defined in
BaseComponent:37
|
import {Component, Input, Output, EventEmitter, Inject} from '@angular/core';
import {BaseComponent} from "./base.component";
import {LoggerService} from "./logger.service";
@Component({
selector: 'header-sort',
templateUrl: './header-sort.component.html',
})
export class HeaderSortComponent extends BaseComponent {
@Input() sort: string = '';
@Input() title: string = '';
@Input() step: string = '';
@Input() variable: string = '';
@Output() headerSortChanged = new EventEmitter<{title: string, variable: string, sort:string, step: string}>();
constructor(
@Inject(LoggerService) private loggerService: LoggerService,
) {
super();
// no deps
this.initDependencies = [];
}
protected override async initComponent(): Promise<void> {
}
headerSortClicked() {
if (this.sort != null) {
if (this.sort == "asc") {
this.sort = "desc";
} else {
this.sort = "asc";
}
} else {
this.sort = "asc";
}
this.headerSortChanged.emit({title: this.title, variable: this.variable, sort: this.sort, step: this.step});
return false;
}
}
<a href="#" role="button" [attr.aria-sort]="sort === 'asc'? 'ascending' : sort === 'desc' ? 'descending' : null" (click)="headerSortClicked()" class="record-table-heading-sort">
{{title}}
<i
*ngIf="sort == 'asc'" class="fa fa-sort-asc"></i><i
*ngIf="sort == 'desc'" class="fa fa-sort-desc"></i><span
*ngIf="!['asc', 'desc'].includes(sort)"> </span>
</a>