@churchapps/apphelper 0.3.35 → 0.3.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersonHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/PersonHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAI5E,qBAAa,YAAY;
|
|
1
|
+
{"version":3,"file":"PersonHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/PersonHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAI5E,qBAAa,YAAY;IAExB,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,eAAe;IAO1C,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,GAAG,MAAM;IAUtC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;WAKtE,cAAc,CAAC,QAAQ,EAAE,oBAAoB,EAAE,QAAQ,EAAE,oBAAoB,GAAG,OAAO;WAUvF,eAAe,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM;WAItD,iBAAiB,CAAC,YAAY,EAAE,oBAAoB,EAAE,YAAY,EAAE,oBAAoB,GAAG,oBAAoB;WAa/G,uBAAuB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO;CAOvE"}
|
|
@@ -5,11 +5,13 @@ const CommonEnvironmentHelper_1 = require("./CommonEnvironmentHelper");
|
|
|
5
5
|
const Locale_1 = require("./Locale");
|
|
6
6
|
class PersonHelper {
|
|
7
7
|
static getPhotoUrl(person) {
|
|
8
|
-
var _a;
|
|
8
|
+
var _a, _b;
|
|
9
9
|
if (!(person === null || person === void 0 ? void 0 : person.photo))
|
|
10
10
|
return "/images/sample-profile.png";
|
|
11
11
|
else
|
|
12
|
-
return ((_a = person === null || person === void 0 ? void 0 : person.photo) === null || _a === void 0 ? void 0 : _a.startsWith("data:image/png;base64,"))
|
|
12
|
+
return (((_a = person === null || person === void 0 ? void 0 : person.photo) === null || _a === void 0 ? void 0 : _a.startsWith("data:image/png;base64,")) || ((_b = person.photo) === null || _b === void 0 ? void 0 : _b.indexOf("://")) > -1)
|
|
13
|
+
? person.photo
|
|
14
|
+
: CommonEnvironmentHelper_1.CommonEnvironmentHelper.ContentRoot + person.photo;
|
|
13
15
|
}
|
|
14
16
|
static getAge(birthdate) {
|
|
15
17
|
if (birthdate !== undefined && birthdate !== null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersonHelper.js","sourceRoot":"","sources":["../../src/helpers/PersonHelper.ts"],"names":[],"mappings":";;;AACA,uEAAoE;AACpE,qCAAkC;AAElC,MAAa,YAAY;
|
|
1
|
+
{"version":3,"file":"PersonHelper.js","sourceRoot":"","sources":["../../src/helpers/PersonHelper.ts"],"names":[],"mappings":";;;AACA,uEAAoE;AACpE,qCAAkC;AAElC,MAAa,YAAY;IAExB,MAAM,CAAC,WAAW,CAAC,MAAuB;;QACzC,IAAI,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAA;YAAE,OAAO,4BAA4B,CAAA;;YAClD,OAAO,CAAC,CAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,0CAAE,UAAU,CAAC,wBAAwB,CAAC,KAAI,CAAA,MAAA,MAAM,CAAC,KAAK,0CAAE,OAAO,CAAC,KAAK,CAAC,IAAG,CAAC,CAAC,CAAC;gBACrG,CAAC,CAAC,MAAM,CAAC,KAAK;gBACd,CAAC,CAAC,iDAAuB,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC;IACvD,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,SAAe;QAC5B,IAAI,SAAS,KAAK,SA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|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
7
|
+
static getPhotoUrl(person: PersonInterface) {
|
|
8
|
+
if (!person?.photo) return "/images/sample-profile.png"
|
|
9
|
+
else return (person?.photo?.startsWith("data:image/png;base64,") || person.photo?.indexOf("://") > -1)
|
|
10
|
+
? person.photo
|
|
11
|
+
: CommonEnvironmentHelper.ContentRoot + person.photo;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static getAge(birthdate: Date): string {
|
|
15
|
+
if (birthdate !== undefined && birthdate !== null) {
|
|
16
|
+
let ageDifMs = Date.now() - new Date(birthdate).getTime();
|
|
17
|
+
let ageDate = new Date(ageDifMs);
|
|
18
|
+
let years = Math.abs(ageDate.getUTCFullYear() - 1970);
|
|
19
|
+
return years + " " + Locale.label("person.years");
|
|
20
|
+
}
|
|
21
|
+
else return "";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static getDisplayName(firstName: string, lastName: string, nickName: string): string {
|
|
25
|
+
if (nickName !== undefined && nickName !== null && nickName.length > 0) return firstName + ' "' + nickName + '" ' + lastName;
|
|
26
|
+
else return firstName + " " + lastName;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public static compareAddress(address1: ContactInfoInterface, address2: ContactInfoInterface): boolean {
|
|
30
|
+
const displayAddress1: string = this.addressToString(address1).trim();
|
|
31
|
+
const displayAddress2: string = this.addressToString(address2).trim();
|
|
32
|
+
|
|
33
|
+
if (displayAddress1 !== displayAddress2) {
|
|
34
|
+
return true
|
|
35
|
+
}
|
|
36
|
+
return false
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public static addressToString(address: ContactInfoInterface): string {
|
|
40
|
+
return `${address.address1 || ""} ${address.address2 || ""} ${address.city || ""}${(address.city && address.state) ? "," : ""} ${address.state || ""} ${address.zip || ""}`
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public static changeOnlyAddress(contactInfo1: ContactInfoInterface, contactInfo2: ContactInfoInterface): ContactInfoInterface {
|
|
44
|
+
const updatedAddress: ContactInfoInterface = {
|
|
45
|
+
...contactInfo1,
|
|
46
|
+
address1: contactInfo2.address1,
|
|
47
|
+
address2: contactInfo2.address2,
|
|
48
|
+
city: contactInfo2.city,
|
|
49
|
+
state: contactInfo2.state,
|
|
50
|
+
zip: contactInfo2.zip
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return updatedAddress
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public static checkAddressAvailabilty(person: PersonInterface): boolean {
|
|
57
|
+
const addressString: string = this.addressToString(person.contactInfo).trim();
|
|
58
|
+
if (addressString !== "") {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
61
63
|
}
|