{"version":3,"file":"app-6de9ed0c.9729664bca28a8e6916d.bundle.js","mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAoBA;AAAA;AAlBA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAIA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAGA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AA9EA;;;;;;;;;;;;;;;;;;ACTA;AACA;AACA;AAEA;AASA;AAAA;AAPA;AACA;AAEA;AACA;AAIA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAnFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AA4BA;AAAA;AA1BA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAGA;AAEA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAGA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AAEA;AACA;AAEA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAvIA;AAAA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;AC1BA;AACA;AACA;AACA;AACA;AAEA;AAUA;AAAA;AARA;AACA;AACA;AAEA;AACA;AAIA;AAEA;AACA;AAEA;AAIA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAzDA;;;;;;;;;;;;;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AAEA;AAUA;AAAA;AARA;AACA;AACA;AAEA;AACA;AAIA;AACA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA3EA;;;;;;;;;;;;;;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAWA;AAAA;AATA;AACA;AACA;AACA;AACA;AAEA;AAIA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAGA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAzEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAcA;AAAA;AAAA;AAAA;AAAA;AARA;AACA;AACA;AACA;AAEA;AAIA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAnJA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACpBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AA+BA;AAAA;AA7BA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAKA;AAEA;AAAA;AAAA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAAA;AACA;AAEA;AACA;AACA;AAmCA;AACA;AACA;AAlCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAEA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA9qBA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;ACrCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACPA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA","sources":["webpack://www.zeusteam.com/./src/resources/elements/pipelines/dialogs/copy-pipeline.js","webpack://www.zeusteam.com/./src/resources/elements/pipelines/dialogs/edit-pipeline-person.js","webpack://www.zeusteam.com/./src/resources/elements/pipelines/dialogs/edit-pipeline.js","webpack://www.zeusteam.com/./src/resources/elements/pipelines/dialogs/edit-stage.js","webpack://www.zeusteam.com/./src/resources/elements/pipelines/dialogs/reorder-pipeline.js","webpack://www.zeusteam.com/./src/resources/elements/pipelines/dialogs/share-pipeline.js","webpack://www.zeusteam.com/./src/resources/elements/pipelines/pipelines.js","webpack://www.zeusteam.com/./src/resources/elements/pipelines/stages.js","webpack://www.zeusteam.com/./src/resources/elements/pipelines/pipelines.scss","webpack://www.zeusteam.com/./src/resources/elements/pipelines/stages.scss","webpack://www.zeusteam.com/./src/resources/elements/pipelines/dialogs/copy-pipeline.html","webpack://www.zeusteam.com/./src/resources/elements/pipelines/dialogs/edit-pipeline-person.html","webpack://www.zeusteam.com/./src/resources/elements/pipelines/dialogs/edit-pipeline.html","webpack://www.zeusteam.com/./src/resources/elements/pipelines/dialogs/edit-stage.html","webpack://www.zeusteam.com/./src/resources/elements/pipelines/dialogs/reorder-pipeline.html","webpack://www.zeusteam.com/./src/resources/elements/pipelines/dialogs/share-pipeline.html","webpack://www.zeusteam.com/./src/resources/elements/pipelines/pipelines.html","webpack://www.zeusteam.com/./src/resources/elements/pipelines/stages.html"],"sourcesContent":["import { DialogController } from 'aurelia-dialog';\r\nimport { NewInstance } from 'aurelia-dependency-injection';\r\nimport { ValidationRules, ValidationController } from 'aurelia-validation';\r\nimport { BootstrapFormValidationRenderer } from 'validation/bootstrap-form-validation-renderer';\r\nimport { Security } from 'common/security';\r\nimport { Pipelines } from 'services/pipelines';\r\nimport { I18n } from 'common/i18n';\r\nimport { PERSON_TYPE } from 'common/constants';\r\n\r\nexport class CopyPipeline {\r\n static inject = [DialogController, Pipelines, Security, I18n, NewInstance.of(ValidationController)];\r\n dialogController;\r\n validationController;\r\n _pipelines;\r\n security;\r\n _i18n;\r\n\r\n name;\r\n personType;\r\n description;\r\n color;\r\n code;\r\n showPersonProperties;\r\n \r\n personPropertyOptions = [];\r\n personPropertyTagOptions = [];\r\n personProperties = [];\r\n personPropertyTags = [];\r\n\r\n constructor(dialogController, pipelines, security, i18n, validationController) {\r\n this.dialogController = dialogController;\r\n this.security = security;\r\n this._pipelines = pipelines;\r\n this._i18n = i18n;\r\n\r\n\t\tthis.validationController = validationController;\r\n\t\tthis.validationController.addRenderer(new BootstrapFormValidationRenderer());\r\n\r\n\t\tValidationRules\r\n .ensure('name').required()\r\n .on(this);\r\n }\r\n\r\n activate(model) {\r\n this.pipeline = model.pipeline;\r\n this.personType = this.pipeline.personType;\r\n this.name = this.pipeline.name + ' - Copy';\r\n this.description = this.pipeline.description;\r\n this.showPersonProperties = this.pipeline.showPersonProperties || [];\r\n this.color = this.pipeline.color;\r\n\r\n const pp = PERSON_TYPE.properties(this.personType);\r\n this.personPropertyOptions = pp?.tagOptions() ?? [];\r\n this.personPropertyTagOptions = [];\r\n this.personPropertyOptions.forEach(o => {\r\n if (!o.translation) o.translation = this._i18n.tr(o.translationKey);\r\n this.personPropertyTagOptions.push(o.translation);\r\n });\r\n\r\n this.showPersonProperties.forEach(ap => {\r\n const option = this.personPropertyOptions.find(x => x.id === ap);\r\n if (!option) return;\r\n this.personPropertyTags.push(option.translation);\r\n });\r\n }\r\n\r\n personPropertiesChanged(tags) {\r\n const properties = [];\r\n tags.forEach(t => {\r\n let option = this.personPropertyOptions.find(x => x.translation.toLowerCase() === t.toLowerCase());\r\n if (!option) return;\r\n properties.push(option.id);\r\n });\r\n this.showPersonProperties = properties;\r\n }\r\n\r\n async save() {\r\n try {\r\n const v = await this.validationController.validate();\r\n if (!v.valid) return;\r\n\r\n const pipeline = await this._pipelines.copyPipeline(this.pipeline.id, this.name, this.description, this.color, this.showPersonProperties);\r\n this.dialogController.ok({ pipeline });\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n}\r\n","import { DialogController } from 'aurelia-dialog';\r\nimport { Pipelines } from 'services/pipelines';\r\nimport moment from 'moment';\r\n\r\nexport class EditPipelinePerson {\r\n static inject = [DialogController, Pipelines];\r\n dialogController;\r\n _pipelines;\r\n\r\n name;\r\n color;\r\n deleteText = 'purge';\r\n\r\n constructor(dialogController, pipelines) {\r\n this.dialogController = dialogController;\r\n this._pipelines = pipelines;\r\n }\r\n\r\n activate(model) {\r\n this.pipelineId = model.pipelineId;\r\n this.personType = model.personType;\r\n this.personId = model.pipelinePerson.person.id;\r\n this.name = model.pipelinePerson.person.fullName;\r\n this.isArchived = model.pipelinePerson.isArchived;\r\n this.originalEnteredStageDate = model.pipelinePerson.enteredStageDate ? model.pipelinePerson.enteredStageDate.substring(0, 10) : '';\r\n this.enteredStageDate = model.pipelinePerson.enteredStageDate ? model.pipelinePerson.enteredStageDate.substring(0, 10) : '';\r\n this.metadata = model.pipelinePerson.metadata;\r\n }\r\n\r\n async save() {\r\n try {\r\n const metadata = Object.assign({}, this.metadata, { enteredStageDate: this.enteredStageDate });\r\n const updatedMetadata = await this._pipelines.savePerson(this.pipelineId, this.personType, this.personId, metadata);\r\n const enteredStageDate = this.originalEnteredStageDate === this.enteredStageDate ? null : moment.utc(this.enteredStageDate).toISOString();\r\n this.dialogController.ok({ metadata: updatedMetadata, enteredStageDate });\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n async archive() {\r\n try {\r\n await this._pipelines.removePerson(this.pipelineId, this.personType, this.personId);\r\n this.dialogController.ok({ archived: true });\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n async purge() {\r\n if (!this.showDeleteConfirm) {\r\n this.showDeleteConfirm = true;\r\n this.deleteText = 'purge-confirm';\r\n return;\r\n }\r\n\r\n this.showDeleteConfirm = false;\r\n if (this.deleting) return;\r\n try {\r\n this.deleting = true;\r\n await this._pipelines.purge(this.pipelineId, this.personId, this.personType);\r\n this.dialogController.ok({ deleted: true });\r\n } catch(err) {\r\n console.log(err);\r\n this.resetDelete();\r\n } finally {\r\n this.deleting = false;\r\n }\r\n }\r\n\r\n async restore() {\r\n if (this.restoring) return;\r\n try {\r\n this.restoring = true;\r\n await this._pipelines.restorePerson(this.pipelineId, this.personId, this.personType);\r\n this.dialogController.ok({ restored: true });\r\n } catch(err) {\r\n console.log(err);\r\n } finally {\r\n this.restoring = false;\r\n }\r\n }\r\n\r\n resetDelete() {\r\n this.showDeleteConfirm = false;\r\n this.deleteText = 'purge';\r\n }\r\n}\r\n","import { observable, computedFrom } from 'aurelia-framework';\r\nimport { DialogController } from 'aurelia-dialog';\r\nimport { NewInstance } from 'aurelia-dependency-injection';\r\nimport { ValidationRules, ValidationController } from 'aurelia-validation';\r\nimport { BootstrapFormValidationRenderer } from 'validation/bootstrap-form-validation-renderer';\r\nimport { Security } from 'common/security';\r\nimport { Pipelines } from 'services/pipelines';\r\nimport { Carriers } from 'services/carriers';\r\nimport { I18n } from 'common/i18n';\r\nimport { PERSON_TYPE } from 'common/constants';\r\n\r\nexport class EditPipeline {\r\n static inject = [DialogController, Pipelines, Carriers, Security, I18n, NewInstance.of(ValidationController)];\r\n dialogController;\r\n validationController;\r\n _pipelines;\r\n _carriers;\r\n security;\r\n _i18n;\r\n\r\n pipelineTemplates = [];\r\n @observable pipelineTemplate;\r\n\r\n PERSON_TYPE = PERSON_TYPE;\r\n\r\n name;\r\n @observable personType;\r\n description;\r\n color;\r\n code;\r\n carriers;\r\n carrierId;\r\n showPersonProperties = [];\r\n \r\n personPropertyOptions = [];\r\n personPropertyTagOptions = [];\r\n personProperties = [];\r\n personPropertyTags = [];\r\n\r\n constructor(dialogController, pipelines, carriers, security, i18n, validationController) {\r\n this.dialogController = dialogController;\r\n this.security = security;\r\n this._pipelines = pipelines;\r\n this._carriers = carriers;\r\n this._i18n = i18n;\r\n\r\n\t\tthis.validationController = validationController;\r\n\t\tthis.validationController.addRenderer(new BootstrapFormValidationRenderer());\r\n\r\n\t\tValidationRules\r\n .ensure('name').required()\r\n .on(this);\r\n }\r\n\r\n async activate(model) {\r\n this.pipeline = model.pipeline;\r\n this.titleKey = this.pipeline.id ? 'edit-pipeline' : 'add-pipeline';\r\n this.name = '';\r\n this.personType = model.personType;\r\n this.description = '';\r\n this.code = null;\r\n this.carrierId = null;\r\n this.color = '';\r\n this.step = '';\r\n if (this.pipeline.id) {\r\n this.name = this.pipeline.name;\r\n this.description = this.pipeline.description;\r\n this.code = this.pipeline.code;\r\n this.carrierId = this.pipeline.carrierId;\r\n this.showPersonProperties = this.pipeline.showPersonProperties || [];\r\n this.color = this.pipeline.color;\r\n this.setStep('create-edit', false);\r\n } else {\r\n this.pipelineTemplates = await this._pipelines.availableTemplates(this.personType);\r\n this.setStep(this.pipelineTemplates.length > 0 ? 'select' : 'create-edit');\r\n }\r\n\r\n this._configurePersonProperties();\r\n this.carriers = await this._carriers.all();\r\n }\r\n\r\n @computedFrom('security')\r\n get showCode() {\r\n return this.security.isAdmin;\r\n }\r\n\r\n @computedFrom('security', 'personType')\r\n get showCarrier() {\r\n return this.security.isAdmin && this.personType === PERSON_TYPE.Agent;\r\n }\r\n\r\n setStep(step, clearName = true) {\r\n this.step = step;\r\n if (clearName) this.name = '';\r\n if (step === 'create-edit') {\r\n this.focusName = true;\r\n }\r\n }\r\n\r\n personTypeChanged() {\r\n const pp = PERSON_TYPE.properties(this.personType);\r\n this.personPropertyOptions = pp?.tagOptions() ?? [];\r\n this._configurePersonProperties();\r\n }\r\n\r\n _configurePersonProperties() {\r\n this.personPropertyTagOptions = [];\r\n this.personPropertyOptions.forEach(o => {\r\n if (!o.translation) o.translation = this._i18n.tr(o.translationKey);\r\n this.personPropertyTagOptions.push(o.translation);\r\n });\r\n\r\n this.personPropertyTags = [];\r\n this.showPersonProperties.forEach(ap => {\r\n const option = this.personPropertyOptions.find(x => x.id === ap);\r\n if (!option) return;\r\n this.personPropertyTags.push(option.translation);\r\n });\r\n }\r\n\r\n personPropertiesChanged(tags) {\r\n const properties = [];\r\n tags.forEach(t => {\r\n let option = this.personPropertyOptions.find(x => x.translation.toLowerCase() === t.toLowerCase());\r\n if (!option) return;\r\n properties.push(option.id);\r\n });\r\n this.showPersonProperties = properties;\r\n }\r\n\r\n async createFromTemplate(pipelineTemplate) {\r\n this.pipelineTemplate = pipelineTemplate;\r\n this.name = this.pipelineTemplate.name;\r\n await this.save();\r\n }\r\n\r\n async save() {\r\n try {\r\n const v = await this.validationController.validate();\r\n if (!v.valid) return;\r\n\r\n let pipeline;\r\n if (this.pipeline.id) {\r\n pipeline = await this._pipelines.editPipeline(this.pipeline.id, this.name, this.personType, this.description, this.color, this.showPersonProperties, this.code, this.carrierId);\r\n } else {\r\n if (this.pipelineTemplate) {\r\n pipeline = await this._pipelines.createPipelineFromTemplate(this.pipelineTemplate.id);\r\n } else {\r\n pipeline = await this._pipelines.createPipeline(this.name, this.personType, this.description, this.color, this.showPersonProperties, this.code, this.carrierId);\r\n }\r\n }\r\n this.dialogController.ok({ pipeline });\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n}\r\n","import { DialogController } from 'aurelia-dialog';\r\nimport { NewInstance } from 'aurelia-dependency-injection';\r\nimport { ValidationRules, ValidationController } from 'aurelia-validation';\r\nimport { BootstrapFormValidationRenderer } from 'validation/bootstrap-form-validation-renderer';\r\nimport { Pipelines } from 'services/pipelines';\r\n\r\nexport class EditStage {\r\n static inject = [DialogController, NewInstance.of(ValidationController), Pipelines];\r\n dialogController;\r\n validationController;\r\n _pipelines;\r\n\r\n name;\r\n expectedDaysInStage;\r\n color;\r\n \r\n constructor(dialogController, validationController, pipelines) {\r\n this.dialogController = dialogController;\r\n\r\n\t\tthis.validationController = validationController;\r\n\t\tthis.validationController.addRenderer(new BootstrapFormValidationRenderer());\r\n\r\n\t\tValidationRules\r\n .ensure('name').required()\r\n .on(this);\r\n\r\n this._pipelines = pipelines;\r\n }\r\n\r\n activate(model) {\r\n this.pipelineId = model.pipelineId;\r\n this.stage = model.stage;\r\n this.titleKey = this.stage.id ? 'edit-stage' : 'add-stage';\r\n this.name = '';\r\n this.expectedDaysInStage;\r\n this.color = '';\r\n if (this.stage.id) {\r\n this.name = this.stage.name;\r\n this.expectedDaysInStage = this.stage.expectedDaysInStage;\r\n this.color = this.stage.color;\r\n }\r\n }\r\n\r\n async save() {\r\n if (this.saving) return;\r\n try {\r\n this.saving = true;\r\n const v = await this.validationController.validate();\r\n if (!v.valid) return;\r\n\r\n let stage;\r\n if (this.stage.id) {\r\n stage = await this._pipelines.editStage(this.pipelineId, this.stage.id, this.name, this.expectedDaysInStage, this.color);\r\n } else {\r\n stage = await this._pipelines.addStage(this.pipelineId, this.name, this.expectedDaysInStage, this.color);\r\n }\r\n this.dialogController.ok({ stage });\r\n } catch (err) {\r\n console.log(err);\r\n } finally {\r\n this.saving = false;\r\n }\r\n }\r\n}\r\n","import { DialogController } from 'aurelia-dialog';\r\nimport { Pipelines } from 'services/pipelines';\r\nimport { AGENT_PROPERTY } from 'common/constants';\r\nimport { LevelNameValueConverter } from 'resources/value-converters/level-name';\r\nimport moment from 'moment';\r\n\r\nexport class ReorderPipeline {\r\n static inject = [DialogController, Pipelines, LevelNameValueConverter];\r\n dialogController;\r\n _pipelines;\r\n _levelNameConverter;\r\n\r\n orderByOptions = [];\r\n orderBy;\r\n sortDirection = 'asc';\r\n\r\n constructor(dialogController, pipelines, levelNameValueConverter) {\r\n this.dialogController = dialogController;\r\n this._pipelines = pipelines;\r\n this._levelNameConverter = levelNameValueConverter;\r\n\r\n this.orderByOptions = AGENT_PROPERTY.tagOptions();\r\n this.orderByOptions.unshift({ id: 'firstName', translationKey: 'profile-first-name', type: 'String' });\r\n this.orderByOptions.unshift({ id: 'lastName', translationKey: 'profile-last-name', type: 'String' });\r\n this.orderByOptions.unshift({ id: 'fullName', translationKey: 'name', type: 'String' });\r\n this.orderByOptions.push({ id: 'enteredStageDate', translationKey: 'entered-stage-date', type: 'Date', obj: 'root' });\r\n this.orderBy = this.orderByOptions[0].id;\r\n }\r\n\r\n activate(model) {\r\n this.pipeline = model.pipeline;\r\n this.stage = model.stage;\r\n }\r\n\r\n async reorder() {\r\n try {\r\n const reorder = [];\r\n this.pipeline.stages.forEach(sl => {\r\n if (this.stage && this.stage.id !== sl.id) return;\r\n const orderedPersonIds = this._sortedPersonIds(sl.persons);\r\n if (orderedPersonIds.length === 0) return;\r\n reorder.push(this._pipelines.orderPersons(this.pipeline.id, sl.id, orderedPersonIds));\r\n });\r\n await Promise.all(reorder);\r\n const option = this.orderByOptions.find(x => x.id === this.orderBy);\r\n const payload = this.stage ? {} : { orderBy: option, sortDirection: this.sortDirection };\r\n this.dialogController.ok(payload);\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n _sortedPersonIds(persons) {\r\n if (!persons || persons.length === 0) return [];\r\n const option = this.orderByOptions.find(x => x.id === this.orderBy);\r\n persons.sort((a, b) => {\r\n let aValue = option.obj === 'root' ? a[option.id] : a.person[option.id];\r\n let bValue = option.obj === 'root' ? b[option.id] : b.person[option.id];\r\n let valueA = this.sortDirection === 'asc' ? aValue : bValue;\r\n let valueB = this.sortDirection === 'asc' ? bValue : aValue;\r\n if (option.type === 'Date') {\r\n let valueAMoment = moment.utc(valueA);\r\n let valueBMoment = moment.utc(valueB);\r\n if (!valueAMoment.isValid()) return -1;\r\n if (!valueBMoment.isValid()) return 1;\r\n return valueAMoment.isBefore(valueBMoment) ? -1 : 1;\r\n } else if (option.type === 'Boolean') {\r\n if (valueA === valueB) return 0;\r\n if (valueA) return 1;\r\n return -1;\r\n } else if (option.type === 'Level') {\r\n let valueANumber = valueA ? valueA.replace(/^\\D+/g, '') : -1;\r\n if (valueANumber === '') valueANumber = -1;\r\n let valueBNumber = valueB ? valueB.replace(/^\\D+/g, '') : -1;\r\n return Number(valueANumber) - Number(valueBNumber);\r\n } else {\r\n return valueA.localeCompare(valueB);\r\n }\r\n });\r\n return persons.map(x => x.person.id);\r\n }\r\n}\r\n","import { DialogController } from 'aurelia-dialog';\r\nimport { NewInstance } from 'aurelia-dependency-injection';\r\nimport { ValidationRules, ValidationController } from 'aurelia-validation';\r\nimport { BootstrapFormValidationRenderer } from 'validation/bootstrap-form-validation-renderer';\r\nimport { Security } from 'common/security';\r\nimport { Pipelines } from 'services/pipelines';\r\nimport { I18n } from 'common/i18n';\r\n\r\nexport class SharePipeline {\r\n static inject = [DialogController, Pipelines, Security, I18n, NewInstance.of(ValidationController)];\r\n dialogController;\r\n validationController;\r\n _pipelines;\r\n security;\r\n _i18n;\r\n\r\n agent;\r\n canEdit = false;\r\n\r\n constructor(dialogController, pipelines, security, i18n, validationController) {\r\n this.dialogController = dialogController;\r\n this.security = security;\r\n this._pipelines = pipelines;\r\n this._i18n = i18n;\r\n\r\n\t\tthis.validationController = validationController;\r\n\t\tthis.validationController.addRenderer(new BootstrapFormValidationRenderer());\r\n\r\n\t\tValidationRules\r\n .ensure('agent').required()\r\n .on(this);\r\n }\r\n\r\n activate(model) {\r\n this.pipeline = model.pipeline;\r\n this._loadCurrentShares();\r\n }\r\n\r\n async _loadCurrentShares() {\r\n try {\r\n this.shares = await this._pipelines.pipelineShares(this.pipeline.id);\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n async toggleCanEdit(share) {\r\n try {\r\n await this._pipelines.sharePipeline(this.pipeline.id, share.agent.id, !share.canEdit);\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n async removeShare(index, share) {\r\n try {\r\n await this._pipelines.removePipelineShare(this.pipeline.id, share.agent.id);\r\n this.shares.splice(index, 1);\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n setCanEdit(canEdit) {\r\n this.canEdit = canEdit;\r\n }\r\n\r\n async save() {\r\n try {\r\n const v = await this.validationController.validate();\r\n if (!v.valid) return;\r\n\r\n await this._pipelines.sharePipeline(this.pipeline.id, this.agent.id, this.canEdit);\r\n this.agent = undefined;\r\n this.canEdit = false;\r\n window.setTimeout(() => this.validationController.reset(), 0);\r\n this._loadCurrentShares();\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n}\r\n","import { bindable } from 'aurelia-framework';\r\nimport { PLATFORM } from 'aurelia-pal';\r\nimport { EventAggregator } from 'aurelia-event-aggregator';\r\nimport { Security } from 'common/security';\r\nimport { Pipelines as PipelinesSvc } from 'services/pipelines';\r\nimport { DialogService } from 'aurelia-dialog';\r\nimport { ConfirmDialog } from 'common/dialogs/confirm/confirm-dialog';\r\nimport { EditPipeline } from './dialogs/edit-pipeline';\r\nimport { CopyPipeline } from './dialogs/copy-pipeline';\r\nimport { SharePipeline } from './dialogs/share-pipeline';\r\nimport { PERSON_TYPE } from 'common/constants';\r\nPLATFORM.moduleName('common/dialogs/confirm/confirm-dialog');\r\nPLATFORM.moduleName('./dialogs/edit-pipeline');\r\nPLATFORM.moduleName('./dialogs/copy-pipeline');\r\nPLATFORM.moduleName('./dialogs/share-pipeline');\r\n\r\nexport class Pipelines {\r\n\tstatic inject = [EventAggregator, Security, PipelinesSvc, DialogService];\r\n @bindable memberId;\r\n @bindable showAddPipeline = false;\r\n @bindable personType = PERSON_TYPE.Agent;\r\n\r\n _ea;\r\n _security;\r\n _pipelines;\r\n _dialogService;\r\n\r\n pipelines = [];\r\n _handlers = [];\r\n\r\n constructor(ea, security, pipelinesSvc, dialogService) {\r\n this._ea = ea;\r\n this._security = security;\r\n this._pipelines = pipelinesSvc;\r\n this._dialogService = dialogService;\r\n }\r\n\r\n attached() {\r\n this._load();\r\n this._handlers.push(this._ea.subscribe('dnd:didEnd', () => {\r\n window.setTimeout(() => this._savePipelineOrdering(), 0);\r\n }));\r\n }\r\n\r\n detached() {\r\n this._handlers.forEach(h => h.dispose());\r\n this._handlers = [];\r\n }\r\n\r\n pipelineAction(key, pipeline, index) {\r\n switch (key) {\r\n case 'share':\r\n this.sharePipeline(pipeline);\r\n break;\r\n case 'edit':\r\n this.editPipeline(pipeline);\r\n break;\r\n case 'delete':\r\n this.deletePipeline(pipeline, index);\r\n break;\r\n case 'copy':\r\n this.copyPipeline(pipeline);\r\n break;\r\n }\r\n }\r\n\r\n async _savePipelineOrdering() {\r\n try {\r\n const orderedIds = [];\r\n this.pipelines.forEach(p => {\r\n orderedIds.push(p.id);\r\n });\r\n await this._pipelines.setPipelineOrdering(orderedIds);\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n async _load() {\r\n try {\r\n this.pipelines = await this._pipelines.pipelines(this.personType, this.memberId);\r\n this.pipelines.forEach(p => this._setPipelineActions(p));\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n _setPipelineActions(pipeline) {\r\n pipeline.actions = [];\r\n if (this._security.isAdmin && pipeline.personType === PERSON_TYPE.Agent) pipeline.actions.push({ key: 'share', name: 'share-pipeline', icon: 'fa-duotone fa-handshake-simple' });\r\n if (pipeline.canEdit) pipeline.actions.push({ key: 'edit', name: 'edit-pipeline', icon: 'fa-duotone fa-pencil' });\r\n if (pipeline.canEdit) pipeline.actions.push({ key: 'copy', name: 'copy-pipeline', icon: 'fa-duotone fa-clone' });\r\n if (pipeline.canDelete) pipeline.actions.push({ key: 'delete', name: 'delete-pipeline', icon: 'fa-duotone fa-trash-alt' });\r\n }\r\n\r\n addPipeline() {\r\n const model = { personType: this.personType, pipeline: {} };\r\n this._dialogService.open({ viewModel: EditPipeline, model, ignoreTransitions: true }).whenClosed(response => {\r\n if (response.wasCancelled) return;\r\n this._setPipelineActions(response.output.pipeline);\r\n this.pipelines.push(response.output.pipeline);\r\n });\r\n }\r\n\r\n async sharePipeline(pipeline) {\r\n try {\r\n const model = { pipeline };\r\n this._dialogService.open({ viewModel: SharePipeline, model, ignoreTransitions: true });\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n async copyPipeline(pipeline) {\r\n try {\r\n const model = { pipeline };\r\n this._dialogService.open({ viewModel: CopyPipeline, model, ignoreTransitions: true }).whenClosed(response => {\r\n if (response.wasCancelled) return;\r\n this.pipelines.push(response.output.pipeline);\r\n });\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n async editPipeline(pipeline) {\r\n try {\r\n const model = { personType: this.personType, pipeline };\r\n this._dialogService.open({ viewModel: EditPipeline, model, ignoreTransitions: true }).whenClosed(async(response) => {\r\n if (response.wasCancelled) return;\r\n pipeline.name = response.output.pipeline.name;\r\n pipeline.description = response.output.pipeline.description;\r\n pipeline.color = response.output.pipeline.color;\r\n pipeline.showAgentProperties = response.output.pipeline.showAgentProperties;\r\n });\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n pipelineEdited(pipeline) {\r\n this.viewPipeline = pipeline;\r\n }\r\n\r\n deletePipeline(pipeline, index) {\r\n const model = { key: 'delete-ats-pipeline', okButtonClass: 'btn-danger', messageObject: { name: pipeline.name } };\r\n\t this._dialogService.open({ viewModel: ConfirmDialog, model, ignoreTransitions: true }).whenClosed(async(response) => {\r\n\t if (response.wasCancelled) return;\r\n\t\t\ttry {\r\n\t\t\t\tawait this._pipelines.deletePipeline(pipeline.id);\r\n this.pipelines.splice(index, 1);\r\n\t\t\t} catch (err) {\r\n console.log(err);\r\n\t\t\t}\r\n });\r\n }\r\n\r\n showPipeline(pipeline) {\r\n this.viewPipeline = pipeline;\r\n }\r\n\r\n hidePipeline() {\r\n this.viewPipeline = undefined;\r\n this._load();\r\n }\r\n}","import { bindable, observable } from 'aurelia-framework';\r\nimport { EventAggregator } from 'aurelia-event-aggregator';\r\nimport { Security } from 'common/security';\r\nimport { Pipelines } from 'services/pipelines';\r\nimport { TemplatingEngine } from 'aurelia-templating';\r\nimport { LpfnUtil } from 'common/utils';\r\nimport { DialogService } from 'aurelia-dialog';\r\nimport { Notifier } from 'common/ui';\r\nimport { SharePipeline } from './dialogs/share-pipeline';\r\nimport { EditPipeline } from './dialogs/edit-pipeline';\r\nimport { CopyPipeline } from './dialogs/copy-pipeline';\r\nimport { ReorderPipeline } from './dialogs/reorder-pipeline';\r\nimport { EditStage } from './dialogs/edit-stage';\r\nimport { EditPipelinePerson } from './dialogs/edit-pipeline-person';\r\nimport { ConfirmDialog } from 'common/dialogs/confirm/confirm-dialog';\r\nimport { c } from 'common/common';\r\nimport { PERSON_TYPE } from 'common/constants';\r\nimport moment from 'moment';\r\nPLATFORM.moduleName('./dialogs/share-pipeline');\r\nPLATFORM.moduleName('./dialogs/edit-pipeline');\r\nPLATFORM.moduleName('./dialogs/copy-pipeline');\r\nPLATFORM.moduleName('./dialogs/reorder-pipeline');\r\nPLATFORM.moduleName('./dialogs/edit-stage');\r\nPLATFORM.moduleName('./dialogs/edit-pipeline-person');\r\nPLATFORM.moduleName('common/dialogs/confirm/confirm-dialog');\r\n\r\nexport class Stages {\r\n static inject = [Element, EventAggregator, Security, Pipelines, TemplatingEngine, DialogService, Notifier]\r\n _element;\r\n _ea;\r\n _security;\r\n _templatingEngine;\r\n _pipelines;\r\n _dialogService;\r\n _notifier;\r\n\r\n @bindable pipelineId;\r\n @observable addPerson;\r\n\r\n PERSON_TYPE = PERSON_TYPE;\r\n\r\n pipeline = { stages: [] };\r\n backlog = [];\r\n _itemViews = [];\r\n\r\n archivedPersons = false;\r\n VIEWS = {\r\n standard: 'view-standard',\r\n compact: 'view-compact',\r\n minimized: 'view-minimized',\r\n };\r\n view = this.VIEWS.standard;\r\n\r\n pipelineActions = [];\r\n _handlers = [];\r\n reordering = false;\r\n\r\n constructor(element, ea, security, pipelines, templatingEngine, dialogService, notifier) {\r\n this._element = element;\r\n this._ea = ea;\r\n this._security = security;\r\n this._pipelines = pipelines;\r\n this._templatingEngine = templatingEngine;\r\n this._dialogService = dialogService;\r\n this._notifier = notifier;\r\n this.id = c.Helpers.uniqueId();\r\n }\r\n\r\n async attached() {\r\n this._isAttached = true;\r\n if (this.pipelineId) await this._load();\r\n this._handlers.push(this._ea.subscribe('dnd:didEnd', () => {\r\n window.setTimeout(() => this._onAfterReorder(), 0);\r\n }));\r\n this._handlers.push(this._ea.subscribe('dnd:willStart', () => {\r\n this.reordering = true;\r\n this._onBeforeReorder();\r\n }));\r\n LpfnUtil.addResizeHandler(this._onResize);\r\n }\r\n\r\n detached() {\r\n this._isAttached = false;\r\n this._handlers.forEach(h => h.dispose());\r\n this._handlers = [];\r\n this.dispose(true);\r\n LpfnUtil.removeResizeHandler(this._setBigButtonView);\r\n }\r\n\r\n _onResize = () => {\r\n this.stageMaxHeightCss = undefined;\r\n this._setStageHeight();\r\n }\r\n\r\n _onBeforeReorder() {\r\n try {\r\n this.dispose(false);\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n async _onAfterReorder() {\r\n try {\r\n const orderedIds = [];\r\n this.pipeline.stages.forEach(sl => {\r\n orderedIds.push(sl.id);\r\n });\r\n await this._pipelines.setStageOrdering(this.pipeline.id, orderedIds);\r\n this.pipeline.stages.forEach(sl => {\r\n const slEl = document.getElementById(`sl-container-${sl.id}`);\r\n const gridStackEl = document.createElement('div');\r\n gridStackEl.id = sl.id;\r\n gridStackEl.style.backgroundColor = sl.stageBackgroundColor;\r\n gridStackEl.style.borderLeft = `1px solid ${sl.placeholderColor}`;\r\n gridStackEl.style.borderRight = `1px solid ${sl.placeholderColor}`;\r\n gridStackEl.classList.add('grid-stack', `grid-stack-${this.id}`, 'zeus-stage');\r\n slEl.appendChild(gridStackEl);\r\n });\r\n this._initializeGrids();\r\n this.stageMaxHeightCss = undefined;\r\n this._setStageHeight();\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n dispose(clearPipeline = true) {\r\n try {\r\n this.archivedPersons = false;\r\n this.orderByKey = undefined;\r\n this.sortDirection = undefined;\r\n this._itemViews.forEach(iv => {\r\n try {\r\n iv.view.detached();\r\n } catch (vErr) {\r\n console.log(vErr);\r\n }\r\n });\r\n if (this._grids) {\r\n try {\r\n this._grids.forEach(g => {\r\n g.offAll();\r\n g.destroy(!clearPipeline);\r\n });\r\n } catch (err2) { /* Do nothing, bug in gridstack where it tries to set the height after removing the grid */ }\r\n this._grids = undefined;\r\n }\r\n if (clearPipeline) {\r\n this.pipeline = { stages: [] };\r\n }\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n pipelineIdChanged() {\r\n if (this._isAttached) this._load();\r\n }\r\n\r\n async _load() {\r\n if (!this.pipelineId) return;\r\n try {\r\n await this._loadPipeline();\r\n this._initializeGrids();\r\n this._setStageHeight();\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n _setStageHeight() {\r\n try {\r\n if (!this.pipeline.stages.length) return;\r\n if (this.stageMaxHeightCss) return;\r\n const firstEl = document.getElementById(this.pipeline.stages[0].id);\r\n const offset = LpfnUtil.offset(firstEl);\r\n const fullHeight = LpfnUtil.getDocumentHeight();\r\n const footerEl = document.getElementById('kt_app_footer');\r\n const footerHeight = LpfnUtil.actualHeight(footerEl);\r\n const maxHeight = fullHeight - footerHeight - offset.top - 50; // buffer\r\n if (maxHeight < 250) {\r\n this.pipeline.stages.forEach(sl => {\r\n document.getElementById(sl.id).style.maxHeight = '500px';\r\n });\r\n return;\r\n }\r\n this.stageMaxHeightCss = `${maxHeight}px`;\r\n this.pipeline.stages.forEach(sl => {\r\n document.getElementById(sl.id).style.maxHeight = this.stageMaxHeightCss;\r\n });\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n async _loadPipeline() {\r\n if (!this.pipelineId) return;\r\n try {\r\n this.orderByKey = undefined;\r\n this.sortDirection = undefined;\r\n this.pipeline = await this._pipelines.pipeline(this.pipelineId);\r\n\r\n this.pipelineActions = [];\r\n if (this.archivedPersons) this.pipelineActions.push({ key: 'current-persons', name: 'view-current-pipeline', icon: 'fa-duotone fa-wave-pulse' });\r\n if (this.pipeline.canReorderStageCards) this.pipelineActions.push({ key: 'reorder-pipeline', name: 'reorder-pipeline', icon: 'fa-duotone fa-arrow-up-short-wide' });\r\n if (this.pipeline.canEdit) {\r\n if (this._security.isAdmin) this.pipelineActions.push({ key: 'share-pipeline', name: 'share-pipeline', icon: 'fa-duotone fa-handshake-simple' });\r\n this.pipelineActions.push({ key: 'edit-pipeline', name: 'edit-pipeline', icon: 'fa-duotone fa-pencil' });\r\n this.pipelineActions.push({ key: 'copy-pipeline', name: 'copy-pipeline', icon: 'fa-duotone fa-clone' });\r\n this.pipelineActions.push({ key: 'add-stage', name: 'add-stage', icon: 'fa-duotone fa-line-columns' });\r\n }\r\n if (!this.archivedPersons) this.pipelineActions.push({ key: 'archived-persons', name: 'view-archived-pipeline', icon: 'fa-duotone fa-box-archive' });\r\n this.pipelineActions.push({ key: this.VIEWS.standard, name: 'pipeline-view-standard', icon: 'fa-duotone fa-arrows-maximize' });\r\n this.pipelineActions.push({ key: this.VIEWS.compact, name: 'pipeline-view-compact', icon: 'fa-duotone fa-arrows-minimize' });\r\n this.pipelineActions.push({ key: this.VIEWS.minimized, name: 'pipeline-view-minimized', icon: 'fa-duotone fa-arrows-to-dot' });\r\n \r\n const loaders = [\r\n this._pipelines.backlog(this.pipelineId),\r\n ];\r\n this.pipeline.stages.forEach(sl => {\r\n this._addActionsToStage(sl);\r\n loaders.push(this._pipelines.personsInStage(this.pipelineId, sl.id, this.archivedPersons));\r\n });\r\n const data = await Promise.all(loaders);\r\n this.backlog = data[0];\r\n let dataIdx = 1;\r\n this.pipeline.stages.forEach(sl => {\r\n sl.persons = data[dataIdx] || [];\r\n sl.backgroundColor = LpfnUtil.hexToRgbString(sl.color, 0.05);\r\n sl.placeholderColor = LpfnUtil.hexToRgbString(sl.color, 0.5, '#D3D3D3');\r\n sl.stageBackgroundColor = LpfnUtil.hexToRgbString(sl.color, 0.08, '#D3D3D3');\r\n dataIdx++;\r\n });\r\n if (!this.pipeline.stages.length && this.pipeline.canEdit) this._addStage();\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n _addEventsToGrid(grid, i) {\r\n grid\r\n .on('added', async (e, items) => {\r\n try {\r\n if (this._waitForAddedEventForPersonId === items[0].id) {\r\n this._waitForAddedEventForPersonId = undefined;\r\n }\r\n const toStageId = grid.el.id ?? null;\r\n const el = items[0].el; // the initial load may contain multiple - still just need to check the first to know if this is the initial load\r\n const isInitialized = LpfnUtil.hasClass(el, 'zeus-initialized');\r\n const personId = items[0].id || el.id;\r\n const backlogIndex = this.backlog.findIndex(x => x.id === personId);\r\n let currentStageIndex = -1;\r\n let toStageIndex = -1;\r\n let currentStagePersonIndex = -1;\r\n if (backlogIndex < 0) {\r\n toStageIndex = this.pipeline.stages.findIndex(x => x.id === toStageId);\r\n currentStageIndex = 0;\r\n for (let sl of this.pipeline.stages) {\r\n currentStagePersonIndex = sl.persons.findIndex(x => x.person.id === personId);\r\n if (currentStagePersonIndex >= 0) break;\r\n currentStageIndex++;\r\n }\r\n }\r\n let updatedPerson;\r\n if (currentStageIndex !== toStageIndex) {\r\n updatedPerson = await this._pipelines.movePerson(this.pipelineId, this.pipeline.personType, personId, toStageId);\r\n if (currentStageIndex >= 0 && toStageIndex >= 0) {\r\n this.pipeline.stages[toStageIndex].persons.push(updatedPerson);\r\n }\r\n if (backlogIndex >= 0) {\r\n this.backlog.splice(backlogIndex, 1);\r\n } else {\r\n if (currentStagePersonIndex >= 0) {\r\n this.pipeline.stages[currentStageIndex].persons.splice(currentStagePersonIndex, 1);\r\n }\r\n }\r\n }\r\n let currentStage = currentStageIndex >= 0 ? this.pipeline.stages[currentStageIndex] : undefined;\r\n const stageColor = currentStage?.color || '#ccc';\r\n\r\n if (isInitialized) {\r\n await this._reorderPersons(toStageId, e.srcElement);\r\n if (updatedPerson) {\r\n this._setPersonPipelineCard(updatedPerson.person.id, undefined, updatedPerson.metadata?.color, updatedPerson.enteredStageDate, currentStage);\r\n this._updateViewContext(updatedPerson);\r\n }\r\n return;\r\n }\r\n // Need to initialize the widget\r\n for (let item of items) {\r\n let contentEl = item.el.querySelector('.grid-stack-item-content');\r\n contentEl.id = `grid-stack-item-${item.id}`;\r\n contentEl.classList.add('show-on-hover-trigger');\r\n const person = this._personFromPipeline(item.id);\r\n if (person.metadata) this._setPersonPipelineCard(item.id, contentEl, person.metadata.color);\r\n const gradientStops = this._gradientStops(person.percentageOfExpectedTimeInStage);\r\n const enteredStage = person.enteredStageDate ? moment(person.enteredStageDate).format('M/D') : '';\r\n item.el.classList.add('zeus-initialized');\r\n item.el.classList.add('zeus-stage-item');\r\n let innerHTML = '';\r\n if (this.pipeline.canEdit) innerHTML += '';\r\n innerHTML += `