| @@ -32,6 +32,15 @@ export class BrokerModel{ | |||
| } | |||
| public toPeopleModel(): PeopleModel{ | |||
| return new PeopleModel( this.Id, this.First, this.Last, this.Middle, this.Title, this.Display, this.Nick, this.Enabled ); | |||
| const ret = new PeopleModel( {} ); | |||
| ret.Id = this.Id; | |||
| ret.First = this.First; | |||
| ret.Last = this.Last; | |||
| ret.Middle = this.Middle; | |||
| ret.Title = this.Title; | |||
| ret.Display = this.Display; | |||
| ret.Nick = this.Nick; | |||
| ret.Enabled = this.Enabled; | |||
| return ret; | |||
| } | |||
| } | |||
| @@ -176,7 +176,7 @@ export class LoanModel { | |||
| this.Client = []; | |||
| v.forEach((c) => { | |||
| this.Client.push( | |||
| new PeopleModel(c.Id, c.First, c.Last, c.Middle, c.Title, c.Display, c.Nick, c.Enabled) | |||
| new PeopleModel(c) | |||
| ); | |||
| }); | |||
| } | |||
| @@ -185,7 +185,7 @@ export class LoanModel { | |||
| this.OtherRewarder = []; | |||
| v.forEach((c) => { | |||
| this.OtherRewarder.push( | |||
| new PeopleModel(c.Id, c.First, c.Last, c.Middle, c.Title, c.Display, c.Nick, c.Enabled) | |||
| new PeopleModel(c) | |||
| ); | |||
| }); | |||
| } | |||
| @@ -204,7 +204,7 @@ export class LoanModel { | |||
| this.RewardPeople = []; | |||
| v.forEach((c) => { | |||
| this.RewardPeople.push( | |||
| new PeopleModel(c.Id, c.First, c.Last, c.Middle, c.Title, c.Display, c.Nick, c.Enabled) | |||
| new PeopleModel(c) | |||
| ); | |||
| }); | |||
| } | |||
| @@ -1,15 +1,24 @@ | |||
| export class PeopleModel{ | |||
| constructor( | |||
| public Id: string, | |||
| public First: string, | |||
| public Last: string, | |||
| public Middle: string, | |||
| public Title: string, | |||
| public Display: string, | |||
| public Nick: string, | |||
| public Enabled: boolean, | |||
| ){} | |||
| public Id: string; | |||
| public First: string; | |||
| public Last: string; | |||
| public Middle: string; | |||
| public Title: string; | |||
| public Display: string; | |||
| public Nick: string; | |||
| public Enabled: boolean; | |||
| constructor(payload: Partial<PeopleModel>){ | |||
| this.Id = payload.Id || ''; | |||
| this.First = payload.First || ''; | |||
| this.Last = payload.Last || ''; | |||
| this.Middle = payload.Middle || ''; | |||
| this.Title = payload.Title || ''; | |||
| this.Display = payload.Display || ''; | |||
| this.Nick = payload.Nick || ''; | |||
| this.Enabled = payload.Enabled || false; | |||
| } | |||
| get FullName(): string { | |||
| if (this.Middle === '') { | |||
| @@ -20,7 +29,7 @@ export class PeopleModel{ | |||
| } | |||
| public static EmptyNew(): PeopleModel { | |||
| return new PeopleModel('', '', '', '', '', '', '', false ); | |||
| return new PeopleModel({}); | |||
| } | |||
| public Copy(ppl: PeopleModel): void { | |||
| @@ -16,7 +16,7 @@ export class PeopleCardComponent implements OnInit { | |||
| @Input() PeopleId: string; | |||
| @ViewChild('enabled', {static: true}) enabled: Button; | |||
| public contact: PeopleModel = new PeopleModel('', '', '', '', '', '', '' , false); | |||
| public contact: PeopleModel = new PeopleModel({}); | |||
| public UserExtra: UserExtraModel = UserExtraModel.EmptyNew(); | |||
| public badgeAlign: BadgeAlign = { vertical: 'bottom', horizontal: 'end' }; | |||
| @@ -26,7 +26,7 @@ export class PeopleCardComponent implements OnInit { | |||
| ngOnInit(): void { | |||
| this.ps.getPeopleById(this.PeopleId).subscribe( | |||
| resp => { | |||
| this.contact = new PeopleModel(resp.Id, resp.First, resp.Last, resp.Middle, resp.Title, resp.Display, resp.Nick, resp.Enabled); | |||
| this.contact = new PeopleModel(resp); | |||
| } | |||
| ); | |||
| @@ -129,16 +129,7 @@ export class PeopleSelectComponent implements OnInit, ControlValueAccessor { | |||
| console.log('searching ... ', nameOrId, this.translateId ? 'by id' : 'by name'); | |||
| this.searchUser(nameOrId, this.translateId).subscribe( | |||
| ppl => { | |||
| const person = new PeopleModel( | |||
| ppl.Id, | |||
| ppl.First, | |||
| ppl.Last, | |||
| ppl.Middle, | |||
| ppl.Title, | |||
| ppl.Display, | |||
| ppl.Nick, | |||
| ppl.Enabled | |||
| ); | |||
| const person = new PeopleModel(ppl); | |||
| console.log('got search result ', person); | |||
| this.searchResult.push(person); // make sure it's available for selection, thus proper display | |||
| this.value = this.translateId ? person.Id : person.FullName; | |||
| @@ -34,9 +34,7 @@ export class AuthService { | |||
| sfm.session, | |||
| sfm.sessionExpire, | |||
| sfm.role, | |||
| new PeopleModel( | |||
| sfm.User.Id, sfm.User.First, sfm.User.Last, sfm.User.Middle, | |||
| sfm.User.Title, sfm.User.Display, sfm.User.Nick, sfm.User.Enabled) | |||
| new PeopleModel(sfm.User) | |||
| ); | |||
| if ( sfm.UserExtra !== undefined ) { | |||
| @@ -71,16 +69,7 @@ export class AuthService { | |||
| this.loggedIn.sessionExpire = responseData.sessionExpire; | |||
| this.loggedIn.role = responseData.role; | |||
| if ( responseData.User !== undefined) { | |||
| this.loggedIn.User = new PeopleModel( | |||
| responseData.User.Id, | |||
| responseData.User.First, | |||
| responseData.User.Last, | |||
| responseData.User.Middle, | |||
| responseData.User.Title, | |||
| responseData.User.Display, | |||
| responseData.User.Nick, | |||
| responseData.User.Enabled, | |||
| ); | |||
| this.loggedIn.User = new PeopleModel(responseData.User); | |||
| if (responseData.UserExtra !== undefined ) { | |||
| this.loggedIn.UserExtra = new UserExtraModel(responseData.UserExtra); | |||