{ "version": 3, "sources": ["src/app/modules/features/editors/packages/package-builder/package-builder.resolver.ts"], "sourcesContent": ["import { Injectable } from '@angular/core';\r\nimport { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\r\nimport { Observable, forkJoin } from 'rxjs';\r\nimport {\r\n PackageFullModel,\r\n AlertsService,\r\n PackageService,\r\n SessionInfoService,\r\n CustomRuleService,\r\n PackageLibraryRuleModel,\r\n SessionKey,\r\n RuleCode,\r\n} from 'degarmo-lib';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class PackageBuilderResolver {\r\n constructor(\r\n private alertsService: AlertsService,\r\n private packageService: PackageService,\r\n private sessionInfoService: SessionInfoService,\r\n private customRuleService: CustomRuleService\r\n ) {}\r\n\r\n resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): PackageFullModel | Observable | Promise {\r\n return this.loadPackageData();\r\n }\r\n\r\n loadPackageData = (): Observable => {\r\n const companyID: number = this.sessionInfoService.getConstant(SessionKey.PackageBuilderCompanyID, 'number', true);\r\n const packageID: number = this.sessionInfoService.getConstant(SessionKey.PackageIDToEdit, 'number', true);\r\n this.sessionInfoService.removeConstant(SessionKey.PrevPackageBuilderData);\r\n return new Observable((subscriber) => {\r\n const promises: any = {\r\n rules: this.customRuleService.getRules({\r\n companyID: companyID,\r\n sets: ['Packages', 'AllowInterviewBuilder', 'ProductUsage'],\r\n }),\r\n };\r\n\r\n if (packageID) promises.packageDetails = this.packageService.getPackageFullDisplayDetails(packageID);\r\n\r\n forkJoin(promises).subscribe({\r\n next: (res: any) => {\r\n const priorities: string[] = ['companyID'];\r\n const rules: PackageLibraryRuleModel = {\r\n useAssessment: this.customRuleService.getPrioritizedRuleValue(RuleCode.UseAssessment, priorities, '0', res.rules) == 1 ? true : false,\r\n useInterviewBuilder:\r\n this.customRuleService.getPrioritizedRuleValue(RuleCode.AllowInterviewBuilder, priorities, '0', res.rules) == 1 ? true : false,\r\n maximumAssessmentPackages: Number(\r\n this.customRuleService.getPrioritizedRuleValue(RuleCode.MaximumAssessmentPackages, priorities, '10', res.rules)\r\n ),\r\n maximumInterviewPackages: Number(\r\n this.customRuleService.getPrioritizedRuleValue(RuleCode.MaximumInterviewPackages, priorities, '10', res.rules)\r\n ),\r\n };\r\n this.sessionInfoService.setConstant(SessionKey.PackageLibraryRules, rules, true);\r\n\r\n if (res.packageDetails) {\r\n this.sessionInfoService.setConstant(SessionKey.PackageBuilderData, res.packageDetails, true);\r\n this.sessionInfoService.setConstant(SessionKey.PrevPackageBuilderData, res.packageDetails, true);\r\n\r\n subscriber.next(res.packageDetails);\r\n } else {\r\n if (!this.sessionInfoService.getConstant(SessionKey.PackageBuilderData, 'object', true)) {\r\n const packageFull: PackageFullModel = {\r\n aorID: 0,\r\n combinedScoring: false,\r\n companyID: 0,\r\n customForms: [],\r\n cutScores: [],\r\n hasDigitalInterviewProduct: false,\r\n isJobMatch: false,\r\n languageID: 1,\r\n languageName: 'English',\r\n packageLanguages: [],\r\n locations: [],\r\n addCombinedPhases: [],\r\n addLocations: [],\r\n combinedPhases: '',\r\n removeCombinedPhases: [],\r\n removeLocations: [],\r\n packageID: 0,\r\n packageName: null,\r\n packageDescription: null,\r\n packageTypes: [],\r\n phases: [],\r\n phaseCount: 0,\r\n reportOptions: [],\r\n statusID: 1,\r\n };\r\n\r\n this.sessionInfoService.setConstant(SessionKey.PackageBuilderData, packageFull, true);\r\n subscriber.next(packageFull);\r\n } else {\r\n subscriber.next(this.sessionInfoService.getConstant(SessionKey.PackageBuilderData, 'object', true));\r\n }\r\n }\r\n\r\n subscriber.complete();\r\n },\r\n });\r\n });\r\n };\r\n}\r\n"], "mappings": ";;;;;;;;;;;;;;AAeM,IAAO,0BAAP,MAAO,wBAAsB;EACjC,YACU,eACA,gBACA,oBACA,mBAAoC;AAHpC,SAAA,gBAAA;AACA,SAAA,iBAAA;AACA,SAAA,qBAAA;AACA,SAAA,oBAAA;AAOV,SAAA,kBAAkB,MAAmC;AACnD,YAAM,YAAoB,K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