fix sort
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { Sort } from '@angular/material/sort';
|
||||
import { I18nService } from './../../services/i18n.service';
|
||||
import {Component, OnInit, Input} from '@angular/core';
|
||||
import {Sort} from '@angular/material/sort';
|
||||
import {I18nService} from './../../services/i18n.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-quotas',
|
||||
@@ -13,22 +13,22 @@ export class QuotasComponent implements OnInit {
|
||||
@Input() quotas;
|
||||
quotaColumns = ["name", "quota", "quotaUnit"];
|
||||
|
||||
constructor(private i18n: I18nService) { }
|
||||
constructor(private i18n: I18nService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
sortData(sort: Sort) {
|
||||
const data = this.quotas.slice();
|
||||
if (!sort.active || sort.direction === '') {
|
||||
if(!sort.active || sort.direction === '') {
|
||||
this.quotas = data;
|
||||
return;
|
||||
}
|
||||
|
||||
this.quotas = data.sort((a, b) => {
|
||||
const isAsc = sort.direction === 'asc';
|
||||
switch (sort.active) {
|
||||
case 'name': return this.compare(this.i18n.get('quotas.' + a.name, []), this.i18n.get('quotas.' + b.name,[]), isAsc);
|
||||
switch(sort.active) {
|
||||
case 'name': return this.compare(this.i18n.get('apps.' + a.name + '.title', []), this.i18n.get('apps.' + b.name + '.title', []), isAsc);
|
||||
case 'value': return this.compare(a.value, b.value, isAsc);
|
||||
default: return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user