build: Use prettier for typescript
Stop ignoring .ts files in prettier and fix existing issues.
This commit is contained in:
@@ -13,7 +13,6 @@ import { OrganizationService } from '../../organization.service';
|
||||
*/
|
||||
@Injectable()
|
||||
export class SmsCampaignTemplateResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {OrganizationService} organizationService Organization service.
|
||||
*/
|
||||
@@ -26,5 +25,4 @@ export class SmsCampaignTemplateResolver implements Resolve<Object> {
|
||||
resolve(): Observable<any> {
|
||||
return this.organizationService.getSmsCampaignTemplate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import { OrganizationService } from 'app/organization/organization.service';
|
||||
*/
|
||||
@Injectable()
|
||||
export class SmsCampaignResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {OrganizationService} organizationService Organization service.
|
||||
*/
|
||||
@@ -24,8 +23,7 @@ export class SmsCampaignResolver implements Resolve<Object> {
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||
const smsCampaignId = route.paramMap.get('id');
|
||||
const smsCampaignId = route.paramMap.get('id');
|
||||
return this.organizationService.getSmsCampaign(smsCampaignId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import { OrganizationService } from '../../organization.service';
|
||||
*/
|
||||
@Injectable()
|
||||
export class SmsCampaignsResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {OrganizationService} organizationService Organization service.
|
||||
*/
|
||||
@@ -26,5 +25,4 @@ export class SmsCampaignsResolver implements Resolve<Object> {
|
||||
resolve(): Observable<any> {
|
||||
return this.organizationService.getSmsCampaigns();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -8,9 +8,8 @@ describe('CreateCampaignComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ CreateCampaignComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [CreateCampaignComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -20,7 +20,6 @@ import { Dates } from 'app/core/utils/dates';
|
||||
styleUrls: ['./create-campaign.component.scss']
|
||||
})
|
||||
export class CreateCampaignComponent {
|
||||
|
||||
/** SMS Campaign Template */
|
||||
smsCampaignTemplate: any;
|
||||
/** Run report headers */
|
||||
@@ -39,11 +38,13 @@ export class CreateCampaignComponent {
|
||||
* @param {SettingsService} settingsService Settings Service
|
||||
* @param {Dates} dateUtils Date Utils
|
||||
*/
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private organizationService: OrganizationService,
|
||||
private settingsService: SettingsService,
|
||||
private dateUtils: Dates) {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private organizationService: OrganizationService,
|
||||
private settingsService: SettingsService,
|
||||
private dateUtils: Dates
|
||||
) {
|
||||
this.route.data.subscribe((data: { smsCampaignTemplate: any }) => {
|
||||
this.smsCampaignTemplate = data.smsCampaignTemplate;
|
||||
});
|
||||
@@ -95,8 +96,13 @@ export class CreateCampaignComponent {
|
||||
smsCampaign.recurrenceStartDate = this.dateUtils.formatDate(prevRecurrenceDate, dateTimeFormat);
|
||||
}
|
||||
this.organizationService.createSmsCampaign(smsCampaign).subscribe((response: any) => {
|
||||
this.router.navigate(['../', response.resourceId], { relativeTo: this.route });
|
||||
this.router.navigate(
|
||||
[
|
||||
'../',
|
||||
response.resourceId
|
||||
],
|
||||
{ relativeTo: this.route }
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('EditCampaignComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ EditCampaignComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [EditCampaignComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -19,7 +19,6 @@ import { CampaignMessageStepComponent } from '../sms-campaign-stepper/campaign-m
|
||||
styleUrls: ['./edit-campaign.component.scss']
|
||||
})
|
||||
export class EditCampaignComponent {
|
||||
|
||||
/** smsCampaign */
|
||||
smsCampaign: any;
|
||||
/** SMS Campaign Template */
|
||||
@@ -38,12 +37,14 @@ export class EditCampaignComponent {
|
||||
* @param {OrganizationService} organizationService Organiztion Service
|
||||
* @param {SettingsService} settingsService Settings Service
|
||||
*/
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dateUtils: Dates,
|
||||
private organizationService: OrganizationService,
|
||||
private settingsService: SettingsService) {
|
||||
this.route.data.subscribe((data: { smsCampaign: any, smsCampaignTemplate: any }) => {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dateUtils: Dates,
|
||||
private organizationService: OrganizationService,
|
||||
private settingsService: SettingsService
|
||||
) {
|
||||
this.route.data.subscribe((data: { smsCampaign: any; smsCampaignTemplate: any }) => {
|
||||
this.smsCampaignTemplate = data.smsCampaignTemplate;
|
||||
this.smsCampaign = data.smsCampaign;
|
||||
this.smsCampaign.editFlag = true;
|
||||
@@ -87,11 +88,13 @@ export class EditCampaignComponent {
|
||||
locale
|
||||
};
|
||||
if (this.smsCampaign.triggerType.id === 2) {
|
||||
smsCampaign.recurrenceStartDate = this.dateUtils.formatDate(new Date(this.smsCampaign.recurrenceStartDate), dateTimeFormat);
|
||||
smsCampaign.recurrenceStartDate = this.dateUtils.formatDate(
|
||||
new Date(this.smsCampaign.recurrenceStartDate),
|
||||
dateTimeFormat
|
||||
);
|
||||
}
|
||||
this.organizationService.updateSmsCampaign(smsCampaign, this.smsCampaign.id).subscribe((response: any) => {
|
||||
this.router.navigate(['../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -8,9 +8,8 @@ describe('CampaignMessageStepComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ CampaignMessageStepComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [CampaignMessageStepComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
+1
-3
@@ -11,7 +11,6 @@ import { UntypedFormControl } from '@angular/forms';
|
||||
styleUrls: ['./campaign-message-step.component.scss']
|
||||
})
|
||||
export class CampaignMessageStepComponent implements OnChanges {
|
||||
|
||||
/** Column headers */
|
||||
@Input() templateParameters: any[];
|
||||
/** Valdity check for sms campaign form */
|
||||
@@ -24,7 +23,7 @@ export class CampaignMessageStepComponent implements OnChanges {
|
||||
/** Column header names */
|
||||
parameterLabels: any[];
|
||||
|
||||
constructor() { }
|
||||
constructor() {}
|
||||
|
||||
/**
|
||||
* Sets template parameters once response headers are retrieved.
|
||||
@@ -58,5 +57,4 @@ export class CampaignMessageStepComponent implements OnChanges {
|
||||
const newText = prevText + ` {{${label}}} `;
|
||||
this.message.patchValue(newText);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -8,9 +8,8 @@ describe('CampaignPreviewStepComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ CampaignPreviewStepComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [CampaignPreviewStepComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
+2
-4
@@ -10,7 +10,6 @@ import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
|
||||
styleUrls: ['./campaign-preview-step.component.scss']
|
||||
})
|
||||
export class CampaignPreviewStepComponent implements OnInit {
|
||||
|
||||
/** SMS Campaign */
|
||||
@Input() campaign: any;
|
||||
/** [Optional] SMS Campaign Template for create form */
|
||||
@@ -24,9 +23,9 @@ export class CampaignPreviewStepComponent implements OnInit {
|
||||
smsProviders: any[];
|
||||
|
||||
/** Emits submit() event */
|
||||
@Output() submitEvent = new EventEmitter;
|
||||
@Output() submitEvent = new EventEmitter();
|
||||
|
||||
constructor() { }
|
||||
constructor() {}
|
||||
|
||||
/**
|
||||
* Sets SMS providers and trigger types options.
|
||||
@@ -35,5 +34,4 @@ export class CampaignPreviewStepComponent implements OnInit {
|
||||
this.triggerTypes = this.smsCampaignTemplate.triggerTypeOptions;
|
||||
this.smsProviders = this.smsCampaignTemplate.smsProviderOptions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -8,9 +8,8 @@ describe('EditBusinessRuleParametersComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ EditBusinessRuleParametersComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [EditBusinessRuleParametersComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
+49
-45
@@ -23,7 +23,6 @@ import { Dates } from 'app/core/utils/dates';
|
||||
styleUrls: ['./edit-business-rule-parameters.component.scss']
|
||||
})
|
||||
export class EditBusinessRuleParametersComponent implements OnInit, OnChanges {
|
||||
|
||||
/** Run Report Parameters Data */
|
||||
@Input() paramData: any;
|
||||
/** SMS Campaign */
|
||||
@@ -46,9 +45,11 @@ export class EditBusinessRuleParametersComponent implements OnInit, OnChanges {
|
||||
* @param {ReportsService} reportsService Reports Service
|
||||
* @param {SettingsService} settingsService Settings Service.
|
||||
*/
|
||||
constructor(private reportsService: ReportsService,
|
||||
private settingsService: SettingsService,
|
||||
private dateUtils: Dates) { }
|
||||
constructor(
|
||||
private reportsService: ReportsService,
|
||||
private settingsService: SettingsService,
|
||||
private dateUtils: Dates
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.maxDate = this.settingsService.businessDate;
|
||||
@@ -69,31 +70,31 @@ export class EditBusinessRuleParametersComponent implements OnInit, OnChanges {
|
||||
* Fetches dropdown options and builds child dependencies.
|
||||
*/
|
||||
createRunReportForm() {
|
||||
this.paramData.forEach(
|
||||
(param: any) => {
|
||||
if (!param.parentParameterName) { // Non Child Parameter
|
||||
this.ReportForm.addControl(param.name, new UntypedFormControl('', Validators.required));
|
||||
const controlValue = this.paramValue[param.variable].toString();
|
||||
switch (param.displayType) {
|
||||
case 'text':
|
||||
this.ReportForm.get(param.name).patchValue(controlValue);
|
||||
break;
|
||||
case 'select':
|
||||
this.fetchSelectOptions(param, param.name);
|
||||
break;
|
||||
case 'date':
|
||||
const dateFormat = this.settingsService.dateFormat;
|
||||
const newControlValue = this.dateUtils.formatDate(controlValue, dateFormat);
|
||||
this.ReportForm.get(param.name).patchValue(newControlValue);
|
||||
break;
|
||||
}
|
||||
} else { // Child Parameter
|
||||
const parent: ReportParameter = this.paramData
|
||||
.find((entry: any) => entry.name === param.parentParameterName);
|
||||
parent.childParameters.push(param);
|
||||
this.updateParentParameters(parent);
|
||||
this.paramData.forEach((param: any) => {
|
||||
if (!param.parentParameterName) {
|
||||
// Non Child Parameter
|
||||
this.ReportForm.addControl(param.name, new UntypedFormControl('', Validators.required));
|
||||
const controlValue = this.paramValue[param.variable].toString();
|
||||
switch (param.displayType) {
|
||||
case 'text':
|
||||
this.ReportForm.get(param.name).patchValue(controlValue);
|
||||
break;
|
||||
case 'select':
|
||||
this.fetchSelectOptions(param, param.name);
|
||||
break;
|
||||
case 'date':
|
||||
const dateFormat = this.settingsService.dateFormat;
|
||||
const newControlValue = this.dateUtils.formatDate(controlValue, dateFormat);
|
||||
this.ReportForm.get(param.name).patchValue(newControlValue);
|
||||
break;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Child Parameter
|
||||
const parent: ReportParameter = this.paramData.find((entry: any) => entry.name === param.parentParameterName);
|
||||
parent.childParameters.push(param);
|
||||
this.updateParentParameters(parent);
|
||||
}
|
||||
});
|
||||
this.setChildControls();
|
||||
}
|
||||
|
||||
@@ -102,10 +103,12 @@ export class EditBusinessRuleParametersComponent implements OnInit, OnChanges {
|
||||
* @param {ReportParameter} parent Parent report parameter
|
||||
*/
|
||||
updateParentParameters(parent: ReportParameter) {
|
||||
const parentNames = this.parentParameters.map(parameter => parameter.name);
|
||||
if (!parentNames.includes(parent.name)) { // Parent's first child.
|
||||
const parentNames = this.parentParameters.map((parameter) => parameter.name);
|
||||
if (!parentNames.includes(parent.name)) {
|
||||
// Parent's first child.
|
||||
this.parentParameters.push(parent);
|
||||
} else { // Parent already has a child
|
||||
} else {
|
||||
// Parent already has a child
|
||||
const index = parentNames.indexOf(parent.name);
|
||||
this.parentParameters[index] = parent;
|
||||
}
|
||||
@@ -132,19 +135,19 @@ export class EditBusinessRuleParametersComponent implements OnInit, OnChanges {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches Select Dropdown options for param type "Select".
|
||||
* @param {ReportParameter} param Parameter for which dropdown options are required.
|
||||
* @param {string} inputstring url substring for API call.
|
||||
*/
|
||||
/**
|
||||
* Fetches Select Dropdown options for param type "Select".
|
||||
* @param {ReportParameter} param Parameter for which dropdown options are required.
|
||||
* @param {string} inputstring url substring for API call.
|
||||
*/
|
||||
fetchSelectOptions(param: ReportParameter, inputstring: string) {
|
||||
this.reportsService.getSelectOptions(inputstring).subscribe((options: SelectOption[]) => {
|
||||
param.selectOptions = options;
|
||||
if (param.selectAll === 'Y') {
|
||||
param.selectOptions.push({id: '-1', name: 'All'});
|
||||
param.selectOptions.push({ id: '-1', name: 'All' });
|
||||
}
|
||||
const optionId = this.paramValue[param.variable].toString();
|
||||
const option = options.find(entry => entry.id === optionId);
|
||||
const option = options.find((entry) => entry.id === optionId);
|
||||
this.ReportForm.controls[param.name].patchValue({ id: optionId, name: option.name });
|
||||
});
|
||||
}
|
||||
@@ -164,9 +167,9 @@ export class EditBusinessRuleParametersComponent implements OnInit, OnChanges {
|
||||
*/
|
||||
disableFormWhenValid() {
|
||||
this.ReportForm.statusChanges.pipe(distinctUntilChanged()).subscribe((status: string) => {
|
||||
if (status === 'VALID') {
|
||||
this.ReportForm.disable();
|
||||
}
|
||||
if (status === 'VALID') {
|
||||
this.ReportForm.disable();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -177,9 +180,11 @@ export class EditBusinessRuleParametersComponent implements OnInit, OnChanges {
|
||||
formatUserResponse(response: any, forHeaders: boolean) {
|
||||
const formattedResponse: any = {};
|
||||
let newKey: string;
|
||||
for (const [key, value] of Object.entries(response)) {
|
||||
const param: ReportParameter = this.paramData
|
||||
.find((_entry: any) => _entry.variable === key);
|
||||
for (const [
|
||||
key,
|
||||
value
|
||||
] of Object.entries(response)) {
|
||||
const param: ReportParameter = this.paramData.find((_entry: any) => _entry.variable === key);
|
||||
newKey = forHeaders ? param.inputName : param.variable;
|
||||
formattedResponse[newKey] = value;
|
||||
}
|
||||
@@ -205,5 +210,4 @@ export class EditBusinessRuleParametersComponent implements OnInit, OnChanges {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -8,9 +8,8 @@ describe('EditSmsCampaignStepComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ EditSmsCampaignStepComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [EditSmsCampaignStepComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
+28
-16
@@ -18,7 +18,6 @@ import { SettingsService } from 'app/settings/settings.service';
|
||||
styleUrls: ['./edit-sms-campaign-step.component.scss']
|
||||
})
|
||||
export class EditSmsCampaignStepComponent implements OnInit {
|
||||
|
||||
/** SMS Campaign Template */
|
||||
@Input() smsCampaignTemplate: any;
|
||||
/** SMS Campaign */
|
||||
@@ -49,9 +48,11 @@ export class EditSmsCampaignStepComponent implements OnInit {
|
||||
* @param {ReportsService} reportService Reports Service
|
||||
* @param {SettingsService} settingsService Settings Service.
|
||||
*/
|
||||
constructor(private formBuilder: UntypedFormBuilder,
|
||||
private reportService: ReportsService,
|
||||
private settingsService: SettingsService) {
|
||||
constructor(
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
private reportService: ReportsService,
|
||||
private settingsService: SettingsService
|
||||
) {
|
||||
this.createSMSCampaignDetailsForm();
|
||||
}
|
||||
|
||||
@@ -60,11 +61,20 @@ export class EditSmsCampaignStepComponent implements OnInit {
|
||||
*/
|
||||
createSMSCampaignDetailsForm() {
|
||||
this.smsCampaignDetailsForm = this.formBuilder.group({
|
||||
'campaignName': ['', Validators.required],
|
||||
'providerId': [null],
|
||||
'triggerType': ['', Validators.required],
|
||||
'runReportId': ['', Validators.required],
|
||||
'isNotification': [false]
|
||||
campaignName: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
providerId: [null],
|
||||
triggerType: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
runReportId: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
isNotification: [false]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -100,15 +110,17 @@ export class EditSmsCampaignStepComponent implements OnInit {
|
||||
*/
|
||||
setControlValues() {
|
||||
this.smsCampaignDetailsForm.patchValue({
|
||||
'campaignName': this.smsCampaign.campaignName,
|
||||
'providerId': this.smsCampaign.providerId,
|
||||
'triggerType': this.smsCampaign.triggerType.id,
|
||||
'runReportId': this.smsCampaign.runReportId,
|
||||
'isNotification': this.smsCampaign.isNotification
|
||||
campaignName: this.smsCampaign.campaignName,
|
||||
providerId: this.smsCampaign.providerId,
|
||||
triggerType: this.smsCampaign.triggerType.id,
|
||||
runReportId: this.smsCampaign.runReportId,
|
||||
isNotification: this.smsCampaign.isNotification
|
||||
});
|
||||
if (this.smsCampaign.triggerType.value === 'Schedule') {
|
||||
this.smsCampaignDetailsForm.addControl('recurrenceStartDate', new UntypedFormControl(new Date(this.smsCampaign.recurrenceStartDate)));
|
||||
this.smsCampaignDetailsForm.addControl(
|
||||
'recurrenceStartDate',
|
||||
new UntypedFormControl(new Date(this.smsCampaign.recurrenceStartDate))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -8,9 +8,8 @@ describe('BusinessRuleParametersComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ BusinessRuleParametersComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [BusinessRuleParametersComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
+37
-33
@@ -20,7 +20,6 @@ import { Dates } from 'app/core/utils/dates';
|
||||
styleUrls: ['./business-rule-parameters.component.scss']
|
||||
})
|
||||
export class BusinessRuleParametersComponent implements OnInit, OnChanges {
|
||||
|
||||
/** Run Report Parameters Data */
|
||||
@Input() paramData: any;
|
||||
|
||||
@@ -43,9 +42,11 @@ export class BusinessRuleParametersComponent implements OnInit, OnChanges {
|
||||
* @param {SettingsService} settingsService Settings Service.
|
||||
* @param {Dates} dateUtils Date Utils.
|
||||
*/
|
||||
constructor(private reportsService: ReportsService,
|
||||
private settingsService: SettingsService,
|
||||
private dateUtils: Dates) { }
|
||||
constructor(
|
||||
private reportsService: ReportsService,
|
||||
private settingsService: SettingsService,
|
||||
private dateUtils: Dates
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.maxDate = this.settingsService.businessDate;
|
||||
@@ -74,20 +75,20 @@ export class BusinessRuleParametersComponent implements OnInit, OnChanges {
|
||||
* Fetches dropdown options and builds child dependencies.
|
||||
*/
|
||||
createRunReportForm() {
|
||||
this.paramData.forEach(
|
||||
(param: any) => {
|
||||
if (!param.parentParameterName) { // Non-Child Parameter
|
||||
this.ReportForm.addControl(param.name, new UntypedFormControl('', Validators.required));
|
||||
if (param.displayType === 'select') {
|
||||
this.fetchSelectOptions(param, param.name);
|
||||
}
|
||||
} else { // Child Parameter
|
||||
const parent: ReportParameter = this.paramData
|
||||
.find((entry: any) => entry.name === param.parentParameterName);
|
||||
parent.childParameters.push(param);
|
||||
this.updateParentParameters(parent);
|
||||
this.paramData.forEach((param: any) => {
|
||||
if (!param.parentParameterName) {
|
||||
// Non-Child Parameter
|
||||
this.ReportForm.addControl(param.name, new UntypedFormControl('', Validators.required));
|
||||
if (param.displayType === 'select') {
|
||||
this.fetchSelectOptions(param, param.name);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Child Parameter
|
||||
const parent: ReportParameter = this.paramData.find((entry: any) => entry.name === param.parentParameterName);
|
||||
parent.childParameters.push(param);
|
||||
this.updateParentParameters(parent);
|
||||
}
|
||||
});
|
||||
this.setChildControls();
|
||||
}
|
||||
|
||||
@@ -96,18 +97,20 @@ export class BusinessRuleParametersComponent implements OnInit, OnChanges {
|
||||
* @param {ReportParameter} parent Parent report parameter
|
||||
*/
|
||||
updateParentParameters(parent: ReportParameter) {
|
||||
const parentNames = this.parentParameters.map(parameter => parameter.name);
|
||||
if (!parentNames.includes(parent.name)) { // Parent's first child.
|
||||
const parentNames = this.parentParameters.map((parameter) => parameter.name);
|
||||
if (!parentNames.includes(parent.name)) {
|
||||
// Parent's first child.
|
||||
this.parentParameters.push(parent);
|
||||
} else { // Parent already has a child
|
||||
} else {
|
||||
// Parent already has a child
|
||||
const index = parentNames.indexOf(parent.name);
|
||||
this.parentParameters[index] = parent;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes to changes in parent parameters value, builds child parameter vis-a-vis parent's value.
|
||||
*/
|
||||
/**
|
||||
* Subscribes to changes in parent parameters value, builds child parameter vis-a-vis parent's value.
|
||||
*/
|
||||
setChildControls() {
|
||||
this.parentParameters.forEach((param: ReportParameter) => {
|
||||
this.ReportForm.get(param.name).valueChanges.subscribe((option: any) => {
|
||||
@@ -126,16 +129,16 @@ export class BusinessRuleParametersComponent implements OnInit, OnChanges {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches Select Dropdown options for param type "Select".
|
||||
* @param {ReportParameter} param Parameter for which dropdown options are required.
|
||||
* @param {string} inputstring url substring for API call.
|
||||
*/
|
||||
/**
|
||||
* Fetches Select Dropdown options for param type "Select".
|
||||
* @param {ReportParameter} param Parameter for which dropdown options are required.
|
||||
* @param {string} inputstring url substring for API call.
|
||||
*/
|
||||
fetchSelectOptions(param: ReportParameter, inputstring: string) {
|
||||
this.reportsService.getSelectOptions(inputstring).subscribe((options: SelectOption[]) => {
|
||||
param.selectOptions = options;
|
||||
if (param.selectAll === 'Y') {
|
||||
param.selectOptions.push({id: '-1', name: 'All'});
|
||||
param.selectOptions.push({ id: '-1', name: 'All' });
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -147,9 +150,11 @@ export class BusinessRuleParametersComponent implements OnInit, OnChanges {
|
||||
formatUserResponse(response: any, forHeaders: boolean) {
|
||||
const formattedResponse: any = {};
|
||||
let newKey: string;
|
||||
for (const [key, value] of Object.entries(response)) {
|
||||
const param: ReportParameter = this.paramData
|
||||
.find((_entry: any) => _entry.name === key);
|
||||
for (const [
|
||||
key,
|
||||
value
|
||||
] of Object.entries(response)) {
|
||||
const param: ReportParameter = this.paramData.find((_entry: any) => _entry.name === key);
|
||||
newKey = forHeaders ? param.inputName : param.variable;
|
||||
switch (param.displayType) {
|
||||
case 'text':
|
||||
@@ -186,5 +191,4 @@ export class BusinessRuleParametersComponent implements OnInit, OnChanges {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -8,9 +8,8 @@ describe('SmsCampaignStepComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ SmsCampaignStepComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [SmsCampaignStepComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
+53
-18
@@ -1,5 +1,5 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, Input, ViewChild, EventEmitter, Output} from '@angular/core';
|
||||
import { Component, OnInit, Input, ViewChild, EventEmitter, Output } from '@angular/core';
|
||||
import { UntypedFormGroup, UntypedFormBuilder, Validators, UntypedFormControl } from '@angular/forms';
|
||||
|
||||
/** Custom Services */
|
||||
@@ -20,7 +20,6 @@ import { BusinessRuleParametersComponent } from './business-rule-parameters/busi
|
||||
styleUrls: ['./sms-campaign-step.component.scss']
|
||||
})
|
||||
export class SmsCampaignStepComponent implements OnInit {
|
||||
|
||||
/** SMS Campaign Template */
|
||||
@Input() smsCampaignTemplate: any;
|
||||
/** Business Rule Parameters Component */
|
||||
@@ -51,8 +50,10 @@ export class SmsCampaignStepComponent implements OnInit {
|
||||
* @param {FormBuilder} formBuilder Form Builder
|
||||
* @param {ReportsService} reportService Reports Service
|
||||
*/
|
||||
constructor(private formBuilder: UntypedFormBuilder,
|
||||
private reportService: ReportsService) {
|
||||
constructor(
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
private reportService: ReportsService
|
||||
) {
|
||||
this.createSMSCampaignDetailsForm();
|
||||
this.buildDependencies();
|
||||
}
|
||||
@@ -112,11 +113,20 @@ export class SmsCampaignStepComponent implements OnInit {
|
||||
*/
|
||||
createSMSCampaignDetailsForm() {
|
||||
this.smsCampaignDetailsForm = this.formBuilder.group({
|
||||
'campaignName': ['', Validators.required],
|
||||
'providerId': [null],
|
||||
'triggerType': ['', Validators.required],
|
||||
'runReportId': ['', Validators.required],
|
||||
'isNotification': [false]
|
||||
campaignName: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
providerId: [null],
|
||||
triggerType: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
runReportId: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
isNotification: [false]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -159,18 +169,44 @@ export class SmsCampaignStepComponent implements OnInit {
|
||||
this.smsCampaignDetailsForm.removeControl('repeatsOnDay');
|
||||
switch (frequency) {
|
||||
case 1: // Daily
|
||||
this.repetitionIntervals = ['1', '2', '3'];
|
||||
break;
|
||||
this.repetitionIntervals = [
|
||||
'1',
|
||||
'2',
|
||||
'3'
|
||||
];
|
||||
break;
|
||||
case 2: // Weekly
|
||||
this.repetitionIntervals = ['1', '2', '3'];
|
||||
this.repetitionIntervals = [
|
||||
'1',
|
||||
'2',
|
||||
'3'
|
||||
];
|
||||
this.smsCampaignDetailsForm.addControl('repeatsOnDay', new UntypedFormControl('', Validators.required));
|
||||
break;
|
||||
break;
|
||||
case 3: // Monthly
|
||||
this.repetitionIntervals = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11'];
|
||||
break;
|
||||
this.repetitionIntervals = [
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5',
|
||||
'6',
|
||||
'7',
|
||||
'8',
|
||||
'9',
|
||||
'10',
|
||||
'11'
|
||||
];
|
||||
break;
|
||||
case 4: // Yearly
|
||||
this.repetitionIntervals = ['1', '2', '3', '4', '5'];
|
||||
break;
|
||||
this.repetitionIntervals = [
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5'
|
||||
];
|
||||
break;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -181,5 +217,4 @@ export class SmsCampaignStepComponent implements OnInit {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('SmsCampaignsComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ SmsCampaignsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [SmsCampaignsComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -17,11 +17,17 @@ import { of } from 'rxjs';
|
||||
styleUrls: ['./sms-campaigns.component.scss']
|
||||
})
|
||||
export class SmsCampaignsComponent implements OnInit {
|
||||
|
||||
/** SMS Campaigns data. */
|
||||
smsCampaignsData: any;
|
||||
/** Columns to be displayed in sms campaigns table. */
|
||||
displayedColumns: string[] = ['campaignName', 'campaignMessage', 'campaignType.value', 'triggerType.value', 'campaignStatus.value', 'smsCampaignTimeLine.submittedByUsername'];
|
||||
displayedColumns: string[] = [
|
||||
'campaignName',
|
||||
'campaignMessage',
|
||||
'campaignType.value',
|
||||
'triggerType.value',
|
||||
'campaignStatus.value',
|
||||
'smsCampaignTimeLine.submittedByUsername'
|
||||
];
|
||||
/** Data source for SMS campaigns table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
@@ -35,7 +41,7 @@ export class SmsCampaignsComponent implements OnInit {
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
this.route.data.subscribe(( data: { smsCampaigns: any }) => {
|
||||
this.route.data.subscribe((data: { smsCampaigns: any }) => {
|
||||
this.smsCampaignsData = data.smsCampaigns.pageItems;
|
||||
});
|
||||
}
|
||||
@@ -62,15 +68,19 @@ export class SmsCampaignsComponent implements OnInit {
|
||||
this.dataSource = new MatTableDataSource(this.smsCampaignsData);
|
||||
this.dataSource.sortingDataAccessor = (item, property) => {
|
||||
switch (property) {
|
||||
case 'campaignType.value': return item.campaignType.value;
|
||||
case 'triggerType.value': return item.triggerType.value;
|
||||
case 'campaignStatus.value': return item.campaignStatus.value;
|
||||
case 'smsCampaignTimeLine.submittedByUsername': return item.smsCampaignTimeLine.submittedByUsername;
|
||||
default: return item[property];
|
||||
case 'campaignType.value':
|
||||
return item.campaignType.value;
|
||||
case 'triggerType.value':
|
||||
return item.triggerType.value;
|
||||
case 'campaignStatus.value':
|
||||
return item.campaignStatus.value;
|
||||
case 'smsCampaignTimeLine.submittedByUsername':
|
||||
return item.smsCampaignTimeLine.submittedByUsername;
|
||||
default:
|
||||
return item[property];
|
||||
}
|
||||
};
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('ViewCampaignComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ViewCampaignComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [ViewCampaignComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -27,7 +27,6 @@ import { Dates } from 'app/core/utils/dates';
|
||||
styleUrls: ['./view-campaign.component.scss']
|
||||
})
|
||||
export class ViewCampaignComponent implements OnInit {
|
||||
|
||||
/** Minimum date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum date allowed. */
|
||||
@@ -39,7 +38,12 @@ export class ViewCampaignComponent implements OnInit {
|
||||
/** Message Status */
|
||||
status: any;
|
||||
/** Data Table Columns */
|
||||
displayedColumns: string[] = ['Message', 'Status', 'Mobile No.', 'Campaign Name'];
|
||||
displayedColumns: string[] = [
|
||||
'Message',
|
||||
'Status',
|
||||
'Mobile No.',
|
||||
'Campaign Name'
|
||||
];
|
||||
/** Data source for SMS campaigns table. */
|
||||
dataSource = new MatTableDataSource();
|
||||
|
||||
@@ -80,13 +84,15 @@ export class ViewCampaignComponent implements OnInit {
|
||||
* @param {OrganizationService} organizationService Organization Service
|
||||
* @param {SettingsService} settingsService Setting Service
|
||||
*/
|
||||
constructor(private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
public dialog: MatDialog,
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
private dateUtils: Dates,
|
||||
private organizationService: OrganizationService,
|
||||
private settingsService: SettingsService) {
|
||||
constructor(
|
||||
private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
public dialog: MatDialog,
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
private dateUtils: Dates,
|
||||
private organizationService: OrganizationService,
|
||||
private settingsService: SettingsService
|
||||
) {
|
||||
this.route.data.subscribe((data: { smsCampaign: any }) => {
|
||||
this.smsCampaignData = data.smsCampaign;
|
||||
});
|
||||
@@ -102,8 +108,8 @@ export class ViewCampaignComponent implements OnInit {
|
||||
*/
|
||||
createSMSForm() {
|
||||
this.smsForm = this.formBuilder.group({
|
||||
'fromDate': [''],
|
||||
'toDate': [''],
|
||||
fromDate: [''],
|
||||
toDate: ['']
|
||||
});
|
||||
}
|
||||
|
||||
@@ -134,6 +140,7 @@ export class ViewCampaignComponent implements OnInit {
|
||||
type: 'date',
|
||||
required: true
|
||||
})
|
||||
|
||||
];
|
||||
const data = {
|
||||
title: 'Close SMS Campaign',
|
||||
@@ -150,9 +157,11 @@ export class ViewCampaignComponent implements OnInit {
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
this.organizationService.executeSmsCampaignCommand(this.smsCampaignData.id, dataObject, 'close').subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
this.organizationService
|
||||
.executeSmsCampaignCommand(this.smsCampaignData.id, dataObject, 'close')
|
||||
.subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -169,6 +178,7 @@ export class ViewCampaignComponent implements OnInit {
|
||||
type: 'date',
|
||||
required: true
|
||||
})
|
||||
|
||||
];
|
||||
const data = {
|
||||
title: 'Activate SMS Campaign',
|
||||
@@ -185,9 +195,11 @@ export class ViewCampaignComponent implements OnInit {
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
this.organizationService.executeSmsCampaignCommand(this.smsCampaignData.id, dataObject, 'activate').subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
this.organizationService
|
||||
.executeSmsCampaignCommand(this.smsCampaignData.id, dataObject, 'activate')
|
||||
.subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -204,6 +216,7 @@ export class ViewCampaignComponent implements OnInit {
|
||||
type: 'date',
|
||||
required: true
|
||||
})
|
||||
|
||||
];
|
||||
const data = {
|
||||
title: 'Reactivate SMS Campaign',
|
||||
@@ -220,9 +233,11 @@ export class ViewCampaignComponent implements OnInit {
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
this.organizationService.executeSmsCampaignCommand(this.smsCampaignData.id, dataObject, 'reactivate').subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
this.organizationService
|
||||
.executeSmsCampaignCommand(this.smsCampaignData.id, dataObject, 'reactivate')
|
||||
.subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -249,7 +264,8 @@ export class ViewCampaignComponent implements OnInit {
|
||||
*/
|
||||
private reload() {
|
||||
const url: string = this.router.url;
|
||||
this.router.navigateByUrl(`/organization/sms-campaigns`, {skipLocationChange: true})
|
||||
this.router
|
||||
.navigateByUrl(`/organization/sms-campaigns`, { skipLocationChange: true })
|
||||
.then(() => this.router.navigate([url]));
|
||||
}
|
||||
|
||||
@@ -280,5 +296,4 @@ export class ViewCampaignComponent implements OnInit {
|
||||
this.messageTableRef.renderRows();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user