import { Component, OnInit } from '@angular/core';
import { IKiewitDropdown } from '../../../lib/kiewit-dropdown';
@Component({
selector: 'app-user-roles',
templateUrl: './user-roles.component.html',
styleUrls: ['./user-roles.component.scss']
})
export class UserRolesComponent implements OnInit {
//This users list must be loaded from database and must be List<User>...
arrayOfUsers = ['Gonzalo Ferrando', 'Dan Nash', 'Chaitanya Thalloory', 'Greg Thompson'];
public selectedUsers: User[] = []
public appsData: any[] = [
"Application 1",
"Application 2",
"Application 3",
"Application 4",
"Application 5"
]
public rolesData: any[] = [
"Role 1",
"Role 2",
"Role 3",
"Role 4",
"Role 5"
]
public appsDataConfig:IKiewitDropdown={
data: this.appsData,
//textField: "ApplicationName",
//valueField: "ApplicationId"
}
public rolesDataConfig: IKiewitDropdown = {
data: this.rolesData,
//textField: "ApplicationName",
//valueField: "ApplicationId"
}
selectUser(newVal) {
this.selectedUsers.push(new User(Math.random() * (1000 - 1) + 1, newVal));
}
constructor() { }
ngOnInit() {
}
removeUser(user) {
let index: number = this.selectedUsers.indexOf(user);
if (index !== -1) {
this.selectedUsers.splice(index, 1);
}
}
}
export class User {
constructor(
public id: number,
public name: string) { }
}