UNPKG

angular-location-selector

Version:

![Logo](https://iili.io/HWfBDgV.png)

592 lines (580 loc) 33.1 kB
import { __decorate } from 'tslib'; import { EventEmitter, Input, Output, Component, ElementRef, HostListener, ChangeDetectorRef, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { ButtonsModule } from '@progress/kendo-angular-buttons'; import { TreeViewModule } from '@progress/kendo-angular-treeview'; import { FormsModule } from '@angular/forms'; var AngularLocationSelectorComponent = /** @class */ (function () { function AngularLocationSelectorComponent() { this.type = "single"; this.selectedLocationId = null; this.selectedLocationName = 'Select'; this.selectorDisabledLocation = false; this.onChange = new EventEmitter(); } AngularLocationSelectorComponent.prototype.ngOnInit = function () { }; AngularLocationSelectorComponent.prototype.onLocationsFetched = function (locations) { this.locationHierachy = locations; }; AngularLocationSelectorComponent.prototype.updateLocationState = function (dataItem) { this.onChange.emit(dataItem); }; __decorate([ Input() ], AngularLocationSelectorComponent.prototype, "type", void 0); __decorate([ Input() ], AngularLocationSelectorComponent.prototype, "labelText", void 0); __decorate([ Input() ], AngularLocationSelectorComponent.prototype, "selectedLocationId", void 0); __decorate([ Input() ], AngularLocationSelectorComponent.prototype, "selectedLocationName", void 0); __decorate([ Input() ], AngularLocationSelectorComponent.prototype, "selectorDisabledLocation", void 0); __decorate([ Input() ], AngularLocationSelectorComponent.prototype, "locationHierachy", void 0); __decorate([ Input() ], AngularLocationSelectorComponent.prototype, "hoverText", void 0); __decorate([ Output() ], AngularLocationSelectorComponent.prototype, "onChange", void 0); AngularLocationSelectorComponent = __decorate([ Component({ selector: 'angular-location-selector', template: "<location-single-selector *ngIf=\"type == 'single'\" labelText=\"{{labelText}}\" class=\"location-selector-view\" [locationHierachy]=\"locationHierachy\"\r\nisDisableParentClick=\"false\" selectedLocationId=\"{{selectedLocationId}}\" hoverText=\"{{hoverText}}\"\r\nselectedLocationName=\"{{selectedLocationName}}\" isIncludeFloatLocation=\"true\"\r\n(onLocationsData)=\"onLocationsFetched($event)\" [selectorDisabled]=\"selectorDisabledLocation\" [hideBranchLess]=\"true\"\r\n(onChange)=\"updateLocationState($event)\">\r\n</location-single-selector>\r\n\r\n<location-multi-selector *ngIf=\"type == 'multi'\" labelText=\"{{labelText}}\" class=\"location-selector-view\" [locationHierachy]=\"locationHierachy\"\r\nisDisableParentClick=\"false\" selectedLocationId=\"{{selectedLocationId}}\" hoverText=\"{{hoverText}}\"\r\nselectedLocationName=\"{{selectedLocationName}}\" isIncludeFloatLocation=\"true\"\r\n(onLocationsData)=\"onLocationsFetched($event)\" [selectorDisabled]=\"selectorDisabledLocation\" [hideBranchLess]=\"true\"\r\n(onChange)=\"updateLocationState($event)\">\r\n</location-multi-selector>" }) ], AngularLocationSelectorComponent); return AngularLocationSelectorComponent; }()); var LocationMultiSelectorComponent = /** @class */ (function () { function LocationMultiSelectorComponent(elementRef) { this.elementRef = elementRef; this.expandedKeys = []; this.selectorOpened = false; this.selectedLocationName = "Select"; this.selectedLocationId = 0; this.isIncludeFloatLocation = true; this.hideBranchLess = false; this.includeInactive = false; this.isDisableParentClick = false; this.onChange = new EventEmitter(); this.page = ""; this.checkedKeys = []; this.selectorDisabled = false; this.onLocationsData = new EventEmitter(); this.selectedLocations = []; } LocationMultiSelectorComponent.prototype.ngOnInit = function () { this.onLocationsData.emit(this.locationHierachy); this.addExpandListItem(this.locationHierachy.locations); this.setDefaultValue(this.checkedKeys, this.locationHierachy.locations); }; LocationMultiSelectorComponent.prototype.onGlobalClick = function (event) { if (!this.elementRef.nativeElement.contains(event.target)) { // clicked outside => close dropdown list this.selectorOpened = false; } }; LocationMultiSelectorComponent.prototype.closeDropDown = function () { this.selectorOpened = false; }; LocationMultiSelectorComponent.prototype.onItemSelected = function (data) { this.selectorOpened = false; }; LocationMultiSelectorComponent.prototype.setDefaultValue = function (checkedKeys, items) { for (var i = 0; i < items.length; i++) { if (checkedKeys.indexOf(items[i].locationId) > -1) { if (items[i].isSelectable) { this.selectedLocations.push(items[i]); this.setDefaultValue(checkedKeys, items[i].items); } } else { this.setDefaultValue(checkedKeys, items[i].items); } } }; LocationMultiSelectorComponent.prototype.addExpandListItem = function (treeItem) { var _this = this; treeItem.forEach(function (item) { if (item.items && item.items.length > 0) { _this.expandedKeys.push(item.locationId); _this.addExpandListItem(item.items); } }); }; LocationMultiSelectorComponent.prototype.handleChange = function (data) { this.checkedKeys = data; var locationsFlatArray = this.locationHierachy.locationsFlatData; var selectedLocatonsArray = locationsFlatArray.filter(function (item) { return data.indexOf(item.locationId) !== -1; }); this.selectedLocations = selectedLocatonsArray; this.onChange.emit(this.selectedLocations); }; LocationMultiSelectorComponent.prototype.locationClick = function () { this.selectorOpened = !this.selectorOpened; }; LocationMultiSelectorComponent.prototype.onRemove = function (item) { var index = this.selectedLocations.findIndex(function (c) { return c.locationId === item.locationId; }); var checkedKeyIndex = this.checkedKeys.findIndex(function (k) { return k == item.locationId; }); this.checkedKeys.splice(checkedKeyIndex, 1); this.selectedLocations.splice(index, 1); this.onChange.emit(this.selectedLocations); }; LocationMultiSelectorComponent.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input() ], LocationMultiSelectorComponent.prototype, "selectedLocationName", void 0); __decorate([ Input() ], LocationMultiSelectorComponent.prototype, "selectedLocationId", void 0); __decorate([ Input() ], LocationMultiSelectorComponent.prototype, "labelText", void 0); __decorate([ Input() ], LocationMultiSelectorComponent.prototype, "hoverText", void 0); __decorate([ Input() ], LocationMultiSelectorComponent.prototype, "isIncludeFloatLocation", void 0); __decorate([ Input() ], LocationMultiSelectorComponent.prototype, "hideBranchLess", void 0); __decorate([ Input() ], LocationMultiSelectorComponent.prototype, "includeInactive", void 0); __decorate([ Input() ], LocationMultiSelectorComponent.prototype, "isDisableParentClick", void 0); __decorate([ Output() ], LocationMultiSelectorComponent.prototype, "onChange", void 0); __decorate([ Input() ], LocationMultiSelectorComponent.prototype, "locationHierachy", void 0); __decorate([ Input() ], LocationMultiSelectorComponent.prototype, "page", void 0); __decorate([ Input() ], LocationMultiSelectorComponent.prototype, "checkedKeys", void 0); __decorate([ Input() ], LocationMultiSelectorComponent.prototype, "selectorDisabled", void 0); __decorate([ Output() ], LocationMultiSelectorComponent.prototype, "onLocationsData", void 0); __decorate([ HostListener('document:mousedown', ['$event']) ], LocationMultiSelectorComponent.prototype, "onGlobalClick", null); LocationMultiSelectorComponent = __decorate([ Component({ selector: 'location-multi-selector', template: "<div class=\"row align-items-center\" (click)=\"closeDropDown()\">\r\n <div class=\"col-md-12\">\r\n <label *ngIf=\"labelText?.length > 0\">{{labelText}}</label>\r\n\r\n <div #menu class=\"d-flex justify-content-between location-selector-form\"\r\n [ngClass]=\"{'disableSelector':selectorDisabled,'location-selector-focus' : selectorOpened}\" id=\"ddlLocationy\"\r\n (click)=\"locationClick()\" [title]=\"hoverText\" (click)=\"$event.stopPropagation()\">\r\n <div >\r\n <span *ngIf=\"selectorDisabled && selectedLocations.length<1\">\r\n {{selectedLocationName}}\r\n </span>\r\n <span *ngIf=\"!selectorDisabled && selectedLocations.length<1\">\r\n Select\r\n </span>\r\n <kendo-chip *ngFor=\"let selectedLocation of selectedLocations.slice(0,3)\"\r\n [label]=\"selectedLocation.locationName\" removable=\"true\" removeIcon=\"k-icon k-i-close\"\r\n (remove)=\"onRemove(selectedLocation);\">\r\n </kendo-chip>\r\n </div>\r\n <div class=\"d-flex flex-column align-items-center ml-1\">\r\n <em class=\"fas fa-chevron-down\"></em>\r\n <span *ngIf=\"selectedLocations?.length >3\">+{{selectedLocations?.length-3}}\r\n </span>\r\n </div>\r\n </div>\r\n <div class=\"location-tree-wrapper p-2\" *ngIf=\"selectorOpened\" (click)=\"$event.stopPropagation()\">\r\n <location-multi-selector-tree-view [locations]=\"locationHierachy.locations\"\r\n [expandedKeys]=\"expandedKeys\" \r\n [selectedLocationId]=\"selectedLocationId\" [checkedKeys]=\"checkedKeys\" (onChange)=\"handleChange($event)\"\r\n (closeEvent)=\"onItemSelected($event)\">\r\n </location-multi-selector-tree-view>\r\n </div>\r\n </div>\r\n</div>", styles: [":host ::ng-deep .location-selector-form{align-items:center;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;color:#495057;cursor:pointer;display:block;font-size:.9rem;height:auto;font-weight:400;line-height:1.5;padding:.2rem .4rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;width:300px}:host ::ng-deep .location-selector-focus{background-color:#fff;box-shadow:0 0 0 .2rem rgba(0,81,81,.1);color:#495057;outline:0}:host ::ng-deep .location-tree-wrapper{position:absolute;z-index:10}:host ::ng-deep .disableSelector{opacity:.6;pointer-events:none}.k-chip{color:#fff;margin:2px;background-color:#005151;float:left;border-radius:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px}.k-chip:last-child{max-width:230px}"] }) ], LocationMultiSelectorComponent); return LocationMultiSelectorComponent; }()); var LocationMultiSelectorTreeViewComponent = /** @class */ (function () { function LocationMultiSelectorTreeViewComponent(cdRef) { this.cdRef = cdRef; this.closeEvent = new EventEmitter(); this.onChange = new EventEmitter(); this.locationSelector = { id: 0, locationName: null, locationCode: null, utcoffsetInMinutes: 0, locationTypeId: 0, timezoneId: null, timeZoneName: null, dropDownDisabled: null, lastLocationAutoWraupTime: null }; // currently checked Tree view unique id this.checkedKeys = []; this.checkAll = true; // Checking component this.key = 'locationId'; } LocationMultiSelectorTreeViewComponent.prototype.ngOnChanges = function (changes) { this.checkDefaultValue(changes.checkedKeys.currentValue, this.locations); }; LocationMultiSelectorTreeViewComponent.prototype.ngOnInit = function () { this.checkDefaultValue(this.checkedKeys, this.locations); this.onChange.emit(this.checkedKeys); }; LocationMultiSelectorTreeViewComponent.prototype.ngAfterContentInit = function () { this.addExpandListItem(this.locations); }; LocationMultiSelectorTreeViewComponent.prototype.ngAfterViewInit = function () { this.cdRef.detectChanges(); }; LocationMultiSelectorTreeViewComponent.prototype.checkDefaultValue = function (checkedKeys, items) { for (var i = 0; i < items.length; i++) { if (checkedKeys.indexOf(items[i].locationId) > -1) { if (items[i].isSelectable) { items[i].isSelected = true; this.checkDefaultValue(checkedKeys, items[i].items); } else { items[i].isSelected = false; } } else { items[i].isSelected = false; this.checkDefaultValue(checkedKeys, items[i].items); } } }; LocationMultiSelectorTreeViewComponent.prototype.handleCheck = function (dataItem) { dataItem.isSelected = !dataItem.isSelected; this.handleChildCheck(dataItem.items, dataItem.isSelected); this.checkedKeys = []; this.checkedKeys = this.getCheckedKeys(this.locations, this.checkedKeys); this.onChange.emit(this.checkedKeys); }; LocationMultiSelectorTreeViewComponent.prototype.handleChildCheck = function (childItems, isSelected) { for (var i = 0; i < childItems.length; i++) { if (childItems[i].isSelectable) { childItems[i].isSelected = isSelected; this.handleChildCheck(childItems[i].items, isSelected); } } }; LocationMultiSelectorTreeViewComponent.prototype.unCheckAll = function (items) { for (var i = 0; i < items.length; i++) { if (items[i].isSelectable) { items[i].isSelected = false; this.unCheckAll(items[i].items); } } }; LocationMultiSelectorTreeViewComponent.prototype.getCheckedKeys = function (items, keys) { for (var i = 0; i < items.length; i++) { if (items[i].isSelected) { keys.push(items[i].locationId); } keys = this.getCheckedKeys(items[i].items, keys); } return keys; }; LocationMultiSelectorTreeViewComponent.prototype.showClick = function (dataItem) { var _a, _b, _c, _d, _e, _f, _g, _h; this.locationSelector = { id: (_a = dataItem) === null || _a === void 0 ? void 0 : _a.locationId, locationName: (_b = dataItem) === null || _b === void 0 ? void 0 : _b.locationName, locationCode: (_c = dataItem) === null || _c === void 0 ? void 0 : _c.locationCode, locationTypeId: (_d = dataItem) === null || _d === void 0 ? void 0 : _d.locationTypeId, utcoffsetInMinutes: (_e = dataItem) === null || _e === void 0 ? void 0 : _e.utcoffsetInMinutes, timezoneId: (_f = dataItem) === null || _f === void 0 ? void 0 : _f.timezoneId, timeZoneName: (_g = dataItem) === null || _g === void 0 ? void 0 : _g.timeZoneName, dropDownDisabled: null, lastLocationAutoWraupTime: (_h = dataItem) === null || _h === void 0 ? void 0 : _h.lastLocationAutoWraupTime }; this.closeEvent.emit(this.locationSelector); }; LocationMultiSelectorTreeViewComponent.prototype.addExpandListItem = function (treeItem) { var _this = this; treeItem.forEach(function (item) { if (item.hasChild) { _this.addExpandListItem(item.items); } }); }; LocationMultiSelectorTreeViewComponent.ctorParameters = function () { return [ { type: ChangeDetectorRef } ]; }; __decorate([ Input() ], LocationMultiSelectorTreeViewComponent.prototype, "expandedKeys", void 0); __decorate([ Input() ], LocationMultiSelectorTreeViewComponent.prototype, "selectedLocationId", void 0); __decorate([ Input() ], LocationMultiSelectorTreeViewComponent.prototype, "locations", void 0); __decorate([ Output() ], LocationMultiSelectorTreeViewComponent.prototype, "closeEvent", void 0); __decorate([ Output() ], LocationMultiSelectorTreeViewComponent.prototype, "onChange", void 0); __decorate([ Input() ], LocationMultiSelectorTreeViewComponent.prototype, "checkedKeys", void 0); LocationMultiSelectorTreeViewComponent = __decorate([ Component({ selector: 'location-multi-selector-tree-view', template: "<kendo-treeview [nodes]=\"locations\" textField=\"locationName\" childrenField=\"items\" \r\n[(expandedKeys)]=\"expandedKeys\" expandBy=\"locationId\" \r\n[filterable]=\"true\" \r\n filterInputPlaceholder=\"Search\" kendoTreeViewExpandable \r\n kendoTreeViewHierarchyBinding>\r\n <ng-template kendoTreeViewNodeTemplate let-dataItem>\r\n <input [(ngModel)]=\"dataItem.isSelected\" (click)=\"handleCheck(dataItem)\" [disabled]=\"!dataItem.isSelectable\" class=\"k-checkbox\" type=\"checkbox\"\r\n kendoCheckBox /><span class=\"selectoritem\" (click)=\"handleCheck(dataItem)\" [ngClass]=\"{'disableNode': dataItem.isSelectable === false,'itemactive' : selectedLocationId == dataItem.locationId}\"> \r\n {{ dataItem.locationName }} \r\n </span>\r\n \r\n </ng-template>\r\n</kendo-treeview>\r\n", styles: [":host ::ng-deep .k-checkbox{border-color:#000}:host ::ng-deep .k-textbox{width:100%;margin-bottom:8px}:host ::ng-deep .k-in.k-state-focused{box-shadow:none!important}:host ::ng-deep .selectoritem:hover{background-color:#005151;border-radius:3px;color:#fff;font-weight:500;cursor:default}:host ::ng-deep .k-treeview .k-icon{font-size:20px}:host ::ng-deep .k-treeview .k-in{padding:0;width:100%}:host ::ng-deep .selectoritem{padding:5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%}:host ::ng-deep .disableNode{opacity:.6;pointer-events:none}:host ::ng-deep .itemactive{color:#005151;font-weight:500}"] }) ], LocationMultiSelectorTreeViewComponent); return LocationMultiSelectorTreeViewComponent; }()); var LocationMultiSelectorModule = /** @class */ (function () { function LocationMultiSelectorModule() { } LocationMultiSelectorModule = __decorate([ NgModule({ declarations: [ LocationMultiSelectorTreeViewComponent, LocationMultiSelectorComponent ], imports: [ CommonModule, FormsModule, ButtonsModule, TreeViewModule ], exports: [ LocationMultiSelectorComponent ], entryComponents: [LocationMultiSelectorComponent] }) ], LocationMultiSelectorModule); return LocationMultiSelectorModule; }()); var LocationSingleSelectorComponent = /** @class */ (function () { function LocationSingleSelectorComponent(elementRef) { this.elementRef = elementRef; this.expandedKeys = []; this.selectorOpened = false; this.disableSelector = false; this.selectedLocationName = "Select"; this.selectedLocationId = 0; this.isIncludeFloatLocation = true; this.isDisableParentClick = false; this.page = ""; this.hideBranchLess = false; this.selectableTypes = []; // an array of location types to be made selectable this.selectorDisabled = false; this.onChange = new EventEmitter(); this.onLocationsData = new EventEmitter(); } LocationSingleSelectorComponent.prototype.ngOnInit = function () { var _this = this; this.onLocationsData.emit(this.locationHierachy); if (this.selectableTypes.length > 0) this.locationHierachy.locations[0] = this.makeSelectableByLocationType(this.locationHierachy.locations[0]); if (this.locationHierachy.locations.length > 0 && this.locationHierachy.locations[0].items == null) { this.disableSelector = true; this.selectedLocationName = "No branches available"; } else if (this.selectedLocationName == null && this.selectedLocationId != null) { // if a location name is not passed in as an input, we set it using the locationId this.selectedLocationName = this.locationHierachy.locationsFlatData.find(function (l) { return l.locationId == _this.selectedLocationId; }).locationName; } this.addExpandListItem(this.locationHierachy.locations); this.setDropDownState(); }; LocationSingleSelectorComponent.prototype.makeSelectableByLocationType = function (locations) { var _this = this; locations.isSelectable = this.selectableTypes.includes(locations.locationTypeId); if (locations.hasChild) { locations.items.forEach(function (i) { return _this.makeSelectableByLocationType(i); }); } return locations; }; LocationSingleSelectorComponent.prototype.setDropDownState = function () { this.disableSelector = this.selectorDisabled; }; LocationSingleSelectorComponent.prototype.onGlobalClick = function (event) { if (!this.elementRef.nativeElement.contains(event.target)) { // clicked outside => close dropdown list this.selectorOpened = false; } }; LocationSingleSelectorComponent.prototype.closeDropDown = function () { this.selectorOpened = false; }; LocationSingleSelectorComponent.prototype.onItemSelected = function (data) { this.selectorOpened = false; this.onChange.emit(data); this.selectedLocationName = data.locationName; }; LocationSingleSelectorComponent.prototype.addExpandListItem = function (treeItem) { var _this = this; treeItem.forEach(function (item) { if (item.items && item.items.length > 0) { _this.expandedKeys.push(item.locationId); _this.addExpandListItem(item.items); } }); }; LocationSingleSelectorComponent.prototype.locationClick = function () { if (!this.selectorDisabled) { this.selectorOpened = !this.selectorOpened; } }; LocationSingleSelectorComponent.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input() ], LocationSingleSelectorComponent.prototype, "selectedLocationName", void 0); __decorate([ Input() ], LocationSingleSelectorComponent.prototype, "selectedLocationId", void 0); __decorate([ Input() ], LocationSingleSelectorComponent.prototype, "labelText", void 0); __decorate([ Input() ], LocationSingleSelectorComponent.prototype, "hoverText", void 0); __decorate([ Input() ], LocationSingleSelectorComponent.prototype, "isIncludeFloatLocation", void 0); __decorate([ Input() ], LocationSingleSelectorComponent.prototype, "isDisableParentClick", void 0); __decorate([ Input() ], LocationSingleSelectorComponent.prototype, "page", void 0); __decorate([ Input() ], LocationSingleSelectorComponent.prototype, "hideBranchLess", void 0); __decorate([ Input() ], LocationSingleSelectorComponent.prototype, "selectableTypes", void 0); __decorate([ Input() ], LocationSingleSelectorComponent.prototype, "selectorDisabled", void 0); __decorate([ Output() ], LocationSingleSelectorComponent.prototype, "onChange", void 0); __decorate([ Output() ], LocationSingleSelectorComponent.prototype, "onLocationsData", void 0); __decorate([ Input() ], LocationSingleSelectorComponent.prototype, "locationHierachy", void 0); __decorate([ HostListener('document:mousedown', ['$event']) ], LocationSingleSelectorComponent.prototype, "onGlobalClick", null); LocationSingleSelectorComponent = __decorate([ Component({ selector: 'location-single-selector', template: "<div class=\"row align-items-center\" (click)=\"closeDropDown()\">\r\n <div class=\"col-md-12\">\r\n <label *ngIf=\"labelText?.length > 0\">{{labelText}}</label>\r\n\r\n <div #menu class=\"d-flex justify-content-between location-selector-form\"\r\n [ngClass]=\"{'disableSelector':selectorDisabled,'location-selector-focus' : selectorOpened}\" id=\"ddlLocationy\"\r\n (click)=\"locationClick()\" (click)=\"$event.stopPropagation()\" [title]=\"hoverText\">\r\n <div class=\"selected-location\">{{selectedLocationName}}</div>\r\n <div><em class=\"fas fa-chevron-down\"></em></div>\r\n </div>\r\n <div class=\"location-tree-wrapper p-2\" *ngIf=\"selectorOpened\" (click)=\"$event.stopPropagation()\">\r\n <location-single-selector-tree-view [locations]=\"locationHierachy.locations\" [expandedKeys]=\"expandedKeys\"\r\n [selectedLocationId]=\"selectedLocationId\" (closeEvent)=\"onItemSelected($event)\">\r\n </location-single-selector-tree-view>\r\n </div>\r\n </div>\r\n</div>", styles: [":host ::ng-deep .location-selector-form{cursor:pointer;display:block;width:300px;height:calc(1.5em + .75rem + 2px);padding:.375rem .75rem;font-size:.9rem;font-weight:400;line-height:1.5;color:#495057;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}:host ::ng-deep .location-selector-focus{color:#495057;background-color:#fff;outline:0;box-shadow:0 0 0 .2rem rgba(0,81,81,.1)}:host ::ng-deep .location-tree-wrapper{position:absolute;z-index:10}:host ::ng-deep .disableSelector{opacity:.6;cursor:default}.selected-location{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:350px}"] }) ], LocationSingleSelectorComponent); return LocationSingleSelectorComponent; }()); var LocationSingleSelectorTreeViewComponent = /** @class */ (function () { function LocationSingleSelectorTreeViewComponent() { this.closeEvent = new EventEmitter(); this.locationSelector = { id: 0, locationName: null, locationCode: null, utcoffsetInMinutes: 0, locationTypeId: 0, timezoneId: null, timeZoneName: null, dropDownDisabled: null, lastLocationAutoWraupTime: null }; } LocationSingleSelectorTreeViewComponent.prototype.ngOnInit = function () { }; LocationSingleSelectorTreeViewComponent.prototype.ngAfterContentInit = function () { this.addExpandListItem(this.locations); }; LocationSingleSelectorTreeViewComponent.prototype.showClick = function (dataItem) { var _a, _b, _c, _d, _e, _f, _g, _h; this.locationSelector = { id: (_a = dataItem) === null || _a === void 0 ? void 0 : _a.locationId, locationName: (_b = dataItem) === null || _b === void 0 ? void 0 : _b.locationName, locationCode: (_c = dataItem) === null || _c === void 0 ? void 0 : _c.locationCode, locationTypeId: (_d = dataItem) === null || _d === void 0 ? void 0 : _d.locationTypeId, utcoffsetInMinutes: (_e = dataItem) === null || _e === void 0 ? void 0 : _e.utcoffsetInMinutes, timezoneId: (_f = dataItem) === null || _f === void 0 ? void 0 : _f.timeZoneId, timeZoneName: (_g = dataItem) === null || _g === void 0 ? void 0 : _g.timeZoneName, dropDownDisabled: null, lastLocationAutoWraupTime: (_h = dataItem) === null || _h === void 0 ? void 0 : _h.lastLocationAutoWraupTime }; this.closeEvent.emit(this.locationSelector); }; LocationSingleSelectorTreeViewComponent.prototype.addExpandListItem = function (treeItem) { var _this = this; treeItem.forEach(function (item) { if (item.hasChild) { _this.addExpandListItem(item.items); } }); }; __decorate([ Input() ], LocationSingleSelectorTreeViewComponent.prototype, "expandedKeys", void 0); __decorate([ Input() ], LocationSingleSelectorTreeViewComponent.prototype, "selectedLocationId", void 0); __decorate([ Input() ], LocationSingleSelectorTreeViewComponent.prototype, "locations", void 0); __decorate([ Output() ], LocationSingleSelectorTreeViewComponent.prototype, "closeEvent", void 0); LocationSingleSelectorTreeViewComponent = __decorate([ Component({ selector: 'location-single-selector-tree-view', template: "<kendo-treeview [nodes]=\"locations\" textField=\"locationName\" childrenField=\"items\" \r\n[(expandedKeys)]=\"expandedKeys\" expandBy=\"locationId\" \r\n[filterable]=\"true\" \r\n filterInputPlaceholder=\"Search\" kendoTreeViewExpandable \r\n kendoTreeViewHierarchyBinding>\r\n <ng-template kendoTreeViewNodeTemplate let-dataItem >\r\n <span class=\"selectoritem\" (click)=\"showClick(dataItem)\" [ngClass]=\"{'disableNode': dataItem.isSelectable === false,'itemactive' : selectedLocationId == dataItem.locationId}\"> \r\n {{ dataItem.locationName }} \r\n </span> \r\n </ng-template>\r\n</kendo-treeview>", styles: [":host ::ng-deep .k-checkbox{border-color:#000}:host ::ng-deep .k-textbox{width:100%;margin-bottom:8px}:host ::ng-deep .k-in.k-state-focused{box-shadow:none!important}:host ::ng-deep .selectoritem:hover{background-color:#005151;border-radius:3px;color:#fff;font-weight:500;cursor:default}:host ::ng-deep .k-treeview .k-icon{font-size:20px}:host ::ng-deep .k-treeview .k-in{padding:0;width:100%}:host ::ng-deep .selectoritem{padding:5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%}:host ::ng-deep .disableNode{opacity:.6;pointer-events:none}:host ::ng-deep .itemactive{color:#005151;font-weight:500}"] }) ], LocationSingleSelectorTreeViewComponent); return LocationSingleSelectorTreeViewComponent; }()); var LocationSingleSelectorModule = /** @class */ (function () { function LocationSingleSelectorModule() { } LocationSingleSelectorModule = __decorate([ NgModule({ declarations: [ LocationSingleSelectorTreeViewComponent, LocationSingleSelectorComponent, ], imports: [ CommonModule, TreeViewModule ], exports: [ LocationSingleSelectorComponent ], entryComponents: [LocationSingleSelectorComponent], }) ], LocationSingleSelectorModule); return LocationSingleSelectorModule; }()); var AngularLocationSelectorModule = /** @class */ (function () { function AngularLocationSelectorModule() { } AngularLocationSelectorModule = __decorate([ NgModule({ declarations: [AngularLocationSelectorComponent], imports: [ LocationSingleSelectorModule, LocationMultiSelectorModule, CommonModule ], exports: [AngularLocationSelectorComponent] }) ], AngularLocationSelectorModule); return AngularLocationSelectorModule; }()); /* * Public API Surface of angular-location-selector */ /** * Generated bundle index. Do not edit. */ export { AngularLocationSelectorComponent, AngularLocationSelectorModule, LocationSingleSelectorModule as ɵa, LocationSingleSelectorTreeViewComponent as ɵb, LocationSingleSelectorComponent as ɵc, LocationMultiSelectorModule as ɵd, LocationMultiSelectorTreeViewComponent as ɵe, LocationMultiSelectorComponent as ɵf }; //# sourceMappingURL=angular-location-selector.js.map