Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/scripts/dist/interfaces/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export interface Options {
};
TidyContact?: false | {
cid?: string;
page_types?: ("DONATION" | "ECARD" | "SURVEY" | "EMAILTOTARGET" | "ADVOCACY" | "SUBSCRIBEFORM" | "EVENT" | "SUPPORTERHUB" | "UNSUBSCRIBE" | "TWEETPAGE" | "UNKNOWN")[];
record_field?: string;
date_field?: string;
status_field?: string;
Expand Down
1 change: 1 addition & 0 deletions packages/scripts/dist/tidycontact.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export declare class TidyContact {
private countries_dropdown;
private country_ip;
constructor();
private shouldRun;
private loadOptions;
private createFields;
private createPhoneFields;
Expand Down
12 changes: 12 additions & 0 deletions packages/scripts/dist/tidycontact.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ export class TidyContact {
this.options = ENGrid.getOption("TidyContact");
if (this.options === false || !((_a = this.options) === null || _a === void 0 ? void 0 : _a.cid))
return;
if (!this.shouldRun()) {
this.logger.log("TidyContact is disabled on this page type");
return;
}
this.loadOptions();
if (!this.hasAddressFields() && !this.phoneEnabled()) {
this.logger.log("No address fields found");
Expand Down Expand Up @@ -298,6 +302,14 @@ export class TidyContact {
}
}
}
shouldRun() {
if (this.options &&
this.options.page_types &&
this.options.page_types.length > 0) {
return this.options.page_types.includes(ENGrid.getPageType());
}
return true;
}
loadOptions() {
var _a, _b, _c, _d;
if (this.options) {
Expand Down
1 change: 1 addition & 0 deletions packages/scripts/src/interfaces/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface Options {
| false
| {
cid?: string; // Client ID
page_types?: ("DONATION" | "ECARD" | "SURVEY" | "EMAILTOTARGET" | "ADVOCACY" | "SUBSCRIBEFORM" | "EVENT" | "SUPPORTERHUB" | "UNSUBSCRIBE" | "TWEETPAGE" | "UNKNOWN")[]; // Page Types to enable TidyContact on, if left blank will run on all page types
record_field?: string; // TidyContact Record
date_field?: string; // TidyContact Date
status_field?: string; // TidyContact Status
Expand Down
14 changes: 14 additions & 0 deletions packages/scripts/src/tidycontact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ export class TidyContact {
constructor() {
this.options = ENGrid.getOption("TidyContact") as Options["TidyContact"];
if (this.options === false || !this.options?.cid) return;
if (!this.shouldRun()) {
this.logger.log("TidyContact is disabled on this page type");
return;
}
this.loadOptions();
if (!this.hasAddressFields() && !this.phoneEnabled()) {
this.logger.log("No address fields found");
Expand Down Expand Up @@ -309,6 +313,16 @@ export class TidyContact {
}
}
}
private shouldRun(): boolean {
if (
this.options &&
this.options.page_types &&
this.options.page_types.length > 0
) {
return this.options.page_types.includes(ENGrid.getPageType());
}
return true;
}
private loadOptions() {
if (this.options) {
if (!this.options.address_fields) {
Expand Down
Loading