Explorar el Código

people model constructor changed

tags/2.037
Patrick Sun hace 4 años
padre
commit
fb2f6282d4
Se han modificado 6 ficheros con 38 adiciones y 40 borrados
  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 Ver fichero

@@ -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;
}
}

+ 3
- 3
src/app/models/loan.model.ts Ver fichero

@@ -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)
);
});
}

+ 20
- 11
src/app/models/people.model.ts Ver fichero

@@ -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 {

+ 2
- 2
src/app/people-card/people-card.component.ts Ver fichero

@@ -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);
}
);


+ 1
- 10
src/app/people-select/people-select.component.ts Ver fichero

@@ -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;

+ 2
- 13
src/app/service/auth.service.ts Ver fichero

@@ -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);

Cargando…
Cancelar
Guardar