You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.8 KiB

import { Component, ViewChild } from '@angular/core';
import { DialogService } from '@app/core/services/dialog.service';
import { I18nService } from '@app/core/services/i18n.service';
import { ToastService } from '@app/core/services/toast.service';
import { CrudComponent } from '@app/routes/.templates/crud/crud.component';
import { RoleMenuComponent } from './menu/menu.component';
@Component({
selector: 'app-basic-role',
templateUrl: './role.component.html',
styleUrls: ['./role.component.scss']
})
export class RoleComponent {
constructor(
private _dialogService: DialogService,
private _i18nService: I18nService,
private _toastService: ToastService
) {
this._defination = [{
id: 'name',
header: 'routes.basic.role.name',
filter: { field: 'text' },
editor: { field: 'text', required: true }
}, {
id: 'remark',
header: 'routes.basic.role.remark',
editor: { field: 'text' }
}];
}
@ViewChild('$crud')
private _template: CrudComponent;
private _defination: any;
public get defination() {
return this._defination;
}
public error = (e: any) => {
switch (e.status) {
case 409:
this._toastService.show(this._i18nService.translate(`routes.basic.role.error.conflict.${e.error}`));
return false;
case 410:
this._toastService.show(this._i18nService.translate(`routes.basic.role.error.gone.${e.error?.propertyName?.toLowerCase()}`));
return true;
case 422:
// debugger;
this._toastService.show(this._i18nService.translate('shared.notification.fail'));
return true;
default:
return true;
}
}
public menu = async (id: number) => {
var res: any = await this._dialogService.open(RoleMenuComponent, { data: id });
if (res && !res.success) {
this._template.refresh();
}
}
};