Просмотр исходного кода

people model constructor changed

tags/2.037
Patrick Sun 4 лет назад
Родитель
Сommit
fb2f6282d4
6 измененных файлов: 38 добавлений и 40 удалений
  1. +10
    -1
      src/app/models/broker.model.ts
  2. +3
    -3
      src/app/models/loan.model.ts
  3. +20
    -11
      src/app/models/people.model.ts
  4. +2
    -2
      src/app/people-card/people-card.component.ts
  5. +1
    -10
      src/app/people-select/people-select.component.ts
  6. +2
    -13
      src/app/service/auth.service.ts

+ 10
- 1
src/app/models/broker.model.ts Просмотреть файл

} }


public toPeopleModel(): PeopleModel{ 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;
} }
} }

+ 3
- 3
src/app/models/loan.model.ts Просмотреть файл

this.Client = []; this.Client = [];
v.forEach((c) => { v.forEach((c) => {
this.Client.push( this.Client.push(
new PeopleModel(c.Id, c.First, c.Last, c.Middle, c.Title, c.Display, c.Nick, c.Enabled)
new PeopleModel(c)
); );
}); });
} }
this.OtherRewarder = []; this.OtherRewarder = [];
v.forEach((c) => { v.forEach((c) => {
this.OtherRewarder.push( this.OtherRewarder.push(
new PeopleModel(c.Id, c.First, c.Last, c.Middle, c.Title, c.Display, c.Nick, c.Enabled)
new PeopleModel(c)
); );
}); });
} }
this.RewardPeople = []; this.RewardPeople = [];
v.forEach((c) => { v.forEach((c) => {
this.RewardPeople.push( this.RewardPeople.push(
new PeopleModel(c.Id, c.First, c.Last, c.Middle, c.Title, c.Display, c.Nick, c.Enabled)
new PeopleModel(c)
); );
}); });
} }

+ 20
- 11
src/app/models/people.model.ts Просмотреть файл



export class PeopleModel{ 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 { get FullName(): string {
if (this.Middle === '') { if (this.Middle === '') {
} }


public static EmptyNew(): PeopleModel { public static EmptyNew(): PeopleModel {
return new PeopleModel('', '', '', '', '', '', '', false );
return new PeopleModel({});
} }


public Copy(ppl: PeopleModel): void { public Copy(ppl: PeopleModel): void {

+ 2
- 2
src/app/people-card/people-card.component.ts Просмотреть файл



@Input() PeopleId: string; @Input() PeopleId: string;
@ViewChild('enabled', {static: true}) enabled: Button; @ViewChild('enabled', {static: true}) enabled: Button;
public contact: PeopleModel = new PeopleModel('', '', '', '', '', '', '' , false);
public contact: PeopleModel = new PeopleModel({});
public UserExtra: UserExtraModel = UserExtraModel.EmptyNew(); public UserExtra: UserExtraModel = UserExtraModel.EmptyNew();


public badgeAlign: BadgeAlign = { vertical: 'bottom', horizontal: 'end' }; public badgeAlign: BadgeAlign = { vertical: 'bottom', horizontal: 'end' };
ngOnInit(): void { ngOnInit(): void {
this.ps.getPeopleById(this.PeopleId).subscribe( this.ps.getPeopleById(this.PeopleId).subscribe(
resp => { 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);
} }
); );



+ 1
- 10
src/app/people-select/people-select.component.ts Просмотреть файл

console.log('searching ... ', nameOrId, this.translateId ? 'by id' : 'by name'); console.log('searching ... ', nameOrId, this.translateId ? 'by id' : 'by name');
this.searchUser(nameOrId, this.translateId).subscribe( this.searchUser(nameOrId, this.translateId).subscribe(
ppl => { 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); console.log('got search result ', person);
this.searchResult.push(person); // make sure it's available for selection, thus proper display this.searchResult.push(person); // make sure it's available for selection, thus proper display
this.value = this.translateId ? person.Id : person.FullName; this.value = this.translateId ? person.Id : person.FullName;

+ 2
- 13
src/app/service/auth.service.ts Просмотреть файл

sfm.session, sfm.session,
sfm.sessionExpire, sfm.sessionExpire,
sfm.role, 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 ) { if ( sfm.UserExtra !== undefined ) {
this.loggedIn.sessionExpire = responseData.sessionExpire; this.loggedIn.sessionExpire = responseData.sessionExpire;
this.loggedIn.role = responseData.role; this.loggedIn.role = responseData.role;
if ( responseData.User !== undefined) { 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 ) { if (responseData.UserExtra !== undefined ) {
this.loggedIn.UserExtra = new UserExtraModel(responseData.UserExtra); this.loggedIn.UserExtra = new UserExtraModel(responseData.UserExtra);

Загрузка…
Отмена
Сохранить