{"version":3,"file":"app-1ea6b48a.9729664bca28a8e6916d.bundle.js","mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AASA;AAAA;AAPA;AACA;AACA;AACA;AAKA;AACA;AAEA;AACA;AAEA;AAIA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAnDA;;;;;;;;;;;;;;;;;;;;;;;;;;ACRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAsBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAfA;AACA;AACA;AACA;AACA;AACA;AAAA;AAIA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAKA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;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;AAEA;AACA;AACA;AACA;AACA;AACA;AA/GA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACxBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAkCA;AAAA;AAAA;AA/BA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;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;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AArIA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;ACbA;AACA;AACA;AACA;AACA;AAEA;AAWA;AAAA;AATA;AACA;AAAA;AAAA;AAAA;AAAA;AASA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA3EA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;ACdA;AACA;AAEA;AAUA;AAAA;AAAA;AAAA;AAAA;AALA;AACA;AACA;AAAA;AAIA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;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;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AAlFA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAsBA;AAAA;AApBA;AACA;AACA;AACA;AACA;AAAA;AAKA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAIA;AACA;AACA;AAgCA;AACA;AA9BA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAvKA;AAAA;AAAA;AAAA;AAAA;AAOA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;ACzBA;AACA;AAAA;AAAA;AAAA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AARA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;ACFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAkBA;AAAA;AAhBA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA;AAKA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;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;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;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AA7IA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AA+BA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AACA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;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;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;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;AA3KA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;ACjCA;AACA;AAAA;AAAA;AAAA;AAAA;AAGA;AAFA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;ACHA;AACA;AAAA;AAAA;AAAA;AAEA;AADA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;ACFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;ACPA;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;;;;;;;;;;;ACHA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA","sources":["webpack://www.zeusteam.com/./src/resources/elements/notes/dialogs/edit-note.js","webpack://www.zeusteam.com/./src/resources/elements/notes/notes.js","webpack://www.zeusteam.com/./src/resources/elements/notifications/notifications-button.js","webpack://www.zeusteam.com/./src/resources/elements/notifications/notifications.js","webpack://www.zeusteam.com/./src/resources/elements/onboarding-progress-tracker/onboarding-progress-tracker.js","webpack://www.zeusteam.com/./src/resources/elements/onboarding/onboarding-status-chart.js","webpack://www.zeusteam.com/./src/resources/elements/persistency-percentage/persistency-percentage.js","webpack://www.zeusteam.com/./src/resources/elements/person/person-avatar.js","webpack://www.zeusteam.com/./src/resources/elements/person/person-name.js","webpack://www.zeusteam.com/./src/resources/elements/person/person.js","webpack://www.zeusteam.com/./src/resources/elements/phone/phone.js","webpack://www.zeusteam.com/./src/resources/elements/notes/notes.scss","webpack://www.zeusteam.com/./src/resources/elements/notifications/notifications.scss","webpack://www.zeusteam.com/./src/resources/elements/onboarding-progress-tracker/onboarding-progress-tracker.scss","webpack://www.zeusteam.com/./src/resources/elements/onboarding/onboarding-status-chart.scss","webpack://www.zeusteam.com/./src/resources/elements/person/person-avatar.scss","webpack://www.zeusteam.com/./src/resources/elements/person/person-name.scss","webpack://www.zeusteam.com/./src/resources/elements/notes/dialogs/edit-note.html","webpack://www.zeusteam.com/./src/resources/elements/notes/notes.html","webpack://www.zeusteam.com/./src/resources/elements/notifications/notifications-button.html","webpack://www.zeusteam.com/./src/resources/elements/notifications/notifications.html","webpack://www.zeusteam.com/./src/resources/elements/onboarding-progress-tracker/onboarding-progress-tracker.html","webpack://www.zeusteam.com/./src/resources/elements/onboarding/onboarding-status-chart.html","webpack://www.zeusteam.com/./src/resources/elements/persistency-percentage/persistency-percentage.html","webpack://www.zeusteam.com/./src/resources/elements/person/person-avatar.html","webpack://www.zeusteam.com/./src/resources/elements/person/person-name.html","webpack://www.zeusteam.com/./src/resources/elements/person/person.html","webpack://www.zeusteam.com/./src/resources/elements/phone/phone.html"],"sourcesContent":["import { DialogController } from 'aurelia-dialog';\r\nimport { EventAggregator } from 'aurelia-event-aggregator';\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 { Notes } from 'services/notes';\r\nimport { c } from 'common/common';\r\n\r\nexport class EditNote {\r\n static inject = [EventAggregator, DialogController, NewInstance.of(ValidationController), Notes];\r\n _ea;\r\n dialogController;\r\n validationController;\r\n _notes;\r\n\r\n notes;\r\n \r\n constructor(ea, dialogController, validationController, notes) {\r\n this._ea = ea;\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('note').required()\r\n .on(this);\r\n\r\n this._notes = notes;\r\n }\r\n\r\n activate(model) {\r\n this.type = model.type;\r\n this.aboutId = model.aboutId;\r\n this.titleKey = 'add-note';\r\n this.notes = '';\r\n this.id = undefined;\r\n if (model.note) {\r\n this.id = model.note.id\r\n this.notes = model.note.notes;\r\n this.titleKey = 'edit-note';\r\n }\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 this.saving = true;\r\n await this._notes.save(this.id, this.type, this.aboutId, this.notes);\r\n this._ea.publish(c.EventKeys.notes.updated, { type: this.type, aboutId: this.aboutId });\r\n this.dialogController.ok();\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 { PLATFORM } from 'aurelia-pal';\r\nimport { EventAggregator } from 'aurelia-event-aggregator';\r\nimport { bindable, observable } from 'aurelia-framework';\r\nimport { DialogService } from 'aurelia-dialog';\r\nimport { Notes as NotesService } from 'services/notes';\r\nimport { ConfirmDialog } from 'common/dialogs/confirm/confirm-dialog';\r\nimport { EditNote } from './dialogs/edit-note';\r\nPLATFORM.moduleName('common/dialogs/confirm/confirm-dialog');\r\nPLATFORM.moduleName('./dialogs/edit-note');\r\nimport { c } from 'common/common';\r\n\r\nexport class Notes {\r\n static inject = [Element, EventAggregator, DialogService, NotesService];\r\n @bindable type;\r\n @bindable aboutId;\r\n @bindable minimal = false;\r\n @bindable showAdd = true;\r\n\r\n _element;\r\n _ea;\r\n _dialogService;\r\n _notes;\r\n note;\r\n canAddNote = false;\r\n @observable searchOn;\r\n\r\n noteActions = [\r\n { key: 'delete', name: 'delete' },\r\n { key: 'edit', name: 'edit' }\r\n ];\r\n\r\n _handlers = [];\r\n\r\n constructor(element, ea, dialogService, notes) {\r\n this._element = element;\r\n this._ea = ea;\r\n this._dialogService = dialogService;\r\n this._notes = notes;\r\n }\r\n\r\n attached() {\r\n this._handlers.push(this._ea.subscribe(c.EventKeys.notes.updated, (data) => {\r\n if (this.type !== data.type || this.aboutId !== data.aboutId) return;\r\n this._load();\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 typeChanged() {\r\n this._load();\r\n }\r\n\r\n aboutIdChanged() {\r\n this._load();\r\n }\r\n\r\n async _load() {\r\n if (!this.type || !this.aboutId) return;\r\n try {\r\n const model = await this._notes.list(this.type, this.aboutId);\r\n this.notes = model.notes;\r\n this.notes.forEach(n => n.display = true);\r\n this.canAddNote = model.canAddNote;\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n editNote(note) {\r\n const model = { type: this.type, aboutId: this.aboutId, note };\r\n\t this._dialogService.open({ viewModel: EditNote, model, ignoreTransitions: true }).whenClosed(async(response) => {\r\n\t if (response.wasCancelled) return;\r\n this._dispatchUpdatedEvent();\r\n await this._load();\r\n });\r\n }\r\n\r\n _dispatchUpdatedEvent() {\r\n this._element.dispatchEvent(new CustomEvent('updated', { bubbles: true, detail: {} }));\r\n }\r\n\r\n async deleteNote(note) {\r\n const model = { key: 'delete-note', okButtonClass: 'btn-danger' };\r\n\t this._dialogService.open({ viewModel: ConfirmDialog, model, ignoreTransitions: true }).whenClosed(async(response) => {\r\n\t if (response.wasCancelled) return;\r\n try {\r\n await this._notes.delete(note.id);\r\n this._dispatchUpdatedEvent();\r\n await this._load();\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n });\r\n }\r\n\r\n searchOnChanged() {\r\n try {\r\n if (!this.searchOn) {\r\n this.notes.forEach(n => n.display = true);\r\n return;\r\n }\r\n this.notes.forEach(n => {\r\n let matchesSearch = false;\r\n const rule = `*${this.searchOn.toLowerCase()}*`;\r\n if (this._matches(n.notes.toLowerCase(), rule)) matchesSearch = true;\r\n if (n.byMember) {\r\n if (this._matches(n.byMember.fullName.toLowerCase(), rule)) matchesSearch = true;\r\n }\r\n n.display = matchesSearch;\r\n });\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n _matches(value, rule) {\r\n // https://stackoverflow.com/questions/26246601/wildcard-string-comparison-in-javascript\r\n let escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\\[\\]\\/\\\\])/g, '\\\\$1');\r\n return new RegExp('^' + rule.split('*').map(escapeRegex).join('.*') + '$').test(value);\r\n }\r\n}\r\n","import { bindable } from 'aurelia-framework';\r\nimport { EventAggregator } from 'aurelia-event-aggregator';\r\nimport { Security } from 'common/security';\r\nimport { Tasks } from 'services/tasks';\r\nimport { Messages } from 'services/messages';\r\nimport { ToDos } from 'services/to-dos';\r\nimport { Notifier } from 'common/ui';\r\nimport { Sites } from 'services/sites';\r\nimport { c } from 'common/common';\r\nimport { ROLE } from 'common/constants';\r\n\r\nexport class NotificationsButton {\r\n static inject = [EventAggregator, Security, Tasks, Messages, ToDos, Notifier, Sites];\r\n @bindable router = null;\r\n _ea;\r\n security;\r\n _tasks;\r\n _messages;\r\n _toDos;\r\n _notifier;\r\n _sites;\r\n\r\n showTab = 'tasks';\r\n notificationCount;\r\n\r\n _tasksInitialized;\r\n taskCount = 0;\r\n messageCount = 0;\r\n unopenedMessageCount = 0;\r\n recentMessages;\r\n _toDosInitialized;\r\n toDoCount = 0;\r\n triggerClass = 'btn btn-icon fw-bold';\r\n _triggerClassNoNotifications = 'btn btn-icon btn-light fw-bold';\r\n _triggerClassWithNotifications = 'btn btn-icon btn-primary fw-bold';\r\n\r\n showPulse = false;\r\n _pulseTask;\r\n _pulseMessage;\r\n _pulseToDo;\r\n\r\n _hasPoppedWindow;\r\n\r\n _handlers = [];\r\n\r\n constructor(ea, security, tasks, messages, toDos, notifier, sites) {\r\n this._ea = ea;\r\n this.security = security;\r\n this._tasks = tasks;\r\n this._messages = messages;\r\n this._toDos = toDos;\r\n this._notifier = notifier;\r\n this._sites = sites;\r\n }\r\n\r\n async attached() {\r\n this.theme = await this._sites.theme();\r\n this._handlers.push(this._ea.subscribe(c.EventKeys.loginAuthenticationUpdated, () => this._authenticationChanged()));\r\n this._handlers.push(this._ea.subscribe(c.EventKeys.tasks.updated, () => this._checkForTasks()));\r\n this._handlers.push(this._ea.subscribe(c.EventKeys.messages.updated, (data) => this._checkForMessages(data.showNotification)));\r\n this._handlers.push(this._ea.subscribe(c.EventKeys.toDos.todayUpdated, () => this._checkForToDos()));\r\n this._setNotificationCount();\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 async opened() {\r\n try {\r\n if (this.recentMessages !== undefined) return;\r\n const messages = await this._messages.current();\r\n let ct = 1;\r\n this.recentMessages = [];\r\n messages.forEach(m => {\r\n if (ct > 6) return;\r\n this.recentMessages.push(m);\r\n });\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n close() {\r\n this.closeMenu = new Date().getTime();\r\n return true;\r\n }\r\n\r\n _authenticationChanged() {\r\n if (this.security.isAuthenticated) return; // the bootstrapper will initiate all of the loads\r\n this._hasPoppedWindow = false;\r\n this._tasksInitialized = false;\r\n this._toDosInitialized = false;\r\n }\r\n\r\n _checkForTasks() {\r\n const newTaskCount = this._tasks.current.length;\r\n this._pulseTask = newTaskCount > this.taskCount\r\n this.taskCount = newTaskCount;\r\n this.recentTasks = [];\r\n const recentCount = this.taskCount <= 5 ? this.taskCount : 5;\r\n for (let i = 0; i < recentCount; i++) this.recentTasks.push(this._tasks.current[i]);\r\n this._tasksInitialized = true;\r\n this._setNotificationCount();\r\n }\r\n\r\n _checkForMessages(showNotification = true) {\r\n const newMessageCount = this._messages.counts?.count || 0;\r\n this.unopenedMessageCount = this._messages.counts?.unopened || 0;\r\n this._pulseMessage = showNotification && newMessageCount > this.messageCount && this.unopenedMessageCount > 0;\r\n this.messageCount = newMessageCount;\r\n this._setNotificationCount();\r\n this.recentMessages = undefined;\r\n }\r\n\r\n _checkForToDos() {\r\n const newToDoCount = this._toDos.today.length;\r\n this._pulseToDo = newToDoCount > this.toDoCount;\r\n this.toDoCount = newToDoCount;\r\n this.recentToDos = [];\r\n const recentCount = this.toDoCount <= 5 ? this.toDoCount : 5;\r\n for (let i = 0; i < recentCount; i++) this.recentToDos.push(this._toDos.today[i]);\r\n this._toDosInitialized = true;\r\n this._setNotificationCount();\r\n }\r\n\r\n _setNotificationCount() {\r\n this.notificationCount = this.unopenedMessageCount + this.taskCount + this.toDoCount;\r\n let triggerClass = this.notificationCount > 0 ? this._triggerClassWithNotifications : this._triggerClassNoNotifications;\r\n if ((this._pulseMessage || this._pulseTask || this._pulseToDo) && this.notificationCount > 0) {\r\n triggerClass += ' pulse pulse-white';\r\n this.showPulse = true;\r\n } else {\r\n this.showPulse = false;\r\n }\r\n this.triggerClass = triggerClass;\r\n\r\n if (this._toDosInitialized && this._tasksInitialized && !this._hasPoppedWindow) {\r\n this._hasPoppedWindow = true;\r\n if (this.taskCount + this.toDoCount > 0) {\r\n if (this.toDoCount > 0) this.showTab = 'todos';\r\n this.openWindow = new Date().valueOf();\r\n }\r\n }\r\n }\r\n}\r\n","import { bindable } from 'aurelia-framework';\r\nimport { Calendar } from 'services/calendar';\r\nimport { I18n } from 'common/i18n';\r\nimport moment from 'moment';\r\nimport { TIME_PERIOD } from 'common/constants';\r\n\r\nexport class Notifications {\r\n static inject = [Calendar, I18n];\r\n _calendar;\r\n _i18n;\r\n\r\n @bindable view;\r\n @bindable timePeriod;\r\n @bindable notificationTypes;\r\n @bindable staticHeight = false;\r\n notifications = [];\r\n\r\n constructor(calendar, i18n) {\r\n this._calendar = calendar;\r\n this._i18n = i18n;\r\n }\r\n\r\n attached() {\r\n this._load();\r\n }\r\n\r\n viewChanged(newValue, oldValue) {\r\n if (!oldValue) return;\r\n this._load();\r\n }\r\n\r\n timePeriodChanged(newValue, oldValue) {\r\n if (!oldValue) return;\r\n this._load();\r\n }\r\n\r\n notificationTypesChanged(newValue, oldValue) {\r\n if (!oldValue || newValue === null) return;\r\n if (oldValue && newValue && oldValue === newValue) return;\r\n this._load();\r\n }\r\n\r\n selectTimePeriod(timePeriod, range) {\r\n if (this.timePeriod === TIME_PERIOD.Custom && this.customRange && this.customRange[0].isSame(range[0]) && this.customRange[1].isSame(range[1])) {\r\n return;\r\n }\r\n this.customRange = range;\r\n const loadData = this.timePeriod === timePeriod;\r\n this.timePeriod = timePeriod;\r\n if (loadData) this._load();\r\n }\r\n\r\n async _load() {\r\n try {\r\n if (!this.view || !this.timePeriod || !this.notificationTypes) return;\r\n this.loading = true;\r\n let start;\r\n let end;\r\n if (this.timePeriod === TIME_PERIOD.Custom && this.customRange) {\r\n start = this.customRange[0].format('l');\r\n end = this.customRange[1].format('l');\r\n }\r\n const notifications = await this._calendar.events(this.view, this.timePeriod, this.notificationTypes, start, end);\r\n notifications.forEach(n => {\r\n n.title = this._i18n.tr(n.titleKey);\r\n if (n.isAboutMember) n.aboutFullName = n.aboutMember.fullName;\r\n if (n.isAboutClient) n.aboutFullName = n.aboutClient.fullName;\r\n n.sortByDate = moment(n.date).isValid() ? moment(n.date).year(moment().year()) : n.date;\r\n });\r\n this.notifications = notifications;\r\n const displayTypes = this.notificationTypes ? this.notificationTypes.split(',') : [];\r\n const displayTypesWithCounts = [];\r\n displayTypes.forEach(dt => {\r\n const dtWithCount = {\r\n type: dt,\r\n count: this.notifications.filter(x => x.type === dt).length\r\n };\r\n if (dtWithCount.count > 0) displayTypesWithCounts.push(dtWithCount);\r\n });\r\n this.displayTypes = displayTypesWithCounts;\r\n } catch (err) {\r\n console.log(err);\r\n } finally {\r\n this.loading = false;\r\n }\r\n }\r\n}\r\n","import { bindable } from 'aurelia-framework';\r\nimport { Onboardings } from 'services/onboardings';\r\n\r\nexport class OnboardingProgressTracker {\r\n static inject = [Element, Onboardings];\r\n @bindable tracker;\r\n @bindable memberId;\r\n @bindable refreshMemberId;\r\n _element;\r\n steps;\r\n countsByStep; // contains the number in each step\r\n textEl;\r\n\r\n constructor(element, onboardings) {\r\n this._element = element;\r\n this._onboardings = onboardings;\r\n }\r\n\r\n bind() {\r\n if (!this.tracker && !this.memberId) return;\r\n if (this.memberId) return;\r\n }\r\n\r\n trackerChanged() {\r\n if (!this.tracker) return;\r\n this.countsByStep = this.tracker.countsByStep;\r\n this._style();\r\n }\r\n\r\n memberIdChanged() {\r\n if (!this.memberId) return;\r\n this._loadByMemberId();\r\n }\r\n\r\n refreshMemberIdChanged() {\r\n if (!this.refreshMemberId) return;\r\n this.memberIdChanged();\r\n }\r\n\r\n async attached() {\r\n if (this.memberId) {\r\n await this._loadByMemberId();\r\n return;\r\n }\r\n this._style();\r\n }\r\n\r\n async _loadByMemberId() {\r\n try {\r\n const data = await this._onboardings.memberStatus(this.memberId);\r\n this.tracker = data.tracker;\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n _style() {\r\n if (!this.tracker) return;\r\n this.stepNumber = this.tracker.steps.findIndex(x => !x.isComplete) + 1;\r\n if (this.stepNumber === 0) this.stepNumber = this.tracker.steps.length; // when everything is complete, set the stepNumber to the last number\r\n window.setTimeout(() => this._setBackgroundGradient(), 100);\r\n }\r\n\r\n _setBackgroundGradient() {\r\n try {\r\n const secondaryColor = getComputedStyle(document.body).getPropertyValue('--kt-primary');\r\n const backgroundImageStyle = `linear-gradient(to right, ${secondaryColor}, ${this.tracker.percentComplete}%, transparent)`;\r\n if (this.textEl) this.textEl.style.backgroundImage = backgroundImageStyle;\r\n let ctr = 0;\r\n this.tracker.steps.forEach(step => {\r\n ctr++;\r\n if (step.isComplete) return;\r\n if (ctr > this.stepNumber) return;\r\n if (ctr === this.stepNumber && step.percentComplete === 0) step.percentComplete = 10;\r\n if (step.percentComplete === 0) return;\r\n let stepBackgroundImageStyle = `linear-gradient(to right, ${secondaryColor}, ${step.percentComplete}%, transparent)`;\r\n const stepEl = document.getElementById(`zeus-opt-step-${step.code}`);\r\n if (stepEl) stepEl.style.backgroundImage = stepBackgroundImageStyle;\r\n });\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n selectStep(code) {\r\n this._element.dispatchEvent(new CustomEvent('selected', { bubbles: true, detail: { code }}));\r\n }\r\n}\r\n","import { bindable } from 'aurelia-framework';\r\nimport { Router } from 'aurelia-router';\r\nimport { EventAggregator } from 'aurelia-event-aggregator';\r\nimport { Security } from 'common/security';\r\nimport { Onboardings } from 'services/onboardings';\r\nimport { I18n } from 'common/i18n';\r\nimport Chart from 'chart.js/auto';\r\nimport ChartDataLabels from 'chartjs-plugin-datalabels';\r\n\r\nexport class OnboardingStatusChart {\r\n static inject = [Router, EventAggregator, Security, Onboardings, I18n];\r\n _router;\r\n _ea;\r\n _security;\r\n _onboardings;\r\n _i18n;\r\n\r\n @bindable data;\r\n\r\n CHART_TYPE = {\r\n Both: 'both',\r\n ByStatus: 'by-status',\r\n ByStep: 'by-step',\r\n };\r\n @bindable chartType = this.CHART_TYPE.Both;\r\n @bindable clickToDashboard = false;\r\n\r\n statusChartEl;\r\n stepChartEl;\r\n showChart = true;\r\n\r\n constructor(router, ea, security, onboardings, i18n) {\r\n this._router = router;\r\n this._ea = ea;\r\n this._security = security;\r\n this._onboardings = onboardings;\r\n this._i18n = i18n;\r\n }\r\n\r\n attached() {\r\n this._loadCharts();\r\n }\r\n\r\n dataChanged() {\r\n if (!this.data) return;\r\n this._loadCharts();\r\n }\r\n\r\n chartTypeChanged() {\r\n if (!this.chartType) return;\r\n this._loadCharts();\r\n }\r\n\r\n _loadCharts() {\r\n if (!this.data || !this.data.onboardings || !this.statusChartEl || !this.stepChartEl) return;\r\n this.showChart = this.data.onboardings.length > 0;\r\n this._loadStepChart();\r\n this._loadStatusChart();\r\n }\r\n\r\n _onClick = () => {\r\n this._router.navigate('#/members/my-team/onboarding', true);\r\n }\r\n\r\n _loadStepChart() {\r\n try {\r\n const labels = [];\r\n const labelsAbbr = [];\r\n const values = [];\r\n this.data.steps.forEach(step => {\r\n labels.push(this._i18n.tr(`onboarding-step-${step.code}`));\r\n labelsAbbr.push(this._i18n.tr(`onboarding-step-abbr-${step.code}`));\r\n\r\n let stepCount = step.count;\r\n if (this.data.onboardings) {\r\n const displayedInStep = this.data.onboardings.filter(x => x.currentStepCode === step.code);\r\n stepCount = displayedInStep.length;\r\n }\r\n values.push(stepCount);\r\n });\r\n\r\n const data = {\r\n labels,\r\n labelsAbbr,\r\n datasets: [\r\n {\r\n label: '',\r\n data: values,\r\n backgroundColor: this._onboardings.STEP_COLORS,\r\n hoverOffset: 4\r\n }\r\n ]\r\n };\r\n const config = {\r\n type: 'pie',\r\n data: data,\r\n plugins: [ChartDataLabels],\r\n options: {\r\n plugins: {\r\n legend: { display: false },\r\n datalabels: {\r\n color: 'white',\r\n formatter: function(value, context) {\r\n const count = context.dataset.data[context.dataIndex];\r\n if (count === 0) return '';\r\n return `${context.chart.data.labelsAbbr[context.dataIndex]} (${count})`;\r\n }\r\n },\r\n },\r\n },\r\n };\r\n\r\n if (this.clickToDashboard) {\r\n config.options.events = ['click'];\r\n config.options.onClick = this._onClick;\r\n }\r\n\r\n if (this._stepChart) {\r\n this._stepChart.data.datasets = data.datasets;\r\n this._stepChart.update();\r\n return;\r\n }\r\n\r\n this._stepChart = new Chart(this.stepChartEl, config);\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n _loadStatusChart() {\r\n try {\r\n const labels = [this._i18n.tr('onboarding-status-red'), this._i18n.tr('onboarding-status-yellow'), this._i18n.tr('onboarding-status-green')];\r\n\r\n const countsRYG = [0, 0, 0];\r\n countsRYG[0] = this.data.onboardings.filter(x => x.statusColor === 'r').length;\r\n countsRYG[1] = this.data.onboardings.filter(x => x.statusColor === 'y').length;\r\n countsRYG[2] = this.data.onboardings.filter(x => x.statusColor === 'g').length;\r\n\r\n const data = {\r\n labels,\r\n datasets: [\r\n {\r\n label: '',\r\n data: countsRYG,\r\n backgroundColor: ['red', 'orange', 'green'],\r\n hoverOffset: 4\r\n }\r\n ]\r\n };\r\n const config = {\r\n type: 'pie',\r\n data: data,\r\n plugins: [ChartDataLabels],\r\n options: {\r\n plugins: {\r\n legend: { display: false },\r\n datalabels: {\r\n color: 'white',\r\n formatter: function(value, context) {\r\n const count = context.dataset.data[context.dataIndex];\r\n if (count === 0) return '';\r\n return `${context.chart.data.labels[context.dataIndex]} (${count})`;\r\n }\r\n },\r\n },\r\n },\r\n };\r\n\r\n if (this.clickToDashboard) {\r\n config.options.events = ['click'];\r\n config.options.onClick = this._onClick;\r\n }\r\n\r\n if (this._statusChart) {\r\n this._statusChart.data.datasets = data.datasets;\r\n this._statusChart.update();\r\n return;\r\n }\r\n\r\n this._statusChart = new Chart(this.statusChartEl, config);\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n}\r\n","import { bindable } from 'aurelia-framework';\r\nexport class PersistencyPercentage {\r\n @bindable data;\r\n breaks;\r\n\r\n dataChanged() {\r\n if (!this.data) return;\r\n this.breaks = [this.data.persistencyPercentageRequired, this.data.persistencyPercentageRequired];\r\n this.percentage = this.data.persistencyPercentage;\r\n }\r\n}\r\n","import { PLATFORM } from 'aurelia-pal';\r\nimport { bindable, computedFrom } from 'aurelia-framework';\r\nimport { EventAggregator } from 'aurelia-event-aggregator';\r\nimport { DialogService } from 'aurelia-dialog';\r\nimport { Sites } from 'services/sites';\r\nimport { EditAgentProfileImageDialog } from './../../../members/agents/dialogs/edit-agent-profile-image-dialog';\r\nimport { c } from 'common/common';\r\nimport { PERSON_TYPE } from 'common/constants';\r\nimport environment from '../../../../config/environment.json';\r\nPLATFORM.moduleName('./../../../members/agents/dialogs/edit-agent-profile-image-dialog');\r\n\r\nexport class PersonAvatar {\r\n static inject = [EventAggregator, DialogService, Sites];\r\n _ea;\r\n _dialogService;\r\n _sites;\r\n\r\n @bindable id = '';\r\n @bindable person;\r\n @bindable size = 'sm'\r\n @bindable cssClass;\r\n @bindable editable = false;\r\n @bindable useLogo = false;\r\n @bindable score;\r\n\r\n imgEl;\r\n\r\n _handlers = [];\r\n\r\n constructor(ea, dialogService, sites) {\r\n this._ea = ea;\r\n this._dialogService = dialogService;\r\n this._sites = sites;\r\n }\r\n\r\n bind() {\r\n this._setSize();\r\n if (this.useLogo) this._setLogo();\r\n }\r\n\r\n @computedFrom('personType')\r\n get hasCustomImage() {\r\n return this.personType === PERSON_TYPE.Agent;\r\n }\r\n\r\n async _setLogo() {\r\n try {\r\n const theme = await this._sites.theme();\r\n this.imgSrc = `${environment.static}/files/themes/${theme.key}/favicons/favicon-96x96.png`;\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n scoreChanged() {\r\n try {\r\n if (!this.score) return;\r\n if (this.score < 10) this.formattedScore = c.Helpers.formatNumber(this.score, 1);\r\n else this.formattedScore = c.Helpers.formatNumber(this.score, 0);\r\n if (this.formattedScore.toString().length >= 4) this.scoreClass = 'smaller';\r\n else this.scoreClass = '';\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n personChanged() {\r\n this._setPerson();\r\n }\r\n\r\n sizeChanged() {\r\n this._setSize();\r\n }\r\n\r\n attached() {\r\n try {\r\n this.labelEl.style.display = 'none';\r\n this._handlers.push(this._ea.subscribe(c.EventKeys.agent.profileImageUpdated, (data) => this._imageUpdated(data.agentId)));\r\n this._setSize();\r\n this._setPerson();\r\n } catch (err) {\r\n console.log(err);\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 _imageUpdated(personId) {\r\n try {\r\n if (!this.person || !personId) return;\r\n if (this.person.id.toLowerCase() !== personId.toLowerCase()) return;\r\n this.imgEl.src = 'about:blank';\r\n window.setTimeout(() => {\r\n this.imgSrc = `${environment.static}/memberzone/profile/${this.person.id}-t.jpg?v=${new Date().getTime()}`;\r\n this.imgEl.src = this.imgSrc;\r\n this.imgEl.style.display = 'inline-block';\r\n this.labelEl.style.display = 'none';\r\n }, 500);\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n _setPerson() {\r\n if (!this.person) return;\r\n try {\r\n if (!this.useLogo) {\r\n this.imgSrc = `${environment.static}/memberzone/profile/${this.person.id}-t.jpg`;\r\n }\r\n let fullName = this.person.fullName;\r\n if (this.person.firstName && this.person.lastName) {\r\n this.initials = `${this.person.firstName.substr(0, 1)}${this.person.lastName.substr(0, 1)}`.toUpperCase();\r\n if (!fullName) fullName = `${this.person.firstName} ${this.person.lastName}`;\r\n } else if (this.person.fullName) {\r\n const names = this.person.fullName.split(' ');\r\n if (names.length >= 2) this.initials = `${names[0].substr(0, 1)}${names[1].substr(0, 1)}`.toUpperCase();\r\n else this.initials = this.person.fullName.substr(0, 1).toUpperCase();\r\n } else this.initials = this.person.fullName || '';\r\n this.colors = c.Helpers.stringToColor(fullName);\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n _setSize() {\r\n if (!this.size) {\r\n this.sizeCss = 'symbol-40px';\r\n return;\r\n }\r\n switch (this.size) {\r\n case 'xxs': this.sizeCss = 'symbol-20px'; break;\r\n case 'xs': this.sizeCss = 'symbol-25px'; break;\r\n case 'sm': this.sizeCss = 'symbol-40px'; break;\r\n case 'md': this.sizeCss = 'symbol-65px'; break;\r\n case 'ml': this.sizeCss = 'symbol-75px'; break;\r\n case 'lg': this.sizeCss = 'symbol-75px symbol-lg-125px'; break;\r\n case 'xl': this.sizeCss = 'symbol-125px symbol-sm-60px symbol-lg-60px symbol-xl-100px symbol-xxl-125px'; break;\r\n default: this.sizeCss = 'symbol-40px'; break;\r\n }\r\n }\r\n\r\n onImageError() {\r\n try {\r\n this.style.onerror = null;\r\n this.style.display = 'none';\r\n const labelEl = this.parentNode.querySelector('.symbol-label');\r\n labelEl.style.display = 'flex';\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n openProfileImageEditor() {\r\n this._dialogService.open({ viewModel: EditAgentProfileImageDialog, model: this.agent, ignoreTransitions: true });\r\n }\r\n}","import { bindable, computedFrom } from 'aurelia-framework';\r\nimport { EventAggregator } from 'aurelia-event-aggregator';\r\nimport { I18n } from 'common/i18n';\r\nimport { Members } from 'services/members';\r\nimport { TextareaToHtmlValueConverter } from 'resources/value-converters/textarea-to-html';\r\nimport { AgentNumberStatusValueConverter } from 'resources/value-converters/agent-number-status';\r\nimport { DialogService } from 'aurelia-dialog';\r\nimport { LevelNameValueConverter } from 'resources/value-converters/level-name';\r\nimport { FormatPhoneValueConverter } from 'resources/value-converters/format-phone';\r\nimport { BoolToYesNoValueConverter } from 'resources/value-converters/bool-to-yesno';\r\nimport { LeadStatusValueConverter } from 'resources/value-converters/lead-status';\r\nimport { LeadDispositionValueConverter } from 'resources/value-converters/lead-disposition';\r\nimport { c } from 'common/common';\r\nimport { ABOUT_TYPE, AGENT_PROPERTY, PERSON_TYPE, LEAD_PROPERTY } from 'common/constants';\r\nimport { EditToDo } from '../to-dos/dialogs/edit-to-do';\r\nimport { EditNote } from '../notes/dialogs/edit-note';\r\nPLATFORM.moduleName('../to-dos/dialogs/edit-to-do');\r\nPLATFORM.moduleName('../notes/dialogs/edit-note');\r\nimport moment from 'moment';\r\n\r\nexport class PersonName {\r\n static inject = [EventAggregator, DialogService, I18n, Members, TextareaToHtmlValueConverter, AgentNumberStatusValueConverter, LevelNameValueConverter, FormatPhoneValueConverter, BoolToYesNoValueConverter, LeadStatusValueConverter, LeadDispositionValueConverter];\r\n @bindable person;\r\n @bindable personType;\r\n @bindable showIcon = true;\r\n @bindable iconSize = 'sm';\r\n @bindable showName = true;\r\n @bindable showBadges = true;\r\n @bindable canViewProfile = true;\r\n @bindable showActions = false;\r\n @bindable showProperties;\r\n @bindable carrierId = false;\r\n @bindable cardTab;\r\n @bindable nameCss;\r\n _ea;\r\n _dialogService;\r\n _i18n;\r\n _members;\r\n _textareaToHtmlValueConverter;\r\n _agentNumberStatusValueConverter;\r\n _levelNameValueConverter;\r\n _formatPhoneValueConverter;\r\n _boolToYesNoValueConverter;\r\n _leadStatusValueConverter;\r\n _leadDispositionValueConverter;\r\n PERSON_TYPE = PERSON_TYPE;\r\n\r\n carrierNotes = '';\r\n elId;\r\n personProperties = [];\r\n\r\n constructor(ea, dialogService, i18n, members, textareaToHtmlValueConverter, agentNumberStatusValueConverter, levelNameValueConverter, formatPhoneValueConverter, boolToYesNoValueConverter, leadStatusValueConverter, leadDispositionValueConverter) {\r\n this._ea = ea;\r\n this._dialogService = dialogService;\r\n this._i18n = i18n;\r\n this._members = members;\r\n this._textareaToHtmlValueConverter = textareaToHtmlValueConverter;\r\n this._agentNumberStatusValueConverter = agentNumberStatusValueConverter;\r\n this._levelNameValueConverter = levelNameValueConverter;\r\n this._formatPhoneValueConverter = formatPhoneValueConverter;\r\n this._boolToYesNoValueConverter = boolToYesNoValueConverter;\r\n this._leadStatusValueConverter = leadStatusValueConverter;\r\n this._leadDispositionValueConverter = leadDispositionValueConverter;\r\n this.elId = c.Helpers.uniqueId();\r\n }\r\n\r\n @computedFrom('personType')\r\n get canHaveBadges() {\r\n return this.personType === PERSON_TYPE.Agent;\r\n }\r\n\r\n @computedFrom('personType')\r\n get aboutType() {\r\n if (this.personType === PERSON_TYPE.Agent) return ABOUT_TYPE.Agent;\r\n if (this.personType === PERSON_TYPE.Lead) return ABOUT_TYPE.Lead;\r\n return null;\r\n }\r\n\r\n @computedFrom('personType')\r\n get showProfileLink() {\r\n return this.personType === PERSON_TYPE.Agent || this.personType === PERSON_TYPE.Lead;\r\n }\r\n\r\n nameFontSize() {\r\n switch (this.iconSize) {\r\n case 'xl': return 'fs-3 fw-bold';\r\n case 'lg': return 'fs-3 fw-bold';\r\n case 'md': return 'fs-4 fw-bold';\r\n default: return 'fs-6 fw-semibold';\r\n }\r\n }\r\n\r\n openProfile(ev) {\r\n ev.stopPropagation();\r\n ev.preventDefault();\r\n switch (this.personType) {\r\n case PERSON_TYPE.Agent:\r\n this._ea.publish(c.EventKeys.site.openProfile, { memberId: this.person.id, tab: this.cardTab });\r\n break;\r\n default:\r\n this._ea.publish(c.EventKeys.site.openLead, { leadId: this.person.id });\r\n break;\r\n }\r\n }\r\n\r\n addToDo() {\r\n if (!this.aboutType) return;\r\n const model = { type: this.aboutType, aboutId: this.person.id, aboutName: this.person.fullName, toDo: undefined };\r\n this._dialogService.open({ viewModel: EditToDo, model, ignoreTransitions: true });\r\n }\r\n\r\n addNote() {\r\n if (!this.aboutType) return;\r\n const model = { type: this.aboutType, aboutId: this.person.id, note: undefined };\r\n this._dialogService.open({ viewModel: EditNote, model, ignoreTransitions: true });\r\n }\r\n\r\n showPropertiesChanged() {\r\n try {\r\n this.personProperties = [];\r\n if (!this.showProperties || !this.showProperties.length) return;\r\n this.showProperties.forEach(id => {\r\n let ap;\r\n switch (this.personType) {\r\n case PERSON_TYPE.Agent:\r\n ap = AGENT_PROPERTY.find(id);\r\n break;\r\n case PERSON_TYPE.Lead:\r\n ap = LEAD_PROPERTY.find(id);\r\n break;\r\n }\r\n if (!ap) return;\r\n this.personProperties.push({\r\n label: ap.translationKey,\r\n value: this._personPropertyValue(ap),\r\n });\r\n });\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n _personPropertyValue(pp) {\r\n try {\r\n let value = this.person[pp.id];\r\n if (pp.propertyBag && this.person.propertyBag) {\r\n const pbv = this.person.propertyBag.properties.find(x => x.key === pp.id);\r\n if (pbv) value = pbv.value;\r\n }\r\n if (value === undefined || value === null || value === '') return '';\r\n let formattedValue = value;\r\n switch (pp.type) {\r\n case 'String': break;\r\n case 'Level': formattedValue = this._levelNameConverter.toView(value); break;\r\n case 'Phone': formattedValue = this._formatPhoneValueConverter.toView(value); break;\r\n case 'Date': formattedValue = moment(value).format('l'); break;\r\n case 'Boolean': formattedValue = this._boolToYesNoValueConverter.toView(value); break;\r\n case 'LeadStatus': formattedValue = this._leadStatusValueConverter.toView(value); break;\r\n case 'LeadDisposition': formattedValue = this._leadDispositionValueConverter.toView(value); break;\r\n default: break;\r\n }\r\n return formattedValue;\r\n } catch (err) {\r\n return this.person[pp.id];\r\n }\r\n }\r\n\r\n async loadCarrierNotes() {\r\n if (this.personType !== PERSON_TYPE.Agent) return;\r\n if (this.loadingCarrierNotes || this.carrierNotes) return;\r\n try {\r\n this.loadingCarrierNotes = true;\r\n const data = await this._members.getAgentNumber(this.member.id, this.carrierId);\r\n if (!data || data.length !== 1) return;\r\n const notes = [];\r\n data[0].agentNumbers.forEach(an => {\r\n const anNotes = []\r\n if (an.agentNumber) anNotes.push(`