\\r\\n\\r\\n\";","import {ColorLegendDto, ColorLegendVisibility, VisibilitySettings} from \"../../../models/color-legend-dto\";\r\nimport {EventAggregator} from \"aurelia-event-aggregator\";\r\nimport {ObjectIDsIF} from \"../../ifc-fun/openbim-container\";\r\n\r\nexport class ColorVisibilityHandler {\r\n\tprivate events: EventAggregator;\r\n\t\r\n\tconstructor(events: EventAggregator) {\r\n\t\tthis.events = events;\r\n\t}\r\n\r\n\tprivate static visibilitySettings = [ColorLegendVisibility.VISIBLE, ColorLegendVisibility.TRANSLUCENT, ColorLegendVisibility.HIDDEN];\r\n\r\n\ttoggleVisibility(colorLegend: ColorLegendDto) : void {\r\n\t\tlet indexOfCurrentVisibility = ColorVisibilityHandler.visibilitySettings.indexOf(colorLegend.visibility);\r\n\r\n\t\tlet nextVisibilityIndex = (indexOfCurrentVisibility + 1) % ColorVisibilityHandler.visibilitySettings.length;\r\n\t\tcolorLegend.visibility = ColorVisibilityHandler.visibilitySettings[nextVisibilityIndex]\r\n\t}\r\n\r\n\tsetVisibilityInViewer(visibility: VisibilitySettings, entityLabels: number[]) {\r\n\t\tconst objectIds : ObjectIDsIF = { objectIds: entityLabels, revitObjectIds: [] }\r\n\t\t\r\n\t\tswitch (visibility) {\r\n\t\t\tcase \"visible\":\r\n\t\t\t\tthis.events.publish('3dViewer:show-items', objectIds);\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"translucent\":\r\n\t\t\t\tthis.events.publish('3dViewer:isolate-items', objectIds);\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"hidden\":\r\n\t\t\t\tthis.events.publish('3dViewer:hide-items', objectIds);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n","import {autoinject, bindable, observable} from \"aurelia-framework\";\r\nimport {ValueListService} from \"../../../services/value-list/value-list-service\";\r\nimport {ValueFilter} from \"../../../models/object-filter\";\r\nimport {\r\n\tColorLegendDto,\r\n\tColorLegendVisibility,\r\n\tInstanceColorData,\r\n\tVisibilitySettings\r\n} from \"../../../models/color-legend-dto\";\r\nimport {ApiClient} from \"app/services/api-client\";\r\nimport {AppContextService} from \"app/services/app-context-service\";\r\nimport {I18N} from \"aurelia-i18n\";\r\nimport {EventAggregator, Subscription} from \"aurelia-event-aggregator\";\r\nimport {ObjectValues} from \"../../../models/object-values\";\r\nimport {ObjectFilterService} from \"../../../services/object-services/object-filter-service\";\r\nimport {AocObjectFilterService} from \"../../../services/object-services/aoc-object-filter-service\";\r\nimport {ColorLegendUpdateColorsDto} from \"./color-legend-dto\";\r\nimport {IFC_Dto} from \"../../../viewer/viewer-content-table/viewer-content-table\";\r\nimport Color from \"color\";\r\nimport {FakeStaticValueFilter} from \"./fake-static-value-filter\";\r\nimport {ColorLegendService} from \"../../../services/color-legend/color-legend-service\";\r\nimport {BuildingPartsComponent} from \"../../building-parts-component/building-parts-component\";\r\nimport {ModalService} from \"../../../services/modal-service\";\r\nimport {ObjectRow} from \"../../../services/object-list/object-list-row\";\r\nimport {ColorLegendUtils} from \"../../../services/color-legend/color-legend-utils\";\r\nimport {ColorVisibilityHandler} from \"./color-visibility-handler\";\r\n\r\ndeclare let $: any;\r\n\r\n@autoinject()\r\nexport class ColorLegend {\r\n\r\n\t@bindable public projectId : string = \"\";\r\n\t@bindable public isViewerVisible : boolean = false;\r\n\t@bindable public isBpVisible: boolean = false;\r\n\t@bindable public grid : BuildingPartsComponent | undefined;\r\n\r\n\tpublic objectFilterService: ObjectFilterService\r\n\tprivate colorVisibilityHandler: ColorVisibilityHandler;\r\n\t\r\n\tpublic filters: ValueFilter[] = [];\r\n\tpublic searchResults: ValueFilter[] = [];\r\n\tpublic shownLegends: ColorLegendDto[] = [];\r\n\r\n\tprivate valueToColorMap: Map | null = null; // Value --> Color in hex\r\n\tprivate isSelectedParameterAValueList: boolean = false;\r\n\r\n\tprivate valueListItemOrderingMap?: Map | null;\r\n\tpublic isSearching: boolean = false;\r\n\r\n\tpublic isHoveringOverParameterButtons: boolean = false;\r\n\tpublic selectedParameter: ValueFilter | null = null;\r\n\r\n\t@observable public searchText : string = \"\";\r\n\tprivate pageSize: number = 1000;\r\n\r\n\tprivate subscriptions: Subscription[] = [];\r\n\tpublic keyButtonHandling?: (this: Window, ev: KeyboardEvent) => any;\r\n\r\n\tconstructor(private valueListService : ValueListService, private colorLegendService: ColorLegendService, private api: ApiClient, private appContext: AppContextService, public events: EventAggregator, private i18n: I18N, public modal: ModalService) {\r\n\t\tthis.objectFilterService = new AocObjectFilterService(this.api, this.appContext.projectId); \r\n\t\tthis.colorVisibilityHandler = new ColorVisibilityHandler(events);\r\n\t}\r\n\r\n\tasync bind() {\r\n\t\tthis.setupKeyHandler();\r\n\t\tthis.filters = await this.getFilters();\r\n\t\tthis.searchResults = this.filters;\r\n\t}\r\n\t\r\n\tattached() {\r\n\t\tthis.subscriptions = [\r\n\t\t\tthis.events.subscribe(\"color-legend:update-colors\", async (data: ColorLegendUpdateColorsDto) => { await this.updateColors(data) }),\r\n\t\t\tthis.events.subscribe(\"color-legend:color-instances\", async () => { await this.colorInstances(this.selectedParameter) }),\r\n\t\t\tthis.events.subscribe(\"3dViewer:ShowAll\", () => { this.shownLegends.forEach(value => value.visibility = 'visible') }),\r\n\t\t\tthis.events.subscribe('3dViewer:TransluteAll', () => { this.shownLegends.forEach(value => value.visibility = 'translucent') }),\r\n\t\t\tthis.events.subscribe('3dViewer:HideAll', () => { this.shownLegends.forEach(value => value.visibility = 'hidden') }),\r\n\t\t]\r\n\t\t\r\n\t\tif (this.selectedParameter == null) {\t// Only focus if no parameter has been chosen, or it would get annoying\r\n\t\t\tconst searchBarElement: HTMLInputElement = $(\"#legend-search-bar\");\r\n\t\t\tsearchBarElement.focus();\r\n\t\t}\r\n\t}\r\n\t\r\n\tdetached() {\r\n\t\tthis.subscriptions.forEach(subscription => subscription.dispose());\r\n\t}\r\n\r\n\tsetupKeyHandler() {\r\n\t\tthis.keyButtonHandling = (event) => {\r\n\t\t\tif (event.key == \"Escape\") {\r\n\t\t\t\tthis.isSearching = false;\r\n\t\t\t\tthis.isHoveringOverParameterButtons = false;\r\n\t\t\t\tColorLegend.unfocusSearchBar();\r\n\t\t\t}\r\n\t\t};\r\n\t\twindow.addEventListener('keyup', this.keyButtonHandling, false);\r\n\t}\r\n\r\n\tprivate static unfocusSearchBar() {\r\n\t\tconst searchBarElement: HTMLInputElement = $(\"#legend-search-bar\");\r\n\t\tsearchBarElement.blur();\r\n\t}\r\n\r\n\tprivate async getFilters() : Promise {\r\n\t\t// Explanation of how static filters are implemented:\r\n\t\t// We cheat a bit to make the static filters family and type use the same mechanism a the parameters.\r\n\t\t// This is done by renaming the parameters 'TypeName' and 'FamilyName' in the UI to Type and Family.\r\n\t\t// Categories have their own implementation.\r\n\t\t\r\n\t\tlet filters = await this.getAllFilters();\r\n\t\t// (color-legend skal p.t. kun bruge isUsed og Name.)'\r\n\t\t\r\n\t\tfilters = filters.filter(value => !ColorLegend.isUnwantedFilter(value));\r\n\r\n\t\t// Replace the typeName and familyName parameters with fake filters to look like the static Family and Type filters\r\n\t\tfilters = filters.map((value: ValueFilter) => {\r\n\t\t\tif (value.name == \"TypeName\" || value.name == \"FamilyName\") {\r\n\t\t\t\treturn new FakeStaticValueFilter(value);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\treturn value;\r\n\t\t});\r\n\t\t\r\n\t\t// Make the new \"static\" filters first\r\n\t\tlet staticFilters = filters.filter(value => ColorLegend.isStaticFilterInColorLegend(value));\r\n\t\tlet otherFilters = filters.filter(value => !ColorLegend.isStaticFilterInColorLegend(value));\r\n\t\tfilters = [...staticFilters, ...otherFilters];\r\n\t\t\r\n\t\treturn filters;\r\n\t}\r\n\r\n\tprivate async getAllFilters():Promise {\r\n\t\tlet availableFilters:ValueFilter[] = await this.objectFilterService.getAvailableFilters([]);\r\n\t\treturn [...this.objectFilterService.getStaticFilters, ...availableFilters];\r\n\t}\r\n\r\n\tprivate static isUnwantedFilter(value: ValueFilter) : boolean {\r\n\t\tlet isRealStaticType = value.targetType === ObjectValues.targetTypes.instance ||\r\n\t\t\tvalue.targetType === ObjectValues.targetTypes.type ||\r\n\t\t\tvalue.targetType === ObjectValues.targetTypes.family;\r\n\t\t\r\n\t\tlet isInstanceParameter = value.targetType === ObjectValues.targetTypes.instanceParameter;\r\n\t\t\r\n\t\treturn isRealStaticType || isInstanceParameter;\r\n\t}\r\n\r\n\tpublic searchTextChanged(newValue: string) {\r\n\t\tthis.filterSearchResults(newValue);\r\n\t}\r\n\t\r\n\tpublic filterSearchResults(searchText: string) : void {\r\n\t\tif (searchText.length == 0) {\r\n\t\t\tthis.searchResults = this.filters;\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis.searchResults = this.filters.filter(value => value.name.toLowerCase().includes(searchText.toLowerCase()));\r\n\t}\r\n\r\n\tpublic async select(filter: ValueFilter) : Promise {\r\n\t\tconst filterActiveInGrid = this.isFilterActiveInGrid(filter);\r\n\t\tconst showError = this.isBpVisible && !this.isViewerVisible && !filterActiveInGrid;\r\n\t\tif (showError) {\r\n\t\t\tthis.modal.OpenMessage('Cannot display colors in grid','The selected parameter to color by needs to be selected as a filter in the grid.');\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t\r\n\t\tconsole.log('Parameter selected', filter)\r\n\t\tthis.shownLegends = [];\r\n\t\tthis.isSearching = false;\r\n\t\tthis.isHoveringOverParameterButtons = false;\r\n\t\tColorLegend.unfocusSearchBar();\r\n\t\t\r\n\t\tthis.searchText = filter.name;\r\n\t\tthis.filterSearchResults(filter.name);\t// Is updated due to search text being changed\r\n\t\tthis.selectedParameter = filter;\r\n\r\n\t\tthis.events.publish('object-grid:resetAllLockedColumns');\r\n\r\n\t\tawait this.colorLegendService.setActiveValueFilter(filter);\r\n\t\tlet mapOfColors: Map | undefined = this.colorLegendService.currentColorData?.colorMap;\r\n\t\tlet hasAValueList: boolean | undefined = this.colorLegendService.currentColorData?.hasValueList;\r\n\t\tlet valueListItemOrder: Map | null | undefined = this.colorLegendService.currentColorData?.valueListItemOrdering;\r\n\t\tthis.isSelectedParameterAValueList = Boolean(hasAValueList);\r\n\t\tif (valueListItemOrder) {\r\n\t\t\tthis.valueListItemOrderingMap = valueListItemOrder;\r\n\t\t}\r\n\t\tif (mapOfColors) {\t\r\n\t\t\tthis.valueToColorMap = mapOfColors;\r\n\t\t}\r\n\t\t\r\n\t\tif (this.isViewerVisible) {\r\n\t\t\tthis.events.publish('3dViewer:ShowAll');\t// Is this annoying for the user?\r\n\t\t\t/*\r\n\t\t\t Necessary due to instances being left translucent or invisible due to previous state thus making \r\n\t\t\t the statement \"all elements in this color is visible\" false.\r\n\t\t\t A possible improvement could be to only make instances that are colored in the new selected filter visible.\r\n\t\t\t (The entity labels of the newly colored instances are available in the colorInstances method body)\r\n\t\t\t*/\r\n\t\t\tawait this.colorInstances(filter);\r\n\t\t}\r\n\r\n\t\tthis.updateColorLegends();\r\n\t}\r\n\r\n\tpublic setSearching(newValue: boolean) : void {\r\n\t\t// If you are hovering over the buttons, then don't hide them before you've had the change to click on them\r\n\t\tif (this.isHoveringOverParameterButtons) return;\r\n\r\n\t\tthis.isSearching = newValue;\r\n\t}\r\n\t\r\n\tpublic setHover(newValue: boolean) : void {\r\n\t\tthis.isHoveringOverParameterButtons = newValue;\r\n\t}\r\n\r\n\tpublic async colorInstances(filter: ValueFilter | null): Promise {\r\n\t\tif (filter == null) {\r\n\t\t\tconsole.info('Coloring of instances is aborted. No filter was null')\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t\r\n\t\t// Reset old colors\r\n\t\tthis.events.publish('3dViewer:reset-colors');\r\n\t\t\r\n\t\t// this.shownLegends = [];\r\n\t\tthis.colorLegendService.clearInstanceData();\r\n\r\n\t\tlet moreEntries: boolean = true;\r\n\t\tlet pageNumber: number = 1;\r\n\t\t\r\n\t\t// Take a subset of the instances and color them. Repeat until done...\r\n\t\twhile (moreEntries) {\r\n\t\t\tlet instanceColoringData : InstanceColorData[] = \r\n\t\t\t\tawait this.getInstanceColoringData(pageNumber, filter);\r\n\t\t\t\r\n\t\t\tthis.colorLegendService.insertInstanceData(...instanceColoringData);\r\n\t\t\t\r\n\t\t\tif (instanceColoringData.length < this.pageSize) \r\n\t\t\t\tmoreEntries = false;\r\n\t\t\t\r\n\t\t\t// Color in viewer\r\n\t\t\tthis.colorViewerInstances(instanceColoringData);\r\n\t\t\t\r\n\t\t\tpageNumber++;\r\n\t\t}\r\n\t}\r\n\r\n\tresetColors() {\r\n\t\tthis.events.publish('3dViewer:reset-colors');\r\n\t\tthis.searchText = \"\";\r\n\t\tthis.isSearching = true;\r\n\t\tthis.selectedParameter = null;\r\n\t\tthis.shownLegends = [];\r\n\r\n\t\tthis.colorLegendService.clearColorInfo();\r\n\r\n\t\tconst searchBarElement: HTMLInputElement = $(\"#legend-search-bar\");\r\n\t\tsearchBarElement.focus();\r\n\t\tthis.events.publish('object-grid:resetAllLockedColumns');\t// Fixes issue with floating name cells \r\n\t}\r\n\r\n\tprivate updateColorLegends() : void {\r\n\t\tlet usedValues: Set | undefined = this.colorLegendService?.currentColorData?.usedValuesContainer.usedValues;\r\n\t\tif (usedValues) {\r\n\t\t\tthis.shownLegends = [...usedValues].map((value): ColorLegendDto => {\r\n\t\t\t\treturn {name: value, color: this.valueToColorMap?.get(value), visibility: ColorLegendVisibility.VISIBLE}\r\n\t\t\t})\t\r\n\t\t\tthis.sortLegends();\r\n\t\t}\r\n\t}\r\n\r\n\tprivate colorViewerInstances(instanceColoringData: InstanceColorData[]) : void {\r\n\t\tthis.events.publish('3dViewer:color-instances', {\r\n\t\t\tinstances: instanceColoringData,\r\n\t\t\tcolorMap: this.valueToColorMap\r\n\t\t});\r\n\t}\r\n\r\n\tprivate sortLegends() : void {\r\n\t\tif (ColorLegend.isStaticFilterInColorLegend(this.selectedParameter)) {\r\n\t\t\tthis.shownLegends.sort((a, b) => a.name.localeCompare(b.name))\r\n\t\t} \r\n\t\telse if (this.isSelectedParameterAValueList) {\r\n\t\t\t// Get value list ordering and use that to sort...\r\n\t\t\tthis.shownLegends.sort((a, b) => {\r\n\t\t\t\tconst aSortOrder = this.valueListItemOrderingMap?.get(a.name);\r\n\t\t\t\tconst bSortOrder = this.valueListItemOrderingMap?.get(b.name);\r\n\t\t\t\t\r\n\t\t\t\tif (aSortOrder && bSortOrder && aSortOrder === bSortOrder)\r\n\t\t\t\t\treturn aSortOrder - bSortOrder;\r\n\t\t\t\telse\r\n\t\t\t\t\treturn a.name.localeCompare(b.name);\r\n\t\t\t});\r\n\t\t}\r\n\t\t\r\n\t\t// It was not specified how we should sort the rest so we just sort alphabetically\r\n\t\tthis.shownLegends.sort((a, b) => a.name.localeCompare(b.name));\r\n\t}\r\n\r\n\tprivate async getInstanceColoringData(pageNumber: number, filter: ValueFilter) : Promise {\r\n\t\t\r\n\t\tif (ColorLegendUtils.isCategory(filter)) {\r\n\t\t\treturn await this.api.project(this.appContext.projectId).get(`ColorLegend/GetInstanceColoringDataForCategories/${pageNumber}/${this.pageSize}`)\r\n\t\t\t\t.handleError('Error retrieving instance coloring data', 'The instance data could not be retrieved')\r\n\t\t\t\t.jsonResult();\r\n\t\t} else {\r\n\t\t\treturn await this.api.project(this.appContext.projectId).get(`ColorLegend/GetInstanceColoringData/${this.selectedParameter?.targetId}/${pageNumber}/${this.pageSize}`)\r\n\t\t\t\t.handleError('Error retrieving instance coloring data', 'The instance data could not be retrieved')\r\n\t\t\t\t.jsonResult();\r\n\t\t}\r\n\t}\r\n\t\r\n\tprivate static isStaticFilterInColorLegend(value: ValueFilter | null) : boolean {\r\n\t\treturn value?.name == 'Type' || value?.name == 'Family' || value?.name == 'Category';\r\n\t}\r\n\r\n\tpublic async projectIdChanged() : Promise {\r\n\t\tawait this.projectChangedHandler();\r\n\t\tthis.colorLegendService.clearColorInfo();\r\n\t\tthis.colorLegendService.clearInstanceData();\r\n\t}\r\n\t\r\n\tprivate async projectChangedHandler(): Promise {\r\n\r\n\t\tthis.objectFilterService = new AocObjectFilterService(this.api, this.appContext.projectId);\t// To change the project id. I don't know if there is a better way...\r\n\t\tthis.filters = await this.getFilters();\r\n\t\tthis.searchResults = this.filters;\r\n\r\n\t\tthis.shownLegends = [];\r\n\t\tthis.valueToColorMap = null;\r\n\r\n\t\tthis.isSelectedParameterAValueList = false;\r\n\t\tthis.valueListItemOrderingMap = null;\r\n\r\n\t\tthis.selectedParameter = null;\r\n\t\tthis.isSearching = false;\r\n\t\tthis.searchText = \"\";\r\n\t}\r\n\t\r\n\tprivate async updateColors(data: ColorLegendUpdateColorsDto): Promise {\r\n\t\tlet {cell, row, rows} = data;\r\n\t\tif (!rows.includes(row)) {\r\n\t\t\trows = [row]\t// We don't want to alter the old selection array\r\n\t\t}\r\n\t\t\r\n\t\tif (this.selectedParameter == undefined) return;\r\n\t\tif (this.selectedParameter.targetId != cell.definitionId) return;\r\n\r\n\t\tlet typeIds: Set = ColorLegend.getSelectedTypeIds(rows);\r\n\r\n\t\tfor (let typeId of typeIds) {\r\n\t\t\tif (cell.newValue) {\r\n\t\t\t\tthis.colorLegendService.updateData(cell.newValue, typeId);\r\n\t\t\t}\r\n\t\t\tif (this.isViewerVisible) {\r\n\t\t\t\tconst instanceIfcData: IFC_Dto[] = await this.api.project(this.projectId)\r\n\t\t\t\t\t.get(`ObjectDetail/InstancesForType?TypeId=${typeId}`)\r\n\t\t\t\t\t.handleError(\"Could not get instances\", \"The instances for this type could not get fetched.\")\r\n\t\t\t\t\t.objectResult();\r\n\r\n\t\t\t\tlet instanceData: (InstanceColorData | undefined)[] = instanceIfcData.map(value => {\r\n\t\t\t\t\tif (value.ifC_EntityId && cell.newValue) {\r\n\t\t\t\t\t\tconst inst: InstanceColorData = {value: cell.newValue, entityLabel: value.ifC_EntityId}\r\n\t\t\t\t\t\treturn inst;\r\n\t\t\t\t\t}\r\n\t\t\t\t})\r\n\t\t\t\tthis.colorViewerInstances(instanceData.filter((data: InstanceColorData | undefined) => data != undefined));\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.updateColorLegends();\r\n\t\t// signalBindings('colors-changed');\t// Re-renders the grid view model\r\n\r\n\t\tconsole.log(typeIds);\r\n\t}\r\n\r\n\tprivate static getSelectedTypeIds(rows: ObjectRow[]) {\r\n\t\tlet allTypeIds: (string |undefined)[] = rows\r\n\t\t\t.map(value => value?.value?.typeId)\r\n\t\t\t.filter(value => value != null);\r\n\r\n\t\treturn new Set(allTypeIds.filter(data => data != undefined));\r\n\t}\r\n\r\n\tprivate isFilterActiveInGrid(filter: ValueFilter) : boolean {\r\n\t\tlet result: boolean | undefined = this.grid?.objects?.shownColumns?.some(column => column.name === filter.name);\r\n\t\treturn Boolean(result);\r\n\t}\r\n\t\r\n\tpublic toggleVisibility(legend: ColorLegendDto) {\r\n\t\tthis.colorVisibilityHandler.toggleVisibility(legend);\r\n\t\t\r\n\t\tconst entityLabels: number[] = this.colorLegendService.getInstanceEntityLabels(legend.name);\r\n\t\tthis.colorVisibilityHandler.setVisibilityInViewer(legend.visibility, entityLabels);\r\n\t}\r\n\t\r\n\tprivate showAllLegends() {\r\n\t\tconst visibility: VisibilitySettings = 'visible';\r\n\t\t\r\n\t\tconst allEntityLabels: number[] = this.colorLegendService.getAllEntityLabels();\r\n\t\tthis.colorVisibilityHandler.setVisibilityInViewer(visibility, allEntityLabels);\r\n\r\n\t\tthis.shownLegends.forEach(value => value.visibility = visibility)\r\n\t}\r\n\t\r\n\tprivate transluteAllLegends() {\r\n\t\tconst visibility: VisibilitySettings = 'translucent';\r\n\r\n\t\tconst allEntityLabels: number[] = this.colorLegendService.getAllEntityLabels();\r\n\t\tthis.colorVisibilityHandler.setVisibilityInViewer(visibility, allEntityLabels);\r\n\r\n\t\tthis.shownLegends.forEach(value => value.visibility = visibility)\r\n\t}\r\n\t\r\n\tprivate hideAllLegends() {\r\n\t\tconst visibility: VisibilitySettings = 'hidden';\r\n\r\n\t\tconst allEntityLabels: number[] = this.colorLegendService.getAllEntityLabels();\r\n\t\tthis.colorVisibilityHandler.setVisibilityInViewer(visibility, allEntityLabels);\r\n\r\n\t\tthis.shownLegends.forEach(value => value.visibility = visibility)\r\n\t}\r\n}\r\n","export enum FakeFilterMimicEnum {\r\n\tTYPE,\r\n\tFAMILY\r\n}\r\n","import {ValueFilter} from \"../../../models/object-filter\";\r\nimport {FakeFilterMimicEnum} from \"./fake-filter-mimic-enum\";\r\n\r\n/**\r\n * Used to differentiate between the real static filters and the fake ones we use in the color legend context\r\n */\r\nexport class FakeStaticValueFilter implements ValueFilter {\r\n\tconstructor(value: ValueFilter) {\r\n\t\tthis.targetType = value.targetType;\r\n\t\tthis.targetId = value.targetId ? value.targetId : \"\";\r\n\t\tthis.name = value.name;\r\n\t\tthis.type = value.type;\r\n\t\tthis.isUsed = value.isUsed == true;\r\n\t\tthis.SyncToAoc = value.SyncToAoc;\r\n\t\tthis.SyncToRevit = value.SyncToRevit;\r\n\t\tthis.syncDirection = value.syncDirection;\r\n\t\tthis.anyCat = value.anyCat;\r\n\t\tthis.readOnly = value.readOnly;\r\n\t\tthis.hasClassification = value.hasClassification;\r\n\r\n\t\tthis.isMimicking = value.name == \"TypeName\" ? FakeFilterMimicEnum.TYPE : FakeFilterMimicEnum.FAMILY;\r\n\t\tthis.name = this.name.replace('Name', '');\r\n\t}\r\n\t\r\n\ttargetType: string;\r\n\ttargetId: string;\r\n\tname: string;\r\n\ttype: string;\r\n\tisUsed: boolean;\r\n\tSyncToAoc?: boolean;\r\n\tSyncToRevit?: boolean;\r\n\tsyncDirection?: string;\r\n\tanyCat?: string;\r\n\treadOnly: boolean;//field-in-FakeStaticValueFilter.\r\n\thasClassification: boolean;\r\n\tisMimicking: FakeFilterMimicEnum\r\n}\r\n","import {UsedTypeValue} from \"../../../models/color-legend-dto\";\r\n\r\nexport class UsedTypeValuesContainer {\r\n\t\r\n\tprivate typeValues: Map;\t// typeId --> value\r\n\tprivate _usedValues: Set | undefined;\r\n\t\r\n\tconstructor(typeValues: UsedTypeValue[]) {\r\n\t\tthis.typeValues = new Map(typeValues.map(typeValue => [typeValue.prjRevitTypeId, typeValue.value]));\r\n\t\tthis.computeUsedValues()\r\n\t}\r\n\r\n\tget usedValues(): Set {\r\n\t\tif (this._usedValues == undefined) this.computeUsedValues();\r\n\t\treturn this._usedValues!;//Will get computed so we should be able to trust it.\r\n\t}\r\n\t\r\n\tpublic updateType(typeId: string, value: string): void {\r\n\t\tthis.typeValues.set(typeId, value);\r\n\t\tthis.computeUsedValues()\r\n\t}\r\n\t\r\n\tprivate computeUsedValues(): void {\r\n\t\tthis._usedValues = new Set(this.typeValues.values())\r\n\t}\r\n}\r\n"],"names":["___CSS_LOADER_EXPORT___","push","module","id","exports","ColorVisibilityHandler","constructor","events","this","toggleVisibility","colorLegend","nextVisibilityIndex","visibilitySettings","indexOf","visibility","length","setVisibilityInViewer","entityLabels","objectIds","revitObjectIds","publish","VISIBLE","TRANSLUCENT","HIDDEN","ColorLegend","valueListService","colorLegendService","api","appContext","i18n","modal","projectId","isViewerVisible","isBpVisible","filters","searchResults","shownLegends","valueToColorMap","isSelectedParameterAValueList","isSearching","isHoveringOverParameterButtons","selectedParameter","searchText","pageSize","subscriptions","objectFilterService","colorVisibilityHandler","bind","setupKeyHandler","getFilters","attached","subscribe","async","data","updateColors","colorInstances","forEach","value","$","focus","detached","subscription","dispose","keyButtonHandling","event","key","unfocusSearchBar","window","addEventListener","blur","getAllFilters","filter","isUnwantedFilter","map","name","staticFilters","isStaticFilterInColorLegend","otherFilters","availableFilters","getAvailableFilters","getStaticFilters","isRealStaticType","targetType","targetTypes","instance","type","family","isInstanceParameter","instanceParameter","searchTextChanged","newValue","filterSearchResults","toLowerCase","includes","select","filterActiveInGrid","isFilterActiveInGrid","OpenMessage","console","log","setActiveValueFilter","mapOfColors","currentColorData","colorMap","hasAValueList","hasValueList","valueListItemOrder","valueListItemOrdering","Boolean","valueListItemOrderingMap","updateColorLegends","setSearching","setHover","info","clearInstanceData","moreEntries","pageNumber","instanceColoringData","getInstanceColoringData","insertInstanceData","colorViewerInstances","resetColors","clearColorInfo","usedValues","usedValuesContainer","color","get","sortLegends","instances","sort","a","b","localeCompare","aSortOrder","bSortOrder","isCategory","project","handleError","jsonResult","targetId","projectIdChanged","projectChangedHandler","cell","row","rows","undefined","definitionId","typeIds","getSelectedTypeIds","typeId","updateData","instanceData","objectResult","ifC_EntityId","entityLabel","allTypeIds","Set","result","grid","objects","shownColumns","some","column","legend","getInstanceEntityLabels","showAllLegends","allEntityLabels","getAllEntityLabels","transluteAllLegends","hideAllLegends","bindable","observable","autoinject","EventAggregator","I18N","FakeFilterMimicEnum","FakeStaticValueFilter","isUsed","SyncToAoc","SyncToRevit","syncDirection","anyCat","readOnly","hasClassification","isMimicking","TYPE","FAMILY","replace","UsedTypeValuesContainer","typeValues","Map","typeValue","prjRevitTypeId","computeUsedValues","_usedValues","updateType","set","values"],"sourceRoot":""}