File
Description
Address class, each project can extend this address class
Index
Properties
|
|
Methods
|
|
Accessors
|
|
Public
addressLine1
|
Type : string
|
|
Public
addressLine2
|
Type : string
|
|
Used to store optional extra address fields. Can be used with addressLine1 OR street.
|
Public
addressLine3
|
Type : string
|
|
Used to store optional extra address fields. Can be used with addressLine1 OR street.
|
Static
PostalCodeBCRegEx
|
Type : string
|
Default value : '^[Vv]\\d[ABCEGHJ-NPRSTV-Zabceghj-nprstv-z][ ]?\\d[ABCEGHJ-NPRSTV-Zabceghj-nprstv-z]\\d$'
|
|
Public
streetName
|
Type : string
|
|
Public
streetNumber
|
Type : string
|
|
Public
unitNumber
|
Type : string
|
|
Methods
copy
|
copy(object: Address)
|
|
Parameters :
Name |
Type |
Optional |
object |
Address
|
No
|
|
isComplete
|
isComplete()
|
|
Address must have all fields filled out to be considered
complete
|
toString
|
toString()
|
|
Overwrite the native JavaScript toString method to determine how the
object should be printed, instead of [object Object]. This provides a
standard way to print out an address. If you need something specific you
should access the properties directly. We omit Province/Country because of
PharmaCare's BC focus.
|
Accessors
street
|
getstreet()
|
|
setstreet(val: string)
|
|
Parameters :
Name |
Type |
Optional |
val |
string
|
No
|
|
export class Address {
static PostalCodeBCRegEx = '^[Vv]\\d[ABCEGHJ-NPRSTV-Zabceghj-nprstv-z][ ]?\\d[ABCEGHJ-NPRSTV-Zabceghj-nprstv-z]\\d$';
public addressLine1: string;
/** Used to store optional extra address fields. Can be used with addressLine1 OR street. */
public addressLine2: string;
/** Used to store optional extra address fields. Can be used with addressLine1 OR street. */
public addressLine3: string;
public unitNumber: string;
public streetNumber: string;
public streetName: string;
public postal: string;
public country: string;
public province: string;
public city: string;
public hasValue: boolean; // TODO: Why do we need this? - Remove - breaking change
public isValid: boolean; // TODO: Why do we need this? - Remove - breaking change
// For backward compatibilty with applications that use street.
get street() {
return this.addressLine1;
}
set street( val: string ) {
this.addressLine1 = val;
}
/** Overwrite the native JavaScript toString method to determine how the
* object should be printed, instead of [object Object]. This provides a
* standard way to print out an address. If you need something specific you
* should access the properties directly. We omit Province/Country because of
* PharmaCare's BC focus. */
toString() {
return `${this.addressLine1}, ${this.city}`;
}
/**
* Address must have all fields filled out to be considered
* complete
*/
isComplete(): boolean {
// All fields have data - not empty
return !!(this.addressLine1 && this.city && this.country &&
this.province && this.postal);
}
get isBCOnly(): boolean {
let isValid = false;
if (this.postal &&
this.postal.length > 0) {
const regEx = new RegExp(Address.PostalCodeBCRegEx);
isValid = regEx.test(this.postal);
}
return isValid;
}
/* Copy function */
copy(object: Address) {
this.addressLine1 = object.addressLine1;
this.addressLine2 = object.addressLine2;
this.addressLine3 = object.addressLine3;
this.city = object.city;
this.country = object.country;
this.postal = object.postal;
this.province = object.province;
}
}