init order

This commit is contained in:
_Bastler 2021-12-15 13:30:12 +01:00
parent 572a1c8a45
commit 285ab37e10
2 changed files with 21 additions and 13 deletions

View File

@ -1,4 +1,4 @@
import {Component, OnInit, Input} from '@angular/core';
import {Component, OnInit, Input, SimpleChanges, OnChanges} from '@angular/core';
import {Sort} from '@angular/material/sort';
import {I18nService} from './../../services/i18n.service';
@ -7,7 +7,7 @@ import {I18nService} from './../../services/i18n.service';
templateUrl: './permissions.component.html',
styleUrls: ['./permissions.component.scss']
})
export class PermissionsComponent implements OnInit {
export class PermissionsComponent implements OnInit, OnChanges {
datetimeformat: String;
@Input() permissions;
@ -20,6 +20,10 @@ export class PermissionsComponent implements OnInit {
this.datetimeformat = this.i18n.get('format.datetime', []);
}
ngOnChanges(changes: SimpleChanges): void {
this.sortData({ "active": "name", "direction": "asc" });
}
sortData(sort: Sort) {
const data = this.permissions.slice();
if(!sort.active || sort.direction === '') {

View File

@ -1,4 +1,4 @@
import {Component, OnInit, Input} from '@angular/core';
import { Component, OnInit, Input, OnChanges, SimpleChanges } from '@angular/core';
import { Sort } from '@angular/material/sort';
import { I18nService } from './../../services/i18n.service';
@ -7,7 +7,7 @@ import {I18nService} from './../../services/i18n.service';
templateUrl: './quotas.component.html',
styleUrls: [ './quotas.component.scss' ]
})
export class QuotasComponent implements OnInit {
export class QuotasComponent implements OnInit, OnChanges {
@Input() quotas;
@ -19,6 +19,10 @@ export class QuotasComponent implements OnInit {
this.sortData({ "active": "name", "direction": "asc" });
}
ngOnChanges(changes: SimpleChanges): void {
this.sortData({ "active": "name", "direction": "asc" });
}
sortData(sort: Sort) {
const data = this.quotas.slice();
if (!sort.active || sort.direction === '') {