Commit 7d463ed7 by GD-A-150752

edit-workflow-template 85%

parent 5121545b
...@@ -4,7 +4,7 @@ import { Select2Module } from 'ng2-select2'; ...@@ -4,7 +4,7 @@ import { Select2Module } from 'ng2-select2';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { ModalModule } from 'ngx-bootstrap/modal'; import { ModalModule } from 'ngx-bootstrap/modal';
import { DeviceDetectorModule } from 'ngx-device-detector'; import { DeviceDetectorModule } from 'ngx-device-detector';
import { ConfirmationService } from 'primeng/primeng'; import { ConfirmationService, DragDropModule, InputMaskModule, OrderListModule } from 'primeng/primeng';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { AppRoutingModule } from './app.routing'; import { AppRoutingModule } from './app.routing';
import { AppService } from './app.service'; import { AppService } from './app.service';
...@@ -31,7 +31,10 @@ import { OneITModule } from './oneit/oneit.module'; ...@@ -31,7 +31,10 @@ import { OneITModule } from './oneit/oneit.module';
DeviceDetectorModule.forRoot(), DeviceDetectorModule.forRoot(),
Select2Module, Select2Module,
ModalModule.forRoot(), ModalModule.forRoot(),
BsDropdownModule.forRoot() BsDropdownModule.forRoot(),
InputMaskModule,
DragDropModule,
OrderListModule
], ],
declarations: [ declarations: [
AppComponent, AppComponent,
......
...@@ -26,8 +26,9 @@ export class AppService { ...@@ -26,8 +26,9 @@ export class AppService {
return this.enumService.getEnumsWithNULLOptionLabel('PlaceholderOptions', 'Select variable'); return this.enumService.getEnumsWithNULLOptionLabel('PlaceholderOptions', 'Select variable');
} }
getTypes(serviceName: string): Observable<Array<any>> { getTypes(serviceName: string, includeNull = false, blankLabel = null): Observable<Array<any>> {
return this.enumService.getEnums(serviceName, true); return includeNull ? this.enumService.getEnumsWithNULLOptionLabel(serviceName, blankLabel) :
this.enumService.getEnums(serviceName, true);
} }
getSearchListing(serviceName: string, queryType: string, queryParams, assocs, searchName): Observable<Array<any>> { getSearchListing(serviceName: string, queryType: string, queryParams, assocs, searchName): Observable<Array<any>> {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<app-error-message></app-error-message> <app-error-message></app-error-message>
<form #form="ngForm"> <form #form="ngForm">
<div class="ui-g ui-fluid"> <div class="ui-g ui-fluid">
<div class="ui-g-10 listing-title pt-0 pb-0">{{editMode ? "Edit" : "Add"}} Message Template</div> <div class="ui-g-10 listing-title pt-0 pb-0">{{editMode ? "Edit" : "Add"}} Workflow Template</div>
</div> </div>
<div class="ui-g form-group"> <div class="ui-g form-group">
<div class="ui-g-12 ui-md-12"> <div class="ui-g-12 ui-md-12">
...@@ -100,21 +100,19 @@ ...@@ -100,21 +100,19 @@
</div> </div>
<div class="ui-g form-group"> <div class="ui-g form-group">
<div class="ui-g-12 ui-md-12"> <div class="ui-g-12 ui-md-12">
<div class="ui-g form-group"> <div class="text-center form-group">
<div class="ui-g-12 ui-md-3 ui-fluid"> <button type="button" value="Cancel" class="btn btn-primary largeBtn greyBtn"
<p-button label="Cancel" [disabled]="showLoader" routerLink="/admin/list-message-templates">Cancel
routerLink="/admin/list-message-templates"></p-button> </button>
</div> <button *ngIf="showSaveBtn()" type="button" value="Save" class="btn btn-primary largeBtn"
<div class="ui-g-12 ui-md-3 ui-fluid"> (click)="saveMessageTemplate()" [disabled]="showLoader">
<p-button *ngIf="showSaveBtn()" label="Save" [disabled]="showLoader" Save
(onClick)="saveMessageTemplate()"> </button>
</p-button> <button *ngIf="showSaveCopyBtn()" type="button" value="Save As a Copy"
</div> class="btn btn-primary largeBtn"
<div class="ui-g-12 ui-md-3 ui-fluid"> (click)="saveMessageTemplate(true)" [disabled]="showLoader">
<p-button *ngIf="showSaveCopyBtn()" label="Save As a Copy" [disabled]="showLoader" Save As a Copy
(onClick)="saveMessageTemplate(true)"> </button>
</p-button>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -400,4 +400,6 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -400,4 +400,6 @@ export class EditMessageTemplateComponent extends BaseComponent implements OnIni
createdExists(): boolean { createdExists(): boolean {
return Object.keys(this.createdObjs).length > 0; return Object.keys(this.createdObjs).length > 0;
} }
// tslint:disable-next-line:max-file-line-count
} }
p-dropdown {
::ng-deep {
.ui-dropdown {
width: 100% !important;
}
.dropdown-text {
top: 0;
font-size: 14px;
margin-top: 4px;
position: absolute;
left: 30px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
width: 180px;
}
}
}
p-inputMask {
::ng-deep {
input {
width: 100%;
height: 100%;
}
}
}
::ng-deep {
.ui-orderlist-controls {
display: none !important;
}
.ui-orderlist-list-container {
width: 100%;
border: 0;
.ui-orderlist-caption {
border: 0;
}
.ui-orderlist-list {
border: 0;
height: auto;
.ui-orderlist-item {
cursor: auto;
min-height: 50px;
&:hover {
background-color: transparent !important;
}
}
}
}
}
.drag-block {
cursor: pointer;
}
import { Component, OnInit, ViewChild } from '@angular/core'; import { Component, OnInit, ViewChild } from '@angular/core';
import { NgForm } from '@angular/forms'; import { NgForm } from '@angular/forms';
import { ActivatedRoute, Params, Router } from '@angular/router'; import { ActivatedRoute, Params, Router } from '@angular/router';
import { ConfirmationService } from 'primeng/api';
import { combineLatest } from 'rxjs/observable/combineLatest';
import { Subscription } from 'rxjs/Subscription'; import { Subscription } from 'rxjs/Subscription';
import { AppService } from '../../app.service'; import { AppService } from '../../app.service';
import { SERVICES } from '../../constants';
import { MessageTemplateModel } from '../../models/messageTemplate.model';
import { ResponseActionEnum } from '../../models/responseAction.enum'; import { ResponseActionEnum } from '../../models/responseAction.enum';
import { StageTypeEnum } from '../../models/stageType.enum'; import { StageTypeEnum } from '../../models/stageType.enum';
import { StepTypeEnum } from '../../models/stepType.enum'; import { StepTypeEnum } from '../../models/stepType.enum';
import { WorkflowMessageModel } from '../../models/workflowMessage.model';
import { WorkflowStageModel } from '../../models/workflowStage.model';
import { WorkflowStepModel } from '../../models/workflowStep.model';
import { WorkflowTemplateModel } from '../../models/workflowTemplate.model'; import { WorkflowTemplateModel } from '../../models/workflowTemplate.model';
import { SaveService } from '../../oneit/services/save.service'; import { SaveService } from '../../oneit/services/save.service';
import { UtilsService } from '../../oneit/services/utils.service'; import { UtilsService } from '../../oneit/services/utils.service';
import { AdminPortalLayoutService } from '../admin-portal/admin-portal-layout/admin-portal-layout.service';
import { BaseComponent } from '../base/base.component'; import { BaseComponent } from '../base/base.component';
import { WorkflowTemplate } from './edit-workflow-template.model';
import { EditWorkflowTemplateService } from './edit-workflow-template.service'; import { EditWorkflowTemplateService } from './edit-workflow-template.service';
@Component({ @Component({
selector: 'app-edit-workflow-template', selector: 'app-edit-workflow-template',
templateUrl: './edit-workflow-template.component.html' templateUrl: './edit-workflow-template.component.html',
styleUrls: ['./edit-workflow-template.component.scss']
}) })
export class EditWorkflowTemplateComponent extends BaseComponent implements OnInit { export class EditWorkflowTemplateComponent extends BaseComponent implements OnInit {
subscriptions: Array<Subscription> = []; subscriptions: Array<Subscription> = [];
@ViewChild('form') form: NgForm; @ViewChild('form') form: NgForm;
createdObjs = {}; createdObjs;
updatedObjs = {}; updatedObjs;
deletedObjs = {}; deletedObjs;
workflow = new WorkflowTemplateModel(); workflow = new WorkflowTemplateModel();
preStages: Array<WorkflowStageModel> = [];
genericStages: Array<WorkflowStageModel> = [];
postStages: Array<WorkflowStageModel> = [];
stageTypes: Array<StageTypeEnum>; stageTypes: Array<StageTypeEnum>;
stepTypeOptions: Array<StepTypeEnum>;
stepTypes: Array<StepTypeEnum>; stepTypes: Array<StepTypeEnum>;
responseActions: Array<ResponseActionEnum>; responseActions: Array<ResponseActionEnum>;
messageTemplates: Array<MessageTemplateModel> = [];
editField: any = {}; editField: any = {};
showLoader = false; showLoader = false;
editMode = false; editMode = false;
displayNewMessageTemplate = false;
workflowTemplate = new WorkflowTemplate();
s: Array<any> = [];
messagetemplates: Array<any> = [];
messagetemplate_withdraws: Array<any> = [];
Automatically_progress_to_next_stages = [];
Use_messagings = [];
constructor( constructor(
private router: Router, private router: Router,
...@@ -46,7 +53,9 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -46,7 +53,9 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
private utilsService: UtilsService, private utilsService: UtilsService,
private saveService: SaveService, private saveService: SaveService,
private appService: AppService, private appService: AppService,
private editWorkflowTemplateService: EditWorkflowTemplateService private editWorkflowTemplateService: EditWorkflowTemplateService,
private adminPortalLayoutService: AdminPortalLayoutService,
private confirmationService: ConfirmationService
) { ) {
super(utilsService); super(utilsService);
} }
...@@ -55,28 +64,65 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -55,28 +64,65 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
this.createdObjs = {}; this.createdObjs = {};
this.updatedObjs = {}; this.updatedObjs = {};
this.deletedObjs = {}; this.deletedObjs = {};
this.utilsService.resetCounter();
this.showLoader = true; this.showLoader = true;
this.utilsService.resetCounter();
this.startComponent();
this.subscriptions.push(this.adminPortalLayoutService.userDataUpdated
.subscribe(
() => {
this.startComponent();
}
));
}
startComponent(): void {
if (!this.adminPortalLayoutService.userData || this.alreadyExists()) {
return;
}
this.subscriptions.push(this.activatedRoute.params this.subscriptions.push(this.activatedRoute.params
.subscribe( .subscribe(
(params: Params) => { (params: Params) => {
this.showLoader = true; this.subscriptions.push(
this.getStageTypes(); combineLatest(
this.getStepTypes(); this.appService.getTypes('StageTypes'),
this.getResponseActions(); this.appService.getTypes('StepTypes', true, 'Add Step'),
if (params.id && params.id !== '0') { this.appService.getTypes('ResponseActions')
this.editMode = true; )
this.getWorkflowTemplateByID(params.id); .subscribe(response => {
} else {
this.utilsService.createObject(this.workflow, this.createdObjs); if (this.alreadyExists()) {
this.setDefaults(); return;
this.showLogs(); }
this.showLoader = false;
} this.stageTypes = response[0];
this.stepTypeOptions = response[1];
if (!this.adminPortalLayoutService.getHiringTeamID().HasDiversity) {
this.stepTypeOptions = this.stepTypeOptions.filter(type => type.Value !== 'DIVERSITY');
}
this.responseActions = response[2];
if (params.id && params.id !== '0') {
this.editMode = true;
this.getWorkflowTemplateByID(params.id);
} else {
this.editMode = false;
this.utilsService.createObject(this.workflow, this.createdObjs);
this.setDefaults();
this.addDefaultStages();
this.stepTypes = [...this.stepTypeOptions];
this.showLogs();
this.showLoader = false;
}
})
);
} }
)); ));
this.gets(); this.getMessageTemplates();
} }
setDefaults(): void { setDefaults(): void {
...@@ -86,56 +132,157 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -86,56 +132,157 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
this.workflow.ThankYouHeaderText = 'Thank You for your application to:'; this.workflow.ThankYouHeaderText = 'Thank You for your application to:';
this.workflow.ThankYouSecondaryText = 'We will get in touch with you soon'; this.workflow.ThankYouSecondaryText = 'We will get in touch with you soon';
this.workflow.ApplicationButtonText = 'Submit'; this.workflow.ApplicationButtonText = 'Submit';
this.workflow.JobOutlineButtonText = 'Continue';
this.workflow.CaptureCV = true; this.workflow.CaptureCV = true;
this.workflow.CaptureCL = true;
this.workflow.HiringTeam = this.adminPortalLayoutService.getHiringTeamID().ObjectID;
} }
getStageTypes(): void { addDefaultStages(): void {
this.subscriptions.push( this.workflow.WorkFlowStages = [];
this.appService.getTypes('StageTypes') let topIndex = 1;
.subscribe((types: Array<StageTypeEnum>) => { this.stageTypes.forEach(stage => {
this.stageTypes = types; const index = (!stage.IsPostStage && !stage.IsPreStage) ? topIndex++ : -1;
}) const stageObject = new WorkflowStageModel(`${stage.Description} Stage`, false, stage, index,
); false, this.workflow.ObjectID);
this.utilsService.addMultiRefObject(stageObject, this.workflow, 'WorkFlowStages', this.createdObjs);
});
this.reOrderStages(this.filterStages(true, true, true));
} }
getStepTypes(): void { reOrderStages(callback): void {
this.subscriptions.push( this.showLoader = true;
this.appService.getTypes('StepTypes') this.workflow.WorkFlowStages
.subscribe((types: Array<StepTypeEnum>) => { .sort((a, b) => a.SortOrder < b.SortOrder ? -1 : a.SortOrder > b.SortOrder ? 1 : 0);
this.stepTypes = types; if (callback) {
}) callback();
); }
this.showLoader = false;
} }
getResponseActions(): void { isGeneric(stage: WorkflowStageModel): boolean {
this.subscriptions.push( return !stage.StageType.IsPostStage && !stage.StageType.IsPreStage;
this.appService.getTypes('ResponseActions') }
.subscribe((types: Array<ResponseActionEnum>) => {
this.responseActions = types; filterStages(pre = false, generic = false, post = false): void {
}) if (pre) {
); this.preStages = this.filteredStages(true, false);
}
if (generic) {
this.genericStages = this.filteredStages(false, false)
.sort((a, b) => a.SortOrder > b.SortOrder ? -1 : a.SortOrder < b.SortOrder ? 1 : 0);
}
if (post) {
this.postStages = this.filteredStages(false, true);
}
}
showSaveBtn(): boolean {
return this.workflow && this.workflow.ObjectID ?
(this.workflow.HiringTeam === this.adminPortalLayoutService.getHiringTeamID().ObjectID ||
!this.editMode) : false;
}
showSaveCopyBtn(): boolean {
return this.workflow && this.workflow.ObjectID ?
(!!this.workflow.HiringTeam) : false;
}
getStageHeader(stage: WorkflowStageModel): string {
return `${stage.Name} (${stage.Steps ? stage.Steps.length : 0})`;
} }
showLabel(id: string): boolean { showLabel(id: string): boolean {
return (this.editField[id] === undefined || this.editField[id] === false); return (this.editField[id] === undefined || this.editField[id] === false);
} }
showStageLabel(id: string, stage: WorkflowStageModel): boolean {
if (stage.StageType.IsPreStage || stage.StageType.IsPostStage) {
return true;
} else {
return this.showLabel(id);
}
}
showStageInput(id: string, stage: WorkflowStageModel): boolean {
if (stage.StageType.IsPreStage || stage.StageType.IsPostStage) {
return false;
} else {
return this.showInput(id);
}
}
showDelayInput(id: string, message: WorkflowMessageModel): boolean {
if (!message.Delay || message.Delay === '') {
return true;
} else {
return this.editField ? (this.editField[id] ? this.editField[id] : true) : true;
}
}
showDelayLabel(id: string, message: WorkflowMessageModel): boolean {
if (!message.Delay || message.Delay === '') {
return false;
} else {
return this.editField ? (this.editField[id] ? this.editField[id] : false) : false;
}
}
filteredStages(isPreStage: boolean, isPostStage: boolean): Array<WorkflowStageModel> {
return this.workflow && this.workflow.WorkFlowStages ? (
(!isPreStage && !isPostStage) ?
this.workflow.WorkFlowStages.filter(stage => !stage.StageType.IsPreStage && !stage.StageType.IsPostStage)
: isPreStage ?
this.workflow.WorkFlowStages.filter(stage => stage.StageType.IsPreStage) :
isPostStage ?
this.workflow.WorkFlowStages.filter(stage => stage.StageType.IsPostStage) : []) : [];
}
emailResponseSelected(): boolean {
return this.workflow.ApplicationResponseAction &&
this.workflow.ApplicationResponseAction.Value === 'EMAIL_RESPONSE';
}
showInput(id: string): boolean { showInput(id: string): boolean {
return this.editField && !!this.editField[id]; return this.editField && !!this.editField[id];
} }
toggleInput(event, fieldName, save = true): void { toggleInput(event, fieldName): void {
this.utilsService.clearErrorMessages(); this.utilsService.clearErrorMessages();
if (event.type === 'blur') { if (event.type === 'blur') {
if (!this.form.controls[fieldName].invalid) { if (!this.form.controls[fieldName].invalid) {
this.editField[fieldName] = false; this.editField[fieldName] = false;
if (save) { } else {
// save call to be sent this.utilsService.showAllErrorMessages();
}
} else {
this.editField[fieldName] = true;
setTimeout(() => {
try {
document.getElementById(`${fieldName}Id`)
.focus();
document.getElementById(`${fieldName}Id`)
.getElementsByTagName('input')[0]
.focus();
} catch (e) {
// ignore this.
} }
}, 0);
}
}
toggleStageInput(event, fieldName, stage: WorkflowStageModel): void {
this.utilsService.clearErrorMessages();
if (event.type === 'blur') {
if (!this.form.controls[fieldName].invalid) {
this.editField[fieldName] = false;
} else { } else {
this.utilsService.showAllErrorMessages(); this.utilsService.showAllErrorMessages();
} }
} else { } else {
if (stage.StageType.IsPreStage || stage.StageType.IsPostStage) {
return;
}
this.editField[fieldName] = true; this.editField[fieldName] = true;
setTimeout(() => { setTimeout(() => {
try { try {
...@@ -151,67 +298,207 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -151,67 +298,207 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
} }
} }
gets(): void { toggleDelayInput(event, fieldName, message: WorkflowMessageModel): void {
this.subscriptions.push(this.editWorkflowTemplateService.getDummy456s([]) this.utilsService.clearErrorMessages();
.subscribe( if (event.type === 'blur') {
data => {
this.s = data; if (!message.Delay || message.Delay === '') {
}, return;
error => { }
this.utilsService.handleError(error);
if (!this.form.controls[fieldName].invalid) {
this.editField[fieldName] = false;
} else {
this.utilsService.showAllErrorMessages();
}
} else {
this.editField[fieldName] = true;
setTimeout(() => {
try {
document.getElementById(`${fieldName}Id`)
.focus();
document.getElementById(`${fieldName}Id`)
.getElementsByTagName('input')[0]
.focus();
} catch (e) {
// ignore this.
} }
}, 0);
}
}
getMessageTemplates(): void {
const sharedMsgParams = {
OnlyGlobalTemplate: true,
attribsByName: 'Autocomplete'
};
const myMsgParams = {
OnlyGlobalTemplate: false,
attribsByName: 'Autocomplete'
};
this.subscriptions.push(
combineLatest(
this.editWorkflowTemplateService.getMessageTemplates([], myMsgParams),
this.editWorkflowTemplateService.getMessageTemplates([], sharedMsgParams)
) )
.subscribe(
(response: [Array<MessageTemplateModel>, Array<MessageTemplateModel>]) => {
const myTemplates = response[0].filter(message => message.HiringTeam ===
this.adminPortalLayoutService.getHiringTeamID().ObjectID);
this.messageTemplates = [...myTemplates, ...response[1]];
const newTemplate = new MessageTemplateModel();
newTemplate.TemplateName = 'New Template';
newTemplate.id = '0';
this.messageTemplates.push(newTemplate);
},
error => {
this.utilsService.handleError(error);
}
)
); );
} }
autoCompleteMessagetemplate(event): void { showMessageTemplateDialog($event): void {
this.subscriptions.push(this.editWorkflowTemplateService.getmessagetemplatesForAutocomplete(event.query, []) const template = $event.value;
.subscribe( if (template.id && template.id === '0') {
data => { this.displayNewMessageTemplate = true;
for (const obj of data) { }
// If you need to display anything complex in autocomplete label, put that code here }
// e.g. obj.Name = obj.FirstName + ' ' + obj.LastName. So that you can use "Name" attribute in HTML
} availableStepTypes(): Array<StepTypeEnum> {
this.messagetemplates = data; const availableStepTypes = this.stepTypeOptions;
}, if (this.workflow.WorkFlowStages) {
error => { this.workflow.WorkFlowStages.forEach(stage => {
this.utilsService.handleError(error); if (stage.Steps) {
stage.Steps.forEach(step => {
if (availableStepTypes.indexOf(step.StepType) > -1) {
availableStepTypes.slice(availableStepTypes.indexOf(step.StepType), 0);
}
});
} }
) });
); }
return availableStepTypes;
} }
autoCompleteMessagetemplate_withdraw(event): void { stageMessagesCount(stage: WorkflowStageModel): string {
this.subscriptions.push(this.editWorkflowTemplateService.getmessagetemplate_withdrawsForAutocomplete(event.query, []) return `Message Schedule (${stage.WorkFlowMessages.length})`;
.subscribe( }
data => {
for (const obj of data) { addStep($event, stage: WorkflowStageModel): void {
// sd
if (!$event.data[0] && $event.data[0].Value !== null) {
return;
}
const selectedStepType = this.stepTypeOptions.find(step => step.Value === $event.data[0].Value);
const step = new WorkflowStepModel(stage.Steps.length + 1, selectedStepType, stage.ObjectID);
this.utilsService.addMultiRefObject(step, stage, 'Steps', this.createdObjs);
this.removeStepType(selectedStepType);
}
removeStep(step: WorkflowStepModel, stage: WorkflowStageModel): void {
const stepType = step.StepType;
this.utilsService.removeMultiRefObject(step, stage, 'Steps', this.createdObjs, this.updatedObjs, this.deletedObjs);
this.reAssignStepOrders(stage);
this.addStepType(stepType);
}
removeStepType(step: StepTypeEnum): void {
this.stepTypes.splice(this.stepTypes.findIndex(elem => elem.Value === step.Value), 1);
this.resetSelect('stepTypes');
}
addStepType(step: StepTypeEnum): void {
this.stepTypes.push(step);
this.resetSelect('stepTypes');
}
reAssignStepOrders(stage: WorkflowStageModel): void {
stage.Steps.map((step, index) => step.SortOrder = index + 1);
}
addMessage(stage: WorkflowStageModel): void {
const message = new WorkflowMessageModel(stage.ObjectID);
this.utilsService.addMultiRefObject(message, stage, 'WorkFlowMessages', this.createdObjs);
}
removeMessage(message: WorkflowMessageModel, stage: WorkflowStageModel): void {
this.confirmationService.confirm({
message: 'Are you sure you want to delete this record?',
header: 'Delete Confirmation',
icon: 'fa fa-trash',
key: 'RemoveRow',
accept: () => {
this.utilsService.removeMultiRefObject(message, stage, 'WorkFlowMessages', this.createdObjs,
this.updatedObjs, this.deletedObjs);
}
});
}
addStage(): void {
const stageType = this.stageTypes.find(type => !type.IsPreStage && !type.IsPostStage);
const stage = new WorkflowStageModel(`${stageType.Description} Stage`, false, stageType, this.getStageOrder(),
false, this.workflow.ObjectID);
this.utilsService.addMultiRefObject(stage, this.workflow, 'WorkFlowStages', this.createdObjs);
this.filterStages(false, true, false);
}
removeStage(stage: WorkflowStageModel): void {
this.confirmationService.confirm({
message: 'Are you sure you want to delete this record?',
header: 'Delete Confirmation',
icon: 'fa fa-trash',
key: 'RemoveRow',
accept: () => {
if (this.isGeneric(stage)) {
const decrement = this.workflow.WorkFlowStages.filter(stg => this.isGeneric(stg))
.length - stage.SortOrder;
if (decrement > 0) {
this.workflow.WorkFlowStages.map(stg => {
if (this.isGeneric(stg) && stg.SortOrder > decrement) {
stg.SortOrder = stg.SortOrder - decrement;
}
});
} }
this.messagetemplate_withdraws = data; this.reOrderStages(this.filterStages(false, true, false));
},
error => {
this.utilsService.handleError(error);
} }
) this.utilsService.removeMultiRefObject(stage, this.workflow, 'WorkFlowStages', this.createdObjs,
); this.updatedObjs, this.deletedObjs);
}
});
} }
getWorkflowTemplateByID(id): void { getStageOrder(): number {
return this.workflow && this.workflow.WorkFlowStages ? (
this.workflow.WorkFlowStages.filter(stage => this.isGeneric(stage))
.length + 1
) : 0;
}
resetSelect(key: string): void {
const temp = this[key];
this[key] = [];
setTimeout(() => (this[key] = temp), 0);
}
getWorkflowTemplateByID(id): void {
this.showLoader = true; this.showLoader = true;
this.createdObjs = {}; this.createdObjs = {};
this.updatedObjs = {}; this.updatedObjs = {};
this.deletedObjs = {}; this.deletedObjs = {};
this.utilsService.resetCounter(); this.utilsService.resetCounter();
this.utilsService.clearErrorMessages(); this.utilsService.clearErrorMessages();
this.subscriptions.push(this.editWorkflowTemplateService.getWorkflowTemplateByID(id, []) this.subscriptions.push(this.editWorkflowTemplateService.getWorkflowTemplateByID(id, [])
.subscribe( .subscribe(
data => { data => {
this.workflowTemplate = data; this.workflow = data;
this.updatedObjs[this.workflowTemplate.ObjectID] = this.workflowTemplate; this.updatedObjs[this.workflow.ObjectID] = this.workflow;
this.showLoader = false; this.showLoader = false;
}, },
error => { error => {
...@@ -222,29 +509,30 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -222,29 +509,30 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
); );
} }
saveWorkflowTemplate(reload: boolean): void { getMessageClass(message: MessageTemplateModel): string {
return message.TemplateType ? `ui-icon-${message.TemplateType.Value.toLowerCase()}` :
'ui-icon-sms';
}
saveWorkflowTemplate(saveCopy = false, testing = true): void {
this.utilsService.clearErrorMessages(); this.utilsService.clearErrorMessages();
const service = `svc/${saveCopy ? SERVICES.SAVE_MESSAGE_AS_COPY : SERVICES.SAVE}`;
if (testing) {
this.showLogs();
return;
}
if (this.form.invalid) { if (this.form.invalid) {
this.utilsService.showAllErrorMessages(); this.utilsService.showAllErrorMessages();
} else { } else {
this.showLoader = true; this.showLoader = true;
this.subscriptions.push(this.saveService.saveObjectsWithDefaultSvc(this.createdObjs, this.updatedObjs, this.deletedObjs) this.subscriptions.push(this.saveService.saveObjects(service, this.createdObjs, this.updatedObjs, this.deletedObjs)
.subscribe( .subscribe(
data => { () => {
this.utilsService.handleSuccess(); this.utilsService.handleSuccess();
if (reload) { this.router.navigate(['/admin/list-workflow-templates']);
let idToNavigate = this.workflowTemplate.ObjectID;
if (data.created[idToNavigate]) {
idToNavigate = data.created[idToNavigate];
this.router.navigate(['/edit-workflow-template', idToNavigate]);
return;
}
this.getWorkflowTemplateByID(idToNavigate);
} else {
this.router.navigate(['']);
}
}, },
error => { error => {
this.showLoader = false; this.showLoader = false;
...@@ -256,6 +544,12 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn ...@@ -256,6 +544,12 @@ export class EditWorkflowTemplateComponent extends BaseComponent implements OnIn
} }
showLogs(): void { showLogs(): void {
console.log(this.workflow); console.log(this.workflow.WorkFlowStages);
} }
alreadyExists(): boolean {
return Object.keys(this.createdObjs).length > 0 || Object.keys(this.updatedObjs).length > 0;
}
// tslint:disable-next-line:max-file-line-count
} }
export class WorkflowTemplate {
ObjectID: string;
ButtonText: string;
HeaderText: string;
CaptureCV: boolean;
MandatoryCV: boolean;
CaptureCoverLetter: boolean;
Mandatorycoverletter: boolean;
HeaderTextforThankYoupage: string;
SecondaryText: string;
Automaticallyprogresstonextstage: boolean;
Hrs1: string;
BusinessHrsOnly: boolean;
Messagetemplate: any;
Hrswithdraw: string;
Variationwithdraw: string;
Messagetemplate_withdraw: any;
Usemessaging: boolean;
Dummy457: string;
messagetemplate_withdraw: string;
messagetemplate: string;
Dummy461: string;
}
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { SERVICES } from "../../constants";
import { MessageTemplateModel } from "../../models/messageTemplate.model";
import { SearchService } from '../../oneit/services/search.service'; import { SearchService } from '../../oneit/services/search.service';
import { UtilsService } from '../../oneit/services/utils.service'; import { UtilsService } from '../../oneit/services/utils.service';
...@@ -12,11 +14,10 @@ export class EditWorkflowTemplateService { ...@@ -12,11 +14,10 @@ export class EditWorkflowTemplateService {
) { ) {
} }
getDummy456s(assocs): Observable<any> { getMessageTemplates(assocs, queryParam): Observable<Array<MessageTemplateModel>> {
return this.searchService.getObjects('MessageTemplates', 'All', {}, assocs, null, null, null, null) return this.searchService.getObjects(SERVICES.MESSAGE_TEMPLATES, 'All', queryParam, assocs, 'Autocomplete', null, null, null)
.map( .map(
data => data => this.utilsService.convertResponseToObjects(data, assocs)
this.utilsService.convertResponseToObjects(data, assocs)
); );
} }
......
...@@ -24,7 +24,7 @@ export class ErrorMessageComponent implements OnInit { ...@@ -24,7 +24,7 @@ export class ErrorMessageComponent implements OnInit {
this.subscriptions.push( this.subscriptions.push(
this.msgsService.errorMsgsUpdated.subscribe( this.msgsService.errorMsgsUpdated.subscribe(
data => { data => {
console.log(data); // console.log(data);
this.errorMsgs = data; this.errorMsgs = data;
} }
) )
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { combineLatest } from 'rxjs/observable/combineLatest';
import { Subscription } from 'rxjs/Subscription'; import { Subscription } from 'rxjs/Subscription';
import { AppService } from '../../app.service'; import { AppService } from '../../app.service';
import { SEARCH, SERVICES } from '../../constants'; import { SEARCH, SERVICES } from '../../constants';
...@@ -7,6 +8,7 @@ import { MessageTemplateModel } from '../../models/messageTemplate.model'; ...@@ -7,6 +8,7 @@ import { MessageTemplateModel } from '../../models/messageTemplate.model';
import { SorterModel } from '../../models/sorterModel'; import { SorterModel } from '../../models/sorterModel';
import { SearchService } from '../../oneit/services/search.service'; import { SearchService } from '../../oneit/services/search.service';
import { UtilsService } from '../../oneit/services/utils.service'; import { UtilsService } from '../../oneit/services/utils.service';
import { AdminPortalLayoutService } from '../admin-portal/admin-portal-layout/admin-portal-layout.service';
import { BaseComponent } from '../base/base.component'; import { BaseComponent } from '../base/base.component';
@Component({ @Component({
...@@ -20,13 +22,15 @@ export class ListMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -20,13 +22,15 @@ export class ListMessageTemplateComponent extends BaseComponent implements OnIni
sharedTemplates: Array<MessageTemplateModel> = []; sharedTemplates: Array<MessageTemplateModel> = [];
sortOptions: Array<SorterModel>; sortOptions: Array<SorterModel>;
showLoader = false; showLoader = false;
processing = false;
constructor( constructor(
private router: Router, private router: Router,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private utilsService: UtilsService, private utilsService: UtilsService,
private searchService: SearchService, private searchService: SearchService,
private appService: AppService private appService: AppService,
private adminPortalLayoutService: AdminPortalLayoutService
) { ) {
super(utilsService); super(utilsService);
} }
...@@ -37,6 +41,24 @@ export class ListMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -37,6 +41,24 @@ export class ListMessageTemplateComponent extends BaseComponent implements OnIni
new SorterModel('Alphabetical (Z-A)', false) new SorterModel('Alphabetical (Z-A)', false)
]; ];
this.showLoader = true; this.showLoader = true;
this.processing = true;
this.startComponent();
this.subscriptions.push(this.adminPortalLayoutService.userDataUpdated
.subscribe(
() => {
this.startComponent();
}
));
}
startComponent(): void {
if (!this.processing) {
return;
}
this.processing = false;
const sharedMsgParams = { const sharedMsgParams = {
OnlyGlobalTemplate: true OnlyGlobalTemplate: true
}; };
...@@ -45,33 +67,21 @@ export class ListMessageTemplateComponent extends BaseComponent implements OnIni ...@@ -45,33 +67,21 @@ export class ListMessageTemplateComponent extends BaseComponent implements OnIni
}; };
this.subscriptions.push( this.subscriptions.push(
this.appService.getSearchListing(SERVICES.MESSAGE_TEMPLATES, 'All', myMsgParams, [], SEARCH.MESSAGE_TEMPLATE) combineLatest(
this.appService.getSearchListing(SERVICES.MESSAGE_TEMPLATES, 'All', myMsgParams, [], SEARCH.MESSAGE_TEMPLATE),
this.appService.getSearchListing(SERVICES.MESSAGE_TEMPLATES, 'All', sharedMsgParams, [], SEARCH.MESSAGE_TEMPLATE)
)
.subscribe( .subscribe(
messages => { (response: [Array<MessageTemplateModel>, Array<MessageTemplateModel>]) => {
this.myTemplates = messages; this.myTemplates = response[0].filter(message => message.HiringTeam ===
this.adminPortalLayoutService.getHiringTeamID().ObjectID);
this.sharedTemplates = response[1];
this.sortSpecificTemplate('myTemplates'); this.sortSpecificTemplate('myTemplates');
},
error => {
this.showLoader = false;
this.utilsService.handleError(error);
}
)
);
this.subscriptions.push(
this.appService
.getSearchListing(SERVICES.MESSAGE_TEMPLATES, 'All', sharedMsgParams, [], SEARCH.MESSAGE_TEMPLATE)
.subscribe(
messages => {
this.sharedTemplates = messages;
this.sortSpecificTemplate('sharedTemplates'); this.sortSpecificTemplate('sharedTemplates');
},
error => {
this.showLoader = false; this.showLoader = false;
this.utilsService.handleError(error);
} }
) )
); );
setTimeout(() => (this.showLoader = false), 0);
} }
sortSpecificTemplate(arrayName: string): void { sortSpecificTemplate(arrayName: string): void {
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { combineLatest } from 'rxjs/observable/combineLatest';
import { Subscription } from 'rxjs/Subscription'; import { Subscription } from 'rxjs/Subscription';
import { AppService } from '../../app.service'; import { AppService } from '../../app.service';
import { SEARCH, SERVICES } from '../../constants'; import { SEARCH, SERVICES } from '../../constants';
import { SorterModel } from '../../models/sorterModel'; import { SorterModel } from '../../models/sorterModel';
import { WorkflowTemplateModel } from '../../models/workflowTemplate.model'; import { WorkflowTemplateModel } from '../../models/workflowTemplate.model';
import { UtilsService } from '../../oneit/services/utils.service'; import { UtilsService } from '../../oneit/services/utils.service';
import { AdminPortalLayoutService } from '../admin-portal/admin-portal-layout/admin-portal-layout.service';
import { BaseComponent } from '../base/base.component'; import { BaseComponent } from '../base/base.component';
@Component({ @Component({
...@@ -19,11 +21,13 @@ export class ListWorkFlowsComponent extends BaseComponent implements OnInit { ...@@ -19,11 +21,13 @@ export class ListWorkFlowsComponent extends BaseComponent implements OnInit {
sharedTemplates: Array<WorkflowTemplateModel> = []; sharedTemplates: Array<WorkflowTemplateModel> = [];
sortOptions: Array<SorterModel>; sortOptions: Array<SorterModel>;
showLoader = false; showLoader = false;
processing = false;
constructor( constructor(
private router: Router, private router: Router,
private utilsService: UtilsService, private utilsService: UtilsService,
private appService: AppService private appService: AppService,
private adminPortalLayoutService: AdminPortalLayoutService
) { ) {
super(utilsService); super(utilsService);
} }
...@@ -33,31 +37,48 @@ export class ListWorkFlowsComponent extends BaseComponent implements OnInit { ...@@ -33,31 +37,48 @@ export class ListWorkFlowsComponent extends BaseComponent implements OnInit {
new SorterModel('Alphabetical (A-Z)', true), new SorterModel('Alphabetical (A-Z)', true),
new SorterModel('Alphabetical (Z-A)', false) new SorterModel('Alphabetical (Z-A)', false)
]; ];
this.showLoader = true;
this.processing = true;
this.startComponent();
this.subscriptions.push(this.adminPortalLayoutService.userDataUpdated
.subscribe(
() => {
this.startComponent();
}
));
}
startComponent(): void {
if (!this.processing) {
return;
}
this.processing = false;
const sharedParams = { const sharedParams = {
OnlyGlobalTemplates: true OnlyGlobalTemplates: true
}; };
const myParams = { const myParams = {
OnlyGlobalTemplates: false OnlyGlobalTemplates: false
}; };
this.subscriptions.push( this.subscriptions.push(
this.appService.getSearchListing(SERVICES.WORKFLOW_TEMPLATES, 'All', myParams, [], SEARCH.WORKFLOW_TEMPLATE) combineLatest(
this.appService.getSearchListing(SERVICES.WORKFLOW_TEMPLATES, 'All', myParams, [], SEARCH.WORKFLOW_TEMPLATE),
this.appService.getSearchListing(SERVICES.WORKFLOW_TEMPLATES, 'All', sharedParams, [], SEARCH.WORKFLOW_TEMPLATE)
)
.subscribe( .subscribe(
messages => { (response: [Array<WorkflowTemplateModel>, Array<WorkflowTemplateModel>]) => {
this.myTemplates = messages; this.myTemplates = response[0].filter(wf => wf.HiringTeam ===
this.adminPortalLayoutService.getHiringTeamID().ObjectID);
this.sortSpecificTemplate('myTemplates'); this.sortSpecificTemplate('myTemplates');
}, this.sharedTemplates = response[1];
error => {
this.showLoader = false;
this.utilsService.handleError(error);
}
)
);
this.subscriptions.push(
this.appService.getSearchListing(SERVICES.WORKFLOW_TEMPLATES, 'All', sharedParams, [], SEARCH.WORKFLOW_TEMPLATE)
.subscribe(
messages => {
this.sharedTemplates = messages;
this.sortSpecificTemplate('sharedTemplates'); this.sortSpecificTemplate('sharedTemplates');
const val = this.myTemplates.map(m => m.ObjectID)
.join(',');
console.log(val);
this.showLoader = false;
}, },
error => { error => {
this.showLoader = false; this.showLoader = false;
...@@ -65,7 +86,6 @@ export class ListWorkFlowsComponent extends BaseComponent implements OnInit { ...@@ -65,7 +86,6 @@ export class ListWorkFlowsComponent extends BaseComponent implements OnInit {
} }
) )
); );
setTimeout(() => (this.showLoader = false), 0);
} }
sortSpecificTemplate(arrayName: string): void { sortSpecificTemplate(arrayName: string): void {
......
...@@ -4,7 +4,10 @@ export const CLASSES = { ...@@ -4,7 +4,10 @@ export const CLASSES = {
APPLICATION_STATUS: 'performa.orm.types.ApplicationStatus', APPLICATION_STATUS: 'performa.orm.types.ApplicationStatus',
HIRING_TEAM: 'performa.orm.HiringTeam', HIRING_TEAM: 'performa.orm.HiringTeam',
PLACEHOLDER_OPTIONS: 'performa.orm.types.PlaceholderOptions', PLACEHOLDER_OPTIONS: 'performa.orm.types.PlaceholderOptions',
WORKFLOW_TEMPLATE: 'performa.orm.WorkFlowTemplate' WORKFLOW_TEMPLATE: 'performa.orm.WorkFlowTemplate',
WORKFLOW_MESSAGE: 'performa.orm.WorkFlowMessage',
WORKFLOW_STAGE: 'performa.orm.WorkFlowStage',
WORKFLOW_STEP: 'performa.orm.WorkFlowStep'
}; };
export const SERVICES = { export const SERVICES = {
......
import { CLASSES } from '../constants';
import { MessageTemplateModel } from './messageTemplate.model';
export class WorkflowMessageModel {
ObjectID: string;
ObjectClass = CLASSES.WORKFLOW_MESSAGE;
Delay: string;
Variance: string;
BusinessHoursOnly: boolean;
IsWithdrawalMessage: boolean;
ApplicantSources: any;
MessageTemplate: MessageTemplateModel | string;
WorkFlowStage: string;
constructor(wfStageID: string) {
this.WorkFlowStage = wfStageID;
}
}
import { CLASSES } from '../constants';
import { StageTypeEnum } from './stageType.enum';
import { WorkflowMessageModel } from './workflowMessage.model';
import { WorkflowStepModel } from './workflowStep.model';
export class WorkflowStageModel {
ObjectID: string;
ObjectClass = CLASSES.WORKFLOW_STAGE;
Name: string;
UseMessaging: boolean;
StageType: StageTypeEnum;
SortOrder: number;
AutoProgress: boolean;
WorkFlowTemplate: string; // ID of WorkflowTemplateModel
WorkFlowMessages: Array<WorkflowMessageModel>;
Steps: Array<WorkflowStepModel>;
constructor(name: string, useMsg: boolean, stage: StageTypeEnum, order: number, autoProgress: boolean,
templateID: string) {
this.Name = name;
this.UseMessaging = useMsg;
this.StageType = stage;
this.SortOrder = order;
this.AutoProgress = autoProgress;
this.WorkFlowTemplate = templateID;
this.Steps = [];
this.WorkFlowMessages = [];
}
}
import { CLASSES } from '../constants';
import { StepTypeEnum } from './stepType.enum';
export class WorkflowStepModel {
ObjectID: string;
ObjectClass = CLASSES.WORKFLOW_STEP;
SortOrder: number;
StepType: StepTypeEnum;
WorkFlowStage: string; // ID of WorkflowStageModel
constructor(order: number, step: StepTypeEnum, stageID: string) {
this.SortOrder = order;
this.StepType = step;
this.WorkFlowStage = stageID;
}
}
import { CLASSES } from '../constants'; import { CLASSES } from '../constants';
import { HiringTeamModel } from './hiringTeam.model'; import { HiringTeamModel } from './hiringTeam.model';
import { ResponseActionEnum } from './responseAction.enum'; import { ResponseActionEnum } from './responseAction.enum';
import { WorkflowMessageModel } from './workflowMessage.model';
import { WorkflowStageModel } from './workflowStage.model';
export class WorkflowTemplateModel { export class WorkflowTemplateModel {
ObjectID: string; ObjectID: string;
...@@ -19,8 +21,7 @@ export class WorkflowTemplateModel { ...@@ -19,8 +21,7 @@ export class WorkflowTemplateModel {
JobOutlineButtonText: string; JobOutlineButtonText: string;
RelatedToJob: boolean; RelatedToJob: boolean;
IsSystemGenerated: boolean; IsSystemGenerated: boolean;
WithdrawalMessage: string;
HiringTeam: HiringTeamModel | string; HiringTeam: HiringTeamModel | string;
WorkFlowStages: Array<string>; WorkFlowStages: Array<WorkflowStageModel>;
Jobs: Array<string>; Jobs: Array<string>;
} }
...@@ -10,6 +10,33 @@ ...@@ -10,6 +10,33 @@
white-space: nowrap; white-space: nowrap;
} }
::ng-deep {
.ui-inputswitch {
height: 18px;
width: 36px !important;
overflow: visible;
background-color: #9e9e9e;
border-color: #9e9e9e;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
}
.ui-inputswitch-slider {
&:before {
border-radius: 50%;
position: absolute;
content: "";
height: 15px;
width: 15px;
left: 1px;
bottom: 0;
background-color: white;
transition: .4s;
}
}
}
.w-80 { .w-80 {
width: 80% !important; width: 80% !important;
} }
......
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