public isPaletteLoading: boolean;
private paletteDraggedElement: LeftPaletteComponent;
public position: Point = new Point();
+ private openAccordion: boolean = false;
ngOnInit() {
this.isPaletteLoading = true;
public buildPaletteByCategories = (searchText?: string) => { // create nested by category & subcategory, filtered by search parans
// Flat the object and run on its leaves
if (searchText) {
+ this.openAccordion = true;
searchText = searchText.toLowerCase();
const paletteElementsAfterSearch = {};
this.paletteElements = this.compositionPaletteService.getLeftPaletteElements();
const subCategoryToCheck = this.paletteElements[category][subCategory];
const res = subCategoryToCheck.filter((item) => item.searchFilterTerms.toLowerCase().indexOf(searchText) >= 0)
if (res.length > 0) {
- paletteElementsAfterSearch[category] = {};
+ if (paletteElementsAfterSearch[category] == null) {
+ paletteElementsAfterSearch[category] = {};
+ }
paletteElementsAfterSearch[category][subCategory] = res;
}
}
}
this.paletteElements = paletteElementsAfterSearch;
} else {
+ this.openAccordion = false;
this.paletteElements = this.compositionPaletteService.getLeftPaletteElements();
}
this.numberOfElements = this.countLeftPalleteElements(this.paletteElements);
return counter;
}
- private isGroupOrPolicy(component: LeftPaletteComponent): boolean {
- if (component &&
- (component.categoryType === LeftPaletteMetadataTypes.Group ||
- component.categoryType === LeftPaletteMetadataTypes.Policy)) {
- return true;
- }
- return false;
- }
@HostListener('document:dragover', ['$event'])
public onDrag(event) {
this.position.x = event.clientX;
}
- public onMouseOver = (sectionElem:MouseEvent, displayComponent:LeftPaletteComponent) => {
- console.debug("On palette element MOUSE HOVER: ", displayComponent);
- if (this.isGroupOrPolicy(displayComponent)) {
- this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_PALETTE_COMPONENT_SHOW_POPUP_PANEL, displayComponent, sectionElem.target);
- } else {
- this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_PALETTE_COMPONENT_HOVER_IN, displayComponent);
- }
- };
-
- public onMouseOut = (displayComponent:LeftPaletteComponent) => {
- console.debug("On palette element MOUSE OUT: ", displayComponent);
- if (this.isGroupOrPolicy(displayComponent)) {
- this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_PALETTE_COMPONENT_HIDE_POPUP_PANEL);
- } else {
- this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_PALETTE_COMPONENT_HOVER_OUT);
- }
- };
-
}