UNPKG

mp-common

Version:

This is XPO MarketPlace common libary

46 lines (36 loc) 1.32 kB
import { Component, OnInit, Input } from '@angular/core'; import { XpoDialogRef } from '@xpo/common'; import { UserListComponent } from '../user-list/user-list.component'; import { User, UserService } from '../../shared/index'; @Component({ selector: 'user-dialog-component', templateUrl: './user-dialog.component.html', styleUrls: [ './user-dialog.component.scss' ] }) export class UserDialogComponent implements OnInit { selectedUser: User; constructor(private dialogRef: XpoDialogRef<UserDialogComponent>, private userService: UserService) { this.userService.getEditUserInfo().then(user => { this.selectedUser = user }); } ngOnInit() { } onDeleteUser() { console.log("On Delete"); this.dialogRef.close('deleted'); } isRolesEmpty() { if (this.selectedUser.roles.length == 0 || this.selectedUser.roles[ 0 ].roleName.length == 0) { return true; } } onSave() { console.log("On Save"); if (this.selectedUser.roles[ this.selectedUser.roles.length - 1 ].roleName.length == 0) { this.selectedUser.roles.splice(this.selectedUser.roles.length - 1, 1); } this.userService.saveUser(this.selectedUser); this.dialogRef.close('saved'); } onClose() { this.dialogRef.close('canceled'); } }