app.directive('objectEditor', function() { return { scope: { bindingParent: "=", bindingName: "=", allowEditValues: "=?", allowNewKeys: "=?", allowEditKeys: "=?", allowDeleteKeys: "=?", keyPlaceholder: "=?" }, transclude: false, controller: ctrl_5f3dd39edd634d71eadb48ba, template: `
  • {{directiveScope.bindingName}}
  • {{directiveScope.bindingName}}
  • {{directiveScope.bindingName}}
  • {{directiveScope.bindingName}}
  • `, bindToController: true};}); function ctrl_5f3dd39edd634d71eadb48ba($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.t = function() { return (!this.bindingParent || !this.bindingName || !this.bindingParent[this.bindingName]) ? "null" : typeof(this.bindingParent[this.bindingName]); } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: objectEditor failed to initialize: " + e); } }); } app.controller('ctrl_5f3dd39edd634d71eadb48ba', ctrl_5f3dd39edd634d71eadb48ba); app.directive('layoutEditorElement', function() { return { scope: { selected: "=?" }, controller: ctrl_5f3dd6c450a9cc72d8fcbfd0, template: `
    {{directiveScope.dragging}} {{directiveScope.unique}}
    `, bindToController: true};}); function ctrl_5f3dd6c450a9cc72d8fcbfd0($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.supportingJsLoaded = false; $scope.directiveScope = this; this.unique = createUniqueTag(); this.dragging = false; this.selected = false; $timeout(() => { var element = document.getElementById(this.unique); element.onmousedown = (e) => { this.startTop = element.offsetTop; this.dragging = true; $scope.$apply(); }; document.onmousemove = (e) => { if (this.dragging) { element.style.top = (e.clientY) + "px"; element.style.left = (e.clientX) + "px"; $scope.$apply(); } }; document.onmouseup = (e) => { this.dragging = false; $scope.$apply(); }; }, 1000); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: layoutEditorElement failed to initialize: " + e); } }); } app.controller('ctrl_5f3dd6c450a9cc72d8fcbfd0', ctrl_5f3dd6c450a9cc72d8fcbfd0); app.directive('baseForm', function() { return { scope: { inWindow: "=?", modelName: "=", layout: "=?", initValues: "=?", bindingName: "=?", bindingParent: "=?", allowInsert: "
     
    ⚠ {{directiveScope.error}}
    {{directiveScope.modelData.singular_name}}{{directiveScope.record[directiveScope.modelData.display_field]}} Updating every {{directiveScope.reloadRate / 1000}} second{{directiveScope.reloadRate / 1000 > 1 ? "s" : ""}}
    {{directiveScope.record._id ? directiveScope.record._id : '{New Record}'}}
    {{directiveScope.record[field.name]}}
    {{directiveScope.record[field.name]}}
    {{directiveScope.trimNote(field.note)}}
    {{field.note}}
    `, bindToController: true};}); function ctrl_5f3dd70950a9cc72d8fcbfd1($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { //a //BOUND TO ID STRING this.$onInit = function() { this.auditModal = {}; this.jsonModal = {}; this.recordArticleModal = {}; this.reloadIntervalId = null; this.modifiedFields = []; this.parentModal = $scope.$parent.$parent.$parent.directiveScope ? $scope.$parent.$parent.$parent.directiveScope.directiveRef : null; $scope.directiveScope = this; this.unique = createUniqueTag(); this.error = null; this.loading = false; $rootScope.tabStates = {}; this.showHeader = this.showHeader == null ? true : this.showHeader; this.checkForCtrlCode = function(_event) { _event.preventDefault(); if (_event.ctrlKey && String.fromCharCode(_event.which).toLowerCase()) { _event.preventDefault(); } }; //Get permissions for referenced table this.allowUpdate = (this.allowUpdate != false) && $scope.$root.roles.some((role) => { return role.allow_all_models || role.update_models.includes(this.modelName); }); this.allowInsert = (this.allowInsert != false) && $scope.$root.roles.some((role) => { return role.allow_all_models || role.insert_models.includes(this.modelName); }); this.allowCopy = (this.allowCopy != false) && $scope.$root.roles.some((role) => { return role.allow_all_models || role.insert_models.includes(this.modelName); }); this.allowDelete = (this.allowDelete != false) && $scope.$root.roles.some((role) => { return role.allow_all_models || role.delete_models.includes(this.modelName); }); this.allowJSON = (this.allowJSON != false) && $scope.$root.roles.some((role) => { return role.name == "sys_admin"; }); //Get model and layout data this.loadModelData(() => { //Now load/handle record data $scope.directiveScope.reloadRecord(); //Set watch $scope.$watch('[directiveScope.modelName, directiveScope.bindingParent, directiveScope.bindingName, directiveScope.bindingParent[directiveScope.bindingName]]', function(_new, _old) { if (_new != _old) { $scope.directiveScope.loadModelData(() => { $scope.directiveScope.reloadRecord(); }); } }); $scope.$watch("directiveScope.record", (_new, _old) => { //Was this a record refresh change? if (!$scope.directiveScope.loading && _new && _old) { //No, UI change, get all the fields that were changed (should usually be only 1, but complex controls may update more) var update = {}; [...Object.keys(_new), ...Object.keys(_old)].distinct().forEach((fieldName) => { //If this field was changed and any of the layout fields for this field are flagged to update on change, add value to update object if (JSON.stringify(_new[fieldName]) != JSON.stringify(_old[fieldName]) && $scope.directiveScope.layoutRecord.fields.some((f) => { return f.name == fieldName && f.update_on_change; })) { update[fieldName] = _new[fieldName]; } }); //Are there any updates to push? if (Object.keys(update).length > 0) { //Yes, apply update updateRecord($scope.directiveScope, $http, $scope.directiveScope.modelName, $scope.directiveScope.record._id, update, (resp) => { if (resp.success) { $scope.$root.$emit('showAlert', "Fields '" + Object.keys(update).join(", ") + "' updated successfully", "success"); // $scope.directiveScope.reloadRecord(); } }); } } }, true); }); }; this.changeLayout = () => { $scope.directiveScope.loadModelData(); $scope.directiveScope.updateCurrentURL(); } this.loadModelData = function(_then) { $scope.directiveScope.error = null; //Evaluate attributes if (!$scope.directiveScope.modelName) { $scope.directiveScope.error = "Model name not provided" $scope.directiveScope.loading = false; if (_then) { _then(); } return; } if (!$scope.$root.models[$scope.directiveScope.modelName]) { $scope.directiveScope.error = "'" + $scope.directiveScope.modelName + "' model not found or permission denied", $scope.directiveScope.loading = false; if (_then) { _then(); } return; } //Get model data $scope.directiveScope.modelData = $scope.$root.models[$scope.directiveScope.modelName]; //Set title of parent window (if on root form) if ($scope.directiveScope.inWindow) { $("#favicon").attr("href", $scope.directiveScope.modelData.icon ? $scope.directiveScope.modelData.icon.link : null); document.title = "KIM - " + $scope.directiveScope.modelData.singular_name; } //Save applicable layouts $scope.directiveScope.layoutSelections = {}; $scope.$root.layouts.filter((l) => { return l._type == "form_layout" && (l.model == $scope.directiveScope.modelName || l.model == $scope.directiveScope.modelData.parent); }).forEach((layout) => { $scope.directiveScope.layoutSelections[layout._id] = { label: layout.display, icon: ($scope.$root.models[layout.model].icon ? $scope.$root.models[layout.model].icon.link : null), class: "ghost" }; }); //Get layout var defaultLayoutId = !$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] && $scope.$root.models[$scope.directiveScope.modelName].default_new_form ? $scope.$root.models[$scope.directiveScope.modelName].default_new_form : $scope.$root.models[$scope.directiveScope.modelName].default_form; $scope.directiveScope.layoutRecord = $scope.$root.layouts.find((l) => { //Return the specified (or default form) layout return ( $scope.directiveScope.layout && $scope.directiveScope.layout == l._id && l._type == "form_layout" && ( l.model == $scope.directiveScope.modelName || l.model == $scope.$root.models[$scope.directiveScope.modelName].parent ) ) || (!$scope.directiveScope.layout && l._id == defaultLayoutId); }); //Layout OK? if (!$scope.directiveScope.layoutRecord) { //Not found $scope.directiveScope.error = "Layout not found"; if (_then) { _then(); } return; } $scope.directiveScope.layout = $scope.directiveScope.layoutRecord._id; //Add global fields if enabled if ($scope.directiveScope.layoutRecord.display_global_fields && !$scope.directiveScope.layoutRecord.globalFieldLoaded) { $scope.directiveScope.layoutRecord.fields.push({ row: 500, row_order: 0, placement: "left", default: "System Fields", field_type: "angular", control: $scope.$root.globalControls.find((c) => { return c._id == "5e41675a7db3990140f5d64a"; }) }); Object.keys($scope.$root.globalFields).forEach((fieldName) => { var field = $scope.$root.globalFields[fieldName]; if (!field.__display) { return; } $scope.directiveScope.layoutRecord.fields.push({ row: 501, row_order: 0, size: 3, placement: "left", name: fieldName, label: $scope.directiveScope.getLabel(fieldName), field_type: field.__default_write_control ? "write" : "read", control: field.__readonly ? ( field.__default_read_control ? field.__default_read_control : null) : ( field.__default_write_control ? field.__default_write_control : null), tab: "System Fields" }); }); $scope.directiveScope.layoutRecord.globalFieldLoaded = true; } //Update field groupings $scope.directiveScope.groupedFields = groupByProperty($scope.directiveScope.layoutRecord.fields, "row"); //Set reload rate if defined (or use layout default, if defined) $scope.directiveScope.reloadRate = $scope.directiveScope.reloadRate || $scope.directiveScope.layoutRecord.default_reload_rate; //Kill old interval (if exists) if ($scope.directiveScope.reloadIntervalId) { $interval.cancel($scope.directiveScope.reloadIntervalId); $scope.directiveScope.reloadIntervalId = null; } //Set up interval if > 250ms (to avoid accidental 1ms blasts) if ($scope.directiveScope.reloadRate > 250) { $scope.directiveScope.reloadIntervalId = $interval(() => { //Don't load if already loading var visible = $("#base_form_" + $scope.directiveScope.unique).parent().is(":visible"); if (visible && !$scope.directiveScope.loading) { $scope.directiveScope.reloadRecord(); } }, $scope.directiveScope.reloadRate); } //Set popovers in a second setTimeout(() => { $scope.directiveScope.layoutRecord.fields.forEach((field) => { if ($scope.directiveScope.modelData.fields[field.name]) { $("#field_label_" + field.name).popover({ title: field.label, html: true, content: atob($scope.directiveScope.modelData.fields[field.name].description || ""), container: 'body' }); } }); $('.popover-dismiss').popover({ trigger: 'focus' }) }, 1000); // if (_then) { _then(); } } this.reloadRecord = function() { $scope.directiveScope.loading = true; if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName) { //Normalize binding (to single id string or null) $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] ? ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]._id ? $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]._id : $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) : null; } if (!$scope.directiveScope.modelName || !$scope.directiveScope.layoutRecord) { //No model provided, cancel all $scope.directiveScope.loading = false; } else if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { //Id provided, retrieve record retrieveRecord($scope.directiveScope, $http, $scope.directiveScope.modelName, { noCache: true, query: { _id: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] }, populate: $scope.directiveScope.layoutRecord.fields.filter((field) => { return ["yes", "custom"].includes(field.populate_mode); }).map((field) => { return field.populate_mode == "yes" ? field.name : { path: field.name, populate: field.populate }; }) }, (record) => { //Record OK? if (!record) { //Not found $scope.directiveScope.loading = false; $scope.directiveScope.error = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] + " not found in '" + $scope.directiveScope.modelName + "' model"; return; } //Record OK, init bound record if null $scope.directiveScope.record = $scope.directiveScope.record || {}; //Apply record values to bindings Object.assign($scope.directiveScope.record, record); //Check if record _type is different than expected if ($scope.directiveScope.record._type && ($scope.directiveScope.record._type != $scope.directiveScope.modelName)) { //Changed, load default layout for the record model instead $scope.directiveScope.modelName = $scope.directiveScope.record._type; $scope.directiveScope.modelData = $scope.$root.models[$scope.directiveScope.modelName]; $scope.directiveScope.layoutRecord = $scope.$root.layouts.find((l) => { return l._id == $scope.$root.models[$scope.directiveScope.modelName].default_form; }); $scope.directiveScope.layout = $scope.directiveScope.layoutRecord._id; } if ($scope.directiveScope.inWindow) { $scope.directiveScope.updateCurrentURL(); document.title = "KIM - " + $scope.directiveScope.modelData.singular_name + " '" + $scope.directiveScope.record[$scope.directiveScope.modelData.display_field] + "' "; } //Update field groupings $scope.directiveScope.groupedFields = groupByProperty($scope.directiveScope.layoutRecord.fields, "row"); $scope.directiveScope.modifiedFields = []; $scope.directiveScope.loading = false; }); } else { //No id specified, create empty record with default values $scope.directiveScope.record = {}; //Load defaults from layout $scope.directiveScope.layoutRecord.fields.forEach((field) => { $scope.directiveScope.record[field.name] = field.default || $scope.directiveScope.record[field.name]; }); //Load init values (if supplied) Object.assign($scope.directiveScope.record, $scope.directiveScope.initValues || {}); $scope.directiveScope.loading = false; } }; this.update = function(_then) { $scope.directiveScope.loading = true; //Move read only fields to $readonly to avoid overwriting, they should not have been edited var writtenRecord = { _readonly: {} }; //Evaluate all fields + _id [...$scope.directiveScope.layoutRecord.fields, ...[{ name: "_id" }, { name: "_meta" }]].filter((fieldDef) => { //Only return write/angular fields and _id return fieldDef.field_type == "angular" || fieldDef.field_type == "write" || fieldDef.name == "_id" || fieldDef.name == "_meta"; }).forEach((fieldDef) => { //Copy values from record writtenRecord[fieldDef.name] = cloneObject($scope.directiveScope.record[fieldDef.name]); }); $scope.directiveScope.layoutRecord.fields.filter((fieldDef) => { return fieldDef.field_type == "read"; }).forEach((fieldDef) => { //Write readonly fields to _readonly writtenRecord._readonly[fieldDef.name] = cloneObject($scope.directiveScope.record[fieldDef.name]); }); //POST modifications updateRecord($scope.directiveScope, $http, $scope.directiveScope.modelName, $scope.directiveScope.record._id, writtenRecord, (resp) => { if (resp.success) { //$scope.directiveScope.loading = false; //Show the succefss alert for a second, then take next action $scope.$root.$emit('showAlert', "Record updated successfully", "success"); if ($scope.directiveScope.onUpdate) { $scope.directiveScope.onUpdate($scope.directiveScope.record._id); } if (_then == "exit") { $scope.directiveScope.exit(); return; } //Apply server side record data (would use the response but it doesnt honor model accessors) $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = resp.record._id; $scope.directiveScope.reloadRecord(); //Object.assign($scope.directiveScope.record, resp.record); } else { //Failed, display error var errorString = "Failed to update record

    " + ((resp.errors || []).map((error) => { return (error.source ? (`` + error.source + `: `) : ``) + error.message; }).join("
    ")); $scope.$root.$emit('showAlert', errorString, "danger"); } $scope.directiveScope.loading = false; }); }; this.delete = function() { if (confirm("Are you sure you want to delete this record?")) { deleteRecord($scope.directiveScope, $http, $scope.directiveScope.modelName, $scope.directiveScope.record._id, (resp) => { $scope.$root.$emit('showAlert', resp.success ? "Record deleted successfully" : "Failed to delete record", resp.success ? "success" : "danger"); if (resp.success) { if ($scope.directiveScope.onDelete) { $scope.directiveScope.onDelete($scope.directiveScope.record._id); } $scope.directiveScope.exit(); } else { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = null; $scope.directiveScope.record = {}; } }); } } this.insert = function(_then) { if (confirm("Are you sure you want to insert a new record?")) { $scope.directiveScope.loading = true; //Remove _id if it already exists var record = cloneObject($scope.directiveScope.record); delete record._id; insertRecord($scope.directiveScope, $http, $scope.directiveScope.modelName, record, (resp) => { if (resp.success) { $scope.$root.$emit('showAlert', "Record inserted successfully", "success"); if ($scope.directiveScope.onInsert) { $scope.directiveScope.onInsert(resp.record._id); } //Show the success alert for a second, then take next action if (_then == "exit") { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = cloneObject(resp.record); $scope.directiveScope.record = resp.record; $scope.directiveScope.exit(); } //Apply server side record data (would use the response but it doesnt honor model accessors) $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = resp.record._id; $scope.directiveScope.reloadRecord(); //Object.assign($scope.directiveScope.record, resp.record); //If the default_new_form is in use, chance layout to default form if ($scope.directiveScope.layoutRecord._id == $scope.$root.models[$scope.directiveScope.modelName].default_new_form) { $scope.directiveScope.layout = $scope.$root.models[$scope.directiveScope.modelName].default_form; } } else { //Failed, display error var errorString = "Failed to insert record

    " + ((resp.errors || []).map((error) => { return (error.source ? (`` + error.source + `: `) : ``) + error.message; }).join("
    ")); $scope.$root.$emit('showAlert', errorString, "danger"); } $scope.directiveScope.loading = false; }); } }; this.exit = function() { if ($scope.directiveScope.inWindow) { if (history.length < 2) { close(); } else if (!document.referrer.split("/")[3]) { window.history.back(); } else { window.location = document.referrer; } } else { $scope.directiveScope.parentModal.hide(); } } this.cancel = function() { $scope.directiveScope.parentModal.hide(); }; this.viewInTab = function() { window.open(window.location.href, '_blank'); } this.updateCurrentURL = function() { var url = "/form?model=" + $scope.directiveScope.modelName + "&_id=" + ($scope.directiveScope.record._id) + "&reloadRate=" + $scope.directiveScope.reloadRate + "&layout=" + $scope.directiveScope.layoutRecord._id; $location.url(url).replace(); } this.getFieldClass = function(_field) { return $scope.directiveScope.record._id ? "" : ($scope.$root.models[$scope.directiveScope.modelName].fields[_field.name] && $scope.$root.models[$scope.directiveScope.modelName].fields[_field.name].required ? ("p-2 border-left border-" + (($scope.directiveScope.record[_field.name] == null || $scope.directiveScope.record[_field.name].length == 0) ? "warning" : "success")) : ""); } this.getLabel = function(_name) { return _name.split("_").map((c) => { return c.charAt(0).toUpperCase() + c.slice(1); }).join(" "); } this.fieldIsEmpty = function(_field) { var value = ($scope.directiveScope.record || {})[_field]; //Not true/false return ![true, false].includes(value) && ( //Is null value == null || //Is empty array (Array.isArray(value) && value.length == 0) || //Is empty object or null date (typeof(value) == "object" && (!value.getDate && Object.keys(value).length == 0)) ); } this.trimNote = function(_note) { return (_note || "").split("\n").filter((l,i) => { return i != 0; }).join("\n"); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: baseForm failed to initialize: " + e); } }); } app.controller('ctrl_5f3dd70950a9cc72d8fcbfd1', ctrl_5f3dd70950a9cc72d8fcbfd1); app.directive('baseList', function() { return { scope: { inWindow: "=?", modelName: "=", layout: "=?", query: "=?", sort: "=?", selectionMode: "=?", bindingName: "=?", bindingParent: "=?", showHeader: "=?", allowNew: "=?", allowDeleteAll: "=?", limit: "=?", skip: "=?", reloadRate: "=?", initValues: "=?", records: "=?", fillToTop: "=?", allowInlineEdit: "=?", allowMassUpdate: "=?", totalCount: "=?", //For ref by ext only rowFontSize: "=?", persistentReload: "=?" }, controller: ctrl_5f3e8c3d50a9cc72d8fcbfd2, template: `
     
    ⚠ {{directiveScope.error}}
    {{directiveScope.modelData.plural_name}}  {{directiveScope.modelData.database_table}}
     {{directiveScope.skip}} → {{directiveScope.limit + directiveScope.skip > directiveScope.totalCount ? directiveScope.totalCount : directiveScope.limit + directiveScope.skip}} of {{directiveScope.totalCount}}  Updating every {{directiveScope.reloadRate / 1000}} second{{directiveScope.reloadRate / 1000 > 1 ? "s" : ""}}

    Query JSON: {{directiveScope.editableQuery}}
    {{directiveScope.sort[field.name] ? (directiveScope.sort[field.name] == 'asc' ? '▲ ' : '▼ ') : ''}}{{field.label}}
    {{field.label}}

    {{line}}
    {{directiveScope.truncateString(record[field.name] == null ? ' ' : record[field.name])}}
     Note: This update will apply to all records matching the current query (not limited to the currently displayed list)


    {{fieldConfig.display_name || fieldName}}
    {{directiveScope.massUpdateModal.updates | json}}
    Records
    Format
    Fields
    `, bindToController: true};}); function ctrl_5f3e8c3d50a9cc72d8fcbfd2($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.quickSearchTerm = ""; this.query = this.query || {}; this.editableQuery = {}; this.sort = this.sort || {}; this.showQuery = false; this.skip = this.skip || 0; this.limit = this.limit || 100; this.loading = true; this.error = null; this.unique = createUniqueTag(); this.firstLoad = false; this.allowMassUpdate = $scope.$root.roles.some((role) => { return role.name == "sys_admin"; }); this.editingField = { record: null, field: null, value: null }; this.getRowspan = function(_record, _field, _index) { if (!$scope.directiveScope.records || !_field.merge_adjacent_values_vertically || _record[_field.name] == null || _record[_field.name].length == 0) { return 1; } if ( //First record, or the last record's value was different (_index == 0 || $scope.directiveScope.records[_index - 1][_field.name] != _record[_field.name]) && //Not the last record, and the next record's value matches (_index != $scope.directiveScope.records.length - 1 || $scope.directiveScope.records[_index + 1] == _record[_field.name])) { //Find the number of subsequent records with this value var i = _index; for(; i < $scope.directiveScope.records.length; i++) { if (JSON.stringify($scope.directiveScope.records[i][_field.name]) != JSON.stringify(_record[_field.name])) { break; } } return i - _index; } return 1; } this.getRowspanDisplay = function(_record, _field, _index) { //Should display the if not merging, or if the previous value is different and the next is the same if (!$scope.directiveScope.records || !_field.merge_adjacent_values_vertically || _record[_field.name] == null || _record[_field.name].length == 0) { return true; } //First record, or previous value is different return _index == 0 || JSON.stringify($scope.directiveScope.records[_index - 1][_field.name]) != JSON.stringify(_record[_field.name]); } this.editField = function(_record, _field, _currentValue) { $scope.directiveScope.editingField.record = _record; $scope.directiveScope.editingField.field = _field; $scope.directiveScope.editingField.value = cloneObject(_currentValue); postProcessJSON($scope.directiveScope.editingField.value); } this.cancelEdit = function() { Object.assign($scope.directiveScope.editingField, { record: null, field: null, value: null }); } this.saveEdit = function() { var updates = {}; updates[$scope.directiveScope.editingField.field] = $scope.directiveScope.editingField.value; updateRecord($scope, $http, $scope.directiveScope.modelName, $scope.directiveScope.editingField.record, updates, (result) => { $scope.$root.$emit("showAlert", "Record updated", "success"); $scope.directiveScope.cancelEdit(); $scope.directiveScope.reloadRecords(); }); } //Normalize attributes if (!this.modelName) { this.error = this.modelName this.error = "Model name not provided" this.loading = false; return; } if (!$scope.$root.models[this.modelName]) { this.error = "'" + this.modelName + "' model not found or permission denied", this.loading = false; return; } this.updateEditableQuery = function() { $scope.directiveScope.editableQuery = JSON.parse(JSON.stringify($scope.directiveScope.query)); } this.qsKeypress = function(_event) { if (_event.key == "Enter") { $scope.directiveScope.performQuickSearch(); } }; this.performQuickSearch = function() { if ($scope.directiveScope.quickSearchTerm.length < 1) { $scope.directiveScope.query = {}; $scope.directiveScope.updateEditableQuery(); } else { var validTranslators = ["61fc3fefd59d630c7ac95f0c", "6020673d59d74a2d584dfd5e"]; $scope.directiveScope.query = { $or: Object.keys($scope.directiveScope.modelData.fields).filter((f) => { var field = $scope.directiveScope.modelData.fields[f]; return f != "_type" && ($scope.directiveScope.modelData.parent != "remote_record" || field.remote_queryable) && ((field.type == "reference" && isValidIdString($scope.directiveScope.quickSearchTerm)) || ["string", "enumerator"].includes(field.type)) && field.queryable; }).map((f) => { var c = { $or: [{}] }; c.$or[0][f] = $scope.directiveScope.quickSearchTerm; if ($scope.directiveScope.modelData.fields[f].type != "reference") { c.$or.push({}); c.$or[1][f] = { $regex: ".*" + $scope.directiveScope.quickSearchTerm + ".*", $options: 'i' }; } return c; })}; $scope.directiveScope.updateEditableQuery(); } }; this.modelArticleModal = {}; this.massUpdateModal = { updates: {}, model: $scope.directiveScope.modelName, state: null, progress: 0, updatesPending: function() { return Object.keys($scope.directiveScope.massUpdateModal.updates).length }, clearUpdate: function(_fieldName) { delete $scope.directiveScope.massUpdateModal.updates[_fieldName]; }, applyUpdates: function() { $scope.directiveScope.massUpdateModal.state = "applying"; retrieveRecords($scope, $http, $scope.directiveScope.modelName, { query: $scope.directiveScope.query, select: ["_id"] }, (response) => { var recordUpdates = {}; response.records.forEach((r) => { recordUpdates[r._id] = $scope.directiveScope.massUpdateModal.updates; }); updateRecords($scope, $http, $scope.directiveScope.modelName, recordUpdates, () => { //All done $rootScope.$emit('showAlert', "" + Object.keys(recordUpdates).length + " records updated", "success"); Object.keys($scope.directiveScope.massUpdateModal.updates).forEach((k) => { $scope.directiveScope.massUpdateModal.clearUpdate(k); }); $scope.directiveScope.massUpdateModal.hide(); $scope.directiveScope.massUpdateModal.state = null; $scope.directiveScope.massUpdateModal.progress = 0; $scope.directiveScope.reloadRecords(); }, (update) => { //One done $scope.directiveScope.massUpdateModal.progress = update.progress; safeApply($scope); }); }); }, cancelUpdates: function() { }, getControl: (_fieldName) => { var control = { html: null, supporting_js: null }; var fieldConfig = $scope.$root.models[$scope.directiveScope.modelName].fields[_fieldName]; if (!fieldConfig) { return control; } var defaultControls = getDefaultControls($scope, $scope.directiveScope.modelName, _fieldName) return $scope.directiveScope.massUpdateModal.state == 'applying' ? ( //Applying, use read fieldConfig.array ? ( null//fieldConfig.selections ? $scope.$root.controls["6023e2298989745e0939f791"] : defaultControls.plural_read ) : ( fieldConfig.selections ? $scope.$root.controls["6023e2298989745e0939f791"] : defaultControls.singular_read ) ) : ( //Not applying, use write fieldConfig.array ? ( null//fieldConfig.selections ? $scope.$root.controls["62857728fa1f641bafe08e20"] : defaultControls.plural_write ) : ( fieldConfig.selections ? $scope.$root.controls["602338ec175393570a177213"] : defaultControls.singular_write ) ); }, getTitle: () => { return "Mass Update " + $scope.directiveScope.totalCount + " Records"; }, buttons: { cancel: { class: "danger", label: "Cancel" }, cancel: { class: "success", label: "Update" }, }, }; this.viewRecordModal = { id: null, model: null, layout: null }; this.downloadModal = { id: null, buttons: { download: { class: "success", label: "Download" } }, recordsSelection: "current", formatSelection: "json", fieldsSelection: [] }; this.showDownloadModal = function() { $scope.directiveScope.downloadModal.show((selection) => { if (selection == "download") { var query = $scope.directiveScope.downloadModal.recordsSelection == "all" ? {} : $scope.directiveScope.query; downloadLink( "/api/data/" + $scope.directiveScope.modelName + "?query=" + JSON.stringify(query) + "&format=" + $scope.directiveScope.downloadModal.formatSelection, $scope.directiveScope.modelName + "download"); } }); } this.showMassUpdateModal = function() { $scope.directiveScope.massUpdateModal.show((selection) => { if (selection == "update") { } }); } //Evaluate role permissions for referenced table this.allowUpdate = $scope.$root.roles.some((role) => { return role.allow_all_models || role.update_models.includes($scope.directiveScope.modelName); }); this.allowInsert = $scope.$root.roles.some((role) => { return role.allow_all_models || role.insert_models.includes($scope.directiveScope.modelName); }); this.allowCopy = $scope.$root.roles.some((role) => { return role.allow_all_models || role.insert_models.includes($scope.directiveScope.modelName); }); this.allowDelete = $scope.$root.roles.some((role) => { return role.allow_all_models || role.delete_models.includes($scope.directiveScope.modelName); }); this.loadModelData(); //Multiple selection mode? if (this.selectionMode == "multiple") { //Init array on bound record prop this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] || []; } //Set sort if defined (or use layout default, if defined) this.sort = (this.sort && typeof(this.sort) == "object" && Object.keys(this.sort).length > 0) ? this.sort : (this.layoutRecord.initial_sort || {}); //Get records this.reloadRecords(); //Set reload rate if defined (or use layout default, if defined) this.reloadRate = this.reloadRate || this.layoutRecord.default_reload_rate; //Kill old interval (if exists) if ($scope.directiveScope.reloadIntervalId) { $interval.cancel($scope.directiveScope.reloadIntervalId); $scope.directiveScope.reloadIntervalId = null; } //Set up interval if > 250ms (to avoid accidental 1ms blasts) if ($scope.directiveScope.reloadRate > 250) { $scope.directiveScope.reloadIntervalId = $interval(() => { //Don't load if already loading var visible = $("#base_list_" + $scope.directiveScope.unique).parent().is(":visible"); if ((visible || $scope.directiveScope.persistentReload) && !$scope.directiveScope.loading) { $scope.directiveScope.reloadRecords(); } }, $scope.directiveScope.reloadRate); } } this.truncateString = function(_string, _maxLength) { _maxLength = _maxLength || 50; if (_string && _string.length > _maxLength) { return _string.substring(0, _maxLength) + "..."; } else { return _string; } } $scope.$watch("directiveScope.query", function(_new, _old) { if (JSON.stringify(_new) != JSON.stringify(_old)) { //TLM $scope.directiveScope.skip = 0; $scope.directiveScope.reloadRecords(); } }); this.loadModelData = function() { //Get layout var defaultLayoutId = $scope.$root.models[$scope.directiveScope.modelName].default_list || ($scope.$root.models[$scope.directiveScope.modelName].parent ? $scope.$root.models[$scope.$root.models[$scope.directiveScope.modelName].parent].default_list : null); $scope.directiveScope.layoutRecord = $scope.$root.layouts.find((l) => { //Return the specified (or default form) layout return ($scope.directiveScope.layout && $scope.directiveScope.layout == l._id) || (!$scope.directiveScope.layout && l._id == defaultLayoutId); }); //Check layout if (!$scope.directiveScope.layoutRecord) { //Not found $scope.directiveScope.error = "Layout not found" $scope.directiveScope.loading = false; return; } $scope.directiveScope.layout = $scope.directiveScope.layoutRecord._id; //Add global fields if enabled if ($scope.directiveScope.layoutRecord.display_global_fields && !$scope.directiveScope.layoutRecord.globalFieldLoaded) { Object.keys($scope.$root.globalFields).forEach((fieldName) => { //Only show global fields with __display set if (!$scope.$root.globalFields[fieldName].__display) { return; } var field = $scope.$root.globalFields[fieldName]; $scope.directiveScope.layoutRecord.fields.push({ _id: "test", order: 9999999, row_order: 9999999, placement: "left", name: fieldName, label: $scope.directiveScope.getLabel(fieldName), field_type: "read", control: field.__default_read_control ? field.__default_read_control : null }); }); $scope.directiveScope.layoutRecord.globalFieldLoaded = true; } //Get model data $scope.directiveScope.modelData = $scope.$root.models[$scope.directiveScope.modelName]; //Add defaultWriteControl for column filtering $scope.directiveScope.layoutRecord.fields.forEach((field) => { console.log(field.name); if (field.name && !["file", "dynamic_object", "structured_object"].includes(($scope.directiveScope.modelData.fields[field.name] || { type: "unknown" }).type)) { field.filterControl = getDefaultControls($scope, $scope.directiveScope.modelName, field.name).singular_write; } }); //Populate context selections add copyid, matching, not matching $scope.directiveScope.recordContextSelections = { preview: { label: "Preview " + $scope.directiveScope.modelData.singular_name, icon: "/favicon.ico" }, newTab: { label: "Open " + $scope.directiveScope.modelData.singular_name + " in New Tab", icon: "/favicon.ico", onClick: function(_target) { window.open("/form?model=" + $scope.directiveScope.modelName + "&_id=" + _target.record._id , '_blank'); } }, delete: { label: "Delete " + $scope.directiveScope.modelData.singular_name, class: "danger", icon: "/favicon.ico" }, sep1: { seperator: true }, editValue: { label: "Edit Value" } }; //Save applicable layouts $scope.directiveScope.layoutSelections = {}; $scope.$root.layouts.filter((l) => { return l._type == "list_layout" && (l.model == $scope.directiveScope.modelName || l.model == $scope.directiveScope.modelData.parent); }).forEach((layout) => { $scope.directiveScope.layoutSelections[layout._id] = { label: layout.display, icon: ($scope.$root.models[layout.model].icon ? $scope.$root.models[layout.model].icon.link : null), class: "ghost" }; }); if ($scope.directiveScope.inWindow) { $("#favicon").attr("href", $scope.directiveScope.modelData.icon ? $scope.directiveScope.modelData.icon.link : null); document.title = "KIM - " + $scope.directiveScope.modelData.plural_name; } //Save applicable layouts $scope.directiveScope.applicableLayouts = $scope.$root.layouts.filter((l) => { return l._type == "list_layout" && (l.model == $scope.directiveScope.modelName || l.model == $scope.directiveScope.modelData.parent); }); //Set title of parent window (if on root form) if ($scope.directiveScope.inWindow) { document.title = "KIM - " + $scope.directiveScope.modelData.plural_name; } }; this.updateCurrentURL = function() { $scope.listUrl = "/list?model=" + $scope.directiveScope.modelName + "&query=" + JSON.stringify($scope.directiveScope.query) + "&sort=" + JSON.stringify($scope.directiveScope.sort) + "&skip=" + $scope.directiveScope.skip + "&limit=" + $scope.directiveScope.limit + "&layout=" + $scope.directiveScope.layoutRecord._id + "&reloadRate=" + $scope.directiveScope.reloadRate; setUrl($location, $scope.listUrl) } this.applyEditableQuery = function() { $scope.directiveScope.query = $scope.directiveScope.editableQuery; } this.reloadRecords = function() { $scope.directiveScope.updateEditableQuery(); $scope.directiveScope.loading = true; retrieveRecords($scope.directiveScope, $http, $scope.directiveScope.modelName, { query: $scope.directiveScope.query, sort: $scope.directiveScope.sort, skip: $scope.directiveScope.skip, limit: $scope.directiveScope.limit, populate: $scope.directiveScope.layoutRecord.fields.filter((field) => { return field.populate_mode == "yes"; }).map((field) => { return field.name; }) }, (response) => { $scope.directiveScope.totalCount = response.total_count; response.records.forEach((r) => { return r.__trackingId = hashCode(JSON.stringify(r)); }); $scope.directiveScope.records = response.records; $scope.directiveScope.loading = false; if ($scope.directiveScope.inWindow) { $scope.directiveScope.updateCurrentURL(); } //Update binding records $scope.directiveScope.records.forEach((r) => { var existingBindingRecord = $scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] && Array.isArray($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) ? $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].find((b) => { return b._id == r._id; }) : null; if (existingBindingRecord) { Object.assign(existingBindingRecord, r); } }); $scope.directiveScope.firstLoad = true; }); } this.changeLayout = () => { $scope.directiveScope.loadModelData(); $scope.directiveScope.updateCurrentURL(); } this.deleteOne = function(_id) { var record = $scope.directiveScope.records.find((r) => { return r._id == _id; }); if (!record) { return; } var confirmed = window.confirm("Are you sure your want to delete '" + record[$scope.$root.models[$scope.directiveScope.modelName].display_field] + "'"); } this.delete = function() { //Is there any query at all? var confirmed = Object.keys($scope.directiveScope.query).length == 0 ? //ENTIRE MODEL, confirm with text (window.prompt("Are you sure your want to delete ALL " + $scope.directiveScope.totalCount + " '" + $scope.directiveScope.modelName + "' records?", "Type model name to confirm") == $scope.directiveScope.modelName) : //Some kind of query, confirm with OK (confirm("Are you sure your want to delete " + $scope.directiveScope.totalCount + " '" + $scope.directiveScope.modelName + "' records?")); if (confirmed) { deleteRecords($scope, $http, $scope.directiveScope.modelName, $scope.directiveScope.query, (response) => { if (response.success) { $rootScope.$emit('showAlert', "" + $scope.directiveScope.totalCount + " records deleted", "success"); $scope.directiveScope.reloadRecords(); } else { $rootScope.$emit('showAlert', "Failed to delete records", "danger"); } }); } else { $rootScope.$emit('showAlert', "Delete cancelled", "warning"); } } this.nextChunk = function() { $scope.directiveScope.firstLoad = false; $scope.directiveScope.skip += $scope.directiveScope.limit; $scope.directiveScope.reloadRecords(); } this.previousChunk = function() { $scope.directiveScope.firstLoad = false; $scope.directiveScope.skip -= $scope.directiveScope.limit; $scope.directiveScope.reloadRecords(); } this.firstChunk = function() { $scope.directiveScope.firstLoad = false; $scope.directiveScope.skip = 0; $scope.directiveScope.reloadRecords(); } this.endChunk = function() { $scope.directiveScope.firstLoad = false; $scope.directiveScope.skip = $scope.directiveScope.totalCount - $scope.directiveScope.limit; $scope.directiveScope.reloadRecords(); } this.invertSort = function(_field) { $scope.directiveScope.firstLoad = false; //Already sorting?' var newDir = "asc"; if ($scope.directiveScope.sort && Object.keys($scope.directiveScope.sort).length > 0) { //Yes, get default or inverted dir newDir = $scope.directiveScope.sort[_field.name] ? { asc: "desc", desc: "asc" } [$scope.directiveScope.sort[_field.name]] : "asc"; } $scope.directiveScope.sort = {}; $scope.directiveScope.sort[_field.name] = newDir; $scope.directiveScope.reloadRecords(); } this.cancel = function() { $(".modal").modal('hide'); } this.done = function() { $(".modal").modal('hide'); } this.cancel = function() { $(".modal").modal('hide'); } this.isSelected = function(_record) { return $scope.directiveScope.selectionMode == "multiple" ? $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].some((b) => { return b && b._id && b._id == _record._id; }) : false; }; this.getRowClass = function(_record) { try { var classSelection = $scope.directiveScope.modelData.fields[$scope.directiveScope.layoutRecord.class_field].selections[_record[$scope.directiveScope.layoutRecord.class_field]]; } catch (e) {} return $scope.directiveScope.selectionMode == "multiple" && $scope.directiveScope.isSelected(_record) ? "bg-primary text-light" : ( classSelection && $scope.directiveScope.layoutRecord.class_field && $scope.directiveScope.layoutRecord.class_color ? 'bg-gradient-from-left-' + classSelection.class : 'bg-white' ); } this.createNew = function() { window.location.href = '/form?model=' + $scope.directiveScope.modelName + "&init=" + JSON.stringify($scope.directiveScope.initValues || {}); } this.rowClick = function(_record) { if ($scope.directiveScope.selectionMode == "multiple") { if ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].some((r) => { return r && (r._id == _record._id) })) { //Remove $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].filter((r) => { return r && (r._id != _record._id); }); } else { //Add (must be set this way to trigger events) $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].concat([_record]); } } } this.rowDoubleClick = function(_record) { if ($scope.directiveScope.selectionMode == "single") { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _record; $(".modal").modal('hide'); } else if ($scope.directiveScope.selectionMode == "multiple") { } else if ($scope.directiveScope.inWindow) { //Normal mode, open record window.location.href = "/form?model=" + $scope.directiveScope.modelName + "&_id=" + _record._id + ($scope.directiveScope.layoutRecord.default_form_layout ? ("&layout=" + $scope.directiveScope.layoutRecord.default_form_layout) : "") + "&reloadRate=" + $scope.directiveScope.layoutRecord.default_form_reload_rate; } else { //Normal mode, show modal of record $scope.directiveScope.viewRecordModal.id = null; $timeout(() => { $scope.directiveScope.viewRecordModal.layout = ($scope.directiveScope.layoutRecord.default_form_layout || null); $scope.directiveScope.viewRecordModal.model = $scope.directiveScope.modelName; $scope.directiveScope.viewRecordModal.reloadRate = ($scope.directiveScope.layoutRecord.default_form_reload_rate || null); $scope.directiveScope.viewRecordModal.id = _record._id; $scope.directiveScope.viewRecordModal.show(); }, 1); } } this.AddToBinding = function(_record) { //Add record (must be distinct if {distinct} is true) if (($scope.directiveScope.distinct && !$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].find((r) => { return r._id == _record._id; })) || !$scope.directiveScope.distinct) { _record.$selected = true; } }; this.RemoveFromBinding = function(_record) { //Remove _record.$selected = false; }; this.getLabel = function(_name) { return _name.split("_").map((c) => { return c.charAt(0).toUpperCase() + c.slice(1); }).join(" "); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: baseList failed to initialize: " + e); } }); } app.controller('ctrl_5f3e8c3d50a9cc72d8fcbfd2', ctrl_5f3e8c3d50a9cc72d8fcbfd2); app.directive('dynamicController', function() { return { scope: { supportingJs: "=?", htmlPath: "=?", modelName: "=?", record: "=?", field: "=?", fieldModel: "=?", encodedHtml: "=?" }, controller: ctrl_5f3e8c7050a9cc72d8fcbfd3, template: `
    `, bindToController: true};}); function ctrl_5f3e8c7050a9cc72d8fcbfd3($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.supportingJsLoaded = false; $scope.directiveScope = this; /* $scope.record = this.record; $scope.field = this.field; $scope.modelName = this.modelName; $scope.encodedHtml = this.encodedHtml; $scope.fieldModel = this.fieldModel; */ this.decodeHtml = function() { try { $scope.directiveScope.decodedHtml = decodeHtml($scope.directiveScope.encodedHtml); } catch (e) { $scope.directiveScope.decodedHtml = ""; } } Object.defineProperty($scope, "record", { get: function() { return $scope.directiveScope.record; } }); Object.defineProperty($scope, "field", { get: function() { return $scope.directiveScope.field; } }); Object.defineProperty($scope, "modelName", { get: function() { return $scope.directiveScope.modelName; } }); Object.defineProperty($scope, "encodedHtml", { get: function() { return $scope.directiveScope.encodedHtml; } }); Object.defineProperty($scope, "fieldModel", { get: function() { return $scope.directiveScope.fieldModel; } }); $scope.$watch('directiveScope.encodedHtml', function (_new, _old, scope) { if (JSON.stringify(_new) == JSON.stringify(_old)) { return; } $scope.directiveScope.decodeHtml(); }); //Inject all control angular-controllers into scope new Function("$scope", "$http", "$location", "$timeout", "$rootScope", "record", this.supportingJs) ( $scope, $http, $location, $timeout, $rootScope, this.record); this.decodeHtml(); this.supportingJsLoaded = true; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: dynamicController failed to initialize: " + e); } }); } app.controller('ctrl_5f3e8c7050a9cc72d8fcbfd3', ctrl_5f3e8c7050a9cc72d8fcbfd3); app.directive('modelSelection', function() { return { scope: { parentsOnly: "=?", onChange: "&", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) placeholder: "=?", allowFreeEntry: "=?", rootModel: "=?" }, controller: ctrl_5f3e8d0450a9cc72d8fcbfd6, template: `
    `, bindToController: true};}); function ctrl_5f3e8d0450a9cc72d8fcbfd6($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { //BINDS TO ID STRING this.$onInit = function() { this.parentsOnly = this.parentsOnly == null ? false : this.parentsOnly; this.unique = createUniqueTag(); this.search = ""; this.show = false; this.allowFreeEntry = this.allowFreeEntry == null ? false : this.allowFreeEntry; $scope.directiveScope = this; //Get models getModels($scope, $http, (data) => { $scope.directiveScope.modelsData = data; $scope.directiveScope.childModels = {}; $scope.directiveScope.parentModels = {}; Object.keys($scope.directiveScope.modelsData).forEach((modelName) => { var model = $scope.directiveScope.modelsData[modelName]; if (!$scope.directiveScope.rootModel || [model.parent, modelName].includes($scope.directiveScope.rootModel)) { if (!model.parent) { $scope.directiveScope.parentModels[modelName] = model; } else { $scope.directiveScope.childModels[model.parent] = $scope.directiveScope.childModels[model.parent] || {}; $scope.directiveScope.childModels[model.parent][modelName] = model; } } }); $scope.directiveScope.search = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; }); }; this.cancel = function() { $scope.directiveScope.show = false; } this.checkForFreeEntry = function(_freeEntry) { if ($scope.directiveScope.allowFreeEntry) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _freeEntry; } } this.select = function(_modelName) { var previousValue = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _modelName; $scope.directiveScope.search = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; if ($scope.directiveScope.onChange && _modelName != previousValue) { $scope.directiveScope.onChange(); } $scope.directiveScope.show = false; }; this.clear = function() { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = null; $scope.directiveScope.search = ""; if ($scope.directiveScope.onChange) { $scope.directiveScope.onChange(); } }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modelSelection failed to initialize: " + e); } }); } app.controller('ctrl_5f3e8d0450a9cc72d8fcbfd6', ctrl_5f3e8d0450a9cc72d8fcbfd6); app.directive('singleReferenceSelection', function() { return { scope: { display: "=?", //Field to display (default if not provided) onChange: "&", refModel: "=", allowNew: "=?", allowView: "=?", allowEdit: "=?", allowSelection: "=?", displayRecord: "=?", refQualifier: "=?", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) layoutName: "=", //Name of list layout to use when choosing a new value. If not set the first applicable layout is used viewLayout: "=?", allowInteraction: "=?", //Overrides form detection and allows interaction (CAREFUL OF INFINITE RECURSIVE LOADING) displayTextClass: "=?" //Whether to apply the context_class to the text }, controller: ctrl_5f3e8d3350a9cc72d8fcbfd7, template: `
    `, bindToController: true};}); function ctrl_5f3e8d3350a9cc72d8fcbfd7($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { //BINDS TO ID STRING this.$onInit = function() { this.listModal = {}; this.currentRecordModal = {}; this.newRecordModal = { newRecord: {} }; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.allowNew = this.allowNew == null ? true : this.allowNew; this.allowView = this.allowView == null ? true : this.allowView; this.allowEdit = this.allowEdit == null ? true : this.allowEdit; $scope.directiveScope = this; this.unique = createUniqueTag(); this.loading = false; this.refQualifier = this.refQualifier || {}; //Normlize binding (to single id string or null) if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && this.bindingParent[this.bindingName] && typeof(this.bindingParent[this.bindingName]) == "object") { //Load in the populated record this.displayRecord = this.bindingParent[this.bindingName]; //If in interactive mode, set the binding to the _id, otherwise leave as is (possibly populated) this.bindingParent[this.bindingName] = this.allowInteraction ? this.displayRecord._id : this.displayRecord; } else { //id or null provded, load bound record this.loading = true; if (this.bindingParent[this.bindingName]) { //Get existing record this.loadDisplayRecord(); } else { this.displayRecord = null; this.loading = false; } } //Watch for binding change $scope.$watch('directiveScope.bindingParent[directiveScope.bindingName]', function (newValue, oldValue, scope) { if (newValue != oldValue && !$scope.directiveScope.displayUpdating) { $scope.directiveScope.bindingUpdating = true; $scope.directiveScope.loadDisplayRecord(() => { $scope.directiveScope.bindingUpdating = false; }); } }, true); //Watch for record change $scope.$watch('directiveScope.displayRecord', function (newValue, oldValue, scope) { if (newValue != oldValue) { $scope.directiveScope.displayUpdating = true; //If in interactive mode, set the binding to the _id, otherwise leave as is (possibly populated) $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.displayRecord ? $scope.directiveScope.displayRecord._id : null; $scope.directiveScope.displayUpdating = false; $scope.directiveScope.onChange(); } }, true); //Get default layout for display field this.layout = $scope.$root.layouts.find((l) => { return l.model == this.refModel && l.default && l._type == "form_layout"; }); } this.loadDisplayRecord = function(_fresh, _then) { if (!this.bindingParent[this.bindingName]) { this.displayRecord = null; this.loading = false; if (_then) { _then(); } } else { retrieveRecord($scope, $http, this.refModel, { query: { _id: this.bindingParent[this.bindingName] }, cached: true }, (record) => { this.displayRecord = record; this.loading = false; if (_then) { _then(); } }); } } this.showCurrent = function() { if (this.allowView && this.displayRecord) { this.currentRecordModal.show(() => { this.loadDisplayRecord(true); }); } } this.showNew = function() { this.newRecordModal.newRecord = {}; this.newRecordModal.show(() => { if (this.newRecordModal.newRecord._id) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = this.newRecordModal.newRecord._id; this.loadDisplayRecord(true); } }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: singleReferenceSelection failed to initialize: " + e); } }); } app.controller('ctrl_5f3e8d3350a9cc72d8fcbfd7', ctrl_5f3e8d3350a9cc72d8fcbfd7); app.directive('singleReferenceDropdownSelection', function() { return { scope: { title: "=", display: "=?", refModel: "=", refQualifier: "=?", sort: "=?", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) onChange: "&", displayRecord: "=?", allowInteraction: "=?" }, controller: ctrl_5f3e8d6850a9cc72d8fcbfd8, template: ` `, bindToController: true};}); function ctrl_5f3e8d6850a9cc72d8fcbfd8($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); this.display = this.display == null ? $scope.$root.models[this.refModel].display_field : this.display; $scope.directiveScope = this; this.updateDisplayRecord = function() { if (!$scope.directiveScope.bindingParent || !$scope.directiveScope.bindingName || !$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] || !$scope.directiveScope.selections) { $scope.directiveScope.displayRecord = null; } else { $scope.directiveScope.displayRecord = $scope.directiveScope.selections[$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]].record; } } //Populate selections retrieveRecords($scope, $http, $scope.directiveScope.refModel, { query: ($scope.directiveScope.refQualifier ? $scope.directiveScope.refQualifier : {}), sort: ($scope.directiveScope.sort || {}) }, (response) => { $scope.directiveScope.selections = { null: { label: "None" } }; response.records.forEach((record) => { $scope.directiveScope.selections[record._id] = { label: record[$scope.directiveScope.display], icon: record.icon ? record.icon.link : ($scope.$root.models[record._type || $scope.directiveScope.refModel].icon.link), record: record }; }); }); $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { //Update display record if binding changes $scope.directiveScope.updateDisplayRecord(); }); $scope.$watch("directiveScope.selections", () => { //Update display record if selections change (sometimes the binding is set before the selections are available) $scope.directiveScope.updateDisplayRecord(); }); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: singleReferenceDropdownSelection failed to initialize: " + e); } }); } app.controller('ctrl_5f3e8d6850a9cc72d8fcbfd8', ctrl_5f3e8d6850a9cc72d8fcbfd8); app.directive('multipleReferenceSelection', function() { return { scope: { onChange: "&", allowNew: "=?", allowInteraction: "=?", title: "=", refModel: "=", refQualifier: "=?", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) distinct: "=", layoutName: "=?", //Name of list layout to use when choosing a new value. If not set the first applicable layout is used ordered: "=?", limit: "=?", allowSelectAll: "=?", subIconField: "=?", displayTextClass: "=?", displayField: "=?" }, controller: ctrl_5f3e8d9c50a9cc72d8fcbfd9, template: `
     All 
    `, bindToController: true};}); function ctrl_5f3e8d9c50a9cc72d8fcbfd9($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.listModal = {}; this.currentRecordModal = { id: null }; this.newRecordModal = { id: null }; this.displayRecords = []; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.refQualifier = this.refQualifier == null ? {} : this.refQualifier; $scope.directiveScope = this; $scope.parentBaseFormScope = searchFullScope($scope.$parent, "directiveScope") //CLone ref qualifier into malleable object this.qualifier = {}; Object.assign(this.qualifier, this.refQualifier); //Create unique tag this.unique = createUniqueTag() //Normalize binding (to array of id strings or empty array) if (Array.isArray(this.bindingParent[this.bindingName]) && this.bindingParent[this.bindingName].some((v) => { return typeof(v) == "object"; })) { //Array of objects provided Object.assign(this.displayRecords, this.bindingParent[this.bindingName]); } else { $scope.directiveScope.updateDisplay(); } $scope.$watch('directiveScope.displayRecords', function (_new, _old) { if (JSON.stringify(_new) != JSON.stringify(_old)) { $scope.directiveScope.updateBinding(); } }); //Get default layout for display field this.layout = $scope.$root.layouts.find((l) => { return l.model == this.refModel && l.default && l._type == "form_layout"; }); }; $scope.$watch('directiveScope.bindingParent[directiveScope.bindingName]', function (_new, _old) { if (JSON.stringify(_new) != JSON.stringify(_old)) { $scope.directiveScope.updateDisplay(); } }); this.updateDisplay = function() { if (!$scope.directiveScope.loading) { //Array of IDs supplied, populate dispalyRecords if (!$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { $scope.directiveScope.displayRecords = []; $scope.directiveScope.updateBinding(); $scope.directiveScope.loading = false; } else { $scope.directiveScope.loading = true retrieveRecords($scope, $http, $scope.directiveScope.refModel, { query: { _id: { $in: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] } } }, (response) => { $scope.directiveScope.displayRecords = []; //Set displayRecords in same order as binding to avoid reordering for(var i in $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { var record = response.records.find((r) => { return r._id == $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][i]; }); if (record) { $scope.directiveScope.displayRecords.push(record); } } $scope.directiveScope.updateBinding(); $scope.directiveScope.loading = false; }); } } } this.updateBinding = function() { if (!$scope.directiveScope.loading) { $scope.directiveScope.loading = true $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.displayRecords.filter((r) => { return r && r._id; }).map((r) => { return r._id }); $scope.directiveScope.loading = false; $scope.directiveScope.onChange(); } } this.showCurrent = function(_id) { $scope.directiveScope.currentRecordModal.id = _id; $scope.directiveScope.currentRecordModal.show(() => { //$scope.directiveScope.loadDisplayRecord(true); }); } this.showNew = function(_id) { $scope.directiveScope.newRecordModal.ready = true; $scope.directiveScope.newRecordModal.id = null; $scope.directiveScope.newRecordModal.show(() => { if ($scope.directiveScope.newRecordModal.id && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].push($scope.directiveScope.newRecordModal.id); $scope.directiveScope.updateDisplay(); $scope.directiveScope.newRecordModal.ready = false; safeApply($scope); } }); } this.selectAll = function() { if (confirm("Are you sure you want to select all applicable " + $scope.$root.models[$scope.directiveScope.refModel].plural_name + " records?")) { $scope.directiveScope.selectingAll = true; retrieveRecords($scope, $http, $scope.directiveScope.refModel, { query: $scope.directiveScope.refQualifier }, (response) => { $scope.directiveScope.displayRecords = response.records; $scope.directiveScope.selectingAll = false; }); } } this.moveRecord = function(_index, _up) { var record = $scope.directiveScope.displayRecords[_index]; $scope.directiveScope.displayRecords.splice(_index, 1); $scope.directiveScope.displayRecords.splice(_up ? (_index - 1) : (_index + 1), 0, record); $scope.directiveScope.updateBinding(); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: multipleReferenceSelection failed to initialize: " + e); } }); } app.controller('ctrl_5f3e8d9c50a9cc72d8fcbfd9', ctrl_5f3e8d9c50a9cc72d8fcbfd9); app.directive('baseAlert', function() { return { scope: {}, controller: ctrl_5f3e8dca50a9cc72d8fcbfda, template: ` `, bindToController: true};}); function ctrl_5f3e8dca50a9cc72d8fcbfda($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { $scope.currentTimeout = null; $scope.$root.$on('showAlert', function(event, _message, _severity, _timeout) { if ($scope.currentTimeout) { $timeout.cancel($scope.currentTimeout); } _severity = _severity ? _severity : "primary"; $scope.severity = _severity; $scope.text = _message ; $scope.visible = true; $scope.loaded = true; $scope.currentTimeout = $timeout(() => { $scope.visible = false; }, Math.max(2000, _timeout || _message.split(" ").length * 500)); }); $scope.toTrusted = function(_html) { return $sce.trustAsHtml(_html); };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: baseAlert failed to initialize: " + e); } }); } app.controller('ctrl_5f3e8dca50a9cc72d8fcbfda', ctrl_5f3e8dca50a9cc72d8fcbfda); app.directive('queryClause', function() { return { scope: { allowInteraction: "=?", bindingParent: "=?", bindingName: "=?", modelName: "=?", fieldName: "=?", //Used for dynamic UI, not binding operators: "=", level: "=?" }, controller: ctrl_5f3e8e0a50a9cc72d8fcbfdb, template: `
    {{directiveScope.bindingParent[directiveScope.dynamicFieldBinding.name]}}
    `, bindToController: true};}); function ctrl_5f3e8e0a50a9cc72d8fcbfdb($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.clauseRemoveMouseover = function() { $scope.directiveScope.deleteHovered = true; } this.clauseRemoveMouseleave = function() { $scope.directiveScope.deleteHovered = false; } this.removeClause = function() { delete $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; } this.currentDynamicControl; Object.defineProperty($scope.directiveScope, "dynamicControl", { get: function() { var operatorConfig = $scope.directiveScope.operators[$scope.directiveScope.bindingName]; var typeConfig = operatorConfig.types[$scope.$root.models[$scope.directiveScope.modelName].fields[$scope.directiveScope.fieldName].type]; var newControl = getDefaultControls( $scope, $scope.directiveScope.modelName, $scope.directiveScope.fieldName)[(operatorConfig.array ? "plural" : "singular") + "_" + ($scope.directiveScope.allowInteraction ? 'write' : 'read')]; if (angular.toJson(newControl) != angular.toJson($scope.directiveScope.currentDynamicControl)) { $scope.directiveScope.currentDynamicControl = newControl; } return $scope.directiveScope.currentDynamicControl; } }); this.currentDynamicFieldBinding; Object.defineProperty($scope.directiveScope, "dynamicFieldBinding", { get: function() { var f = {}; Object.assign(f, $scope.$root.models[$scope.directiveScope.modelName].fields[$scope.directiveScope.fieldName]); f.name = $scope.directiveScope.bindingName; if (angular.toJson(f) != angular.toJson($scope.directiveScope.currentDynamicFieldBinding)) { $scope.directiveScope.currentDynamicFieldBinding = f; } return $scope.directiveScope.currentDynamicFieldBinding; } }); $scope.$watch("directiveScope.bindingName", (_new, _old) => { if (_new && _old && (_new != _old) && $scope.directiveScope.bindingParent) { if ($scope.directiveScope.operators[_old].array == $scope.directiveScope.operators[_new].array) { $scope.directiveScope.bindingParent[_new] = $scope.directiveScope.bindingParent[_old]; } else if ($scope.directiveScope.operators[_new].array) { $scope.directiveScope.bindingParent[_new] = $scope.directiveScope.bindingParent[_old] == null ? null : [$scope.directiveScope.bindingParent[_old]]; } else { $scope.directiveScope.bindingParent[_new] = $scope.directiveScope.bindingParent[_old][0]; } delete $scope.directiveScope.bindingParent[_old]; } else if (_old != null && _new == null) { delete $scope.directiveScope.bindingParent[_old]; } }); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: queryClause failed to initialize: " + e); } }); } app.controller('ctrl_5f3e8e0a50a9cc72d8fcbfdb', ctrl_5f3e8e0a50a9cc72d8fcbfdb); app.directive('nodeRelationMap', function() { return { scope: { nodes: "=", relations: "=?", options: "=?", onNodeSelection: "=?", onRelationSelection: "=?" }, controller: ctrl_5f3e8e5a50a9cc72d8fcbfdc, template: `
    Building node map...
    `, bindToController: true};}); function ctrl_5f3e8e5a50a9cc72d8fcbfdc($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { $element.append($compile("
    ")($scope)); this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; var defaults = { height: "500px", width: "100%", nodes: { shape: 'image', size: 20 }, edges: { arrows: "to" }, layout: { improvedLayout: true, hierarchical: { // direction: "UD", //sortMethod: "directed" } }, physics: { enabled: false } }; Object.assign(defaults, this.options); this.options = defaults; this.redraw(); $scope.$watch('directiveScope.nodes', function (newValue, oldValue, scope) { if (newValue != oldValue) { $scope.directiveScope.redraw(); } }, true); $scope.$watch('directiveScope.relations', function (newValue, oldValue, scope) { if (newValue != oldValue) { $scope.directiveScope.redraw(); } }, true); }; this.redraw = function() { waitForElement('nodemap_' + this.unique, (element) => { this.container = element; this.network = new vis.Network(this.container, { nodes: new vis.DataSet(this.nodes || []), edges: new vis.DataSet(this.relations || []) }, this.options); this.network.stabilize(10); this.network.on("selectNode", (_data) => { if (this.onNodeSelection) { this.onNodeSelection(_data); } }); this.network.on("selectEdge", (_data) => { if (this.onRelationSelection) { this.onRelationSelection(_data); } }); }); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: nodeRelationMap failed to initialize: " + e); } }); } app.controller('ctrl_5f3e8e5a50a9cc72d8fcbfdc', ctrl_5f3e8e5a50a9cc72d8fcbfdc); app.directive('singleFileUpload', function() { return { scope: { bindingParent: "=", bindingName: "=", acceptedExtensions: "=?", imagePreview: "=?", imagePreviewSize: "=?", allowDownload: "=?", readOnly: "=?", //Remove this later allowInteraction: "=?", showPreview: "=?", showTag: "=?", showFile: "=?", truncateLength: "=?", allowPrint: "=?", printerSelectionQualifier: "=?", defaultPrinter: "=?" //For initial set }, controller: ctrl_5f3e8eb050a9cc72d8fcbfde, template: `
    {{directiveScope.truncate(directiveScope.bindingParent[directiveScope.bindingName].name + "." + directiveScope.bindingParent[directiveScope.bindingName].extension)}} ({{directiveScope.formatSize(directiveScope.bindingParent[directiveScope.bindingName].size)}}) Save to Upload
    {{directiveScope.getTrustedResourceUrl(directiveScope.bindingParent[directiveScope.bindingName].link)}}
    Printer
    `, bindToController: true};}); function ctrl_5f3e8eb050a9cc72d8fcbfde($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); this.showFile = this.showFile == null ? true : this.showFile; this.imagePreviewExtensions = ["png", "jpg", "jpeg", "ico", "bmp", "webp"]; this.showPreview = this.showPreview == null ? true : this.showPreview; this.trustAsResourceUrl = function(_url) { return $sce.trustAsResourceUrl(_url); } this.truncateLength = this.truncateLength == null ? 999 : this.truncateLength; this.allowDownload = this.allowDownload == null ? true : this.allowDownload; this.imagePreviewSize = this.imagePreviewSize == null ? 12 : this.imagePreviewSize; this.printer = this.defaultPrinter ? this.defaultPrinter + "" : null; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; $scope.directiveScope = this; this.previewModal = { buttons: {} }; if (this.allowPrint) { this.previewModal.buttons.print = { label: "Print", class: "primary" }; } if (this.allowDownload) { this.previewModal.buttons.download = { label: "Download", class: "success" }; } this.showPreviewModal = function() { if ($scope.directiveScope.showPreview) { $scope.directiveScope.firstOpen = true; $scope.directiveScope.previewModal.title = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].name + " (" + $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].extension + ")", $scope.directiveScope.previewModal.show((selection) => { if (selection == "print") { printLink($scope, $http, $scope.directiveScope.printer, $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].link, { }, () => { }); } else if (selection == "download") { downloadLink($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].link, $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].name); } }); } else { window.open($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].link, '_blank'); } } this.truncate = function(_string) { return _string.truncate($scope.directiveScope.truncateLength); } this.formatSize = function(_size) { if (_size > 1073741823) { return (_size / 1073741824).toFixed(0) + " GB"; } else if (_size > 1048575) { return (_size / 1048576).toFixed(0) + " MB"; } else if (_size > 1023) { return (_size / 1024).toFixed(0) + " KB"; } else { return _size + " Bytes"; } } this.openBrowser = function() { $("#" + this.unique).click(); }; this.changed = function(_event){ var reader = new FileReader(); var targetFile = _event.target.files[0]; reader.readAsDataURL(targetFile); var nameSplit = targetFile.name.split("."); reader.onloadend = (e) => { //Build file payload to be handled at the model level this.bindingParent[this.bindingName] = { data: reader.result.split(",")[1], extension: nameSplit.length > 1 ? nameSplit.pop() : "", name: nameSplit.join("."), size: targetFile.size, }; $rootScope.$digest(); }; } };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: singleFileUpload failed to initialize: " + e); } }); } app.controller('ctrl_5f3e8eb050a9cc72d8fcbfde', ctrl_5f3e8eb050a9cc72d8fcbfde); app.directive('multipleFileUpload', function() { return { scope: { bindingParent: "=", bindingName: "=", acceptedExtensions: "=?", imagePreview: "=?", imagePreviewSize: "=?", allowDownload: "=?", showTags: "=?", allowInteraction: "=?" }, controller: ctrl_5f3e8ed650a9cc72d8fcbfdf, template: `
    `, bindToController: true};}); function ctrl_5f3e8ed650a9cc72d8fcbfdf($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.allowDownload = this.allowDownload == null ? true : this.this.allowDownload; this.imagePreviewSize = this.imagePreviewSize == null ? 100 : this.imagePreviewSize; $scope.directiveScope = this; this.newUpload = null; $scope.$watch("directiveScope.newUpload", function (newValue, oldValue, scope) { if ($scope.directiveScope.newUpload) { $scope.directiveScope.newUpload.unique = new Date().getTime(); $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].push($scope.directiveScope.newUpload); $scope.directiveScope.newUpload = null; } }); this.moveRecord = function(_index, _up) { var record = this.bindingParent[this.bindingName][_index]; this.bindingParent[this.bindingName].splice(_index, 1); this.bindingParent[this.bindingName].splice(_up ? (_index - 1) : (_index + 1), 0, record); } };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: multipleFileUpload failed to initialize: " + e); } }); } app.controller('ctrl_5f3e8ed650a9cc72d8fcbfdf', ctrl_5f3e8ed650a9cc72d8fcbfdf); app.directive('printTemplateRenderer', function() { return { scope: { templateId: "=", templateData: "=?", fileType: "=?" } , controller: ctrl_5f4ff2e22c4f26499f6f39ec, template: `
    `, bindToController: true};}); function ctrl_5f4ff2e22c4f26499f6f39ec($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { //Break binding of value this.unique = createUniqueTag(); this.templateData = this.templateData || {}; $scope.directiveScope = this; this.url = ""; this.fileType = this.fileType || "png" this.update(); } $scope.$watch("directiveScope.templateId", () => { $scope.directiveScope.update(); }); $scope.$watch("directiveScope.templateData", () => { $scope.directiveScope.update(); }, true); $scope.$watch("directiveScope.fileType", () => { $scope.directiveScope.update(); }, true); this.update = function() { $scope.directiveScope.url = "/api/render/template/" + $scope.directiveScope.templateId + "/image/" + $scope.directiveScope.fileType + "?data=" + btoa(unescape(encodeURIComponent(JSON.stringify($scope.directiveScope.templateData)))); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: printTemplateRenderer failed to initialize: " + e); } }); } app.controller('ctrl_5f4ff2e22c4f26499f6f39ec', ctrl_5f4ff2e22c4f26499f6f39ec); app.directive('barcode', function() { return { scope: { value: "=", type: "=?", includeText: "=?", actualLength: "=?", actualWidth: "=?", square: "=?" } , controller: ctrl_5f50418e0c22a85c66acf7e0, template: `
    {{directiveScope.value}}
    `, bindToController: true};}); function ctrl_5f50418e0c22a85c66acf7e0($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.id = createUniqueTag(); $scope.directiveScope = this; this.type = this.type || "code128"; this.mmL = this.actualLength || 20; this.mmW = this.actualWidth || 20; if (this.square) { var s = Math.min(this.mmL, this.mmW); this.mmL = s; this.mmW = s; } $scope.$watch("directiveScope.value", () => { $scope.directiveScope.url = "/api/barcode/generate/" + $scope.directiveScope.type + "/" + encodeURIComponent(btoa($scope.directiveScope.value)) + "?length=" + $scope.directiveScope.mmL + "&width=" + $scope.directiveScope.mmW + "&includeText=" + JSON.stringify(!!$scope.directiveScope.includeText) + "&base64=true"; }); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: barcode failed to initialize: " + e); } }); } app.controller('ctrl_5f50418e0c22a85c66acf7e0', ctrl_5f50418e0c22a85c66acf7e0); app.directive('encodedContainer', function() { return { scope: { encodedHtml: "=" }, controller: ctrl_5f52eecf577d7429fcaa0466, template: `
    `, bindToController: true};}); function ctrl_5f52eecf577d7429fcaa0466($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; $scope.$watch('directiveScope.encodedHtml', function (newValue, oldValue, scope) { try { $scope.directiveScope.decodedHtml = decodeHtml($scope.directiveScope.encodedHtml); } catch (e) { $scope.directiveScope.decodedHtml = ""; } }); };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: encodedContainer failed to initialize: " + e); } }); } app.controller('ctrl_5f52eecf577d7429fcaa0466', ctrl_5f52eecf577d7429fcaa0466); app.directive('arrayEditor', function() { return { scope: { bindingParent: "=", bindingName: "=", defaultValue: "=?", columnNames: "=?", onChange: "&" }, transclude: { value1: "?value1", value2: "?value2", value3: "?value3", value4: "?value4", value5: "?value5", value6: "?value6", value7: "?value7", value8: "?value8", value9: "?value9", value10: "?value10", value11: "?value11", value12: "?value12", value13: "?value13", value14: "?value14", value15: "?value15", value16: "?value16", value17: "?value17", value18: "?value18", value19: "?value19", value20: "?value20" }, controller: ctrl_5f559ae6ad965a684404dd15, template: `
    {{columnName}}
    `, bindToController: true};}); function ctrl_5f559ae6ad965a684404dd15($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); this.defaultValue = this.defaultValue != null ? this.defaultValue : null; this.columnNames = this.columnNames != null ? this.columnNames : []; $scope.directiveScope = this; this.addValue = function() { this.bindingParent[this.bindingName].push(cloneObject(this.defaultValue)); if (this.onChange) { this.onChange(); } } this.removeValue = function(_index) { this.bindingParent[this.bindingName].splice(_index, 1); } }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: arrayEditor failed to initialize: " + e); } }); } app.controller('ctrl_5f559ae6ad965a684404dd15', ctrl_5f559ae6ad965a684404dd15); app.directive('dynamicAngularControl', function() { return { scope: { supportingJs: "=?", encodedHtml: "=" }, controller: ctrl_5f6bdf5c67ff216a389cb7b7, template: `
    `, bindToController: true};}); function ctrl_5f6bdf5c67ff216a389cb7b7($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; $scope.$watch('directiveScope.encodedHtml', function (newValue, oldValue, scope) { try { $scope.directiveScope.decodedHtml = decodeHtml($scope.directiveScope.encodedHtml); } catch (e) { $scope.directiveScope.decodedHtml = ""; } }); $scope.$watch('directiveScope.supportingJs', function (newValue, oldValue, scope) { try { new Function("$appScope", "$scope", "$http", "$location", "$timeout", "$rootScope", $scope.directiveScope.supportingJs)($scope.$parent.$parent, $scope, $http, $location, $timeout, $rootScope); } catch (e) { console.log("Error initializing Dynamic Angular Control directive: " + e); } }); this.scriptLoaded = true; } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: dynamicAngularControl failed to initialize: " + e); } }); } app.controller('ctrl_5f6bdf5c67ff216a389cb7b7', ctrl_5f6bdf5c67ff216a389cb7b7); app.directive('printTemplateEditor', function() { return { scope: { templateId: "=", value: "=", field: "=?", x: "=", y: "=", length: "=?", width: "=?", rotation: "=?", borderStyle: "=?", borderWidth: "=?", borderColor: "=?", borderRadius: "=?", parameters: "=?" } , controller: ctrl_5f74faca382d7210bac7e482, template: `
    `, bindToController: true};}); function ctrl_5f74faca382d7210bac7e482($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { //Break binding of value this.unique = createUniqueTag(); $scope.directiveScope = this; //Set defaults/static this.x = this.x || 0; this.y = this.y || 0; this.rotation = this.rotation || 0; this.parameters = this.parameters || {}; //Get template record retrieveRecord($scope, $http, "print_template", { query: { _id: this.templateId }}, (templateRecord) => { //Set default dimensions this.length = this.length || (templateRecord.default_length || 10); this.width = this.width || (templateRecord.default_width || 10); if (this.rotation >= 270) { this.yOffset = this.width; this.xOffset = 0; } else if (this.rotation >= 180) { this.yOffset = this.length; this.xOffset = this.width; } else if (this.rotation >= 90 ) { this.yOffset = 0; this.xOffset = this.length; } else { this.yOffset = 0; this.xOffset = 0; } //Merge template parameters with baseParameters templateRecord.parameters = templateRecord.parameters || {}; //Apply parameter defaults to unassigned Object.keys(templateRecord.parameters).forEach((parameter) => { this.parameters[parameter] = this.parameters.hasOwnProperty(parameter) ? this.parameters[parameter] : templateRecord.parameters[parameter].default; }); //Decode HTML templateRecord.decodedHtml = templateRecord.html.length > 1 ? decodeHtml(templateRecord.html) : null; this.templateRecord = templateRecord; }); }; function toRad(_deg) { return _deg * (Math.PI / 180); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: printTemplateEditor failed to initialize: " + e); } }); } app.controller('ctrl_5f74faca382d7210bac7e482', ctrl_5f74faca382d7210bac7e482); app.directive('singleReferenceDropdownSelectionBeta', function() { return { scope: { title: "=", display: "=", refModel: "=", refQualifier: "=?", sort: "=?", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) selectedRecord: "=?", onChange: "&" }, controller: ctrl_5f7533c4382d7210bac7e560, template: `
    `, bindToController: true};}); function ctrl_5f7533c4382d7210bac7e560($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; //Trigger selectedRecordUpdate if binding is modified $scope.$watch('directiveScope.bindingParent[directiveScope.bindingName]', function (_new, _old, _scope) { $scope.directiveScope.updateSelectedRecord(); }); //selectedRecord should not be updated externally this.updateSelectedRecord = function() { this.selectedRecord = this.bindingParent[this.bindingName] ? this.selections.find((selection) => { return selection.value == this.bindingParent[this.bindingName]; }) : null; }; //Get possible options getRecords($scope, $http, this.refModel, this.refQualifier ? this.refQualifier : {}, [], this.sort || {}, null, null, (response) => { this.selections = response.records.map((record) => { return { label: record[this.display], value: record._id, record: record }; }); if (this.allowNone) { this.selections.unshift({ label: "< None >", value: null }); } this.updateSelectedRecord(); }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: singleReferenceDropdownSelectionBeta failed to initialize: " + e); } }); } app.controller('ctrl_5f7533c4382d7210bac7e560', ctrl_5f7533c4382d7210bac7e560); app.directive('toggleSwitch', function() { return { scope: { bindingName: "=", bindingParent: "=", onChange: "&", readOnly: "=?", trueLabel: "=?", falseLabel: "=?", trueClass: "=?", falseClass: "=?", trueImage: "=?", falseImage: "=?", size: "=?" }, controller: ctrl_5f8838ff9b63ee50b8a3f515, template: ` `, bindToController: true};}); function ctrl_5f8838ff9b63ee50b8a3f515($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.size = this.size == null ? "slim" : this.size; this.trueLabel = this.trueLabel == null ? "Yes" : this.trueLabel; this.falseLabel = this.falseLabel == null ? "No" : this.falseLabel; this.trueClass = this.trueClass == null ? "success" : this.trueClass; this.falseClass = this.falseClass == null ? "secondary" : this.falseClass; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: toggleSwitch failed to initialize: " + e); } }); } app.controller('ctrl_5f8838ff9b63ee50b8a3f515', ctrl_5f8838ff9b63ee50b8a3f515); app.directive('lineChart', function() { return { scope: { seriesConfig: "=?", seriesData: "=?", axisXLabel: "=?", axisYLabel: "=?", printMode: "=?", axisYMax: "=?" }, controller: ctrl_5f8f3f5c4a10fc529fe4b9cc, template: `
    In Development
    `, bindToController: true};}); function ctrl_5f8f3f5c4a10fc529fe4b9cc($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; //Configure watch $scope.$watch('[directiveScope.seriesConfig, directiveScope.seriesData]', function (_new, _old, _scope) { $scope.directiveScope.process(); }, true); this.chartOptions = { devicePixelRatio: this.printMode ? 8 : 1, responsive: true, maintainAspectRatio: false, scales: { yAxes: [{ ticks: { fontSize: 10, weight: "strong" }, scaleLabel: { display: true, labelString: this.axisYLabel, fontSize: 10, fontWeight: "strong", padding: 0 } }], xAxes: [{ ticks: { fontSize: 10, weight: "strong" }, scaleLabel: { display: true, labelString: this.axisXLabel, fontSize: 10, fontWeight: "strong", padding: 0 } }] } }; }; this.process = function() { //Get array of series names from seriesConfig this.chartSeries = Object.values(this.seriesConfig).map((s) => { return s.label; }); //Get array of X axis values this.chartLabels = Object.keys(this.seriesData); //Sort the X axis labels if theyre all numbers if (!this.chartLabels.some((l) => { return isNaN(parseFloat(l)); })) { this.chartLabels = this.chartLabels.sort((a, b) => { return parseFloat(a) > parseFloat(b) ? 1 : -1; }); } //Generate chartData (array (of arrays of Y values), one for each series) this.chartData = Object.keys(this.seriesConfig).map((seriesName) => { return this.chartLabels.map((label) => { var point = this.seriesData[label]; return point[seriesName] ? point[seriesName].value : null; }); }); //Generate chartColors this.chartColors = Object.keys(this.seriesConfig).map((c) => { return { pointBorderColor: Object.values(this.seriesData).map((d) => { return d[c].pointColor; }), pointBackgroundColor: Object.values(this.seriesData).map((d) => { return d[c].pointColor; }) }; }); //Generate chartDatasetOverride this.chartDatasetOverride = Object.values(this.seriesConfig).map((c) => { return { backgroundColor: c.fillColor, fill: c.fill ? c.fillMode : false, borderColor: c.lineColor }; }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: lineChart failed to initialize: " + e); } }); } app.controller('ctrl_5f8f3f5c4a10fc529fe4b9cc', ctrl_5f8f3f5c4a10fc529fe4b9cc); app.directive('spinner', function() { return { scope: { } , controller: ctrl_5f96205725699c5e58d816f2, template: `
    `, bindToController: true};}); function ctrl_5f96205725699c5e58d816f2($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: spinner failed to initialize: " + e); } }); } app.controller('ctrl_5f96205725699c5e58d816f2', ctrl_5f96205725699c5e58d816f2); app.directive('booleanDisplay', function() { return { scope: { bindingName: "=", bindingParent: "=", trueLabel: "=?", falseLabel: "=?", onChange: "&" }, controller: ctrl_5f9ac932e0aef53f2ef0e004, template: ` `, bindToController: true};}); function ctrl_5f9ac932e0aef53f2ef0e004($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: booleanDisplay failed to initialize: " + e); } }); } app.controller('ctrl_5f9ac932e0aef53f2ef0e004', ctrl_5f9ac932e0aef53f2ef0e004); app.directive('progressBar', function() { return { scope: { displayStyle:"=?", bindingName: "=", bindingParent: "=", valueMax: "=?", valueMin: "=?", barClass: "=?", textClass: "=?", text: "=?", height: "=?" }, controller: ctrl_5f9ad4b6c7e18c4624d307d2, template: `
    {{directiveScope.text}}
    {{directiveScope.text}}
    `, bindToController: true};}); function ctrl_5f9ad4b6c7e18c4624d307d2($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.displayStyle = this.displayStyle == null ? "bar" : this.displayStyle; this.valueMax = this.valueMax == null ? 1 : this.valueMax; this.valueMin = this.valueMin == null ? 0 : this.valueMin; this.barClass = this.barClass == null ? 'primary' : this.barClass; this.textClass = this.textClass == null ? (this.displayStyle == "ring" ? 'secondary' : 'light') : this.textClass; } // ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: progressBar failed to initialize: " + e); } }); } app.controller('ctrl_5f9ad4b6c7e18c4624d307d2', ctrl_5f9ad4b6c7e18c4624d307d2); app.directive('hoverFlip', function() { return { scope: { }, transclude: { default: "default", flip: "flip" }, controller: ctrl_5f9cbb4a3b8b3d61285a5a30, template: `
    `, bindToController: true};}); function ctrl_5f9cbb4a3b8b3d61285a5a30($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: hoverFlip failed to initialize: " + e); } }); } app.controller('ctrl_5f9cbb4a3b8b3d61285a5a30', ctrl_5f9cbb4a3b8b3d61285a5a30); app.directive('modal', function() { return { scope: { directiveRef: "=", title: "=?", buttons: "=?", allowClose: "=?", large: "=?", container: " { b.enabled = (b.enable == null ? () => { return true; } : (typeof(b.enable) == "boolean" ? () => { return b.enable; } : new Function("directiveScope", b.enable) ) ); }); //Set up reference object scope.directiveScope.directiveRef.hide = function() { setTimeout(() => { $("#" + scope.directiveScope.unique).modal('hide'); scope.directiveScope.directiveRef.visible = false; }, 200); } $(document).on('hidden.bs.modal', "#" + scope.directiveScope.unique, () => { if (scope.directiveScope.then) { scope.directiveScope.then(); } }); scope.directiveScope.directiveRef.show = function(_then) { scope.directiveScope.then = (button) => { if (button == null || scope.directiveScope.buttons[button].closeOnSelection != false) { scope.directiveScope.directiveRef.hide(); } if(_then) { _then(button, scope.directiveScope.directiveRef); } } scope.directiveScope.firstOpen = true; if (!scope.directiveScope.directiveRef.visible) { scope.directiveScope.directiveRef.visible = true; $("#" + scope.directiveScope.unique).appendTo("body").modal('show'); } } }, controller: ctrl_5f9e3eee6795b23a923439b9, template: ``, bindToController: true};}); function ctrl_5f9e3eee6795b23a923439b9($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = createUniqueTag(); this.container = this.container == null ? true : this.container; }; /* Buttons ex: { ok: { label: "OK", closeOnSelection: true, class: "success" enable: *** Method String or Boolean, default is enabled (expect weird null coalescing from the parser) *** } } */ ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modal failed to initialize: " + e); } }); } app.controller('ctrl_5f9e3eee6795b23a923439b9', ctrl_5f9e3eee6795b23a923439b9); app.directive('codeEditor', function() { return { scope: { bindingParent: "=", bindingName: "=", readOnly: "=?", mode: "=", expanded: "=?", allowExpand: "=?", expandedHeight: "=?", collapsedHeight: "=?", lineNumbers: "=?" }, controller: ctrl_5fa96ad509f1de3faafea4f4, template: `
    {{directiveScope.syntaxError}}
    `, bindToController: true};}); function ctrl_5fa96ad509f1de3faafea4f4($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.readOnly = this.readOnly == null ? false : this.readOnly; this.allowExpand = this.allowExpand == null ? true : this.allowExpand; this.lineNumbers = this.lineNumbers == null ? true : this.lineNumbers; this.expanded = false; this.expandedHeight = this.expandedHeight == null ? 1000 : this.expandedHeight; this.collapsedHeight = this.collapsedHeight == null ? 200 : this.collapsedHeight; this.base64 = ["html","base64"].includes(this.mode); this.language = (["json", "object", "javascript"].includes(this.mode)) ? "javascript" : (this.mode == "html" ? "htmlmixed" : ""); this.unique = createUniqueTag(); this.syntaxError = ""; $scope.directiveScope = this; waitForElement("code_mirror_element_" + $scope.directiveScope.unique, (element) => { this.element = element; this.initEditor(); this.processBindingChange(); }); }; this.$doCheck = function() { /* if ($scope.directiveScope.element){ console.log(JSON.parse(JSON.stringify($scope.directiveScope.element.parentElement ))); } if ($scope.directiveScope.element && $scope.directiveScope.editor && !$scope.directiveScope.fullyInitialized && !this.element.attributes.hidden) { console.log("hit"); setTimeout(() => { $scope.directiveScope.fullyInitialized = true; $scope.directiveScope.editor.refresh(); }, 1) } */ } this.processEditorChange = function() { if ($scope.directiveScope.processingBindingChange || $scope.directiveScope.readOnly) { return; } $scope.directiveScope.processingEditorChange = true; if ($scope.directiveScope.mode == "object") { try { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = JSON.parse($scope.directiveScope.editor.getValue()); $scope.directiveScope.syntaxError = null; } catch(e) { $scope.directiveScope.syntaxError = e; } } else if ($scope.directiveScope.base64) { try { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = encodeHtml($scope.directiveScope.editor.getValue()); $scope.directiveScope.syntaxError = null; } catch(e) { $scope.directiveScope.syntaxError = e; } } else { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.editor.getValue(); } $scope.$root.$digest(); $scope.directiveScope.processingEditorChange = false; } this.processBindingChange = function() { if ($scope.directiveScope.processingEditorChange) { return; } $scope.directiveScope.processingBindingChange = true; try { if( $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] == undefined) { $scope.directiveScope.editor.setValue(""); } else if ($scope.directiveScope.mode == "object") { $scope.directiveScope.editor.setValue(JSON.stringify($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName], null, 2)); } else if ($scope.directiveScope.base64) { $scope.directiveScope.editor.setValue(decodeHtml($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName])); } else { $scope.directiveScope.editor.setValue($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); } } catch(e) {} $scope.directiveScope.processingBindingChange = false; } this.initEditor = function() { $scope.directiveScope.editor = CodeMirror.fromTextArea($scope.directiveScope.element, { lineNumbers: $scope.directiveScope.lineNumbers, mode: $scope.directiveScope.language, htmlMode: $scope.directiveScope.mode == "html", theme: "mdn-like", viewportMargin: Infinity, readOnly: $scope.directiveScope.readOnly, gutters: [], autoRefresh: true }); //Set watches $scope.$watch("directiveScope.bindingParent", () => { $scope.directiveScope.processBindingChange(); }); $scope.$watch("directiveScope.bindingName", () => { $scope.directiveScope.processBindingChange(); }); $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { $scope.directiveScope.processBindingChange(); }); $scope.directiveScope.editor.on("change", () => { $scope.directiveScope.processEditorChange(); }); $scope.directiveScope.editor.setSize(null, $scope.directiveScope.collapsedHeight); $scope.directiveScope.editor.refresh(); $scope.$apply(); } this.resize = function() { $scope.directiveScope.expanded = !$scope.directiveScope.expanded; $scope.directiveScope.editor.setSize(null, $scope.directiveScope.expanded ? $scope.directiveScope.expandedHeight : $scope.directiveScope.collapsedHeight); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: codeEditor failed to initialize: " + e); } }); } app.controller('ctrl_5fa96ad509f1de3faafea4f4', ctrl_5fa96ad509f1de3faafea4f4); app.directive('indicator', function() { return { scope: { bindingParent: "=", bindingName: "=", values: "=", showIcon: "=?" }, controller: ctrl_5fc90953f8db3c543ba5f881, template: ` `, bindToController: true};}); function ctrl_5fc90953f8db3c543ba5f881($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.showIcon = this.showIcon == null ? true : this.showIcon; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: indicator failed to initialize: " + e); } }); } app.controller('ctrl_5fc90953f8db3c543ba5f881', ctrl_5fc90953f8db3c543ba5f881); app.directive('productCodeEntry', function() { return { scope: { bindingParent: "=", bindingName: "=", showCode: "=?", allowCodeEntry: "=?", showDescription: "=?", allowDescriptionEntry: "=?", showPrice: "=?", allowPriceEntry: "=?", showElements: "=?", allowElementEntry: "=?", allowSageUpdate: "=?", allowNewElements: "=?", showStatus: "=?", allowInvalid: "=?" }, controller: ctrl_5fcc343bfbdce631c6cea9bb, template: `
    • Press ENTER to decode
    • Will only populate when valid elements are selected
    $
    Product code FIELDS:
      A = Meta-data
      B = Sensor information
      C = Electrical information
      D = Optional
    
            A          B              C            D
        |       | |         | |               | |      |
    Ex:  0 0 0 0 . 0 0 0 0 0 . 0 0 0 0 0 0 <0> . 0 0 <0>
        |   |   | |     |   | |   |   |       | |      |
          0   1      2    3     4   5     6         7
    
    Product code ATTRIBUTES:
      0 = Series/Model    [always 2 digits]
      1 = Drawing Number  [always 2 digits]
      2 = Pressure Range  [always 3 digits]
      3 = Pressure Type   [always 2 digits]
      4 = Output Type     [always 2 digits]
      5 = Termination     [always 2 digits]
      6 = Cable Length    [2 or 3 digits]*
      7 = Optional        [2 or 3 digits, or omitted]*
    
    * Digits which appear (above) as '<0>' will
    only be present for attributes whose values
    are greater than 99. For example, an option
    of '8', will always appear as '08', and not
    '008'. Likewise, an option of '25' will
    always be '25' and not '025'. This is needed
    for backwards compatibility with older product
    codes.
      
    {{directiveScope.descRemaining}} characters remaining (Max 60)
    New
    New
    New
    New
    New
    New
    New
    New
    `, bindToController: true};}); function ctrl_5fcc343bfbdce631c6cea9bb($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.encoded = this.bindingParent ? this.bindingParent[this.bindingName] : null; this.syncing = false; this.decoded = {}; this.lastDecoded = null; this.selectedRecords = {}; this.refQualifiers = {}; var isProductCodeManager = $scope.$root.roles.some((role) => { return role._id == "5da00197270bf92d4428072b" }); var hasViewPriceRole = $scope.$root.roles.some((role) => { return role._id == "5ec6af6bcb6d1f7c26f0cb29" }); this.showCode = (this.showCode == null ? true : this.showCode); this.allowCodeEntry = (this.allowCodeEntry == null ? isProductCodeManager : this.allowCodeEntry); this.showDescription = (this.showDescription == null ? true : this.showDescription); this.allowDescriptionEntry = (this.allowDescriptionEntry == null ? isProductCodeManager : this.allowDescriptionEntry); this.showPrice = (this.showPrice == null ? hasViewPriceRole : this.showPrice); this.allowPriceEntry = (this.allowPriceEntry == null ? isProductCodeManager : this.allowPriceEntry); this.showElements = (this.showElements == null ? true : this.showElements); this.allowNewElements = (this.allowNewElements == null ? isProductCodeManager : this.allowNewElements); this.allowElementEntry = (this.allowElementEntry == null ? true : this.allowElementEntry); this.allowSageUpdate = (this.allowSageUpdate == null ? isProductCodeManager : this.allowSageUpdate); this.showStatus = (this.showStatus == null ? true : this.showStatus); this.enforceFormatting(); this.decode(); //Create watch on binding $scope.$watch('directiveScope.bindingParent[directiveScope.bindingName]', function (newValue, oldValue, scope) { if (!$scope.directiveScope.syncing) { $scope.directiveScope.syncing = true; $scope.directiveScope.encoded = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; } else { //Syncing skipped, reset flag $scope.directiveScope.syncing = false; } }); //Create watch on active encoded value $scope.$watch('directiveScope.encoded', function (newValue, oldValue, scope) { if (!$scope.directiveScope.syncing) { $scope.directiveScope.syncing = true; if ($scope.directiveScope.allowInvalid || $scope.directiveScope.validFormat) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.encoded; } else { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = null; } } else { //Syncing skipped, reset flag $scope.directiveScope.syncing = false; } }); this.buildRefQualifiers(); }; this.enforceFormatting = function() { if (this.bindingParent && this.encoded) { this.modified = true; //Check for blank input if (this.encoded.length == 0) { this.decoded = { valid: false }; this.validFormat = false; return; } //Trim all whitespace, split by decimals var split = this.encoded.replace(/[^.\d]/g, "").split("."); //Rebuild encoded value (making corrections along the way) this.encoded = ""; var valErrors = 0; if (split.length > 0) { this.encoded += (split[0].substring(0,4)); valErrors += (split[0].length != 4 ? 1 : 0); } if (split.length > 1) { this.encoded += ("." + split[1].substring(0,5)); valErrors += (split[1].length != 5 ? 1 : 0); } if (split.length > 2) { this.encoded += ("." + split[2].substring(0,7)); valErrors += ((split[2].length < 6 || split[2].length > 7) ? 1 : 0); } if (split.length > 3) { this.encoded += ("." + split[3].substring(0,3)); valErrors += ((split[3].length < 2 || split[3].length > 3) ? 1 : 0); } this.validFormat = (split.length > 2 && valErrors == 0); } else { this.validFormat = false; } }; this.checkForEnter = function(_event) { if (event.keyCode == 13) { this.decode(); } }; this.decode = function() { if ( !this.validFormat ) { this.decoded.exists = false; this.decoded.price = 0; this.decoded.description =""; return; } this.loading = true; //Now parse to attributes if a valid code was entered $http.get("/api/production/parse_product_code/" + this.encoded, { withCredentials: true }).then((elements) => { this.decoded = elements.data; //Now check Sage for existence and grab info if it does $http.get("/api/sage/item/" + this.encoded, { withCredentials: true }).then((sage) => { this.decoded.exists = !!sage.data; this.decoded.price = this.decoded.exists ? sage.data.UNITPRICE : 0; this.decoded.description = this.decoded.exists ? sage.data.DESC : this.decoded.suggested_description; this.descRemaining = this.decoded.description ? (60 - this.decoded.description.length) : 60; this.lastDecoded = this.encoded; this.loading = false; this.modified = false; }); }); }; this.elementChanged = function() { //One of the element selections has changed, rebuild ref qualifiers from new selected options this.buildRefQualifiers(); //Update the code from the new selection state this.encode(() => { this.enforceFormatting(); //Once done encoding, trigger a decode to get metadata this.decode(); }); }; this.buildRefQualifiers = function() { this.loading = true; //Wait a moment for selectedRecords to populate setTimeout(() => { //Update all ref qualifiers from each other var elements = ["series", "drawing", "pressure_range", "pressure_type", "output_type", "termination", "cable_length", "optional"]; elements.forEach((element) => { this.refQualifiers[element] = { //Build this elements qualifiers from the otherElements respective qualifiers $and: [ ...elements.filter((otherElement) => { return otherElement != element; }).map((otherElement) => { return this.selectedRecords[otherElement] && this.selectedRecords[otherElement][element + "_qualifier"] ? this.selectedRecords[otherElement][element + "_qualifier"] : {} }), ...[{ available: true }] ] }; }); this.loading = false; }, 1); } this.encode = function(_then) { $http.post("/api/production/generate_product_code/", this.decoded, { withCredentials: true }).then((json) => { this.encoded = json.data; if (_then) { _then(); } }); }; this.modifyCode = function() { if (this.decoded.exists) { this.updateCode(); } else { this.addCode(); } } this.addCode = function() { if (confirm("Are you sure you want to add this product code?")) { $http.post("/api/production/update_product_code/" + this.encoded, this.decoded, { withCredentials: true }).then((res) => { if (res.data && res.data.ok) { if (true || $rootScope.kimEnvironment == "prod") { //Get recipients getRecord(this, $http, "config", { _id: "5e3cacfe6117bf6f2957dbcb" }, [], (recipients) => { recipients = recipients ? recipients.parameters : []; sendTemplatedEmail(this, $http, recipients, "5dc467e4a2d4ad27f5d1af12", { elements: this.selectedRecords, number: this.encoded, description: this.decoded.description, price: this.decoded.price, user: $rootScope.currentUser.full_name }, null, $rootScope.currentUser.email, (success) => { }); }); } $rootScope.$emit('showAlert', "Product code added to Sage", "success"); } else { $rootScope.$emit('showAlert', "Failed to add product code to Sage", "danger"); } this.decode(); }); } } this.updateCode = function() { if (confirm("Are you sure you want to update this product code's description and cost?")) { $http.post("/api/production/update_product_code/" + this.encoded, this.decoded, { withCredentials: true }).then((res) => { if (res.data && res.data.ok) { $rootScope.$emit('showAlert', "Product code updated in Sage", "success"); } else { $rootScope.$emit('showAlert', "Failed to updated product code in Sage", "danger"); } this.decode(); }); } } this.newAttribute = function(_index) { var classes = [ "series_product_code_element", "drawing_product_code_element", "pressure_range_product_code_element", "pressure_type_product_code_element", "output_type_product_code_element", "termination_product_code_element", "cable_length_product_code_element", "optional_product_code_element" ]; //Find highest code of this index getRecords(this, $http, classes[_index], { index: _index }, [], {}, null, null, (response) => { var code = Math.max(...response.records.map((e) => { return e.code; })) + 1; //Goto record form with preset values window.open('/form?model=' + classes[_index] + '&init={"index":' + _index + ',"code":' + code + '}'); }); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: productCodeEntry failed to initialize: " + e); } }); } app.controller('ctrl_5fcc343bfbdce631c6cea9bb', ctrl_5fcc343bfbdce631c6cea9bb); app.directive('singleReferenceAutocompleteSelection', function() { return { scope: { onChange: "&", refModel: "=", selectionFields: "=?", refQualifier: "=", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) allowInteraction: "=?", //Overrides form detection and allows interaction (CAREFUL OF INFINITE RECURSIVE LOADING) placeholder: "=?", readOnly: "=?", selectedRecord: "=?", //Should not be written to, only for external reference keywordMode: "=?" //Treats spaces as wildcards }, controller: ctrl_5fce4d91fc2fe31573f2fc9c, template: `
    `, bindToController: true};}); function ctrl_5fce4d91fc2fe31573f2fc9c($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); this.search = ""; this.showOptions = false; $scope.directiveScope = this; this.loading = true; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.selectedRecord = null; this.bindingValid = function() { return this.bindingParent && this.bindingName; } this.filtered = function() { return JSON.stringify(this.refQualifier).length > 2; } this.loadOptions(); //Set display field this.displayField = $scope.$root.models[this.refModel].display_field; //Configure value watches $scope.$watch(["directiveScope.bindingParent", "directiveScope.bindingName"], function () { $scope.directiveScope.updateSelectedRecordFromBinding(); }); //Configure qualifer watches $scope.$watch("directiveScope.refQualifier", function(_new, _old) { if (JSON.stringify(_new) != JSON.stringify(_old)) { $scope.directiveScope.loadOptions(); } }); //Configure selectedRecord watch $scope.$watch("directiveScope.selectedRecord", function(_new, _old) { if (JSON.stringify(_old) != JSON.stringify(_new)) { $scope.directiveScope.search = $scope.directiveScope.selectedRecord ? $scope.directiveScope.selectedRecord[$scope.directiveScope.displayField] : ""; if ($scope.directiveScope.onChange) { $scope.directiveScope.onChange(); } } }); }; this.updateSelectedRecordFromBinding = function() { if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName) { if ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] && typeof($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) == "object") { $scope.directiveScope.selectedRecord = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; $scope.directiveScope.search = $scope.directiveScope.selectedRecord ? $scope.directiveScope.selectedRecord[$scope.directiveScope.displayField] : ""; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]._id; } else { //Get binding value var bindingId = $scope.directiveScope.bindingValid() ? $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] : null; //Updated selectedRecord $scope.directiveScope.selectedRecord = ($scope.directiveScope.options || []).find((option) => { return option._id == bindingId; }); } } }; this.loadOptions = function() { this.loading = true; retrieveRecords($scope.directiveScope, $http, $scope.directiveScope.refModel, { query: ($scope.directiveScope.refQualifier ? $scope.directiveScope.refQualifier : {}), sort: ($scope.directiveScope.sort || {}), select: ($scope.directiveScope.selectionFields || []) }, (response) => { //Populate all options $scope.directiveScope.options = response.records; //Update selected record $scope.directiveScope.updateSelectedRecordFromBinding(); //Check if current selected record is in options if ($scope.directiveScope.selectedRecord && !$scope.directiveScope.options.some((option) => { return option._id == $scope.directiveScope.selectedRecord._id; })) { $scope.directiveScope.selectedRecord = null; } this.loading = false; }); }; this.matchesSearch = function(_option) { return (!this.search || this.search.length < 1) || this.keywordMode ? (new RegExp(".*" + this.search.toLowerCase().split(" ").join(".*") + ".*")).test(_option[this.displayField].toLowerCase()) : _option[this.displayField].toLowerCase().includes(this.search.toLowerCase()) }; //Called when a user makes or clears a selection (not when updated from binding) this.select = function(_optionId, _stop) { this.selectedRecord = _optionId ? this.options.find((o) => { return o._id == _optionId; }) : null; if (this.bindingValid()) { this.bindingParent[this.bindingName] = _optionId; } } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: singleReferenceAutocompleteSelection failed to initialize: " + e); } }); } app.controller('ctrl_5fce4d91fc2fe31573f2fc9c', ctrl_5fce4d91fc2fe31573f2fc9c); app.directive('selection', function() { return { scope: { bindingParent: "=", bindingName: "=", allowInteraction: "=?", values: "=", onChange: "=?", placeholder: "=?", allowNull: "=?", showIcon: "=?" }, controller: ctrl_5fd90bf2080f5069e2d21a10, template: ` `, bindToController: true};}); function ctrl_5fd90bf2080f5069e2d21a10($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = createUniqueTag(); this.allowNull = this.allowNull == null ? true : this.allowNull; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.allowNshowIconull = this.showIcon == null ? true : this.showIcon; this.showSelections = false; this.select = function(_key) { $scope.directiveScope.selecting = true; $scope.directiveScope.showSelections = false; if (_key == null || $scope.directiveScope.values[_key].selectable != false) { if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _key; } if ($scope.directiveScope.onChange) { $scope.directiveScope.onChange(_key, $scope.directiveScope); } } } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: selection failed to initialize: " + e); } }); } app.controller('ctrl_5fd90bf2080f5069e2d21a10', ctrl_5fd90bf2080f5069e2d21a10); app.directive('filetypeIcon', function() { return { scope: { bindingParent: "=", bindingName: "=" }, controller: ctrl_5fe950ac6ffaae7d29690779, template: ``, bindToController: true};}); function ctrl_5fe950ac6ffaae7d29690779($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.map = [ { e: ["mpg"], u: "1609126079401" }, { e: ["mov"], u: "1609126082387" }, { e: ["avi"], u: "1609126098752" }, { e: ["txt"], u: "1609126102053" }, { e: ["xml"], u: "1609126104833" }, { e: ["json"], u: "1609126113897" }, { e: ["css"], u: "1609126116704" }, { e: ["csv"], u: "1609126124269" }, { e: ["html", "htm"], u: "1609126128069" }, { e: ["xls", "xlsx", "xlsm"], u: "1609126148458" }, { e: ["doc", "docx", "docm"], u: "1609126151207" }, { e: ["pdf"], u: "1609126155001" }, { e: ["tif", "tiff"], u: "1609126158269" }, { e: ["psd"], u: "1609126162257" }, { e: ["ps"], u: "1609126166852" }, { e: ["png"], u: "1609126172657" }, { e: ["jpg", "jpeg"], u: "1609126175199" }, { e: ["gif"], u: "1609126179119" }, { e: ["ai"], u: "1609126182192" }, { e: ["wof", "woff"], u: "1609126199330" }, { e: ["ttf"], u: "1609126201785" }, { e: ["otf"], u: "1609126208979" }, { e: ["exe"], u: "1609126233658" }, { e: ["wma"], u: "1609126238907" }, { e: ["wav"], u: "1609126241987" }, { e: ["ogg"], u: "1609126245058" }, { e: ["mp3"], u: "1609126249507" }, { e: ["aac"], u: "1609126254405" }, { e: ["zip"], u: "1609126257022" }, { e: ["rar"], u: "1609126262077" }, { e: ["7z"], u: "1609126268267" }, { e: ["js"], u: "1609127733294" } ]; this.getLink = function() { var mapEntry = (this.bindingParent && this.bindingName && this.bindingParent[this.bindingName]) ? this.map.find((entry) => { return entry.e.includes(this.bindingParent[this.bindingName]); }) : null; return "/file-cache/directive/5fe950ac6ffaae7d29690779/resources/" + (mapEntry ? mapEntry.u : "1609126550832"); } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: filetypeIcon failed to initialize: " + e); } }); } app.controller('ctrl_5fe950ac6ffaae7d29690779', ctrl_5fe950ac6ffaae7d29690779); app.directive('modelFieldEditor', function() { return { scope: { field: "=", containerUnique: "=?" }, transclude: false, controller: ctrl_5ff7c14469c2ba7220dbde86, template: `






    `, bindToController: true};}); function ctrl_5ff7c14469c2ba7220dbde86($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = createUniqueTag(); this.containerUnique = this.containerUnique == null ? "accordion" : this.containerUnique; this.typeSelections = { string: { label: 'String' }, decimal: { label: 'Decimal' }, integer: { label: 'Integer' }, boolean: { label: 'Boolean' }, reference: { label: 'Reference' }, dynamicObject: { label: 'Dynamic Object' }, staticObject: { label: 'Static Object' }, file: { label: 'File' } }; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modelFieldEditor failed to initialize: " + e); } }); } app.controller('ctrl_5ff7c14469c2ba7220dbde86', ctrl_5ff7c14469c2ba7220dbde86); app.directive('wysiwygHtmlEditor', function() { return { scope: { bindingName: "=", bindingParent: "=", fileSourceRecord: "=?", fileSourceRecordType: "=?" }, controller: ctrl_600110dab7f9de36415ec499, template: `
    { $scope.directiveScope.editorElement = pellElement; window.pell.init({ element: $scope.directiveScope.editorElement, onChange: $scope.directiveScope.controlChanged, defaultParagraphSeparator: 'div', styleWithCSS: false, actions: [...["bold", "underline", "italic", "strikethrough", "olist", "ulist"], ...$scope.directiveScope.customFunctions] }); $scope.directiveScope.bindingChanged(); }); this.processingControlChange = false; this.processingBindingChange = false; this.bindingChanged = function() { if (!$scope.directiveScope.processingControlChange && $scope.directiveScope.editorElement) { $scope.directiveScope.processingBindingChange = true; $scope.directiveScope.editorElement.content.innerHTML = decodeHtml($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); $scope.directiveScope.processingBindingChange = false } }; this.controlChanged = function(_newValue) { if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && !$scope.directiveScope.processingBindingChange && $scope.directiveScope.editorElement) { $scope.directiveScope.processingControlChange = true; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = encodeHtml(_newValue); safeApply($scope); $scope.directiveScope.processingControlChange = false } }; this.getCurrentRecordFiles = function() { var files = []; var modelDef = $scope.$root.models[$scope.directiveScope.fileSourceRecord && $scope.directiveScope.fileSourceRecord._type ? $scope.directiveScope.fileSourceRecord._type : $scope.directiveScope.fileSourceRecordType]; Object.keys(modelDef.fields).forEach((f) => { if (modelDef.fields[f].type == "file") { if (modelDef.fields[f].array) { ($scope.directiveScope.fileSourceRecord[f] || []).forEach((file) => { var toPush = cloneObject(file); toPush.source = f; files.push(toPush); }); } else if ($scope.directiveScope.fileSourceRecord[f]) { var toPush = cloneObject($scope.directiveScope.fileSourceRecord[f]); toPush.source = f; files.push(toPush); } } }); return files; }; $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", $scope.directiveScope.bindingChanged); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: wysiwygHtmlEditor failed to initialize: " + e); } }); } app.controller('ctrl_600110dab7f9de36415ec499', ctrl_600110dab7f9de36415ec499); app.directive('block', function() { return { scope: { title: "@" }, transclude: true, controller: ctrl_6005af3eff96d5622d116933, template: `
    {{directiveScope.title}}
    `, bindToController: true};}); function ctrl_6005af3eff96d5622d116933($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: block failed to initialize: " + e); } }); } app.controller('ctrl_6005af3eff96d5622d116933', ctrl_6005af3eff96d5622d116933); app.directive('candle', function() { return { controller: ctrl_6005af52ff96d5622d116934, template: `
    `, bindToController: true};}); function ctrl_6005af52ff96d5622d116934($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: candle failed to initialize: " + e); } }); } app.controller('ctrl_6005af52ff96d5622d116934', ctrl_6005af52ff96d5622d116934); app.directive('websiteDrawerContainer', function() { return { transclude: true, controller: ctrl_6005af67ff96d5622d116935, template: `
    `, bindToController: true};}); function ctrl_6005af67ff96d5622d116935($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: websiteDrawerContainer failed to initialize: " + e); } }); } app.controller('ctrl_6005af67ff96d5622d116935', ctrl_6005af67ff96d5622d116935); app.directive('websiteDrawer', function() { return { scope: { title: "@", id: "@" }, transclude: true, compile: function(element, attributes) { return { pre: function(scope, element, attributes) { attributes.id = attributes.title.replace(/[^a-zA-Z0-9-]/g, ''); } } }, controller: ctrl_6005af8aff96d5622d116936, template: `
    +
    `, bindToController: true};}); function ctrl_6005af8aff96d5622d116936($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: websiteDrawer failed to initialize: " + e); } }); } app.controller('ctrl_6005af8aff96d5622d116936', ctrl_6005af8aff96d5622d116936); app.directive('alert', function() { return { controller: ctrl_6005b216ff96d5622d116938, template: ` `, bindToController: true};}); function ctrl_6005b216ff96d5622d116938($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $rootScope.$on('showAlert', function(event, _message, _severity) { _severity = _severity ? _severity : "primary"; $scope.severity = _severity; $scope.text = _message; $scope.visible = true; $timeout(() => { $scope.visible = false; }, 2500); }); $scope.toTrusted = function(_html) { return $sce.trustAsHtml(_html); }; };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: alert failed to initialize: " + e); } }); } app.controller('ctrl_6005b216ff96d5622d116938', ctrl_6005b216ff96d5622d116938); app.directive('dropdown', function() { return { scope: { items: "=", default: "@", placeholder: "@", bindingParent: "=", bindingName: "@" }, compile: function(element, attributes) { return { pre: function(scope, element, attributes) { if (attributes.default) { attributes.bindingParent[attributes.bindingName] = attributes.default; } } } }, controller: ctrl_6005b240ff96d5622d116939, template: ` `, bindToController: true};}); function ctrl_6005b240ff96d5622d116939($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: dropdown failed to initialize: " + e); } }); } app.controller('ctrl_6005b240ff96d5622d116939', ctrl_6005b240ff96d5622d116939); app.directive('headerLink', function() { return { scope: { image: "@", link: "@", subtext: "@", newTab: "=", fontSize: "=?" }, transclude: true, controller: ctrl_6005b34cff96d5622d11693a, template: `
    `, bindToController: true};}); function ctrl_6005b34cff96d5622d11693a($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.viewLink = function() { window.location.href = this.link; } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: headerLink failed to initialize: " + e); } }); } app.controller('ctrl_6005b34cff96d5622d11693a', ctrl_6005b34cff96d5622d11693a); app.directive('header', function() { return { scope: { title: "@", showCandle: "=", centerCandle: "=?", fontSize: "=?", image: "@" }, transclude: true, controller: ctrl_6005b386ff96d5622d11693b, template: `

    `, bindToController: true};}); function ctrl_6005b386ff96d5622d11693b($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; if (angular.isUndefined($scope.fontSize)) { this.fontSize = 17; } } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: header failed to initialize: " + e); } }); } app.controller('ctrl_6005b386ff96d5622d11693b', ctrl_6005b386ff96d5622d11693b); app.directive('imageSelection', function() { return { scope: { image: "@", title: "@", link: "@" }, controller: ctrl_6005b39cff96d5622d11693c, template: `


    `, bindToController: true};}); function ctrl_6005b39cff96d5622d11693c($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: imageSelection failed to initialize: " + e); } }); } app.controller('ctrl_6005b39cff96d5622d11693c', ctrl_6005b39cff96d5622d11693c); app.directive('nestedInput', function() { return { scope: { fields: "=", bindingParent: "=", bindingName: "=" }, controller: ctrl_6005b3cbff96d5622d11693e, template: `

    `, bindToController: true};}); function ctrl_6005b3cbff96d5622d11693e($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; $scope.$watch('directiveScope.fields', function (newValue, oldValue, scope) { //If fields defintions are changed, remove any currently selected values from binding if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.fields) { Object.keys($scope.directiveScope.fields) .filter((f) => { return $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].hasOwnProperty(f); }) .forEach((f) => { delete $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][f]; }); } });; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: nestedInput failed to initialize: " + e); } }); } app.controller('ctrl_6005b3cbff96d5622d11693e', ctrl_6005b3cbff96d5622d11693e); app.directive('pageFooter', function() { return { controller: ctrl_6005b3ddff96d5622d11693f, template: `
    `, bindToController: true};}); function ctrl_6005b3ddff96d5622d11693f($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.year = (new Date()).getFullYear(); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: pageFooter failed to initialize: " + e); } }); } app.controller('ctrl_6005b3ddff96d5622d11693f', ctrl_6005b3ddff96d5622d11693f); app.directive('pageHeader', function() { return { controller: ctrl_6005b3eeff96d5622d116940, template: ``, bindToController: true};}); function ctrl_6005b3eeff96d5622d116940($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: pageHeader failed to initialize: " + e); } }); } app.controller('ctrl_6005b3eeff96d5622d116940', ctrl_6005b3eeff96d5622d116940); app.directive('page', function() { return { scope: { title: "@", loading: "=?" }, transclude: true, compile: function(element, attributes) { return { pre: function(scope, element, attributes) { scope.visible = localStorage.getItem('cookies_accepted') == null; scope.ok = function() { localStorage.setItem('cookies_accepted', JSON.stringify(true)); scope.visible = false; } } } }, controller: ctrl_6005b402ff96d5622d116941, template: `
    {{directiveScope.title}}
    LOADING
    `, bindToController: true};}); function ctrl_6005b402ff96d5622d116941($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: page failed to initialize: " + e); } }); } app.controller('ctrl_6005b402ff96d5622d116941', ctrl_6005b402ff96d5622d116941); app.directive('panelButton', function() { return { scope: { link: "@", icon: "@" }, controller: ctrl_6005b418ff96d5622d116942, template: `
    `, bindToController: true};}); function ctrl_6005b418ff96d5622d116942($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: panelButton failed to initialize: " + e); } }); } app.controller('ctrl_6005b418ff96d5622d116942', ctrl_6005b418ff96d5622d116942); app.directive('productCategoriesDrawer', function() { return { scope: { productQualifier: "=?", }, controller: ctrl_6005b437ff96d5622d116943, template: ` `, bindToController: true};}); function ctrl_6005b437ff96d5622d116943($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.productQualifier = this.productQualifier || {}; this.categories = {}; retrieveRecords($scope, $http, "website_product_category", {}, (productCategoryResponse) => { var categories = productCategoryResponse.records; retrieveRecords($scope, $http, "website_product_sub_category", {}, (productSubCategoryResponse) => { var subCategories = productSubCategoryResponse.records; retrieveRecords($scope, $http, "website_product", { query: this.productQualifier }, (productResponse) => { var products = productResponse.records; this.subCategories = subCategories.filter((subCategory) => { return products.some((product) => { return subCategory.products.includes(product._id); })}); this.categories = categories.filter((category) => { return this.subCategories.some((subCategory) => { return category.sub_categories.includes(subCategory._id ); })}); this.products = products; }); }); }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: productCategoriesDrawer failed to initialize: " + e); } }); } app.controller('ctrl_6005b437ff96d5622d116943', ctrl_6005b437ff96d5622d116943); app.directive('productCategoriesPanel', function() { return { scope: { query: "=?", }, controller: ctrl_6005b5d3ff96d5622d116944, template: `
    {{productCategory}}
    `, bindToController: true};}); function ctrl_6005b5d3ff96d5622d116944($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; retrieveRecords($scope, $http, "website_product_category", { sort: { display_order: "asc" } }, (response) => { this.productCategories = response.records; }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: productCategoriesPanel failed to initialize: " + e); } }); } app.controller('ctrl_6005b5d3ff96d5622d116944', ctrl_6005b5d3ff96d5622d116944); app.directive('searchResult', function() { return { scope: { record: "=", searchEvent: "=" }, controller: ctrl_6005b5f6ff96d5622d116945, template: `
    {{directiveScope.record.menu_title}}
    {{directiveScope.record.title}}
    {{directiveScope.record.title}}
    {{directiveScope.record.title}}
    {{directiveScope.record.title}}
    {{directiveScope.record.name}}
    {{directiveScope.record.name}}


    `, bindToController: true};}); function ctrl_6005b5f6ff96d5622d116945($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.title = { "website_product": "Product" }[this.record._type]; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: searchResult failed to initialize: " + e); } }); } app.controller('ctrl_6005b5f6ff96d5622d116945', ctrl_6005b5f6ff96d5622d116945); app.directive('slideShow', function() { return { scope: { slides: "=", delay: "=?", autoplay: "=?" }, controller: ctrl_6005b60fff96d5622d116946, template: ` `, bindToController: true};}); function ctrl_6005b60fff96d5622d116946($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.delay = this.delay || 5000; console.log(this); this.autoplay = (this.autoplay == null) ? false : this.autoplay; //Kick off slideshow if (this.autoplay) { $timeout(() => { $('.carousel').carousel(); }, this.delay); } };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: slideShow failed to initialize: " + e); } }); } app.controller('ctrl_6005b60fff96d5622d116946', ctrl_6005b60fff96d5622d116946); app.directive('multiMediaPanel', function() { return { scope: { items: "=", currentIndex: "=?", allowExpand: "=?", mediaSize: "=?", thumbSize: "=?" }, transclude: false, controller: ctrl_6012b49ff5464958efbdd303, template: `
    🎞️
    `, bindToController: true};}); function ctrl_6012b49ff5464958efbdd303($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.currentIndex = this.currentIndex == null ? 0 : this.currentIndex; this.mediaSize = this.mediaSize == null ? 400 : this.mediaSize; this.thumbSize = this.thumbSize == null ? 50 : this.thumbSize; } this.isVideo = function(_item) { return ["mpg", "mpg2", "wmv"," mpeg", "webm", "webp", "mp4"].includes(_item.extension); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: multiMediaPanel failed to initialize: " + e); } }); } app.controller('ctrl_6012b49ff5464958efbdd303', ctrl_6012b49ff5464958efbdd303); app.directive('queryComponent', function() { return { scope: { modelsData: "=?", parent: "=?", value: "=", name: "=?", refModel: "=?" }, controller: ctrl_602c16737d11354657a3cb8f, template: `
    {{directiveScope.mapping.label}} Add Clause Remove
    Remove
    Remove
    `, bindToController: true};}); function ctrl_602c16737d11354657a3cb8f($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.inWindow = true; this.$onInit = function() { if (!this.parent && typeof(this.value) == "string") { this.value = JSON.parse(this.value); } //Check for passed in model data, no need to load it multiple times if (!this.modelsData) { getModels($scope, $http, (data) => { this.modelsData = data; //Add _id field this.modelsData[this.refModel].fields._id = { type: "ObjectId", array: false, ref: this.refModel }; this.init(); }); } else { this.init(); } }; this.init = function() { $scope.directiveScope = this; if (!this.parent && !this.value) { this.value = {};} //Check for special name mapping this.mapping = this.mappings.hasOwnProperty(this.name || "$root") ? this.mappings[this.name || "$root"] : { //Field mapping type: "field", label: this.name || "" }; if (this.mapping.type == "field") { this.parseFieldExpression(); } }; this.valueKeys = function() { return Object.keys(this.value).sort().filter((key) => { return !key.startsWith("$$"); }); }; this.field = { modelData: {}, constant: null, not: null, comparator: null, implicitEq: null }; this.parseFieldExpression = function() { this.field.modelData = this.modelsData[this.refModel].fields[this.name]; this.field.not = !!this.value.$not; this.field.constant = this.field.not ? this.value.$not : this.value; var comparators = Object.keys(this.field.constant).filter((key) => { return Object.keys(this.comparators).includes("_" + key); }); this.field.comparator = comparators.length == 0 ? "$eq" : comparators[0]; this.field.implicitEq = comparators.length == 0; this.field.constant = comparators.length == 0 ? this.field.constant : this.field.constant[this.field.comparator]; }; this.buildFieldExpression = function() { var oldName = this.name.toString(); this.name = this.mapping.label; var expression = {}; if (this.field.comparator == "$eq" && !this.field.not) { //Implicit EQ, just use constant expression = this.field.constant; } else { //Explicit comparator, add cmoparator property expression[this.field.comparator] = this.field.constant; } //Remove old qualifier if name was changed if (oldName != this.name) { delete this.parent[oldName]; } this.parent[this.name] = this.field.not ? { $not: expression } : expression; } //Field methods ////////////////////////////////////////////////////////////// this.selectField = function(_field) { this.mapping.label = _field; this.field.modelData = this.modelsData[this.refModel].fields[_field]; this.showFieldDropdown = false; this.buildFieldExpression(); //May not be required } this.selectComparator = function(_comparator) { this.field.comparator = _comparator; if (this.comparators["_" + this.field.comparator].selectionType == "array") { this.field.constant = Array.isArray(this.field.constant) ? this.field.constant : []; } else { this.field.constant = this.field.constant = null; } this.showComparatorDropdown = false; this.buildFieldExpression(); } this.addQualifier = function() { this.value["< Select Field >"] = "< Select value >"; this.showAddDropdown = false; } this.removeQualifier = function() { delete this.parent[this.name]; } this.addClause = function() { this.value.push({}); } this.removeMatchingBlock = function() { delete this.parent[this.name]; } this.removeClause = function() { for(var c in this.parent) { if (this.parent[c] == this.value) { this.parent.splice(c, 1); return; } } } this.addMatchingAll = function(_parentValue) { if (!Object.keys(_parentValue).includes("$and")) { _parentValue.$and = []; } this.showAddDropdown = false; } this.addMatchingAny = function(_parentValue) { if (!Object.keys(_parentValue).includes("$or")) { _parentValue.$or = []; } this.showAddDropdown = false; } this.addMatchingNone = function(_parentValue) { if (!Object.keys(_parentValue).includes("$nor")) { _parentValue.$nor = []; } this.showAddDropdown = false; } this.applicableComparators = function() { var comps = {}; for(var name in this.comparators) { var comp = this.comparators[name]; if (this.field.modelData.array && !comp.allowArray) { continue; } if (!comp.dataTypes.includes(this.field.modelData.type)) { continue; } comps[name] = comp; } return comps; } this.comparators = { _$eq: { singleName: "Equal To", arrayName: "Containing", allowArray: true, dataTypes: ["String", "Number", "Date", "Boolean", "ObjectId"], selectionType: "single" }, _$ne: { singleName: "Not Equal To", arrayName: "Not Containing", allowArray: true, dataTypes: ["String", "Number", "Date", "Boolean", "ObjectId"], selectionType: "single" }, _$regex: { singleName: "Matching", allowArray: false, dataTypes: ["String"], selectionType: "single" }, _$gt: { singleName: "Greater Than (After)", allowArray: false, dataTypes: ["Number", "Date"], selectionType: "single" }, _$gte: { singleName: "Greater Than or Equal To (On or After)", allowArray: false, dataTypes: ["Number", "Date"], selectionType: "single" }, _$lt: { singleName: "Less Than (Before)", allowArray: false, dataTypes: ["Number", "Date"], selectionType: "single" }, _$lte: { singleName: "Less Than or Equal To (On or Before)", allowArray: false, dataTypes: ["Number", "Date"], selectionType: "single" }, _$in: { singleName: "Greater Than (After)", allowArray: false, dataTypes: ["Number", "Date"], selectionType: "single" }, _$in: { singleName: "One Of", allowArray: false, dataTypes: ["String", "Number", "Date", "ObjectId"], selectionType: "array" }, _$nin: { singleName: "Not One Of", allowArray: false, dataTypes: ["String", "Number", "Date", "ObjectId"], selectionType: "array" } } this.mappings = { $root: { type: "object", label: "Query", class: "primary" }, $and: { type: "array", label: "Matching All", class: "success" }, $or: { type: "array", label: "Matching Any", class: "warning" }, $nor: { type: "array", label: "Matching None", class: "danger" } }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: queryComponent failed to initialize: " + e); } }); } app.controller('ctrl_602c16737d11354657a3cb8f', ctrl_602c16737d11354657a3cb8f); app.directive('objectTreeEditor', function() { return { scope: { bindingParent: "=", bindingName: "=", showCondition: "=?", selectedValue: "=?", keyDisplay: "=?", d: "=?", allowAddToRoot: "=?", allowAddToChild: "=?", allowRemove: "=?", }, transclude: false, controller: ctrl_6017567c6714f94558f41734, template: ` `, bindToController: true};}); function ctrl_6017567c6714f94558f41734($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] == null ? {} : this.bindingParent[this.bindingName]; this.showCondition = this.showCondition == null ? (() => { return true; }) : this.showCondition; this.keyDisplay = this.keyDisplay == null ? ((_key) => { return _key; }) : this.keyDisplay; this.d = this.d == null ? 0 : this.d; this.isObject = function(_value) { return typeof(_value) == "object"; } this.selectValue = function(_value) { this.selectedValue = _value; } this.addRootValue = function() { var key = prompt("Please enter a new key"); if (key.length > 0) { this.bindingParent[this.bindingName][key] = { __type: "string" }; } } this.cloneValue = function(_value) { var newKey = prompt("Please enter a new key"); if (key.length > 0) { this.bindingParent[this.bindingName][newKey] = {}; Object.assign(this.bindingParent[this.bindingName][newKey], _value); } } this.addChildValue = function(_parent) { var key = prompt("Please enter a new key"); if (key.length > 0) { _parent[key] = { __type: "string" }; } } this.removeValue = function(_name) { if (confirm("Are you sure you want to remove '" + _name + "'")) { delete this.bindingParent[this.bindingName][_name]; } } } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: objectTreeEditor failed to initialize: " + e); } }); } app.controller('ctrl_6017567c6714f94558f41734', ctrl_6017567c6714f94558f41734); app.directive('selectionsConfig', function() { return { scope: { bindingParent: "=", bindingName: "=" }, controller: ctrl_601958f9aad0c41503076221, template: `
    Value Label Selectable Icon Class
    {{value}}
    `, bindToController: true};}); function ctrl_601958f9aad0c41503076221($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] == null ? {} : this.bindingParent[this.bindingName]; this.canAddValue = function() { return !Object.keys(this.bindingParent[this.bindingName]).includes(this.newValue); } this.removeValue = function(_value) { delete this.bindingParent[this.bindingName][_value]; } this.addValue = function() { if (this.canAddValue()) { this.bindingParent[this.bindingName][this.newValue] = {}; this.newValue = ""; } } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: selectionsConfig failed to initialize: " + e); } }); } app.controller('ctrl_601958f9aad0c41503076221', ctrl_601958f9aad0c41503076221); app.directive('modelFieldSelection', function() { return { scope: { modelName: "=", bindingParent: "=", bindingName: "=", placeholder: "=?", onChange: "=?", allowNull: "=?", fieldQualifier: "=?", queryableOnly: "=?" }, transclude: false, controller: ctrl_6020c1821eab984ea8111ef5, template: ` `, bindToController: true};}); function ctrl_6020c1821eab984ea8111ef5($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.fieldQualifier = this.fieldQualifier || (() => { return true; }); this.unique = createUniqueTag(); this.populateSelections = function() { this.values = { }; Object.keys($scope.$root.models[this.modelName].fields).filter((f) => { return this.fieldQualifier($scope.$root.models[this.modelName].fields[f], f); }).sort().forEach((fieldName) => { try { var field = $scope.$root.models[this.modelName].fields[fieldName]; if (!field.queryable && !this.queryableOnly) { return; } var referencedModel = field.reference_model ? getModelById($scope, field.reference_model) : {}; var typeDisplay = field.type == "reference" ? ((field.array ? ("Array of " + referencedModel.plural_name) : referencedModel.singular_name)) : ((field.array ? "Array of " : "") + field.type + (field.array ? "s" : "")); this.values[fieldName] = { label: (field.display_name || fieldName) + (field.type == "reference" ? (" (" + typeDisplay + ")") : ""), icon: ((field.type == "reference") ? (referencedModel.icon ? referencedModel.icon.link : null) : ("/media/icons/" + field.type + ".png")) }; } catch (e) {} }); } $scope.$watch("directiveScope.modelName", function() { $scope.directiveScope.populateSelections(); }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modelFieldSelection failed to initialize: " + e); } }); } app.controller('ctrl_6020c1821eab984ea8111ef5', ctrl_6020c1821eab984ea8111ef5); app.directive('modelFieldIndicator', function() { return { scope: { modelName: "=", bindingParent: "=", bindingName: "=", placeholder: "=?" }, transclude: false, controller: ctrl_6025622502fc51372236d071, template: ` `, bindToController: true};}); function ctrl_6025622502fc51372236d071($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = createUniqueTag(); this.populateSelections = function() { this.values = { }; Object.keys($scope.$root.models[this.modelName].fields).forEach((fieldName) => { var field = $scope.$root.models[this.modelName].fields[fieldName]; var referencedModel = (field.reference_model ? getModelById($scope, field.reference_model) : {}) || {}; this.values[fieldName] = { label: fieldName, icon: (field.type == "reference" ? (referencedModel.icon || {}).link : null) }; }); } $scope.$watch("directiveScope.modelName", function() { $scope.directiveScope.populateSelections(); }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modelFieldIndicator failed to initialize: " + e); } }); } app.controller('ctrl_6025622502fc51372236d071', ctrl_6025622502fc51372236d071); app.directive('virtualModelJoinEditor', function() { return { scope: { value: "=", type: "=?", length: "=?", width: "=?" } , controller: ctrl_603465a82503af58f757b1a9, template: ``, bindToController: true};}); function ctrl_603465a82503af58f757b1a9($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.id = createUniqueTag(); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: virtualModelJoinEditor failed to initialize: " + e); } }); } app.controller('ctrl_603465a82503af58f757b1a9', ctrl_603465a82503af58f757b1a9); app.directive('queryEditor', function() { return { scope: { bindingParent: "=?", bindingName: "=?", modelName: "=?", level: "=?", allowInteraction: "=?" }, controller: ctrl_6039c4a1efaf8d41ea7ed2d2, template: `
    {{directiveScope.booleanArrayNames[propertyName].label}}
    `, bindToController: true};}); function ctrl_6039c4a1efaf8d41ea7ed2d2($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.level = this.level || 0; this.booleanArrayNames = { "_$and": { label: "All Of", class: "success" }, "_$or": { label: "Any Of", class: "warning" }, "_$nor": { label: "None Of", class: "danger" } }; this.operators = { "_$eq": { label: "Equal To", class: "success", array: false, types: { string: true, enumerator: true, dynamic_object: true, structured_object: true, boolean: true, number: true, datetime: true, file: true, color: true, reference: true, query: false } }, "_$ne": { label: "Not Equal To", class: "danger", array: false, types: { string: true, enumerator: true, dynamic_object: true, structured_object: true, boolean: true, number: true, datetime: true, file: true, color: true, reference: true, query: true } }, "_$in": { label: "One Of", class: "success", array: true, types: { string: true, enumerator: true, dynamic_object: true, structured_object: true, boolean: false, number: true, datetime: true, file: false, color: true, reference: true, query: false } }, "_$nin": { label: "Not One Of", class: "danger", array: true, types: { string: true, enumerator: true, dynamic_object: true, structured_object: true, boolean: false, number: true, datetime: true, file: false, color: true, reference: true, query: false } }, "_$gt": { label: ">", class: "info", array: false, types: { string: false, enumerator: false, dynamic_object: false, structured_object: false, boolean: false, number: true, datetime: { label: "After" }, file: false, color: false, reference: false, query: false } }, "_$gte": { label: ">=", class: "info", array: false, types: { string: false, enumerator: false, dynamic_object: false, structured_object: false, boolean: false, number: true, datetime: { label: "On or After" }, file: false, color: false, reference: false, query: false } }, "_$lt": { label: "<", class: "primary", array: false, types: { string: false, enumerator: false, dynamic_object: false, structured_object: false, boolean: false, number: true, datetime: { label: "Before" }, file: false, color: false, reference: false, query: false } }, "_$lte": { label: "<=", class: "primary", array: false, types: { string: false, enumerator: false, dynamic_object: false, structured_object: false, boolean: false, number: true, datetime: { label: "On or Before" }, file: false, color: false, reference: false, query: false } }, "_$regex": { label: "Matching", class: "warning", array: false, types: { string: true, enumerator: true, dynamic_object: false, structured_object: false, boolean: false, number: false, datetime: false, file: false, color: false, reference: false, query: false }, optionalFields: { "_$options": { label: "Options" } } }, "_$elemMatch": { label: "Element Match", class: "warning", array: false, types: { string: false, enumerator: false, dynamic_object: true, structured_object: true, boolean: false, number: false, datetime: false, file: false, color: false, reference: false, query: false }, } }; this.addNewObject = function(_parent) { _parent.push({}); } this.booleanArrayRemoveMouseover = function() { $scope.directiveScope.deleteBooleanArrayHovered = true; } this.booleanArrayRemoveMouseleave = function() { $scope.directiveScope.deleteBooleanArrayHovered = false; } this.removeBooleanArray = function(_name) { delete $scope.directiveScope.transcompiled[_name]; } this.queryRemoveMouseover = function() { $scope.directiveScope.deleteQueryHovered = true; } this.queryRemoveMouseleave = function() { $scope.directiveScope.deleteQueryHovered = false; } this.removeQuery = function() { $scope.directiveScope.transcompiled = null; } this.newClauseSelection; this.onNewClauseSelection = function() { $scope.directiveScope.transcompiled[$scope.directiveScope.newClauseSelection] = $scope.directiveScope.booleanArrayNames[$scope.directiveScope.newClauseSelection] ? [{}]: { _$eq: null }; $scope.directiveScope.newClauseSelection = null; } this.allSpecialFields = [ "_$not", ...Object.keys($scope.directiveScope.operators), ...Object.values(this.operators).map((o) => { return Object.keys(o.optionalFields || {}); }).flat(), ].distinct().filter((f) => { return !!f; }); this.fieldIsSpecial = function(_field) { return $scope.directiveScope.allSpecialFields.includes(_field); } this.transcompileName = function(_name, _fromUi) { return _name ? _name.replace((_fromUi ? "_$" : "$"), (_fromUi ? "$" : "_$")) : null; } this.transcompile = function(_object, _fromUi, _name) { var transcompiled = null; var transcompiledName = $scope.directiveScope.transcompileName(_name, _fromUi); if (_object == null) { } else if (Array.isArray(_object)) { //Array value, recursively transcompile for each value transcompiled = _object.map((value) => { return $scope.directiveScope.transcompile(value, _fromUi, _name); }).filter((value) => { //If we're transcompiling a boolean array, skip null values return ( !Object.keys($scope.directiveScope.booleanArrayNames).includes(_name) && !Object.keys($scope.directiveScope.booleanArrayNames).includes(transcompiledName) ) || value != null; }); } else if (_fromUi) { //Converting from UI, what type of value are we transcompiling? if (typeof(_object) == "object" && typeof(_object.getMonth) != "function") { if (Object.keys(_object).length == 1 && _object._$eq != null) { //Singular equality object,convert to direct equality transcompiled = _object._$eq } else { //Regular object, recursively transcompile for each property, rename "$" properties transcompiled = {}; Object.keys(_object).forEach((property) => { if (property.startsWith("$$")) { return; } transcompiled[$scope.directiveScope.transcompileName(property, _fromUi)] = $scope.directiveScope.transcompile(_object[property], _fromUi, property); }); } } else if ($scope.directiveScope.allSpecialFields.includes(_name)) { //Special value, dont touch transcompiled = _object; } } else { //Converting to UI, what type of value are we transcompiling? if (typeof(_object) == "object" && typeof(_object.getMonth) != "function") { //Object value, recursively transcompile for each property, rename "$" properties transcompiled = {}; Object.keys(_object).forEach((property) => { if (property.startsWith("$$")) { return; } transcompiled[$scope.directiveScope.transcompileName(property, _fromUi)] = $scope.directiveScope.transcompile(_object[property], _fromUi, property); }); } else if ($scope.directiveScope.allSpecialFields.includes(transcompiledName)) { //Special value, dont touch transcompiled = _object; } else { //Normal value, normalize to $eq transcompiled = { _$eq: _object }; } } return transcompiled; } this.transcompiled = null; this.rebuildUi = function() { if (!$scope.directiveScope.updatingBinding) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] || ($scope.directiveScope.level == 0 ? {} : null); var newTranscompiled = ($scope.directiveScope.level == 0 ? //Top level query editor, transcompile to UI query format $scope.directiveScope.transcompile($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) : //Lower level query editor, top level query already transcompile to UI query format $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); postProcessJSON(newTranscompiled); $scope.directiveScope.updatingUi = true; $scope.directiveScope.transcompiled = newTranscompiled $scope.directiveScope.updatingUi = false; } }; this.rebuildBinding = function() { if (!$scope.directiveScope.updatingUi) { var newTranscompiled = ($scope.directiveScope.level == 0 ? //Top level query editor, transcompile back to mongo query format $scope.directiveScope.transcompile($scope.directiveScope.transcompiled, true) : //Lower level query editor, top level query will transcompile back to mongo query format $scope.directiveScope.transcompiled); //postProcessJSON(newTranscompiled); $scope.directiveScope.updatingBinding = true; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = newTranscompiled; $scope.directiveScope.updatingBinding = false; } } $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", (_new, _old) => { $scope.directiveScope.rebuildUi(); }, true); $scope.$watch("directiveScope.transcompiled", (_new, _old) => { $scope.directiveScope.rebuildBinding(); }, true); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: queryEditor failed to initialize: " + e); } }); } app.controller('ctrl_6039c4a1efaf8d41ea7ed2d2', ctrl_6039c4a1efaf8d41ea7ed2d2); app.directive('electricalConnectionDisplay', function() { return { scope: { bindingParent: "=", bindingName: "=" }, transclude: false, controller: ctrl_603dacac6175413b5604ed86, template: `
    Bus {{directiveScope.bindingParent[directiveScope.bindingName].connection_data == 'wire_connection' ? 'Wire' : 'Pin'}}
    {{bus}} {{v}}
    `, bindToController: true};}); function ctrl_603dacac6175413b5604ed86($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: electricalConnectionDisplay failed to initialize: " + e); } }); } app.controller('ctrl_603dacac6175413b5604ed86', ctrl_603dacac6175413b5604ed86); app.directive('electricalConnectionBusConfig', function() { return { scope: { bindingParent: "=", bindingName: "=" }, transclude: false, controller: ctrl_603efe9bdb33e129dcdc3a82, template: `
    `, bindToController: true};}); function ctrl_603efe9bdb33e129dcdc3a82($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] || { layer: 0}; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: electricalConnectionBusConfig failed to initialize: " + e); } }); } app.controller('ctrl_603efe9bdb33e129dcdc3a82', ctrl_603efe9bdb33e129dcdc3a82); app.directive('hexColorSelection', function() { return { scope: { bindingParent: "=", bindingName: "=", readOnly: "=?" }, controller: ctrl_603fb71c92a6ba5827669f89, template: `#{{directiveScope.bindingParent[directiveScope.bindingName]}}
    `, bindToController: true};}); function ctrl_603fb71c92a6ba5827669f89($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.readOnly = this.readOnly == null ? false : true; $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { if ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].startsWith("#")) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].replace("#",""); } }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: hexColorSelection failed to initialize: " + e); } }); } app.controller('ctrl_603fb71c92a6ba5827669f89', ctrl_603fb71c92a6ba5827669f89); app.directive('colorSelection', function() { return { scope: { bindingParent: "=", bindingName: "=", readOnly: "=?" }, controller: ctrl_603fc02a92a6ba5827669f97, template: `
    `, bindToController: true};}); function ctrl_603fc02a92a6ba5827669f97($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.colorRecord; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: colorSelection failed to initialize: " + e); } }); } app.controller('ctrl_603fc02a92a6ba5827669f97', ctrl_603fc02a92a6ba5827669f97); app.directive('numericStepper', function() { return { scope: { bindingParent: "=", bindingName: "=", majorStep: "=?", minorStep: "=?", min: "=?", max: "=?", invertButtons: "=?", onChange: "=?" }, controller: ctrl_60422df7f9bc7338074fcd1b, template: `
    {{directiveScope.bindingParent[directiveScope.bindingName]}}
    `, bindToController: true};}); function ctrl_60422df7f9bc7338074fcd1b($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.majorStep = this.majorStep == null ? 10 : this.majorStep; this.minorStep = this.minorStep == null ? 1 : this.minorStep; this.max = this.max == null ? 10000 : this.max; this.min = this.min == null ? 0 : this.min; this.mod = function(_delta) { _delta *= this.invertButtons ? -1 : 1; var newValue = this.bindingParent[this.bindingName] + _delta; if (newValue >= this.min && newValue <= this.max) { this.bindingParent[this.bindingName] = newValue; if (this.onChange) { this.onChange(); } } } }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: numericStepper failed to initialize: " + e); } }); } app.controller('ctrl_60422df7f9bc7338074fcd1b', ctrl_60422df7f9bc7338074fcd1b); app.directive('electricalConnectionBusDisplay', function() { return { scope: { bindingParent: "=", bindingName: "=" }, transclude: false, controller: ctrl_60491d9366066a78a84b899d, template: `
    {{directiveScope.bindingParent[directiveScope.bindingName].conductor_color.name_abbreviation || ''}}
    {{directiveScope.bindingParent[directiveScope.bindingName].pin}}
    `, bindToController: true};}); function ctrl_605b584ced79905e17b790fc($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; captchaCallback = function(_token) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _token; $scope.$apply(); } captchaExpired = function() { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = null; $scope.$apply(); } } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: captcha failed to initialize: " + e); } }); } app.controller('ctrl_605b584ced79905e17b790fc', ctrl_605b584ced79905e17b790fc); app.directive('tabContainer', function() { return { scope: { tabs: "=?", currentTab: "=?", dynamic: "=?" //True: will populate tabs with their respective 'html' property, otherwise use the static transclusion }, transclude: true, controller: ctrl_5f995a73b6a2e144ba7ac6b5, template: `
    `, bindToController: true};}); function ctrl_5f995a73b6a2e144ba7ac6b5($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.tabs = this.tabs || {}; this.unique = createUniqueTag(); $scope.directiveScope = this; this.dynamic = this.dynamic || false; };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: tabContainer failed to initialize: " + e); } }); } app.controller('ctrl_5f995a73b6a2e144ba7ac6b5', ctrl_5f995a73b6a2e144ba7ac6b5); app.directive('contextMenu', function() { return { scope: { }, controller: ctrl_5fe807156ffaae7d29690585, template: ` `, bindToController: true};}); function ctrl_5fe807156ffaae7d29690585($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = createUniqueTag(); this.select = function(_selectionKey, _selectionValue) { var callingEnvironment = { selectionKey: _selectionKey, selectionValue: _selectionValue, target: this.target, scope: $scope, rootScope: $rootScope, http: $http }; if (_selectionValue.onClick) { _selectionValue.onClick(callingEnvironment); } else { $rootScope.$emit('contextMenuSelected', callingEnvironment); } } waitForElement(this.unique, () => { $('body').on('click', function(e) { $("#" + $scope.directiveScope.unique).removeClass("show"); }); $('body').on('contextmenu', function(e) { var data = $scope.directiveScope.findContextData(e.target); if (data) { $scope.directiveScope.target = data.target; $scope.directiveScope.selections = data.selections; $scope.$digest(); var pos = $scope.directiveScope.setContextMenuPostion(e, $("#" + $scope.directiveScope.unique)); $("#" + $scope.directiveScope.unique).css({ top: pos.y + "px", left: pos.x + "px", }).addClass("show"); return false; } else { $("#" + $scope.directiveScope.unique).removeClass("show"); } }); $('body').on('click', function(e) { $rootScope.$emit('closeContextMenus'); }); }); this.findContextData = function(_element) { if (_element.attributes && _element.dataset.contextSelections) { var elementScope = angular.element(_element).scope(); return { element: _element, scope: elementScope, selections: elementScope.$eval(_element.dataset.contextSelections), target: elementScope.$eval(_element.dataset.contextTarget) }; } else if (_element.parentNode) { return this.findContextData(_element.parentNode); } else { return null; } } //https://stackoverflow.com/a/11802841/9048430 this.setContextMenuPostion = function(event, contextMenu) { var mousePosition = {}; var menuPostion = {}; var menuDimension = {}; menuDimension.x = contextMenu.outerWidth(); menuDimension.y = contextMenu.outerHeight(); mousePosition.x = event.pageX; mousePosition.y = event.pageY; if (mousePosition.x + menuDimension.x > $(window).width() + $(window).scrollLeft()) { menuPostion.x = mousePosition.x - menuDimension.x; } else { menuPostion.x = mousePosition.x; } if (mousePosition.y + menuDimension.y > $(window).height() + $(window).scrollTop()) { menuPostion.y = mousePosition.y - menuDimension.y; } else { menuPostion.y = mousePosition.y; } return menuPostion; } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: contextMenu failed to initialize: " + e); } }); } app.controller('ctrl_5fe807156ffaae7d29690585', ctrl_5fe807156ffaae7d29690585); app.directive('autocompleteSelection', function() { return { scope: { bindingParent: "=", bindingName: "=", selections: "=", onChange: "=?", placeholder: "=?", searchFilter: "=?", contextSelections: "=?" }, controller: ctrl_607830f28e940c6ba3c3fa2d, template: ` `, bindToController: true};}); function ctrl_607830f28e940c6ba3c3fa2d($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.searchFilter = ""; this.selections = this.selections || {}; this.matchesFilter = function(_value) { return ($scope.directiveScope.searchFilter || "").length == 0 || _value.toLowerCase().includes($scope.directiveScope.searchFilter.toLowerCase()) || ($scope.directiveScope.selections[_value] || {}).label.toLowerCase().includes($scope.directiveScope.searchFilter.toLowerCase()); }; this.select = function(_key) { if ($scope.directiveScope.selections[_key].selectable != false) { $scope.directiveScope.searchFilter = $scope.directiveScope.selections[_key].label; if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _key; } if ($scope.directiveScope.onChange) { $scope.directiveScope.onChange(_key); } $scope.directiveScope.showOptions = false; } } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: autocompleteSelection failed to initialize: " + e); } }); } app.controller('ctrl_607830f28e940c6ba3c3fa2d', ctrl_607830f28e940c6ba3c3fa2d); app.directive('trackedLink', function() { return { scope: { href: "@", target: "@?" }, transclude: true, controller: ctrl_60bfbc0614c5b8225d90826e, template: ` `, bindToController: true};}); function ctrl_60bfbc0614c5b8225d90826e($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: trackedLink failed to initialize: " + e); } }); } app.controller('ctrl_60bfbc0614c5b8225d90826e', ctrl_60bfbc0614c5b8225d90826e); app.directive('modalTextEntry', function() { return { scope: { title: "=?", bindingName: "=", bindingParent: "=", subtext: "=?", height: "=?" }, controller: ctrl_60cc0af19c39054a99348675, template: ` {{directiveScope.bindingParent[directiveScope.bindingName]}} None {{directiveScope.subtext}} `, bindToController: true};}); function ctrl_60cc0af19c39054a99348675($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modalTextEntry failed to initialize: " + e); } }); } app.controller('ctrl_60cc0af19c39054a99348675', ctrl_60cc0af19c39054a99348675); app.directive('modalScriptEntry', function() { return { scope: { title: "=?", bindingName: "=", bindingParent: "=", mode: "=", subtext: "=?" }, controller: ctrl_60cc0cfa9c39054a99348676, template: `

    {{directiveScope.bindingParent[directiveScope.bindingName] || " "}}

    {{directiveScope.subtext}} `, bindToController: true};}); function ctrl_60cc0cfa9c39054a99348676($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modalScriptEntry failed to initialize: " + e); } }); } app.controller('ctrl_60cc0cfa9c39054a99348676', ctrl_60cc0cfa9c39054a99348676); app.directive('loadingBox', function() { return { scope: { message: "=?", icon: "=?" }, controller: ctrl_60d38e86d8342a28c4756b43, template: `
    Keller Information Management
    `, bindToController: true};}); function ctrl_60d38e86d8342a28c4756b43($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.loaded = false; } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: loadingBox failed to initialize: " + e); } }); } app.controller('ctrl_60d38e86d8342a28c4756b43', ctrl_60d38e86d8342a28c4756b43); app.directive('menuContainer', function() { return { scope: { containerData: "=", onSelection: "=", searchCollector: "=", depth: "=?" }, controller: ctrl_610b4698fb29f524c0cc0735, template: `
  • {{directiveScope.containerData.title}}
  • `, bindToController: true};}); function ctrl_610b4698fb29f524c0cc0735($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = async function() { $scope.directiveScope = this; this.id = createUniqueTag(); this.useHtmlLabel = (this.containerData.label_html || "").length > 2; $rootScope.$on('contextMenuSelected', function(_event, _selection) { }); this.select = function(_selectionKey, _selectionValue) { var callingEnvironment = { selectionKey: _selectionKey, selectionValue: _selectionValue, scope: $scope, rootScope: $rootScope, http: $http }; if (_selectionValue.onClick) { _selectionValue.onClick(callingEnvironment); } else { $scope.directiveScope.onSelection(callingEnvironment); } }; this.selectContext = function(_callingEnvironment) { $scope.directiveScope.onSelection(_callingEnvironment); }; if (this.containerData.dropdown_enabled) { try { this.selections = await (new Function("scope", "rootScope", "http", "return new Promise((resolve) => {\r\n" + this.containerData.content_script + "\r\n});"))($scope, getRootScope($scope), $http); this.selections = this.selections || {}; //Set up context selections w/ links Object.keys(this.selections).forEach((selectionKey) => { var selection = this.selections[selectionKey]; if (selection.contextSelections) { Object.keys(selection.contextSelections).forEach((contextSelectionKey) => { var contextSelection = selection.contextSelections[contextSelectionKey]; contextSelection.onClick = contextSelection.onClick || $scope.directiveScope.selectContext; }); } }); Object.assign(this.searchCollector, this.selections); safeApply($scope); } catch (e) { this.selections = { "error": { label: "Error: " + e, class: "danger" } }; } } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: menuContainer failed to initialize: " + e); } }); } app.controller('ctrl_610b4698fb29f524c0cc0735', ctrl_610b4698fb29f524c0cc0735); app.directive('ciDependencyMap', function() { return { scope: { rootQuery: "=", rootModel: "=?", allowedModelsQuery: "=?", parentalRelations: "=?", dynamicRelations: "=?", networkRelations: "=?", powerRelations: "=?", showDependants: "=?", showDependencies: "=?", depthLevels: "=?", mapOptions: "=?", onCiSelection: "=" }, link: function(s, e, a) { //Get background color of closest parent, use to set dark mode var p = e[0].parentElement; do { var c = getColorComponents(window.getComputedStyle(p).backgroundColor); if (c.r != 0 || c.g != 0 || c.b != 0) { s.directiveScope.darkMode = c.r < 128 && c.g < 128 && c.b < 128; console.log(s.directiveScope.darkMode); return; } p = p.parentElement; } while(p != null); function getColorComponents(_colorString) { try { _colorString = _colorString.replace("rgba", "rgb").split("rgb(")[1].split(")")[0]; var cs = _colorString.split(", "); return { r: parseInt(cs[0]), g: parseInt(cs[1]), b: parseInt(cs[2]), } } catch (e) { return {} } } } , controller: ctrl_615d9d92fc8f6522e5addce2, template: `
    Building relation map...
    `, bindToController: true};}); function ctrl_615d9d92fc8f6522e5addce2($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.levelCount = 0; this.selectedCi = null this.nodes = []; this.relations = []; this.rootModel = this.rootModel || "cmdb_ci"; this.allowedModelsQuery = this.allowedModelsQuery || {}; this.parentalRelations = this.parentalRelations || true; this.dynamicRelations = this.dynamicRelations || true; this.networkRelations = this.networkRelations || true; this.powerRelations = this.powerRelations || true; this.depthLevels = this.depthLevels || true; this.showDependants = this.showDependants || false; this.showDependencies = this.showDependencies || false; this.dynamicColor = "#2859d4aa"; this.networkColor = "#3fd428aa"; this.powerColor = "#d42828aa"; this.parentalColor = "#cb28d4aa"; this.okColor = "#00ff00aa"; this.degradedColor = "#ffff00aa"; this.errorColor = "#ff0000aa"; this.lastNodeClickTime = null; this.options = { height: "100%", edges:{ smooth: { forceDirection: "none", roundness: 0.35 }, arrows: { to: { enabled: false }, middle: { enabled: true } } }, layout: { randomSeed: 1, improvedLayout: true, hierarchical: { enabled: true, direction: "DU", sortMethod: 'directed', shakeTowards: 'leaves', levelSeparation: 200, nodeSpacing: 300 } }, physics: { enabled: false, solver: "repulsion", repulsion: { centralGravity: 0.0001, springLength: 200, springConstant: 0.01, nodeDistance: 1000, damping: 0.09 } } }; this.update(); $scope.$watch("directiveScope.rootQuery", () => { $scope.directiveScope.update(); }); $scope.$watch("directiveScope.allowedModelsQuery", () => { $scope.directiveScope.update(); }); this.viewCiModal = {}; }; this.stateGlyphs = { ok: "✔️", degraded: "⚠️", error: "❌" }; this.update = function() { if (!this.loading) { this.levelCount = 0; mergeObjects(this.options, this.mapOptions); this.nodes = []; this.relations = []; this.modelLevels = []; this.loading = true; if (this.rootQuery && (this.rootModel != "cmdb_ci" || Object.keys(this.rootQuery).length > 0)) { $http.get( "/api/cmdb/" + JSON.stringify(this.rootQuery) + "/dependencies?rootModel=" + this.rootModel + "&allowedModelsQuery=" + JSON.stringify(this.allowedModelsQuery) + "&getDependants=" + this.showDependants + "&getDependencies=" + this.showDependencies , { withCredentials: true }).then( function(json){ json.data.forEach((result) => { $scope.directiveScope.addNode({ id: result.ci._id, ci: result.ci, label: $scope.directiveScope.stateGlyphs[result.ci.state] + " [" + $scope.$root.models[result.ci._type].singular_name + "]\r\n" + result.ci[$scope.$root.models[result.ci._type].display_field], image: result.ci.icon ? result.ci.icon.link : $scope.$root.models[result.ci._type].icon.link, level: 0 }); if($scope.directiveScope.showDependencies) { $scope.directiveScope.processDependencies(result, 1); } if($scope.directiveScope.showDependants) { $scope.directiveScope.processDependants(result, -1); } }); $scope.directiveScope.options.layout.hierarchical.levelSeparation = Math.min(500, Math.max(200, $scope.directiveScope.levelCount * 60)); $scope.directiveScope.initialized = true; $scope.directiveScope.loading = false; }); } else { this.initialized = true; this.loading = false; } } } this.buildTooltip = function(_ci) { if ($scope.$$phase) { return; } var model = $scope.$root.models[_ci._type]; var tooltip = document.createElement("div"); tooltip.innerHTML = `
    ` + _ci[model.display_field] + `
    ` + model.singular_name + `
    `; return tooltip; } this.processDependencies = function(_data, _level) { this.levelCount = Math.max(_level, this.levelCount); _level = _level || 0; if (this.parentalRelations) { _data.dependencies.forEach((dependency) => { try { this.addNode({ id: dependency.ci._id, ci: dependency.ci, label: $scope.directiveScope.stateGlyphs[dependency.ci.state] + " [" + $scope.$root.models[dependency.ci._type].singular_name + "]\r\n" + dependency.ci[$scope.$root.models[dependency.ci._type].display_field], image: dependency.ci.icon ? dependency.ci.icon.link : $scope.$root.models[dependency.ci._type].icon.link, level: this.depthLevels ? _level : this.getModelLevel(dependency.ci._type) + 1, // title: this.buildTooltip(dependency.ci) }); this.addRelation({ to: _data.ci._id, from: dependency.ci._id, color: { color: this[dependency.highestState + "Color"] } }); } catch (e) { console.log("Invalid Node: " + e); } this.processDependencies(dependency, _level + 1); }); } }; this.processDependants = function(_data, _level) { _level = _level || 0; if (this.parentalRelations) { _data.dependants.forEach((dependant) => { try { this.addNode({ id: dependant.ci._id, ci: dependant.ci, label: "[" + $scope.$root.models[dependant.ci._type].singular_name + "]\r\n" + dependant.ci[$scope.$root.models[dependant.ci._type].display_field], image: dependant.ci.icon ? dependant.ci.icon.link : $scope.$root.models[dependant.ci._type].icon.link, level: this.depthLevels ? _level : ((this.getModelLevel(dependant.ci._type) + 1) * -1), }); this.addRelation({ to: dependant.ci._id, from: _data.ci._id, color: { color: this[dependant.ci.state + "Color"] } }); } catch (e) { console.log("Invalid Node: " + e); } this.processDependants(dependant, _level - 1); }); } }; this.addNode = function(_newNode) { if (!this.nodes.some((node) => { return node.id == _newNode.id; })) { _newNode.font = { color: this.darkMode ? "#ffffff" : "#000000" } this.nodes.push(_newNode); } } this.addRelation = function(_newRelation) { if (!this.relations.some((relation) => { return relation.to == _newRelation.to && relation.from == _newRelation.from ; })) { _newRelation.color = _newRelation.color ? _newRelation.color : {}; _newRelation.color.highlight = "#dddd00"; this.relations.push(_newRelation); } } this.getModelLevel = function(_model) { var index = this.modelLevels.indexOf(_model); if (index == -1) { this.modelLevels.push(_model); return this.modelLevels.length - 1; } else { return index; } } this.onNodeSelection = function(_data) { var node = $scope.directiveScope.nodes.find((node) => { return node.id == _data.nodes[0]; }); if ($scope.directiveScope.selectedCi == node.ci && (new Date() - $scope.directiveScope.lastNodeClickTime) < 500) { //Dispose and re-init the modal form $scope.directiveScope.viewCiModal.ci = null; $scope.$apply(); $scope.directiveScope.viewCiModal.ci = $scope.directiveScope.selectedCi; $scope.$apply(); //Show the modal $scope.directiveScope.viewCiModal.show(); } $scope.directiveScope.selectedCi = node.ci; $scope.directiveScope.lastNodeClickTime = new Date(); if ($scope.directiveScope.onCiSelection) { $scope.directiveScope.onCiSelection($scope.directiveScope.selectedCi); } } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: ciDependencyMap failed to initialize: " + e); } }); } app.controller('ctrl_615d9d92fc8f6522e5addce2', ctrl_615d9d92fc8f6522e5addce2); app.directive('employeeReportsChart', function() { return { scope: { isChild: "=?", bindingParent: "=", bindingName: "=" }, transclude: false, controller: ctrl_618d2dd29f946576ec692490, template: `{{directiveScope.employee.full_name}}
    {{directiveScope.employee.position}} `, bindToController: true};}); function ctrl_618d2dd29f946576ec692490($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; console.log(this); this.employee = null; this.reports = []; retrieveRecord($scope, $http, "employee", { query: { _id: this.bindingParent[this.bindingName] } }, (record) => { $scope.directiveScope.employee = record; }); retrieveRecords($scope, $http, "employee", { query: { supervisor: this.bindingParent[this.bindingName] }, select: ["_id", "full_name"] }, (result) => { $scope.directiveScope.reports = result.records; console.log($scope.directiveScope); }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: employeeReportsChart failed to initialize: " + e); } }); } app.controller('ctrl_618d2dd29f946576ec692490', ctrl_618d2dd29f946576ec692490); app.directive('referenceSelection', function() { return { scope: { display: "=?", //Field to display (default if not provided) onChange: "&", refModel: "=", allowNew: "=?", allowView: "=?", allowEdit: "=?", allowSelection: "=?", displayRecord: "=?", refQualifier: "=?", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) layoutName: "=", //Name of list layout to use when choosing a new value. If not set the first applicable layout is used allowInteraction: "=?" //Overrides form detection and allows interaction (CAREFUL OF INFINITE RECURSIVE LOADING) }, controller: ctrl_618d43be9f946576ec6924a6, template: `
     {{directiveScope.loading ? 'Loading...' : (directiveScope.displayRecord[directiveScope.display ? directiveScope.display : $root.models[directiveScope.refModel].display_field])}}
    `, bindToController: true};}); function ctrl_618d43be9f946576ec6924a6($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { //BINDS TO ID STRING this.$onInit = function() { this.listModal = {}; this.currentRecordModal = {}; this.newRecordModal = { newRecord: {} }; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.allowNew = this.allowNew == null ? true : this.allowNew; this.allowView = this.allowView == null ? true : this.allowView; this.allowEdit = this.allowEdit == null ? true : this.allowEdit; $scope.directiveScope = this; this.unique = createUniqueTag(); this.loading = false; this.refQualifier = this.refQualifier || {}; //Normlize binding (to single id string or null) //this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] ? (typeof(this.bindingParent[this.bindingName]) == "object" ? this.bindingParent[this.bindingName]._id : this.bindingParent[this.bindingName]) : null; if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && this.bindingParent[this.bindingName] && typeof(this.bindingParent[this.bindingName]) == "object") { this.displayRecord = this.bindingParent[this.bindingName]; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName]._id; } else { //Init load bound record this.loading = true; if (this.bindingParent[this.bindingName]) { //Get existing record this.loadDisplayRecord(); } else { this.displayRecord = null; this.loading = false; } } //Watch for binding change $scope.$watch('[directiveScope.bindingParent, directiveScope.bindingName, directiveScope.bindingParent[directiveScope.bindingName]]', function (newValue, oldValue, scope) { if (newValue != oldValue && !$scope.directiveScope.displayUpdating) { $scope.directiveScope.bindingUpdating = true; $scope.directiveScope.loadDisplayRecord(() => { $scope.directiveScope.bindingUpdating = false; }); } }, true); //Watch for record change $scope.$watch('directiveScope.displayRecord', function (newValue, oldValue, scope) { if (newValue != oldValue) { $scope.directiveScope.displayUpdating = true; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.displayRecord ? $scope.directiveScope.displayRecord._id : null; $scope.directiveScope.displayUpdating = false; $scope.directiveScope.onChange(); } }, true); //Get default layout for display field this.layout = $scope.$root.layouts.find((l) => { return l.model == this.refModel && l.default && l._type == "form_layout"; }); } this.loadDisplayRecord = function(_fresh, _then) { if (!this.bindingParent[this.bindingName]) { this.displayRecord = null; this.loading = false; if (_then) { _then(); } } else if (_fresh) { retrieveRecord($scope, $http, this.refModel, { query: { _id: this.bindingParent[this.bindingName] }}, (record) => { this.displayRecord = record; this.loading = false; if (_then) { _then(); } }); } else { retrieveRecord($scope, $http, this.refModel, { query: { _id: this.bindingParent[this.bindingName] }}, (record) => { this.displayRecord = record; this.loading = false; if (_then) { _then(); } }); } } this.showCurrent = function() { if (this.allowView && this.displayRecord) { this.currentRecordModal.show(() => { this.loadDisplayRecord(true); }); } } this.showNew = function() { this.newRecordModal.newRecord = {}; this.newRecordModal.show(() => { if (this.newRecordModal.newRecord._id) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = this.newRecordModal.newRecord._id; this.loadDisplayRecord(true); } }); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: referenceSelection failed to initialize: " + e); } }); } app.controller('ctrl_618d43be9f946576ec6924a6', ctrl_618d43be9f946576ec6924a6); app.directive('pieChart', function() { return { scope: { values: "=", height: "=?", width: "=?", showLegend: "=?" }, controller: ctrl_61ba54770e56cf722b8d22ed, template: `
    `, bindToController: true};}); function ctrl_61ba54770e56cf722b8d22ed($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; // this.height = this.height || 200; // this.width = this.width || 200; this.options = { maintainAspectRatio: false, elements: { arc: { borderWidth: 1, circular: false } }, legend: ($scope.directiveScope.showLegend ? { display: true, position: "left", align: "start", maxWidth: 100, labels: { padding: 2, font: { size: 5 } } } : null) }; //Process plot objects this.process(); //Configure watch $scope.$watch('directiveScope.values', function (_new, _old, _scope) { $scope.directiveScope.process(); }, true); }; this.process = function() { //Build this.labels = Object.keys(this.values); this.data = Object.values(this.values); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: pieChart failed to initialize: " + e); } }); } app.controller('ctrl_61ba54770e56cf722b8d22ed', ctrl_61ba54770e56cf722b8d22ed); app.directive('addressEntry', function() { return { scope: { bindingParent: "=?", bindingName: "=?", allowInteraction: "=?", validateMethod: "=?", //should return an object { field_name: "error", ...} formatMethod: "=?" //should modify the values directly }, controller: ctrl_61e279aaa826a737863a211c, template: `
    {{directiveScope.validationErrors.company}}
    {{directiveScope.validationErrors.address_1}}
    {{directiveScope.validationErrors.address_2}}
    {{directiveScope.validationErrors.address_3}}
    {{directiveScope.validationErrors.phone}}
    {{directiveScope.validationErrors.fax}}
    {{directiveScope.validationErrors.contact}}
    {{directiveScope.validationErrors.city}}
    {{directiveScope.validationErrors.state}}
    {{directiveScope.validationErrors.postal_code}}
    {{directiveScope.validationErrors.country}}
    {{directiveScope.validationErrors.email}}
    `, bindToController: true};}); function ctrl_61e279aaa826a737863a211c($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.validationErrors = {}; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.formatting = false; this.default = { address_1: "", address_2: "", address_3: "", city: "", state: "", country: "", company: "", contact: "", postal_code: "", phone: "", fax: "", email: "", tax_id: "" }; $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", (_new , _old) => { //Normalize binding $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] || {}; Object.keys($scope.directiveScope.default).forEach((k) => { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][k] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][k] || $scope.directiveScope.default[k]; }); //Format and validate if ($scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { if (!$scope.directiveScope.formatting && $scope.directiveScope.formatMethod && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { $scope.directiveScope.formatting = true; $scope.directiveScope.formatMethod($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); $scope.directiveScope.formatting = false; } if ($scope.directiveScope.validateMethod && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { $scope.directiveScope.validationErrors = $scope.directiveScope.validateMethod($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); } } }, true); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: addressEntry failed to initialize: " + e); } }); } app.controller('ctrl_61e279aaa826a737863a211c', ctrl_61e279aaa826a737863a211c); app.directive('singleReferenceSearch', function() { return { scope: { title: "=", display: "=?", refModel: "=", refQualifier: "=?", displayRecord: "=?", searchFields: "=?", //Can be string or array of strings populate: "=?", sort: "=?", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) onChange: "&" }, controller: ctrl_61e4a8fc00f61e070a6522fe, template: `
    `, bindToController: true};}); function ctrl_61e4a8fc00f61e070a6522fe($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); this.display = this.display == null ? $scope.$root.models[this.refModel].display_field : this.display; this.searchFields = this.searchFields == null ? this.display : this.searchFields; this.search = ""; this.populate = this.populate || {}; this.searching = false; this.focused = false; $scope.directiveScope = this; $scope.parentBaseFormScope = searchFullScope($scope.$parent, "directiveScope"); $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { if (!$scope.directiveScope.settingBinding) { retrieveRecord($scope, $http, $scope.directiveScope.refModel, { query: { _id: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] }, populate: $scope.directiveScope.populate }, (record) => { $scope.directiveScope.settingDisplay = true; $scope.directiveScope.displayRecord = record; $scope.directiveScope.settingDisplay = false; $scope.directiveScope.search = $scope.directiveScope.displayRecord ? $scope.directiveScope.displayRecord[this.display] : ($scope.directiveScope.focused ? $scope.directiveScope.search : ""); }); } }); $scope.$watch("directiveScope.displayRecord", () => { if (!$scope.directiveScope.settingDisplay) { $scope.directiveScope.settingBinding = true; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.displayRecord ? $scope.directiveScope.displayRecord._id : null; $scope.directiveScope.settingBinding = false; } }); this.searchChanged = function() { this.settingBinding = true; this.bindingParent[this.bindingName] = null; this.settingBinding = false; } this.keypress = function(_event) { if (_event.originalEvent.charCode == 13) { this.doSearch(); } } this.clear = function() { this.settingBinding = true; this.bindingParent[this.bindingName] = null; this.settingBinding = false; this.search = ""; } this.doSearch = function() { //Populate selections this.searching = true; var query = { $or: (Array.isArray(this.searchFields) ? this.searchFields : [searchFields]).map((f) => { var fq = {}; fq[f] = this.search; return fq; }) }; retrieveRecords($scope, $http, $scope.directiveScope.refModel, { query: query , limit: 1, populate: $scope.directiveScope.populate }, (response) => { $scope.directiveScope.displayRecord = response.total_count == 1 ? response.records[0] : null; $scope.directiveScope.searching = false; }); } this.searchChanged(); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: singleReferenceSearch failed to initialize: " + e); } }); } app.controller('ctrl_61e4a8fc00f61e070a6522fe', ctrl_61e4a8fc00f61e070a6522fe); app.directive('addressDisplay', function() { return { scope: { bindingParent: "=?", bindingName: "=?" }, controller: ctrl_61eb8a0321702358e0553219, template: `

    {{directiveScope.bindingParent[directiveScope.bindingName].address_1}}
    {{directiveScope.bindingParent[directiveScope.bindingName].address_2}}
    {{directiveScope.bindingParent[directiveScope.bindingName].address_3}}
    {{directiveScope.bindingParent[directiveScope.bindingName].city}}, {{directiveScope.bindingParent[directiveScope.bindingName].state}} {{directiveScope.bindingParent[directiveScope.bindingName].postal_code}} {{directiveScope.bindingParent[directiveScope.bindingName].country}}

    {{directiveScope.bindingParent[directiveScope.bindingName].company}}

    {{directiveScope.bindingParent[directiveScope.bindingName].contact}}

    {{directiveScope.bindingParent[directiveScope.bindingName].email}}

    {{directiveScope.bindingParent[directiveScope.bindingName].phone}}

    {{directiveScope.bindingParent[directiveScope.bindingName].fax}}
    `, bindToController: true};}); function ctrl_61eb8a0321702358e0553219($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.bindingParent[this.bindingName] = !this.bindingParent[this.bindingName] || typeof(this.bindingParent[this.bindingName]) != "object" ? {} : this.bindingParent[this.bindingName]; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: addressDisplay failed to initialize: " + e); } }); } app.controller('ctrl_61eb8a0321702358e0553219', ctrl_61eb8a0321702358e0553219); app.directive('addressDisplayMinimal', function() { return { scope: { bindingParent: "=?", bindingName: "=?" }, controller: ctrl_61ecd4b286904661c0c80e9f, template: `{{directiveScope.bindingParent[directiveScope.bindingName].address_1 + " " + directiveScope.bindingParent[directiveScope.bindingName].address_2 + " " + directiveScope.bindingParent[directiveScope.bindingName].address_3 + " " + directiveScope.bindingParent[directiveScope.bindingName].city + ", " + directiveScope.bindingParent[directiveScope.bindingName].state + " " + directiveScope.bindingParent[directiveScope.bindingName].postal_code}}`, bindToController: true};}); function ctrl_61ecd4b286904661c0c80e9f($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: addressDisplayMinimal failed to initialize: " + e); } }); } app.controller('ctrl_61ecd4b286904661c0c80e9f', ctrl_61ecd4b286904661c0c80e9f); app.directive('barChart', function() { return { scope: { maxHeight: "=?", axisXLabel: "=?", axisYLabel: "=?", series: "=?", stack: "=?" }, controller: ctrl_61f7df52926e9304e2bf8351, template: `
    `, bindToController: true};}); function ctrl_61f7df52926e9304e2bf8351($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { /* Series Data Format [ [ { value, barColor, label, hoverTitle, hoverBody } ] ] */ this.$onInit = function() { $scope.directiveScope = this; this.chartData = {}; this.chartSeries = []; this.chartColors = []; this.chartOptions = {}; this.datasetOverride = []; //Process plot objects this.process(); //Configure watch $scope.$watch('directiveScope.series', function (_new, _old, _scope) { $scope.directiveScope.process(); }, true); }; this.process = function() { this.series = this.series || []; this.chartOptions = { responsive: true, maintainAspectRatio: false, tooltips: { yAlign: 'top', bodyFontSize: 14, callbacks: { title: (_tooltipItem, _data) => { return _tooltipItem.map((value) => { return $scope.directiveScope.series[value.datasetIndex].values[value.index].hoverTitle })[0]; }, label: (_tooltipItem, _data) => { return $scope.directiveScope.series[_tooltipItem.datasetIndex].values[_tooltipItem.index].hoverBody } } }, scales: { yAxes: [{ stacked: true, ticks: { suggestedMin: 0, suggestedMax: 100, fontSize: 12, fontColor: "#aaaaaa" }, scaleLabel: { display: true, fontSize: 15, labelString: this.axisYLabel } }], xAxes: [{ stacked: true, ticks: { fontColor: "#aaaaaa", fontSize: 12 }, scaleLabel: { display: true, fontSize: 15, labelString: this.axisXLabel } }] } }; this.chartSeries = []; this.chartData = []; this.chartDatasetOverride = []; //Collect x axis values this.chartLabels = this.series.map((seriesEntry) => { return seriesEntry.values.map((value) => { return value.x }); }).flat().distinct(); //Itterate through array of arrays in binding this.series.forEach((seriesEntry) => { this.chartSeries.push(seriesEntry.label); var seriesData = []; var bgColors = []; seriesEntry.values.forEach((value) => { seriesData.push(value.y); bgColors.push(value.barColor); }); this.chartData.push(seriesData); this.chartDatasetOverride.push({ backgroundColor: bgColors, borderColor: "#00000000" }); }); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: barChart failed to initialize: " + e); } }); } app.controller('ctrl_61f7df52926e9304e2bf8351', ctrl_61f7df52926e9304e2bf8351); app.directive('checkBox', function() { return { scope: { bindingName: "=", bindingParent: "=", onChange: "&", allowInteraction: "=?" }, controller: ctrl_61fc2c0336d8370c1661d424, template: ` `, bindToController: true};}); function ctrl_61fc2c0336d8370c1661d424($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: checkBox failed to initialize: " + e); } }); } app.controller('ctrl_61fc2c0336d8370c1661d424', ctrl_61fc2c0336d8370c1661d424); app.directive('printerSettingsEntry', function() { return { scope: { bindingName: "=?", bindingParent: "=?", printerBindingName: "=?", printerBindingParent: "=?", allowInteraction: "=?" }, controller: ctrl_620ba02ddb5db0052c779b0d, template: `
    {{settingName}}
    `, bindToController: true};}); function ctrl_620ba02ddb5db0052c779b0d($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] || {}; this.cupsDriverData = {}; this.rawBindings = {}; this.selections = {}; this.cupsSizingConstant = 0.283; this.paperSizes = []; this.formatLabels = function(_label) { var paperSize = $scope.directiveScope.paperSizes.find((ps) => { return ps.cups_tags.includes(_label); }); if (paperSize) { return { label: paperSize.name, icon: $scope.$root.models.paper_size.icon.link }; } else if (/[w]\d*[h]\d*/.test(_label)) { var comps = _label.split("w")[1].split("h"); var w = Math.round(parseFloat(comps[0]) / $scope.directiveScope.cupsSizingConstant) / 10; var h = Math.round(parseFloat(comps[1]) / $scope.directiveScope.cupsSizingConstant) / 10; return { label: w + "mm X " + h + "mm (WxH) [" + comps[0] + "x" + parseFloat(comps[1]) + "]" }; } else { return { label: _label }; } } this.buildSelections = function() { $scope.directiveScope.selections = {}; Object.keys($scope.directiveScope.cupsDriverData || {}).forEach((settingName) => { $scope.directiveScope.selections[settingName] = {}; Object.keys($scope.directiveScope.cupsDriverData[settingName]).forEach((settingSelection) => { var formatting = $scope.directiveScope.formatLabels(settingSelection); $scope.directiveScope.selections[settingName][settingSelection] = { label: formatting.label + ($scope.directiveScope.cupsDriverData[settingName][settingSelection] ? " (Default)" : ""), icon: formatting.icon, class: $scope.directiveScope.cupsDriverData[settingName][settingSelection] ? "secondary" : "primary" }; }); }); } retrieveRecords($scope, $http, "paper_size", {}, (response) => { $scope.directiveScope.paperSizes = response.records; $scope.directiveScope.buildSelections(); }); } $scope.$watch("directiveScope.printerBindingParent[directiveScope.printerBindingName]", () => { //Printer has changed, update the available selections if ($scope.directiveScope.printerBindingParent && $scope.directiveScope.printerBindingName && $scope.directiveScope.printerBindingParent[$scope.directiveScope.printerBindingName]) { retrieveRecord($scope, $http, "cmdb_printer", { query: { _id: $scope.directiveScope.printerBindingParent[$scope.directiveScope.printerBindingName] }}, (printer) => { $scope.directiveScope.cupsDriverData = printer.cups_driver_data; $scope.directiveScope.buildSelections(); }); } else { $scope.directiveScope.cupsDriverData = null; $scope.directiveScope.buildSelections(); } }); ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: printerSettingsEntry failed to initialize: " + e); } }); } app.controller('ctrl_620ba02ddb5db0052c779b0d', ctrl_620ba02ddb5db0052c779b0d); app.directive('multipleReferenceCheckboxSelection', function() { return { scope: { refModel: "=", refQualifier: "=?", bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) allowInteraction: "=?", selections: "=?" }, controller: ctrl_6213881852a51a0cc9e0e091, template: `
    {{selection[$root.models[directiveScope.refModel].display_field]}}
    `, bindToController: true};}); function ctrl_6213881852a51a0cc9e0e091($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.listModal = {}; $scope.directiveScope = this; this.selections = []; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.selectionsReady = false; this.refQualifier = this.refQualifier || {}; this.updateBinding = function() { if (!$scope.directiveScope.updatingSelections && $scope.directiveScope.selectionsReady) { $scope.directiveScope.updatingBinding = true; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.selections.filter((s) => { return s._checked; }).map((s) => { return s._id; }); $scope.directiveScope.updatingBinding = false; } } this.updateSelections = function() { if (!$scope.directiveScope.updatingBinding && $scope.directiveScope.selectionsReady) { $scope.directiveScope.updatingSelections = true; $scope.directiveScope.selections.forEach((s) => { s._checked = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].includes(s._id); }); $scope.directiveScope.updatingSelections = false; } } this.updateSelectionRecords = function(){ $scope.directiveScope.selectionsReady = false; retrieveRecords($scope, $http, $scope.directiveScope.refModel, { query: $scope.directiveScope.refQualifier }, (response) => { $scope.directiveScope.selections = response.records; $scope.directiveScope.selectionsReady = true; $scope.directiveScope.updateSelections(); }); } }; $scope.$watch("directiveScope.selections", () => { //Watch selections and update binding using [selections]._checked; if ($scope.directiveScope.selections && $scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { //Now update the binding $scope.directiveScope.updateBinding(); } }, true); $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { //Watch binding and update selection values if ($scope.directiveScope.selections && $scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { //Binding modified $scope.directiveScope.updateSelections(); } }, true); $scope.$watch("directiveScope.refQualifier", () => { $scope.directiveScope.updateSelectionRecords(); });; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: multipleReferenceCheckboxSelection failed to initialize: " + e); } }); } app.controller('ctrl_6213881852a51a0cc9e0e091', ctrl_6213881852a51a0cc9e0e091); app.directive('diagramEditor', function() { return { scope: { bindingName: "=?", bindingParent: "=?", imageBindingName: "=?", //Image file data will be written here template: "=?", allowInteraction: "=?" } , controller: ctrl_624de032795b0e18da834740, template: ``, bindToController: true};}); function ctrl_624de032795b0e18da834740($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.id = createUniqueTag(); $scope.directiveScope = this; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.template = `ddHBDoMgDADQr+GO4hLuzm2XnTzsTKQDErQGWXT7+mnAOeJ2Al5bSgphZTudnej1FSVYklM5EXYkeZ5xTudlkWeUghZBlDMy2ga1eUHEWKgeRsKQJHpE602fYoNdB41PTDiHY5p2R5t27YWCHdSNsHu9Gel1UH6gm1/AKL12zmiMtGJNjjBoIXH8IlYRVjpEH3btVIJdprfOJdSd/kQ/D3PQ+R8F82a7ez4kX8SqNw==`; this.bindingUpdated = function() { if (!$scope.directiveScope.updating && $scope.directiveScope.ready) { if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { $scope.directiveScope.updating = true; $scope.directiveScope.loadXml($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); } else { $scope.directiveScope.loadXml($scope.directiveScope.template); } } } $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", $scope.directiveScope.bindingUpdated); this.editorUpdated = function(_xml) { if (!$scope.directiveScope.updating && $scope.directiveScope.bindingParent && $scope.directiveScope.bindingName) { $scope.directiveScope.updating = true; $scope.directiveScope.renderImage(); $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _xml; safeApply($scope); $scope.directiveScope.updating = false; } } this.renderImage = function() { $scope.directiveScope.editor.contentWindow.postMessage(JSON.stringify({ action: "export", format: "png" }), '*'); } this.loadXml = function(_xml) { $scope.directiveScope.editor.contentWindow.postMessage(JSON.stringify({ action: 'load', autosave: true, xml: _xml }), '*'); } this.onMessageFromEditor = function(_data) { if (_data.event == "init") { $scope.directiveScope.ready = true; $scope.directiveScope.bindingUpdated(); } else if (_data.event == "autosave") { $scope.directiveScope.editorUpdated(_data.xml); } else if (_data.event == "load") { $scope.directiveScope.updating = false; } else if (_data.event == "export" && $scope.directiveScope.bindingParent && $scope.directiveScope.imageBindingName) { $scope.directiveScope.bindingParent[$scope.directiveScope.imageBindingName] = { name: "diagram", extension: "png", data: _data.data.split("data:image/png;base64,")[1], size: _data.data.length } } } waitForElement(this.id, (iframe) => { $scope.directiveScope.editor = iframe; window.addEventListener('message', function(_message) { if (_message && _message.origin == "https://embed.diagrams.net") { var o; try { o = JSON.parse(_message.data) } catch (e) {} if (!o) { o = {}; o[_message.data] = true; } $scope.directiveScope.onMessageFromEditor(o); } }); }); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: diagramEditor failed to initialize: " + e); } }); } app.controller('ctrl_624de032795b0e18da834740', ctrl_624de032795b0e18da834740); app.directive('calendar', function() { return { scope: { bindingParent: "=?", bindingName: "=?", month: "=?", //Date object showStartTimes: "=?", showToday: "=?", customDayDisplay: "=?", customDayHtml: "=?", customEntryDisplay: "=?", customEntryHtml: "=?", customHeaderDisplay: "=?", customHeaderHtml: "=?", onEntryDrop: "=?", firstDate: "=?", //For reference only lastDate: "=?" //For reference only }, transclude: false, controller: ctrl_62617cfe967a3e37fc0e30c8, template: `

    {{directiveScope.month | date: 'MMMM'}} {{directiveScope.month | date: 'y'}}

    Sunday
    Monday
    Tuesday
    Wednesday
    Thursday
    Friday
    Saturday
    {{day.date | date: (day.inMonth ? '' : 'MMM ') + 'd'}} Today
    {{entry.start | date:'shortTime'}} - {{entry.title}}
    `, bindToController: true};}); function ctrl_62617cfe967a3e37fc0e30c8($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.month = this.month || (new Date()); this.showStartTimes = this.showStartTimes || true; this.showToday = this.showToday || true; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] || []; this.display = []; this.onDrop = function(_dropScope, _dragScope) { //Low level if ($scope.directiveScope.onEntryDrop) { $scope.directiveScope.onEntryDrop(_dropScope.dropData, _dragScope.dragData); } } $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { $scope.directiveScope.updateDisplay(); }, true); this.updateDisplay = function() { var display = [[]]; var today = new Date(); //Get first day of month var firstDayOfMonth = new Date($scope.directiveScope.month.getFullYear(), $scope.directiveScope.month.getMonth()); //Get first day of display calendar var paddingDays = firstDayOfMonth.getDay(); $scope.directiveScope.firstDate = new Date(firstDayOfMonth); $scope.directiveScope.firstDate.setDate($scope.directiveScope.firstDate.getDate() - (paddingDays + 1)); //Build display for (var date = new Date($scope.directiveScope.firstDate); date.setDate(date.getDate() + 1);) { display[display.length - 1].push({ date: new Date(date), inMonth: date.getMonth() == firstDayOfMonth.getMonth(), isToday: date.getFullYear() == today.getFullYear() && date.getMonth() == today.getMonth() && date.getDate() == today.getDate(), entriesStarting: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].filter((entry) => { return entry.start.sameDateAs(date); }) }); $scope.directiveScope.lastDate = date; //Done? if (date.getMonth() > firstDayOfMonth.getMonth() && date.getDay() == 6) { break; } //Add next week to display if (date.getDay() == 6) { display.push([]); } } console.log(display); $scope.directiveScope.display = display; } this.updateDisplay(); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: calendar failed to initialize: " + e); } }); } app.controller('ctrl_62617cfe967a3e37fc0e30c8', ctrl_62617cfe967a3e37fc0e30c8); app.directive('drop', function() { return { scope: { onDrop: "=?", allowDropMethod: "=?", dropData: "=?", hideWhenInactive: "=?" }, transclude: true, controller: ctrl_6279c43f0f600a03860259d4, template: `
    `, bindToController: true};}); function ctrl_6279c43f0f600a03860259d4($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.__ISDROP__ = true; this.hideWhenInactive = this.hideWhenInactive || false; this.displayClass = ""; this.readyToDrop = false; this.isDragging = false; this.forceUpdate = function() { $scope.directiveScope.readyToDrop = $scope.directiveScope.readyToDrop && $scope.$root.dragScope; safeApply($scope); } $rootScope.$on('dragStart', () => { $scope.directiveScope.isDragging = true; $scope.directiveScope.forceUpdate(); }); $rootScope.$on('dragEnd', () => { $scope.directiveScope.isDragging = false; $scope.directiveScope.forceUpdate(); }); } findDeepestDropScope = function(_startScope) { if (_startScope.directiveScope && _startScope.directiveScope.__ISDROP__) { return _startScope; } else if(_startScope.$parent) { return findDeepestDropScope(_startScope.$parent); } else { return null; } } onDragLeave = function(_event) { var dropScope = findDeepestDropScope(getScopeFromHTMLElement(_event.toElement)); dropScope.directiveScope.readyToDrop = false; dropScope.directiveScope.forceUpdate(); } onDragover = function(_event) { var dropScope = findDeepestDropScope(getScopeFromHTMLElement(_event.toElement)); if (dropScope && dropScope.directiveScope && dropScope.$root.dragScope && dropScope.directiveScope.allowDropMethod && dropScope.directiveScope.allowDropMethod(dropScope.directiveScope.dropData, dropScope.$root.dragScope.dragData)) { _event.preventDefault(); dropScope.directiveScope.readyToDrop = true; } else { dropScope.directiveScope.readyToDrop = false; } dropScope.directiveScope.forceUpdate(); } onDrop = function(_event) { var dropScope = findDeepestDropScope(getScopeFromHTMLElement(_event.toElement)); if (dropScope && dropScope.directiveScope && dropScope.$root.dragScope && dropScope.directiveScope.onDrop) { dropScope.directiveScope.onDrop(dropScope.directiveScope.dropData, dropScope.$root.dragScope.dragData); } dropScope.directiveScope.readyToDrop = false; dropScope.directiveScope.forceUpdate(); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: drop failed to initialize: " + e); } }); } app.controller('ctrl_6279c43f0f600a03860259d4', ctrl_6279c43f0f600a03860259d4); app.directive('drag', function() { return { scope: { allowDrag: "=?", dragData: "=?" }, transclude: true, controller: ctrl_6279c5300f600a03860259d5, template: `
    `, bindToController: true};}); function ctrl_6279c5300f600a03860259d5($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.allowDrag = this.allowDrag || true; } onDragStart = function(_event) { var scope = getScopeFromHTMLElement(_event.target); scope.$root.dragScope = scope.directiveScope; $rootScope.$emit('dragStart'); } onDragEnd = function(_event) { var scope = getScopeFromHTMLElement(_event.target); scope.$root.dragScope = null; $rootScope.$emit('dragEnd'); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: drag failed to initialize: " + e); } }); } app.controller('ctrl_6279c5300f600a03860259d5', ctrl_6279c5300f600a03860259d5); app.directive('tab', function() { return { scope: { tabId: "=" }, transclude: true, controller: ctrl_627a5289cb98444249f56631, template: `
    `, bindToController: true};}); function ctrl_627a5289cb98444249f56631($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; $scope.containerScope = $scope.$parent.$parent.directiveScope; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: tab failed to initialize: " + e); } }); } app.controller('ctrl_627a5289cb98444249f56631', ctrl_627a5289cb98444249f56631); app.directive('objectRelationshipEditorEntry', function() { return { scope: { entry: "=?", entryHtml: "
    `, bindToController: true};}); function ctrl_627dec5cb21f83037b0279f8($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.depth = this.depth || 0; $scope.directiveScope = this; this.selectedEntry = null; this.updateSelectedEntry = function(_entry) { $scope.directiveScope.selectedEntry = _entry; if ($scope.directiveScope.onSelectedEntryChange) { $scope.directiveScope.onSelectedEntryChange(_entry); } } this.allowDropMethod = function(_destinationEntry, _sourceEntry) { //Destination must not be a child of the source if (_destinationEntry.data._id == _sourceEntry.data._id) { return false; } return true; } /* this.allTasks = this.allTasks || []; this.showDropZones = false; this.dropZones = []; this.allowDropMethod = function(_dropData, _dragData) { //Check for cyclic relation return _dropData._id != _dragData._id; }; this.childTasks = $scope.directiveScope.allTasks.filter((t) => { return t.parent_development_task == $scope.directiveScope.task._id; }); this.onDrop = function(_dropData, _dragData) { if (_dropData._type == "development_task") { if ($scope.directiveScope.onMoveToTask) { $scope.directiveScope.onMoveToTask(_dropData, _dragData); } } else if (_dropData._type == "change") { //Change parent change if ($scope.directiveScope.onMoveToChange) { $scope.directiveScope.onMoveToChange(_dropData, _dragData); } } } */ }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: objectRelationshipEditorEntry failed to initialize: " + e); } }); } app.controller('ctrl_627dec5cb21f83037b0279f8', ctrl_627dec5cb21f83037b0279f8); app.directive('objectRelationshipEditor', function() { return { scope: { entries: "=?", entryHtml: "
    `, bindToController: true};}); function ctrl_627eb2b02d44080b37136918($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.selectedEntry = null; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: objectRelationshipEditor failed to initialize: " + e); } }); } app.controller('ctrl_627eb2b02d44080b37136918', ctrl_627eb2b02d44080b37136918); app.directive('dynamicArrayEditor', function() { return { scope: { bindingParent: "=?", bindingName: "=?", newEntryHtml: "=?", existingEntryHtml: "=?", newEntryTemplate: "=?", allowNewEntry: "=?", allowEntryRemoval: "=?" }, transclude: false, controller: ctrl_6281a43b1116d517d49bb2fd, template: `
    `, bindToController: true};}); function ctrl_6281a43b1116d517d49bb2fd($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.allowNewEntry = this.allowNewEntry == null ? true : this.allowNewEntry; this.allowEntryRemoval = this.allowEntryRemoval == null ? true : this.allowEntryRemoval; this.bindingParent[this.bindingName] = this.bindingParent[this.bindingName] || []; this.newEntry = cloneObject(this.newEntryTemplate); this.commitNewEntry = function() { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].push(cloneObject($scope.directiveScope.newEntry)); Object.assign($scope.directiveScope.newEntry, cloneObject($scope.directiveScope.newEntryTemplate)); } } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: dynamicArrayEditor failed to initialize: " + e); } }); } app.controller('ctrl_6281a43b1116d517d49bb2fd', ctrl_6281a43b1116d517d49bb2fd); app.directive('multipleCheckboxSelection', function() { return { scope: { bindingName: "=", //Name of parent property to bind to bindingParent: "=", //Parent object to bind to (to preserve link in case binding is null) allowInteraction: "=?", selections: "=?", allowNull: "=?" }, controller: ctrl_6281aa031116d517d49bb2ff, template: `
    `, bindToController: true};}); function ctrl_6281aa031116d517d49bb2ff($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.listModal = {}; $scope.directiveScope = this; this.displaySelections = null; this.allowNull = this.allowNull == null ? true : this.allowNull; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.updateBinding = function() { if (!$scope.directiveScope.updatingDisplaySelections) { $scope.directiveScope.updatingBinding = true; $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = Object.keys($scope.directiveScope.displaySelections).filter((s) => { return $scope.directiveScope.displaySelections[s]._checked; }).map((v) => { return v == "null" ? null : v; }); $scope.directiveScope.updatingBinding = false; } } this.updateDisplaySelections = function() { if (!$scope.directiveScope.updatingBinding) { $scope.directiveScope.updatingDisplaySelections = true; $scope.directiveScope.displaySelections = $scope.directiveScope.displaySelections || {}; if ($scope.directiveScope.allowNull) { $scope.directiveScope.displaySelections.null = $scope.directiveScope.displaySelections.null || {}; Object.assign($scope.directiveScope.displaySelections.null, { label: "(None)", class: "danger", //icon: "/media/crossout_icon.png" }); } //Update selection values with _checked Object.keys($scope.directiveScope.displaySelections).forEach((s) => { $scope.directiveScope.displaySelections[s]._checked = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].includes(s == "null" ? null : s); }); $scope.directiveScope.updatingDisplaySelections = false; } } this.canSelectAll = function() { return ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] || []).length != Object.keys(($scope.directiveScope.displaySelections || {})).length; } this.selectAll = function() { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = Object.keys($scope.directiveScope.displaySelections); } this.canClear = function() { return ($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] || []).length > 0; } this.clear = function() { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = []; } }; $scope.$watch("directiveScope.selections", (_old, _new) => { // if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { $scope.directiveScope.updatingDisplaySelections = true; $scope.directiveScope.displaySelections = $scope.directiveScope.displaySelections || {}; //Break binding (avoid metadata writeback) var oldKeys = Object.keys($scope.directiveScope.displaySelections); var newKeys = Object.keys($scope.directiveScope.selections || {}); newKeys.forEach((k) => { $scope.directiveScope.displaySelections[k] = $scope.directiveScope.displaySelections[k] || {}; Object.assign($scope.directiveScope.displaySelections[k], $scope.directiveScope.selections[k]); }); //Remove keys that no longer exist in selections oldKeys.filter((k) => { return !newKeys.includes(k); }).forEach((k) => { delete $scope.directiveScope.displaySelections[k]; }); $scope.directiveScope.updatingDisplaySelections = false; $scope.directiveScope.updateDisplaySelections(); // } }); $scope.$watch("directiveScope.displaySelections", (_old, _new) => { //Watch selections and update binding using [selections]._checked; if ($scope.directiveScope.displaySelections && $scope.directiveScope.bindingParent && $scope.directiveScope.bindingName && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]) { //Now update the binding $scope.directiveScope.updateBinding(); } }, true); $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { //Watch binding and update selection values if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] || []; //Binding modified $scope.directiveScope.updateDisplaySelections(); } }, true); ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: multipleCheckboxSelection failed to initialize: " + e); } }); } app.controller('ctrl_6281aa031116d517d49bb2ff', ctrl_6281aa031116d517d49bb2ff); app.directive('treeView', function() { return { scope: { nodes: "=?", selectedNodes: "=?", selectionMode: "=?", selectNode: "=?", onSelection: "=?" }, transclude: false, controller: ctrl_6286e239a7dd8803adf0247d, template: ``, bindToController: true};}); function ctrl_6286e239a7dd8803adf0247d($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.searchBinding = ""; this.searchFilter = ""; this.selectedNodes = this.selectedNodes || {}; this.selectionMode = this.selectionMode || "single"; this.searchSeleleted = function(_selection) { } this.selectNode = this.selectNode || (function(_id, _node) { $scope.directiveScope.setSelections($scope.directiveScope.nodes, this.selectionMode == "single" ? [_node.selected && _node.selectable ? null : _id] : ( this.selectionMode == "multiple" ? [...Object.keys($scope.directiveScope.selectedNodes), _id].filter((sid) => { return _node.selectable && (sid != _id || !_node.selected); }) : [] ) ); $scope.directiveScope.selectedNodes = $scope.directiveScope.getSelectedNodes($scope.directiveScope.nodes); if ($scope.directiveScope.onSelection) { $scope.directiveScope.onSelection($scope.directiveScope.selectedNodes); } }); this.setSelections = function(_nodes, _selectedIds) { Object.keys(_nodes || {}).forEach((id) => { var node = _nodes[id]; node.selected = _selectedIds.includes(id); $scope.directiveScope.setSelections(node.nodes, _selectedIds) }); safeApply($scope); } this.getSelectedNodes = function(_nodes) { var selected = {}; Object.keys(_nodes || {}).forEach((id) => { var node = _nodes[id]; if (node.selected) { selected[id] = node; } Object.assign(selected, $scope.directiveScope.getSelectedNodes(node.nodes)); }); return selected; } } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: treeView failed to initialize: " + e); } }); } app.controller('ctrl_6286e239a7dd8803adf0247d', ctrl_6286e239a7dd8803adf0247d); app.directive('treeNode', function() { return { scope: { data: "=?", nodeId: "=?", selected: "=?", label: "=?", labelClass: "=?", icon: "=?", subIcon: "=?", expanded: "=?", allowExpand: "=?", showBorder: "=?", nodes: "=?", selected: "=?", selectionMode: "=?", selectNode: "=?", //Method in the tree-view selectable: "=?", contextSelections: "=?", population: "=?", allowDropMethod: "=?", populate: "=?", allowCheck: "=?", checked: "=?" }, transclude: false, controller: ctrl_62870193cafe730fb190e008, template: `
    `, bindToController: true};}); function ctrl_62870193cafe730fb190e008($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.selectable = this.selectable == null ? true : this.selectable; this.allowExpand = this.allowExpand == null ? true : this.allowExpand; this.populate = function() { if ($scope.directiveScope.population) { $scope.directiveScope.population($scope.directiveScope); } } this.onArrowClick = function() { if (!$scope.directiveScope.expanded && Object.keys($scope.directiveScope.nodes || {}).length == 0) { $scope.directiveScope.populate(); } $scope.directiveScope.expanded = !$scope.directiveScope.expanded; } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: treeNode failed to initialize: " + e); } }); } app.controller('ctrl_62870193cafe730fb190e008', ctrl_62870193cafe730fb190e008); app.directive('nodeNavigator', function() { return { scope: { nodes: "=?" }, transclude: false, controller: ctrl_6287a350964fed13fa578da6, template: `
    `, bindToController: true};}); function ctrl_6287a350964fed13fa578da6($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.getSelectedContentHtml = function() { var selectedId = Object.keys($scope.directiveScope.selectedNodes)[0]; return $scope.directiveScope.selectedNodes && Object.keys($scope.directiveScope.selectedNodes).length == 1 ? $scope.directiveScope.selectedNodes[Object.keys($scope.directiveScope.selectedNodes)[0]].data.contentHtml : null; } /* this.selectedId = null; this.selectedModel = null; this.onSelection = function(_selectedNodes) { var ids = Object.keys(_selectedNodes || {}); $scope.directiveScope.updatingFormBindings = true; if (ids.length == 1) { $scope.directiveScope.selectedModel = _selectedNodes[ids[0]].data._type; $timeout(() => { $scope.directiveScope.selectedId = ids[0]; $scope.directiveScope.updatingFormBindings = false; }, 100); } else { $scope.directiveScope.selectedId = null; $scope.directiveScope.selectedModel = null; } } */ }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: nodeNavigator failed to initialize: " + e); } }); } app.controller('ctrl_6287a350964fed13fa578da6', ctrl_6287a350964fed13fa578da6); app.directive('liveTimeDifference', function() { return { scope: { value: "=?" }, controller: ctrl_628b9adc6654132d4f7b79b0, template: `{{directiveScope.days}} Days {{("00" + directiveScope.hours).slice(-2)}} Hr {{("00" + directiveScope.minutes).slice(-2)}} Min {{("00" + directiveScope.seconds).slice(-2)}} Sec `, bindToController: true};}); function ctrl_628b9adc6654132d4f7b79b0($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; setInterval(() => { $scope.directiveScope.diff = ( $scope.directiveScope.value - new Date())/ 1000; $scope.directiveScope.days = 0; $scope.directiveScope.hours = 0; $scope.directiveScope.minutes = 0; $scope.directiveScope.seconds = 0; while($scope.directiveScope.diff > 86400) { $scope.directiveScope.days++; $scope.directiveScope.diff-=86400; } while($scope.directiveScope.diff > 3600) { $scope.directiveScope.hours++; $scope.directiveScope.diff-=3600; } while($scope.directiveScope.diff > 60) { $scope.directiveScope.minutes++; $scope.directiveScope.diff-=60; } while($scope.directiveScope.diff > 1) { $scope.directiveScope.seconds++; $scope.directiveScope.diff-=1; } $rootScope.$digest(); //Force update }, 1000); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: liveTimeDifference failed to initialize: " + e); } }); } app.controller('ctrl_628b9adc6654132d4f7b79b0', ctrl_628b9adc6654132d4f7b79b0); app.directive('downloadData', function() { return { scope: { bindingParent: "=?", bindingName: "=?", label: "=?", icon: "=?", fileName: "=?", fileExtension: "=?" }, controller: ctrl_629faee4f6cd87145fb1eb5f, template: `
    `, bindToController: true};}); function ctrl_629faee4f6cd87145fb1eb5f($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.fileName = this.fileName || "download"; this.fileExtension = this.fileExtension || "txt"; this.label = this.label || "Download"; this.linkHtml = ""; $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { $scope.directiveScope.linkHtml = ''; }); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: downloadData failed to initialize: " + e); } }); } app.controller('ctrl_629faee4f6cd87145fb1eb5f', ctrl_629faee4f6cd87145fb1eb5f); app.directive('diagramDisplay', function() { return { scope: { bindingName: "=?", bindingParent: "=?" } , controller: ctrl_62ba93cb09cbf53cfe7b9d73, template: ``, bindToController: true};}); function ctrl_62ba93cb09cbf53cfe7b9d73($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: diagramDisplay failed to initialize: " + e); } }); } app.controller('ctrl_62ba93cb09cbf53cfe7b9d73', ctrl_62ba93cb09cbf53cfe7b9d73); app.directive('dynamicSearchPanel', function() { return { scope: { definition: "=?", term: "=?", limit: "=?" }, controller: ctrl_62c7acfaa09587149baddff5, template: `
    Search Term

    `, bindToController: true};}); function ctrl_62c7acfaa09587149baddff5($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.limit = this.limit || 25; this.performSearch = function() { $scope.directiveScope.query = { definition: $scope.directiveScope.definition, term: $scope.directiveScope.term }; } }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: dynamicSearchPanel failed to initialize: " + e); } }); } app.controller('ctrl_62c7acfaa09587149baddff5', ctrl_62c7acfaa09587149baddff5); app.directive('modelRelationMap', function() { return { scope: { modelName: "=?", displayDependants: "=?", displayDependencies: "=?" }, controller: ctrl_62cc34678ab13a318d4b48d7, template: `
    Models Referencing this Model
    {{$root.models[dependant.model].singular_name}} {{dependant.field}}
    {{$root.models[directiveScope.modelName].singular_name}}
    Models Referenced by this Model
    {{$root.models[dependencies.model].singular_name}} {{dependencies.field}}
    `, bindToController: true};}); function ctrl_62cc34678ab13a318d4b48d7($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.displayDependants = true; this.displayDependencies = true; this.dependencies = []; this.dependants = []; this.build = function() { this.dependencies = []; this.dependants = []; if (!$scope.directiveScope.modelName) { return; } //Find dependencies Object.keys($scope.$root.models[$scope.directiveScope.modelName].fields).forEach((fieldName) => { var field = $scope.$root.models[$scope.directiveScope.modelName].fields[fieldName]; if (fieldName != "_id" && field.type == "reference" && field.reference_model) { $scope.directiveScope.dependencies.push({ field: fieldName, model: field.ref }); } }); //Find dependants Object.keys($scope.$root.models).forEach((modelName) => { var model = $scope.$root.models[modelName]; Object.keys(model.fields).forEach((fieldName) => { var field = model.fields[fieldName]; if (fieldName != "_id" && field.type == "reference" && field.ref == $scope.directiveScope.modelName) { $scope.directiveScope.dependants.push({ field: fieldName, model: modelName }); } }); }); }; this.build(); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modelRelationMap failed to initialize: " + e); } }); } app.controller('ctrl_62cc34678ab13a318d4b48d7', ctrl_62cc34678ab13a318d4b48d7); app.directive('physicalNetworkMap', function() { return { scope: { nicQuery: "=?" }, controller: ctrl_633280ba49fdea059c8e4b48, template: ` `, bindToController: true};}); function ctrl_633280ba49fdea059c8e4b48($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.relationModal = {}; this.relations = []; this.nics = []; this.nicQuery = this.nicQuery || {}; this.options = { height: "100%", edges:{ smooth: { forceDirection: "none", roundness: 0 } }, layout: { improvedLayout: true }, physics: { enabled: true, barnesHut: { theta: 0.1, gravitationalConstant: -500000, centralGravity: 20, springLength: 150, springConstant: 0.9,// 0.04, damping: 0.5, avoidOverlap: 1 }, maxVelocity: 10, minVelocity: 3, solver: 'barnesHut', timestep: 1 } }; this.onRelationSelection = function(_data) { if (_data.nodes.length == 0) { var relation = $scope.directiveScope.relations.find((r) => { return r.id == _data.edges[0]; }); $scope.directiveScope.relationModal.relation = relation; safeApply($scope); $scope.directiveScope.relationModal.show(); } }; this.buildRelationTitleHeader = function(_to, _from) { return `
    ` + _from.name + `
    ->
    ` + _to.name + `
    ` }; this.buildRelationTitle = function(_to, _from) { return `
    ` + _from.name + `` + (_from.internal_name ? (` (` + _from.internal_name + `)`) : ``) + `
    ->
    ` + _to.name + `` + (_to.internal_name ? (` (` + _to.internal_name + `)`) : ``) + `
    `; }; } retrieveRecords($scope, $http, "cmdb_nic", { query: { connected_to: { $ne: null }, parent: { $ne: null } }, populate: ["parent", { path: "connected_to", populate: "parent" }] }, (response) => { var nodes = []; $scope.directiveScope.nics = response.records; $scope.directiveScope.nics.forEach((nic) => { if (!nodes.some((n) => { return n.id == nic.parent._id; })) { //Add CI node nodes.push({ id: nic.parent._id, label: nic.parent.name, font: { // color: "#eeeeee" }, shadow: { enabled: true }, image: nic.parent.icon ? nic.parent.icon.link : $scope.$root.models[(nic.parent._type || "cmdb_ci")].icon.link }); } //Add relations for NICs connected_to (nic.connected_to || []).forEach((connectedNic) => { if (!$scope.directiveScope.relations.some((r) => { return (r.to == nic.parent._id && r.from == connectedNic.parent._id); })) { //Check for existing relation between these CIs (skip existing reverse connections) var existing = $scope.directiveScope.relations.find((r) => { return r.from == nic.parent._id && r.to == connectedNic.parent._id; }); if (existing) { existing.width++; existing.label = existing.width.toString(); existing.title += $scope.directiveScope.buildRelationTitle(connectedNic, nic); } else { //Add relation between this NICs parent and the connectedNic's parent $scope.directiveScope.relations.push({ from: nic.parent._id, to: connectedNic.parent._id, width: 1, label: nic.name + " -> " + connectedNic.name, title: $scope.directiveScope.buildRelationTitleHeader(connectedNic.parent, nic.parent) + `
    ` + $scope.directiveScope.buildRelationTitle(connectedNic, nic), arrows: { to: { enabled: ["hybrid", "downlink"].includes(connectedNic.role) }, from: { enabled: ["hybrid", "downlink"].includes(nic.role) }, middle: { enabled: true, src: (nic.adapter_type ? $scope.$root.models.cmdb_nic.fields.adapter_type.selections[nic.adapter_type].icon : $scope.$root.models.cmdb_nic.icon.link), type: "image" } } }); } } }); }); $scope.directiveScope.nodes = nodes.filter((n) => { return $scope.directiveScope.relations.some((r) => { return r.to == n.id || r.from == n.id; }); }); }); ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: physicalNetworkMap failed to initialize: " + e); } }); } app.controller('ctrl_633280ba49fdea059c8e4b48', ctrl_633280ba49fdea059c8e4b48); app.directive('webLinkSelectionModal', function() { return { scope: { bindingParent: "=?", bindingName: "=?", record: "=?", modelName: "=?", show: "=?" }, controller: ctrl_6334a6ea2c43372a57deea74, template: `

    `, bindToController: true};}); function ctrl_6334a6ea2c43372a57deea74($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.show = function() { $scope.directiveScope.linkSelectionModal.show(); } this.getCurrentRecordFiles = function() { var files = []; var modelDef = $scope.$root.models[$scope.directiveScope.modelName]; Object.keys(modelDef.fields).forEach((f) => { if (modelDef.fields[f].type == "file") { if (modelDef.fields[f].array) { ($scope.directiveScope.record[f] || []).forEach((file) => { var toPush = cloneObject(file); toPush.source = f; files.push(toPush); }); } else if ($scope.directiveScope.record[f]) { var toPush = cloneObject($scope.directiveScope.record[f]); toPush.source = f; files.push(toPush); } } }); return files; }; this.linkSelectionModal = { currentRecordFiles: $scope.directiveScope.getCurrentRecordFiles(), set linkBinding(_value) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = (typeof(_value) == "object" ? (_value.path) : _value); }, tabs: { url: { label: "URL" }, currentRecord: { label: "From Current Record" }, webResource: { label: "Web Resource", icon: $scope.$root.models.web_resource.icon.link } }, currentTab: "url" }; } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: webLinkSelectionModal failed to initialize: " + e); } }); } app.controller('ctrl_6334a6ea2c43372a57deea74', ctrl_6334a6ea2c43372a57deea74); app.directive('buttonGroupSelection', function() { return { scope: { bindingParent: "=", bindingName: "=", allowInteraction: "=?", values: "=", onChange: "=?", placeholder: "=?", allowNull: "=?", size: "=?", horizontal: "=?" }, controller: ctrl_634e1f0ca88c284dac1c4d0b, template: ``, bindToController: true};}); function ctrl_634e1f0ca88c284dac1c4d0b($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = createUniqueTag(); this.size = this.size == null ? "sm" : this.size; this.getBorderRadius = function(_index) { var selectionCount = Object.keys($scope.directiveScope.values).length; if (_index == 0) { if (selectionCount > 1) { return "border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important"; } else { return ""; } } else if (_index == selectionCount - 1) { if (selectionCount > 0) { return "border-top-left-radius: 0px !important; border-bottom-left-radius: 0px !important"; } else { return ""; } } else { return "border-radius: 0 !important"; } } this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.select = function(_key) { $scope.directiveScope.selecting = true; if (_key == null || $scope.directiveScope.values[_key].selectable != false) { if ($scope.directiveScope.bindingParent && $scope.directiveScope.bindingName) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = _key; } if ($scope.directiveScope.onChange) { $scope.directiveScope.onChange(_key, $scope.directiveScope); } } } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: buttonGroupSelection failed to initialize: " + e); } }); } app.controller('ctrl_634e1f0ca88c284dac1c4d0b', ctrl_634e1f0ca88c284dac1c4d0b); app.directive('instanceDeploymentConfiguration', function() { return { scope: { remoteInstance: "=?" } , controller: ctrl_635699c17e7fde0436dd3c69, template: `
    Segment Description Installed
    Remotely
    Installed
    Locally
    Pull
    Update to Apply
    Push
    Update to Apply
    Active for {{configData.name}}
    {{segmentData.name}}
    Configuration


    Instances will be compared assuming the {{directiveScope.push ? 'LOCAL' : 'REMOTE'}} instance is the desired state.








    Details
    Segment Model Record Field Local Remote
    {{directiveScope.delta.segmentDeltas[matrixEntry.segment].modelDeltas[matrixEntry.model].recordDeltas[matrixEntry.record].fieldDeltas[matrixEntry.field].local.value}}
    {{directiveScope.delta.segmentDeltas[matrixEntry.segment].modelDeltas[matrixEntry.model].recordDeltas[matrixEntry.record].fieldDeltas[matrixEntry.field].remote.value}}
    `, bindToController: true};}); function ctrl_635699c17e7fde0436dd3c69($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.id = createUniqueTag(); $scope.directiveScope = this; this.parseDateDifference = parseDateDifference; this.actions = { excepted: { label: "Excepted", icon: "/media/restrict_icon.png", class: "secondary" }, insert: { label: "Insert", icon: "/media/add_icon.png", class: "success" }, delete: { label: "Delete", icon: "/media/crossout_icon.png", class: "danger" }, update: { label: "Update", icon: "/media/external_icon.png", class: "primary" }, }; this.toObjectBy = function(_array, _field) { var output = {}; _array.forEach((i) => { output[i[_field]] = i; }); return output; }; this.updateConfigs = function() { retrieveRecords($scope, $http, "config", {}, (response) => { $scope.directiveScope.configs = $scope.directiveScope.toObjectBy(response.records, "_id"); }); } this.updateConfigs(); this.updateSegments = function() { $scope.directiveScope.remoteSegments = $scope.directiveScope.toObjectBy($scope.directiveScope.remoteInstance.remote_segments, "_id"); $scope.directiveScope.allSegments = {}; Object.assign($scope.directiveScope.allSegments, $scope.directiveScope.remoteSegments); retrieveRecords($scope, $http, "segment", {}, (segmentResponse) => { $scope.directiveScope.localSegments = $scope.directiveScope.toObjectBy(segmentResponse.records, "_id"); Object.assign($scope.directiveScope.allSegments, $scope.directiveScope.localSegments); }); } this.updateSegments(); this.toggleDeployDefault = function(_type, _id) { if ($scope.directiveScope.remoteInstance[_type + "_segments"].includes(_id)) { $scope.directiveScope.remoteInstance[_type + "_segments"] = $scope.directiveScope.remoteInstance[_type + "_segments"].filter((s) => { return s != _id; }); } else { $scope.directiveScope.remoteInstance[_type + "_segments"] = [...$scope.directiveScope.remoteInstance[_type + "_segments"], _id];; } safeApply($scope); }; this.toggleConfig = function(_configId, _segmentId) { var state = $scope.directiveScope.configs[_configId].active_segments.includes(_segmentId); if (confirm("Are you sure you want to " + (state ? 'DISABLE' : 'ENABLE') + " this segment on the LOCAL instance?")) { if (state) { //Disable updateRecord($scope, $http, "config", _configId, { $pull: { active_segments: _segmentId }}, () => { $scope.directiveScope.updateConfigs(); }); } else { //Enable updateRecord($scope, $http, "config", _configId, { $push: { active_segments: _segmentId }}, () => { $scope.directiveScope.updateConfigs(); }); } safeApply($scope); } }; this.toggleLocalInstall = function(_segmentId) { var state = !!$scope.directiveScope.localSegments[_segmentId]; if (confirm("Are you sure you want to " + (state ? 'REMOVE this segment from' : 'INSTALL this segment on') + " the LOCAL instance?")) { if (state) { //Remove locally deleteRecord($scope, $http, "segment", _segmentId, () => { $scope.directiveScope.updateSegments(); }); } else { //Install locally insertRecord($scope, $http, "segment", $scope.directiveScope.remoteSegments[_segmentId], () => { $scope.directiveScope.updateSegments(); }); } safeApply($scope); } } this.segments = $scope.directiveScope.remoteInstance[($scope.directiveScope.push ? 'push' : 'pull') + '_segments']; this.delta = {}; this.nodes = {}; this.checkDefault = true; this.push = true; this.selectedNodes = null; this.state = null; this.currentTab = "tool"; this.tabs = { matrix: { label: "Matrix" }, tool: { label: "Deployment Tool" } }; this.actionMap = { update: { label: "Update", class: "warning" }, insert: { label: "Insert", class: "success" }, delete: { label: "Delete", class: "danger" }, excepted: { label: "Excepted", class: "secondary" }, "null": { label: "Synchronized", class: "primary" } }; this.normalizeEncoding = function(_string) { try { var d = atob(_string); return d.length > 0 ? d : _string; } catch (e) { return _string; } } this.selectAll = function(_state, _rootNodes) { _state = _state == null ? true : _state; _rootNodes = _rootNodes == null ? $scope.directiveScope.nodes : _rootNodes; Object.values(_rootNodes).forEach((node) => { node.checked = _state; if (node.nodes) { $scope.directiveScope.selectAll(_state, node.nodes); } }); safeApply($scope); } $scope.$watch("directiveScope.push", () => { $scope.directiveScope.segments = $scope.directiveScope.remoteInstance[($scope.directiveScope.push ? 'push' : 'pull') + '_segments']; }); this.buildCommit = function() { var segmentDeltas = {}; Object.values($scope.directiveScope.nodes).forEach((segmentNode) => { if (segmentNode.checked) { segmentDeltas[segmentNode.segmentId] = { action: segmentNode.data.action, models: {} }; if (segmentNode.nodes.modelDeltas) { Object.values(segmentNode.nodes.modelDeltas.nodes).forEach((modelNode) => { if (modelNode.checked) { segmentDeltas[segmentNode.segmentId].models[modelNode.modelName] = { action: modelNode.data.action, records: {} }; if (modelNode.nodes.recordDeltas) { Object.values(modelNode.nodes.recordDeltas.nodes).forEach((recordNode) => { if (recordNode.checked) { segmentDeltas[segmentNode.segmentId].models[modelNode.modelName].records[recordNode.recordId] = { action: recordNode.data.action, fields: [] }; if (recordNode.nodes.fieldDeltas) { Object.values(recordNode.nodes.fieldDeltas.nodes).forEach((fieldNode) => { if (fieldNode.checked) { segmentDeltas[segmentNode.segmentId].models[modelNode.modelName].records[recordNode.recordId].fields.push(fieldNode.fieldName); } }); } } }); } } }); } } }); return segmentDeltas; } this.commitDeltas = function() { if (confirm("You are about to " + ($scope.directiveScope.push ? "PUSH modifications to" : "PULL modifications from") + " the remote instance, are you sure?")) { $scope.directiveScope.state = "committing"; executeTask($scope, $http, "6437561df8ee6f03ce2ca326", { parameters: { instance: $scope.directiveScope.remoteInstance._id, push: $scope.directiveScope.push, commit: $scope.directiveScope.buildCommit() } }, () => {}, (taskExecution) => { $scope.directiveScope.retrieveNewDelta(); }); } } this.excepted = function(_model, _record, _field) { return $scope.directiveScope.remoteInstance.exceptions.some((entry) => { return ($scope.directiveScope.push ? entry.push : entry.pull) && entry.model == _model && entry.record == _record && entry.field == _field }); } this.toggleException = function(_model, _record, _field) { $scope.directiveScope.remoteInstance.exceptions = $scope.directiveScope.remoteInstance.exceptions || []; if ($scope.directiveScope.excepted(_model, _record, _field)) { //Remove $scope.directiveScope.remoteInstance.exceptions = $scope.directiveScope.remoteInstance.exceptions.filter((exception) => { return !(exception.model == _model && exception.record == _record && exception.field == _field); }); } else { //Add $scope.directiveScope.remoteInstance.exceptions.push({ push: $scope.directiveScope.push, pull: !$scope.directiveScope.push, model: _model, record: _record, field: _field }); console.log($scope.directiveScope.remoteInstance.exceptions); } } this.processDelta = function() { $scope.directiveScope.deltaMatrix = []; Object.keys($scope.directiveScope.delta.segmentDeltas).forEach((segmentId) => { var segmentDelta = $scope.directiveScope.delta.segmentDeltas[segmentId]; if (Object.keys(segmentDelta.modelDeltas).length > 0) { Object.keys(segmentDelta.modelDeltas).forEach((modelName) => { var modelDelta = segmentDelta.modelDeltas[modelName]; if (Object.keys(modelDelta.recordDeltas).length > 0) { Object.keys(modelDelta.recordDeltas).forEach((recordId) => { var recordDelta = modelDelta.recordDeltas[recordId]; if (Object.keys(recordDelta.fieldDeltas).length > 0) { Object.keys(recordDelta.fieldDeltas).forEach((fieldName) => { var fieldDelta = recordDelta.fieldDeltas[fieldName]; $scope.directiveScope.deltaMatrix.push({ segment: segmentId, model: modelName, record: recordId, field: fieldName }); }); } else { //Just add record delta entry $scope.directiveScope.deltaMatrix.push({ segment: segmentId, model: modelName, record: recordId }); } }); } else { //Just add model delta entry $scope.directiveScope.deltaMatrix.push({ segment: segmentId, model: modelName }); } }); } else { //Just add segment delta entry $scope.directiveScope.deltaMatrix.push({ segment: segmentId }); } }); } this.retrieveLastDelta = function() { retrieveRecord($scope, $http, "task_execution", { query: { task: "64375611f8ee6f03ce2ca2fa", state: "succeeded" }, sort: { ended: "desc" } }, (execution) => { $scope.directiveScope.delta = JSON.parse(execution.result); postProcessJSON($scope.directiveScope.delta); $scope.directiveScope.processDelta(); }); } this.retrieveNewDelta = function() { $scope.directiveScope.state = "retrieving"; executeTask($scope, $http, "64375611f8ee6f03ce2ca2fa", { parameters: { instance: $scope.directiveScope.remoteInstance._id, push: $scope.directiveScope.push, segments: $scope.directiveScope.segments, exceptions: JSON.stringify($scope.directiveScope.remoteInstance[($scope.directiveScope.push ? "push" : "pull") + "_exceptions"]) } }, () => {}, (taskExecution) => { $scope.directiveScope.delta = JSON.parse(taskExecution.result); postProcessJSON($scope.directiveScope.delta); $scope.directiveScope.processDelta(); $scope.directiveScope.state = null; }); } this.retrieveLastDelta(); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: instanceDeploymentConfiguration failed to initialize: " + e); } }); } app.controller('ctrl_635699c17e7fde0436dd3c69', ctrl_635699c17e7fde0436dd3c69); app.directive('googleTagManager', function() { return { scope: {} , controller: ctrl_63b79e9f3f6e5e2bd00e64f0, template: ` `, bindToController: true};}); function ctrl_63b79e9f3f6e5e2bd00e64f0($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: googleTagManager failed to initialize: " + e); } }); } app.controller('ctrl_63b79e9f3f6e5e2bd00e64f0', ctrl_63b79e9f3f6e5e2bd00e64f0); app.directive('thermometerLogChart', function() { return { scope: { thermometerIds: "=?" } , controller: ctrl_6362a0709fe83b1140fa1704, template: ` `, bindToController: true};}); function ctrl_6362a0709fe83b1140fa1704($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.thermometers = this.thermometers == null ? [] : this.thermometers; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: thermometerLogChart failed to initialize: " + e); } }); } app.controller('ctrl_6362a0709fe83b1140fa1704', ctrl_6362a0709fe83b1140fa1704); app.directive('modalWysiwygHtmlEntry', function() { return { scope: { title: "=?", bindingName: "=", bindingParent: "=", subtext: "=?", height: "=?" }, controller: ctrl_63631f41dc9d8919fa4a919f, template: ` None   {{directiveScope.subtext}} `, bindToController: true};}); function ctrl_63631f41dc9d8919fa4a919f($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modalWysiwygHtmlEntry failed to initialize: " + e); } }); } app.controller('ctrl_63631f41dc9d8919fa4a919f', ctrl_63631f41dc9d8919fa4a919f); app.directive('modalJsonEntry', function() { return { scope: { title: "=?", bindingName: "=", bindingParent: "=", subtext: "=?", height: "=?" }, controller: ctrl_637e1d05c14b310801d5ee38, template: `
    {{directiveScope.pretty(directiveScope.bindingParent[directiveScope.bindingName])}}
    None  
    {{directiveScope.subtext}} `, bindToController: true};}); function ctrl_637e1d05c14b310801d5ee38($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.pretty = function(_json) { return typeof(_json) == "string" ? _json : JSON.stringify(_json, null, 2); } }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modalJsonEntry failed to initialize: " + e); } }); } app.controller('ctrl_637e1d05c14b310801d5ee38', ctrl_637e1d05c14b310801d5ee38); app.directive('scannerInput', function() { return { scope: { bindingParent: "=?", bindingName: "=?", onInput: "=?", allowManualEntry: "=?", showScannedValue: "=?", placeholder: "=?", inactivePlaceholder: "=?", active: "=?" }, controller: ctrl_6389578e63048972e16e4838, template: `
    `, bindToController: true};}); function ctrl_6389578e63048972e16e4838($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.placeholder = this.placeholder == null ? "Scan a barcode..." : this.placeholder; this.inactivePlaceholder = this.inactivePlaceholder == null ? "" : this.inactivePlaceholder; this.allowManualEntry = this.allowManualEntry == null ? true : this.allowManualEntry; this.showScannedValue = this.showScannedValue == null ? true : this.showScannedValue; this.active = this.active == undefined ? true : this.active; this.buffer = ""; this.lastKeypress; this.maxDelay = 100; $(document).keypress(function(_event) { if (!$scope.directiveScope.active) { return; } $scope.directiveScope.lastKeypress = new Date(); if (_event.keyCode == 13) { if ($scope.directiveScope.buffer.length > 0) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.buffer.replace("\r","").replace("\n",""); $scope.directiveScope.buffer = ""; $scope.directiveScope.flash = true; setTimeout(() => { $scope.directiveScope.flash = false; safeApply($scope); }, 500); safeApply($scope); } if ($scope.directiveScope.onInput) { $scope.directiveScope.onInput($scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]); } } else if (!_event.ctrlKey) { if (_event.keyCode > 31 && _event.keyCode < 127) { $scope.directiveScope.buffer += _event.key; } } }); setInterval(() => { if ($scope.directiveScope.buffer.length > 0 && (new Date()) - $scope.directiveScope.lastKeypress > $scope.directiveScope.maxDelay) { $scope.directiveScope.buffer = ""; } }, $scope.directiveScope.maxDelay); }; this.$onDestroy = function() { //If the directive is destroyed (ng-if eval to false) kill the event handler $(document).off("keypress"); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: scannerInput failed to initialize: " + e); } }); } app.controller('ctrl_6389578e63048972e16e4838', ctrl_6389578e63048972e16e4838); app.directive('queryField', function() { return { scope: { allowInteraction: "=?", bindingParent: "=?", bindingName: "=?", modelName: "=?", operators: "=", level: "=?", siblingIndex: "=?" }, controller: ctrl_63bb4af2d1894d29fcf1ce85, template: `
    {{$root.models[directiveScope.modelName].fields[directiveScope.bindingName].display_name || directiveScope.bindingName}}
    {{directiveScope.notMode ? 'Is Not' : 'Is'}}
    (And)
    `, bindToController: true};}); function ctrl_63bb4af2d1894d29fcf1ce85($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; Object.defineProperty($scope.directiveScope, "notMode", { get: function() { return $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] && $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]._$not; }, set: function(value) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = value ? { _$not: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] } : $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]._$not; } }); Object.defineProperty($scope.directiveScope, "dynamicBindingParent", { get: function() { return $scope.directiveScope.notMode ? //Not mode, bind to the bindingParent[bindingName](._$not) property $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] : //Normal mode, bind to bindingParent(bindingName) property $scope.directiveScope.bindingParent; } }); Object.defineProperty($scope.directiveScope, "dynamicBindingName", { get: function() { return $scope.directiveScope.notMode ? //Not mode, bind to the (bindingParent[bindingName])._$not property "_$not" : //Normal mode, bind to (bindingParent).bindingName property $scope.directiveScope.bindingName; } }); this.removeField = function() { delete $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName]; } this.fieldRemoveMouseover = function() { $scope.directiveScope.deleteHovered = true; } this.fieldRemoveMouseleave = function() { $scope.directiveScope.deleteHovered = false; } $scope.$watch("directiveScope.newClause", (_new, _old) => { if ($scope.directiveScope.newClause) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName][$scope.directiveScope.newClause] = null; $scope.directiveScope.newClause = null; } }); this.currentDynamicOperators; Object.defineProperty($scope.directiveScope, "dynamicOperators", { get: function() { var fieldConfig = $scope.$root.models[$scope.directiveScope.modelName].fields[$scope.directiveScope.bindingName]; var filteredOperators = {}; Object.keys($scope.directiveScope.operators).forEach((o) => { var operator = $scope.directiveScope.operators[o]; if (operator.types[fieldConfig.type]) { filteredOperators[o] = operator; Object.assign(filteredOperators[o], operator.types[fieldConfig.type]); filteredOperators[o].selectable = !$scope.directiveScope.bindingParent[$scope.directiveScope.bindingName].hasOwnProperty(o); } }); if (angular.toJson(filteredOperators) != angular.toJson($scope.directiveScope.currentDynamicOperators)) { $scope.directiveScope.currentDynamicOperators = filteredOperators; } return $scope.directiveScope.currentDynamicOperators; } }); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: queryField failed to initialize: " + e); } }); } app.controller('ctrl_63bb4af2d1894d29fcf1ce85', ctrl_63bb4af2d1894d29fcf1ce85); app.directive('recordPieChart', function() { return { scope: { modelName: "=?", query: "=?", aggregationField: "=?", title: "=?", refDisplayField: "=?", reloadRate: "=?" }, controller: ctrl_63bfb8b1f2378c03cf4711b4, template: `
    {{directiveScope.title}}
     Loading... `, bindToController: true};}); function ctrl_63bfb8b1f2378c03cf4711b4($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.slices = {}; this.updating = false; this.update = function() { $scope.directiveScope.updating = true; retrieveRecords($scope, $http, $scope.directiveScope.modelName, { query: $scope.directiveScope.query, select: [$scope.directiveScope.aggregationField] }, (response) => { var fieldConfig = $scope.$root.models[$scope.directiveScope.modelName].fields[$scope.directiveScope.aggregationField]; var newSlices = {}; var groups = groupByProperty(response.records, $scope.directiveScope.aggregationField); if (fieldConfig.type == "reference") { var refDisplayField = $scope.directiveScope.refDisplayField || $scope.$root.models[fieldConfig.ref].display_field; retrieveRecords($scope, $http, fieldConfig.ref, { query: { _id: { $in: Object.keys(groups).filter((v) => { return v && v!= "undefined"; }) }}, select: [refDisplayField] }, (refResponse) => { Object.keys(groups).sort((a, b) => { return groups[a].length < groups[b].length ? 1 : -1; }).forEach((v) => { var label = (((refResponse.records.find((r) => { return r._id == v; }) || {})[refDisplayField]) || v) + " (" + groups[v].length + ")"; newSlices[label] = groups[v].length; }); $scope.directiveScope.slices = newSlices; $scope.directiveScope.updating = false; }); } else { Object.keys(groups).sort((a, b) => { return groups[a].length < groups[b].length ? 1 : -1; }).forEach((v) => { var label = (fieldConfig.selections ? ((fieldConfig.selections[v] || {}).label || v) : v) + " (" + groups[v].length + ")"; newSlices[label] = groups[v].length; }); $scope.directiveScope.slices = newSlices; $scope.directiveScope.updating = false; } //Retrigger if requested if ($scope.directiveScope.reloadRate > 500) { setTimeout(() => { $scope.directiveScope.update(); }, $scope.directiveScope.reloadRate); } }); } this.update(); };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: recordPieChart failed to initialize: " + e); } }); } app.controller('ctrl_63bfb8b1f2378c03cf4711b4', ctrl_63bfb8b1f2378c03cf4711b4); app.directive('modalAddressEntry', function() { return { scope: { title: "=?", subtext: "=?", bindingParent: "=?", bindingName: "=?", allowInteraction: "=?", validateMethod: "=?", //should return an object { field_name: "error", ...} formatMethod: "=?" //should modify the values directly } , controller: ctrl_63c21069f34e1719ad34bd31, template: ` {{directiveScope.subtext}} `, bindToController: true};}); function ctrl_63c21069f34e1719ad34bd31($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: modalAddressEntry failed to initialize: " + e); } }); } app.controller('ctrl_63c21069f34e1719ad34bd31', ctrl_63c21069f34e1719ad34bd31); app.directive('singleLineTextInput', function() { return { scope: { bindingParent: "=", bindingName: "=", allowInteraction: "=?", applyOnChange: "=?", applyOnEnter: "=?", }, controller: ctrl_63c4a4fbf3b28225025ea76b, template: ``, bindToController: true};}); function ctrl_63c4a4fbf3b28225025ea76b($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.unique = createUniqueTag(); $scope.directiveScope = this; this.tempBinding = ""; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.applyOnChange = this.applyOnChange == null ? true : this.applyOnChange; this.keydown = function($event) { if ($event.code.endsWith("Enter") && $scope.directiveScope.applyOnEnter) { $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] = $scope.directiveScope.tempBinding; } } $scope.$watch("directiveScope.bindingParent[directiveScope.bindingName]", () => { if (!$scope.directiveScope.updatingUi) { $scope.directiveScope.updatingBinding = true; $scope.directiveScope.updatingBinding = false; } }); $scope.$watch("directiveScope.tempBinding", () => { if (!$scope.directiveScope.updatingBinding) { $scope.directiveScope.updatingUi = true; $scope.directiveScope.updatingUi = false; } }); };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: singleLineTextInput failed to initialize: " + e); } }); } app.controller('ctrl_63c4a4fbf3b28225025ea76b', ctrl_63c4a4fbf3b28225025ea76b); app.directive('sidepaneFilterList', function() { return { scope: { modelName: "=?", listSort: "=?", enforcedQuery: "=?", listLayout: "=?" } , controller: ctrl_63b780bcb96068189d850b49, template: `
    Filter Reset
    {{$root.models[directiveScope.modelName].fields[fieldName].display_name || fieldName}}
    `, bindToController: true};}); function ctrl_63b780bcb96068189d850b49($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.id = createUniqueTag(); $scope.directiveScope = this; this.query = {}; this.filterFields = []; this.filterValues = {}; this.updateQuery = function() { var newQuery = {}; Object.keys($scope.directiveScope.filterValues).forEach((f) => { var filterValue = $scope.directiveScope.filterValues[f]; var fieldModel = $scope.$root.models[$scope.directiveScope.modelName].fields[f]; if (fieldModel.selections) { newQuery[f] = { $in: filterValue }; } else if (["enumerator", "string"].includes(fieldModel.type)) { if (filterValue) { newQuery[f] = { $regex: (".*" + filterValue + ".*"), $options: "i" }; } } else { newQuery[f] = filterValue; } }); $scope.directiveScope.query = $scope.directiveScope.enforcedQuery ? { $and: [$scope.directiveScope.enforcedQuery, newQuery] } : newQuery; } this.buildFilterFields = function() { $scope.directiveScope.filterValues = {}; $scope.directiveScope.filterFields = Object.keys($scope.$root.models[$scope.directiveScope.modelName].fields).filter((f) => { var fieldModel = $scope.$root.models[$scope.directiveScope.modelName].fields[f]; if (!fieldModel.queryable) { return false; } else if (fieldModel.selections) { $scope.directiveScope.filterValues[f] = Object.keys(fieldModel.selections); $scope.directiveScope.filterValues[f].push(null); return true; } else if (["enumerator", "string"].includes(fieldModel.type)) { return true; } return false; }).sort((a) => { return $scope.$root.models[$scope.directiveScope.modelName].fields[a].selections ? 1 : -1; }); }; this.buildFilterFields(); $scope.$watch("directiveScope.filterValues", () => { $scope.directiveScope.updateQuery(); }, true); }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: sidepaneFilterList failed to initialize: " + e); } }); } app.controller('ctrl_63b780bcb96068189d850b49', ctrl_63b780bcb96068189d850b49); app.directive('taskExecutionLogDisplay', function() { return { scope: { bindingParent: "=?", bindingName: "=?", displayDebug: "=?" }, transclude: false, controller: ctrl_63cff6c96fb17603866a7d19, template: `
    Level Timestamp Message
    {{entry.timestamp | date:'M/d/yy, h:mm:ss a'}} {{entry.message}}
    `, bindToController: true};}); function ctrl_63cff6c96fb17603866a7d19($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.displayDebug = this.displayDebug == null ? true : this.displayDebug; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: taskExecutionLogDisplay failed to initialize: " + e); } }); } app.controller('ctrl_63cff6c96fb17603866a7d19', ctrl_63cff6c96fb17603866a7d19); app.directive('locationVisualization', function() { return { scope: { location: "=?", scaleFactor: "=?", isChild: "=?", contentFunction: "=?", classFunction: "=?" } , controller: ctrl_63d9231f9f678303a34364e4, template: `
    {{directiveScope.location.name}}
    `, bindToController: true};}); function ctrl_63d9231f9f678303a34364e4($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.unique = "location_" + createUniqueTag(); this.scaleFactor; Object.defineProperty(this, "dynamicScaleFactor", { get: function() { if ($scope.directiveScope.isChild) { //Use supplied scale factor return $scope.directiveScope.scaleFactor; } else { var maxWidth = $("#" + $scope.directiveScope.unique).parent().parent().width(); var newFactor = maxWidth / $scope.directiveScope.location.width; return newFactor; } } }); Object.defineProperty(this, "dynamicClass", { get: function() { if ($scope.directiveScope.classFunction && $scope.directiveScope.isChild) { var c = $scope.directiveScope.classFunction($scope.directiveScope.location); return "hover-border-theme text-" + c + " table-" + c+ " border-" + c; } else { return "rounded bg-light"; } } }); }; this.update = function() { if (!$scope.directiveScope.isChild) { retrieveRecords($scope, $http, "location", { query: { location: $scope.directiveScope.location._id }}, (response) => { console.log(response); $scope.directiveScope.containedLocations = response.records; }); } } $scope.$watch("directiveScope.location", () => { this.update(); }); ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: locationVisualization failed to initialize: " + e); } }); } app.controller('ctrl_63d9231f9f678303a34364e4', ctrl_63d9231f9f678303a34364e4); app.directive('shelfRackVisualization', function() { return { scope: { bindingParent: "=?", bindingName: "=?", shelfHtml: "=?", shelfJs: "=?" }, controller: ctrl_64937fe25158c82d95336f18, template: `
    {{shelf.name}}
    `, bindToController: true};}); function ctrl_64937fe25158c82d95336f18($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; retrieveRecord($scope, $http, "shelf_rack", { query: { _id: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] } }, (shelfRack) => { retrieveRecords($scope, $http, "shelf", { query: { location: $scope.directiveScope.bindingParent[$scope.directiveScope.bindingName] } }, (response) => { $scope.directiveScope.shelfRack = shelfRack; $scope.directiveScope.verticalShelfIndexes = groupByProperty(response.records, "parent_vertical_index"); Object.keys($scope.directiveScope.verticalShelfIndexes).forEach((shelf) => { $scope.directiveScope.verticalShelfIndexes[shelf] = arrayToObjectBy($scope.directiveScope.verticalShelfIndexes[shelf], "parent_horizontal_index") }); waitForElement("shelfVisualization", (shelfRack) => { $scope.directiveScope.displayWidth = shelfRack.offsetWidth; $scope.directiveScope.verticalScale = $scope.directiveScope.displayWidth / $scope.directiveScope.shelfRack.length; safeApply($scope); }); }); }); } ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: shelfRackVisualization failed to initialize: " + e); } }); } app.controller('ctrl_64937fe25158c82d95336f18', ctrl_64937fe25158c82d95336f18); app.directive('taskExecutionDetails', function() { return { scope: { bindingParent: "=?", bindingName: "=?" }, controller: ctrl_64583181cdf68a3eeccaee10, template: `
    `, bindToController: true};}); function ctrl_64583181cdf68a3eeccaee10($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.taskExecution = null; };; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: taskExecutionDetails failed to initialize: " + e); } }); } app.controller('ctrl_64583181cdf68a3eeccaee10', ctrl_64583181cdf68a3eeccaee10); app.directive('commonDisplay', function() { return { scope: { text: "=?", textClass: "=?", subText: "=?", subTextClass: "=?", icon: "=?", subIcon: "=?", allowInteraction: "=?", spinnerIcon: "=?", spinnerSubIcon: "=?", progress: "=?", progressClass: "=?" }, controller: ctrl_63fed76c9af6563cf8cbf827, template: `
    {{directiveScope.text}}
    {{directiveScope.subText}}
    {{directiveScope.text}}
    {{directiveScope.subText}}
    `, bindToController: true};}); function ctrl_63fed76c9af6563cf8cbf827($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { this.supportingJsLoaded = false; $scope.directiveScope = this; this.subTextClass = this.subTextClass == null ? "secondary" : this.subTextClass; }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: commonDisplay failed to initialize: " + e); } }); } app.controller('ctrl_63fed76c9af6563cf8cbf827', ctrl_63fed76c9af6563cf8cbf827); app.directive('qrButton', function() { return { scope: { displayClass: "=?", label: "=?", subLabel: "=?", qr: "=?", allowInteraction: "=?", onClick: "=?", icon: "=?", subIcon: "=?" } , controller: ctrl_640b448549f10c03c4870afb, template: `
    `, bindToController: true};}); function ctrl_640b448549f10c03c4870afb($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.displayClass = this.displayClass == null ? "primary" : this.displayClass; this.label = this.label == null ? "" : this.label; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: qrButton failed to initialize: " + e); } }); } app.controller('ctrl_640b448549f10c03c4870afb', ctrl_640b448549f10c03c4870afb); app.directive('recordModal', function() { return { scope: { refModel: "=", allowEdit: "=?", bindingName: "=", bindingParent: "=", layout: "=?", directiveRef: "=" }, controller: ctrl_641b126048d89f256385bb07, template: ` `, bindToController: true};}); function ctrl_641b126048d89f256385bb07($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; this.allowInteraction = this.allowInteraction == null ? true : this.allowInteraction; this.allowNew = this.allowNew == null ? true : this.allowNew; this.allowView = this.allowView == null ? true : this.allowView; this.allowEdit = this.allowEdit == null ? true : this.allowEdit; this.unique = createUniqueTag(); }; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: recordModal failed to initialize: " + e); } }); } app.controller('ctrl_641b126048d89f256385bb07', ctrl_641b126048d89f256385bb07); app.directive('segmentOperationalStateDetailsDisplay', function() { return { scope: { bindingParent: "=?", bindingName: "=?", hideOk: "=?" } , controller: ctrl_643a48e741f8b63c4b6e0a92, template: `
    `, bindToController: true};}); function ctrl_643a48e741f8b63c4b6e0a92($scope, $http, $location, $timeout, $interval, $rootScope, $element, $compile, $sce) { this.$onInit = function() { $scope.directiveScope = this; }; ; this.rawInit = this.$onInit || (()=>{}); this.$onInit = (() => { try { this.rawInit(); } catch (e) { console.log("Directive: segmentOperationalStateDetailsDisplay failed to initialize: " + e); } }); } app.controller('ctrl_643a48e741f8b63c4b6e0a92', ctrl_643a48e741f8b63c4b6e0a92);