fix sort
This commit is contained in:
parent
54e8986be9
commit
4cd6a0028b
@ -1,6 +1,6 @@
|
|||||||
import { Component, OnInit, Input } from '@angular/core';
|
import {Component, OnInit, Input} from '@angular/core';
|
||||||
import { Sort } from '@angular/material/sort';
|
import {Sort} from '@angular/material/sort';
|
||||||
import { I18nService } from './../../services/i18n.service';
|
import {I18nService} from './../../services/i18n.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-permissions',
|
selector: 'app-permissions',
|
||||||
@ -13,23 +13,23 @@ export class PermissionsComponent implements OnInit {
|
|||||||
@Input() permissions;
|
@Input() permissions;
|
||||||
permissionColumns = ["name", "starts", "expires"];
|
permissionColumns = ["name", "starts", "expires"];
|
||||||
|
|
||||||
constructor(private i18n: I18nService) { }
|
constructor(private i18n: I18nService) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.datetimeformat = this.i18n.get('date-time-format',[]);
|
this.datetimeformat = this.i18n.get('date-time-format', []);
|
||||||
}
|
}
|
||||||
|
|
||||||
sortData(sort: Sort) {
|
sortData(sort: Sort) {
|
||||||
const data = this.permissions.slice();
|
const data = this.permissions.slice();
|
||||||
if (!sort.active || sort.direction === '') {
|
if(!sort.active || sort.direction === '') {
|
||||||
this.permissions = data;
|
this.permissions = data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.permissions = data.sort((a, b) => {
|
this.permissions = data.sort((a, b) => {
|
||||||
const isAsc = sort.direction === 'asc';
|
const isAsc = sort.direction === 'asc';
|
||||||
switch (sort.active) {
|
switch(sort.active) {
|
||||||
case 'name': return this.compare(this.i18n.get('permissions.' + a.name, []), this.i18n.get('permissions.' + b.name, []), isAsc);
|
case 'name': return this.compare(this.i18n.get('apps.' + a.name + '.title', []), this.i18n.get('apps.' + b.name + '.title', []), isAsc);
|
||||||
case 'starts': return this.compare(a.starts, b.starts, isAsc);
|
case 'starts': return this.compare(a.starts, b.starts, isAsc);
|
||||||
case 'expires': return this.compare(a.expires, b.expires, isAsc);
|
case 'expires': return this.compare(a.expires, b.expires, isAsc);
|
||||||
default: return 0;
|
default: return 0;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Component, OnInit, Input } from '@angular/core';
|
import {Component, OnInit, Input} from '@angular/core';
|
||||||
import { Sort } from '@angular/material/sort';
|
import {Sort} from '@angular/material/sort';
|
||||||
import { I18nService } from './../../services/i18n.service';
|
import {I18nService} from './../../services/i18n.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-quotas',
|
selector: 'app-quotas',
|
||||||
@ -13,22 +13,22 @@ export class QuotasComponent implements OnInit {
|
|||||||
@Input() quotas;
|
@Input() quotas;
|
||||||
quotaColumns = ["name", "quota", "quotaUnit"];
|
quotaColumns = ["name", "quota", "quotaUnit"];
|
||||||
|
|
||||||
constructor(private i18n: I18nService) { }
|
constructor(private i18n: I18nService) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
sortData(sort: Sort) {
|
sortData(sort: Sort) {
|
||||||
const data = this.quotas.slice();
|
const data = this.quotas.slice();
|
||||||
if (!sort.active || sort.direction === '') {
|
if(!sort.active || sort.direction === '') {
|
||||||
this.quotas = data;
|
this.quotas = data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.quotas = data.sort((a, b) => {
|
this.quotas = data.sort((a, b) => {
|
||||||
const isAsc = sort.direction === 'asc';
|
const isAsc = sort.direction === 'asc';
|
||||||
switch (sort.active) {
|
switch(sort.active) {
|
||||||
case 'name': return this.compare(this.i18n.get('quotas.' + a.name, []), this.i18n.get('quotas.' + b.name,[]), isAsc);
|
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);
|
case 'value': return this.compare(a.value, b.value, isAsc);
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user