Commit 28c5e91e by GD-A-150752

Code-Review comments-added

parent 5acafeab
...@@ -90,6 +90,9 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -90,6 +90,9 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni
.subscribe( .subscribe(
(params: Params) => { (params: Params) => {
/**
* First condition identifies if the template is being created from workflow template
*/
if (this.templateCreationFromWorkflow()) { if (this.templateCreationFromWorkflow()) {
this.messageTemplate.HiringTeam = this.adminPortalLayoutService.getHiringTeamID().ObjectID; this.messageTemplate.HiringTeam = this.adminPortalLayoutService.getHiringTeamID().ObjectID;
...@@ -101,11 +104,17 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -101,11 +104,17 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni
this.setInputListener(); this.setInputListener();
this.showLoader = false; this.showLoader = false;
/**
* Second condition identifies if the template is being updated from workflow template
*/
} else if (this.templateUpdateFromWorkflow() || (params.id && params.id !== '0')) { } else if (this.templateUpdateFromWorkflow() || (params.id && params.id !== '0')) {
this.editMode = true; this.editMode = true;
this.getMessageTemplateByID(this.templateUpdateFromWorkflow() ? this.objectID : params.id); this.getMessageTemplateByID(this.templateUpdateFromWorkflow() ? this.objectID : params.id);
} else { } else {
/**
* Third condition identifies if the template is being created within this component
*/
this.messageTemplate.HiringTeam = this.adminPortalLayoutService.getHiringTeamID().ObjectID; this.messageTemplate.HiringTeam = this.adminPortalLayoutService.getHiringTeamID().ObjectID;
if (this.messageTemplateTypes) { if (this.messageTemplateTypes) {
...@@ -128,6 +137,10 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -128,6 +137,10 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni
); );
} }
/**
* Save button is visible only if selected template is created by the selected hiring team or
* if the template is in edit mode
*/
showSaveBtn(): boolean { showSaveBtn(): boolean {
return this.messageTemplate && this.messageTemplate.ObjectID ? return this.messageTemplate && this.messageTemplate.ObjectID ?
(this.messageTemplate.HiringTeam === this.adminPortalLayoutService.getHiringTeamID().ObjectID || (this.messageTemplate.HiringTeam === this.adminPortalLayoutService.getHiringTeamID().ObjectID ||
...@@ -147,6 +160,10 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -147,6 +160,10 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni
return false; return false;
} }
/**
* This function sets two types of input listeners, upon click and upon writing anything in the field.
* Whenever the event is triggered, it stores the current cursor position of that specific field.
*/
setInputListener(): void { setInputListener(): void {
let editElement; let editElement;
setTimeout(() => { setTimeout(() => {
...@@ -185,6 +202,10 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -185,6 +202,10 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni
}, 0); }, 0);
} }
/**
* In Email template type, user may add anchor tag in editor.
* This function gets the Quill view child and inserts or updates its content as per placeholder selected.
*/
addAnchorText(show: boolean): void { addAnchorText(show: boolean): void {
if (!show || this.linkText === '') { if (!show || this.linkText === '') {
...@@ -217,6 +238,10 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -217,6 +238,10 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni
this.contentLinkModal.hide(); this.contentLinkModal.hide();
} }
/**
* When content of editor is updated using placeholder, it doesn't reflect value in the ngModel
* This function is called only once before saving the template to re-assign value of content in ngModel.
*/
assignContent(): void { assignContent(): void {
const editor = this.messageContentEditor.getQuill().container; const editor = this.messageContentEditor.getQuill().container;
if (editor) { if (editor) {
...@@ -233,7 +258,7 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -233,7 +258,7 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni
this.contentPlaceholder = $event; this.contentPlaceholder = $event;
if (!this.contentPlaceholder || !this.contentPlaceholder.Value) { if (!this.contentPlaceholder || !this.contentPlaceholder.Value || this.contentPlaceholder.Value === 'null') {
return; return;
} }
...@@ -259,6 +284,9 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -259,6 +284,9 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni
this.resetSelect('contentPlaceholderOptions'); this.resetSelect('contentPlaceholderOptions');
} }
/**
* When a template is switched from Email to SMS type, plain text is shown in the textarea instead of rich HTML.
*/
showPlainText(HTMLTitle: string): string { showPlainText(HTMLTitle: string): string {
const temp = document.getElementById('showPlainText'); const temp = document.getElementById('showPlainText');
temp.innerHTML = HTMLTitle; temp.innerHTML = HTMLTitle;
...@@ -268,6 +296,10 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -268,6 +296,10 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni
return title; return title;
} }
/**
* User may revert back to EMAIL from SMS, in this case, rich HTML content is preserved in a variable whenever
* SMS type is changed to EMAIL
*/
storeMessageContent($event): void { storeMessageContent($event): void {
if (!$event) { if (!$event) {
...@@ -289,10 +321,10 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -289,10 +321,10 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni
if (this.ContentPlaceholderOptionsEnum) { if (this.ContentPlaceholderOptionsEnum) {
if (this.emailTemplateType()) { if (this.emailTemplateType()) {
this.contentPlaceholderOptions = this.ContentPlaceholderOptionsEnum.filter(option => option.ShowForContent || this.contentPlaceholderOptions = this.ContentPlaceholderOptionsEnum.filter(option => option.ShowForContent ||
option.Value === '-'); option.Value === 'null');
} else { } else {
this.contentPlaceholderOptions = this.ContentPlaceholderOptionsEnum this.contentPlaceholderOptions = this.ContentPlaceholderOptionsEnum
.filter(option => option.ShowForContent && !option.IsLink || option.Value === '-'); .filter(option => option.ShowForContent && !option.IsLink || option.Value === 'null');
} }
} }
...@@ -340,6 +372,8 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -340,6 +372,8 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni
this.templateTypeId = this.templateTypeId =
this.messageTemplateTypes.find(elem => elem.Value === this.messageTemplate.TemplateType.Value).id; this.messageTemplateTypes.find(elem => elem.Value === this.messageTemplate.TemplateType.Value).id;
this.showLoader = false; this.showLoader = false;
// Significance of setTimeout is to call the function at the end of browser stack
// in order to make sure that UI has been updated prior to calling its view-child
setTimeout(() => this.setInputListener(), 0); setTimeout(() => this.setInputListener(), 0);
}, },
error => { error => {
...@@ -361,7 +395,7 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -361,7 +395,7 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni
} }
cancelClicked(): void { cancelClicked(): void {
// If new message template is being created from 'EditWorkFlowComponent' // If new message template is being created from 'EditWorkFlowComponent', don't show listing.
if (this.templateCreationFromWorkflow() || this.templateUpdateFromWorkflow()) { if (this.templateCreationFromWorkflow() || this.templateUpdateFromWorkflow()) {
this.closeModal.emit(-1); this.closeModal.emit(-1);
} else { } else {
...@@ -389,7 +423,7 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -389,7 +423,7 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni
if (data.created[id]) { if (data.created[id]) {
id = data.created[id]; id = data.created[id];
} }
// emitting value to component, in this case 'Edit-Workflow-Template'
this.closeModal.emit(id); this.closeModal.emit(id);
} else if (this.templateUpdateFromWorkflow()) { } else if (this.templateUpdateFromWorkflow()) {
this.closeModal.emit(this.messageTemplate.ObjectID); this.closeModal.emit(this.messageTemplate.ObjectID);
...@@ -411,16 +445,17 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -411,16 +445,17 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni
this.subscriptions.push(this.appService.getPlaceholderOptionsEnum() this.subscriptions.push(this.appService.getPlaceholderOptionsEnum()
.subscribe(options => { .subscribe(options => {
this.ContentPlaceholderOptionsEnum = options; this.ContentPlaceholderOptionsEnum = options;
// Changed null value to 'null' in order to use it in select-2 component which takes value as a string
this.ContentPlaceholderOptionsEnum.filter(option => option.Value === null) this.ContentPlaceholderOptionsEnum.filter(option => option.Value === null)
.map(val => { .map(val => {
val.Value = '-'; val.Value = 'null';
return val; return val;
}); });
this.contentPlaceholderOptions = this.contentPlaceholderOptions =
this.ContentPlaceholderOptionsEnum.filter(option => option.ShowForContent || option.Value === '-'); this.ContentPlaceholderOptionsEnum.filter(option => option.ShowForContent || option.Value === 'null');
this.subjectPlaceholderOptions = this.subjectPlaceholderOptions =
this.ContentPlaceholderOptionsEnum.filter(option => option.ShowForSubject || option.Value === '-'); this.ContentPlaceholderOptionsEnum.filter(option => option.ShowForSubject || option.Value === 'null');
}) })
); );
} }
......
...@@ -101,13 +101,15 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -101,13 +101,15 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
this.stageTypes = response[0]; this.stageTypes = response[0];
this.stepTypeOptions = response[1]; this.stepTypeOptions = response[1];
// Changed null value to 'null' in order to use it in select-2 component which takes value as a string
this.stepTypeOptions.filter(type => type.Value === null) this.stepTypeOptions.filter(type => type.Value === null)
.map(val => { .map(val => {
val.Value = '-'; val.Value = 'null';
return val; return val;
}); });
// Diversity is shown only is enabled by selected hiring team
if (!this.adminPortalLayoutService.getHiringTeamID().HasDiversity) { if (!this.adminPortalLayoutService.getHiringTeamID().HasDiversity) {
this.stepTypeOptions = this.stepTypeOptions.filter(type => type.Value !== 'DIVERSITY'); this.stepTypeOptions = this.stepTypeOptions.filter(type => type.Value !== 'DIVERSITY');
} }
...@@ -131,6 +133,9 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -131,6 +133,9 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
this.getMessageTemplates(); this.getMessageTemplates();
} }
/**
* When a new template is created, following default values are to assigned.
*/
setDefaults(): void { setDefaults(): void {
this.workflow.TemplateName = 'Workflow Template'; this.workflow.TemplateName = 'Workflow Template';
this.workflow.LandingButtonText = 'Apply Now'; this.workflow.LandingButtonText = 'Apply Now';
...@@ -144,6 +149,9 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -144,6 +149,9 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
this.workflow.HiringTeam = this.adminPortalLayoutService.getHiringTeamID().ObjectID; this.workflow.HiringTeam = this.adminPortalLayoutService.getHiringTeamID().ObjectID;
} }
/**
* Other than generic, add pre-stage and post-stage
*/
addDefaultStages(): void { addDefaultStages(): void {
this.workflow.WorkFlowStages = []; this.workflow.WorkFlowStages = [];
this.stageTypes.forEach(stage => { this.stageTypes.forEach(stage => {
...@@ -169,21 +177,25 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -169,21 +177,25 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
} }
reOrderSteps(): void { reOrderSteps(): void {
this.workflow.WorkFlowStages.forEach(stage => { this.workflow.WorkFlowStages.forEach(stage => {
stage.Steps = this.utilsService.sort(stage.Steps, ['SortOrder'], [1]); stage.Steps = this.utilsService.sort(stage.Steps, ['SortOrder'], [1]);
}); });
} }
isGeneric(stage: WorkflowStageModel): boolean { isGeneric(stage: WorkflowStageModel): boolean {
return !stage.StageType.IsPostStage && !stage.StageType.IsPreStage; return !stage.StageType.IsPostStage && !stage.StageType.IsPreStage;
} }
/**
* Instead of filtering stages on UI, every time a single change is made.
* This function creates three separate arrays for three types of stages (pre-stage, generic-stage, post-stage)
*/
filterStages(): void { filterStages(): void {
this.preStages = this.filteredStages(true, false); this.preStages = this.workflow.WorkFlowStages.filter(stage => stage.StageType.IsPreStage);
this.genericStages = this.filteredStages(false, false); this.genericStages = this.workflow.WorkFlowStages.filter(stage => !stage.StageType.IsPreStage && !stage.StageType.IsPostStage);
this.postStages = this.filteredStages(false, true); this.postStages = this.workflow.WorkFlowStages.filter(stage => stage.StageType.IsPostStage);
} }
showSaveBtn(): boolean { showSaveBtn(): boolean {
...@@ -208,16 +220,6 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -208,16 +220,6 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
return (this.editField[id] === undefined || this.editField[id] === false); return (this.editField[id] === undefined || this.editField[id] === false);
} }
filteredStages(isPreStage: boolean, isPostStage: boolean): Array<WorkflowStageModel> {
if (isPreStage) {
return this.workflow.WorkFlowStages.filter(stage => stage.StageType.IsPreStage);
} else if (isPostStage) {
return this.workflow.WorkFlowStages.filter(stage => stage.StageType.IsPostStage);
} else {
return this.workflow.WorkFlowStages.filter(stage => !stage.StageType.IsPreStage && !stage.StageType.IsPostStage);
}
}
emailResponseSelected(): boolean { emailResponseSelected(): boolean {
return this.workflow.ApplicationResponseAction && return this.workflow.ApplicationResponseAction &&
this.workflow.ApplicationResponseAction.Value === 'EMAIL_RESPONSE'; this.workflow.ApplicationResponseAction.Value === 'EMAIL_RESPONSE';
...@@ -265,6 +267,13 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -265,6 +267,13 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
message.VarianceString = `${message.Variance}m`; message.VarianceString = `${message.Variance}m`;
} }
/**
* Whenever Delay value is provided in message schedule section, it changes it into a delay string consisting of
* number of days, hours and minutes.
* Input mask gets values in the form of __:__:__
* Parsing of this value takes place in this function, moreover it sorts the messages as well
* @param message
*/
generateDelayString(message: WorkflowMessageModel): void { generateDelayString(message: WorkflowMessageModel): void {
if (!message.Delay) { if (!message.Delay) {
...@@ -333,6 +342,11 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -333,6 +342,11 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
this.messageTemplates.push(newTemplate); this.messageTemplates.push(newTemplate);
} }
/**
* This function sets the parameters to be sent to edit-message-template component
* @param $event
* @param message
*/
showMessageTemplateDialog($event, message: WorkflowMessageModel): void { showMessageTemplateDialog($event, message: WorkflowMessageModel): void {
const template = $event.value; const template = $event.value;
if (template.id && template.id === '0') { if (template.id && template.id === '0') {
...@@ -354,6 +368,11 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -354,6 +368,11 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
} }
} }
/**
* When the dialog is closed, whether a template is created or updated, it is fetched by sending request to API.
* Newly created or updated template is selected and shown in the dropdown of message in message scheduling section.
* @param value
*/
closeDialog(value): void { closeDialog(value): void {
if (value === -1) { if (value === -1) {
// Cancel button is clicked // Cancel button is clicked
...@@ -401,7 +420,7 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -401,7 +420,7 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
const stepType = step.StepType; const stepType = step.StepType;
this.utilsService.removeMultiRefObject(step, stage, 'Steps', this.createdObjs, this.updatedObjs, this.deletedObjs); this.utilsService.removeMultiRefObject(step, stage, 'Steps', this.createdObjs, this.updatedObjs, this.deletedObjs);
this.reAssignStepOrders(stage); stage.Steps.map((step, index) => step.SortOrder = index + 1);
this.addStepType(stepType); this.addStepType(stepType);
} }
}); });
...@@ -417,10 +436,6 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -417,10 +436,6 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
this.resetSelect('stepTypes'); this.resetSelect('stepTypes');
} }
reAssignStepOrders(stage: WorkflowStageModel): void {
stage.Steps.map((step, index) => step.SortOrder = index + 1);
}
addMessage(stage: WorkflowStageModel): void { addMessage(stage: WorkflowStageModel): void {
const message = new WorkflowMessageModel(stage.ObjectID); const message = new WorkflowMessageModel(stage.ObjectID);
message.ApplicantSources = this.utilsService.cloneObject(this.applicantSources); message.ApplicantSources = this.utilsService.cloneObject(this.applicantSources);
......
...@@ -2,10 +2,10 @@ export class SorterModel { ...@@ -2,10 +2,10 @@ export class SorterModel {
static count; static count;
description; description;
ascending; ascending;
ObjectID; Value;
constructor(des: string, sort: boolean) { constructor(des: string, sort: boolean) {
this.ObjectID = SorterModel.count++; this.Value = SorterModel.count++;
this.description = des; this.description = des;
this.ascending = sort; this.ascending = sort;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment