From 63c5f804bdf7d3d646516e83f056c52b06cae0fd Mon Sep 17 00:00:00 2001
From: Pratham <162104630+Pratz2005@users.noreply.github.com>
Date: Tue, 17 Dec 2024 18:18:25 +0800
Subject: [PATCH] fixed collectioninfo dropdown order
---
.../src/event-display.ts | 21 +++++------
.../src/loaders/event-data-loader.ts | 4 +-
.../src/loaders/phoenix-loader.ts | 37 ++++++++++---------
.../collections-info-overlay.component.html | 11 ++++--
.../collections-info-overlay.component.ts | 20 +++++++---
5 files changed, 53 insertions(+), 40 deletions(-)
diff --git a/packages/phoenix-event-display/src/event-display.ts b/packages/phoenix-event-display/src/event-display.ts
index 8d4ded2b..92d2304c 100644
--- a/packages/phoenix-event-display/src/event-display.ts
+++ b/packages/phoenix-event-display/src/event-display.ts
@@ -1,18 +1,17 @@
-import { httpRequest, openFile } from 'jsroot';
-import { settings as jsrootSettings } from 'jsroot';
+import { httpRequest, settings as jsrootSettings, openFile } from 'jsroot';
import { build } from 'jsroot/geom';
-import { ThreeManager } from './managers/three-manager/index';
-import { UIManager } from './managers/ui-manager/index';
+import { ActiveVariable } from './helpers/active-variable';
import { InfoLogger } from './helpers/info-logger';
+import { getLabelTitle } from './helpers/labels';
import type { Configuration } from './lib/types/configuration';
-import { StateManager } from './managers/state-manager';
+import { PhoenixLoader } from './loaders/phoenix-loader';
import { LoadingManager } from './managers/loading-manager';
-import { URLOptionsManager } from './managers/url-options-manager';
-import { ActiveVariable } from './helpers/active-variable';
+import { StateManager } from './managers/state-manager';
import type { AnimationPreset } from './managers/three-manager/animations-manager';
+import { ThreeManager } from './managers/three-manager/index';
import { XRSessionType } from './managers/three-manager/xr/xr-manager';
-import { getLabelTitle } from './helpers/labels';
-import { PhoenixLoader } from './loaders/phoenix-loader';
+import { UIManager } from './managers/ui-manager/index';
+import { URLOptionsManager } from './managers/url-options-manager';
declare global {
/**
@@ -540,11 +539,11 @@ export class EventDisplay {
* Get the different collections for the current stored event.
* @returns List of strings, each representing a collection of the event displayed.
*/
- public getCollections(): string[] {
+ public getCollections(): { [key: string]: string[] } {
if (this.configuration.eventDataLoader) {
return this.configuration.eventDataLoader.getCollections();
}
- return [];
+ return {};
}
/**
diff --git a/packages/phoenix-event-display/src/loaders/event-data-loader.ts b/packages/phoenix-event-display/src/loaders/event-data-loader.ts
index ccb38b85..4878d591 100644
--- a/packages/phoenix-event-display/src/loaders/event-data-loader.ts
+++ b/packages/phoenix-event-display/src/loaders/event-data-loader.ts
@@ -1,6 +1,6 @@
+import { InfoLogger } from '../helpers/info-logger';
import { ThreeManager } from '../managers/three-manager/index';
import { UIManager } from '../managers/ui-manager/index';
-import { InfoLogger } from '../helpers/info-logger';
/**
* Event data loader for implementing different event data loaders.
@@ -32,7 +32,7 @@ export interface EventDataLoader {
* Get the different collections for the current stored event.
* @returns List of strings, each representing a collection of the event displayed.
*/
- getCollections(): string[];
+ getCollections(): { [key: string]: string[] };
/**
* Get all the objects inside a collection.
diff --git a/packages/phoenix-event-display/src/loaders/phoenix-loader.ts b/packages/phoenix-event-display/src/loaders/phoenix-loader.ts
index 0e7ed6aa..279680d6 100644
--- a/packages/phoenix-event-display/src/loaders/phoenix-loader.ts
+++ b/packages/phoenix-event-display/src/loaders/phoenix-loader.ts
@@ -1,19 +1,19 @@
-import { Group, Object3D, Vector3 } from 'three';
import { GUI } from 'dat.gui';
-import type { EventDataLoader } from './event-data-loader';
-import { UIManager } from '../managers/ui-manager/index';
-import { ThreeManager } from '../managers/three-manager/index';
-import { Cut } from '../lib/models/cut.model';
-import { PhoenixObjects } from './objects/phoenix-objects';
+import * as _ from 'lodash';
+import { Group, Object3D, Vector3 } from 'three';
+import { CoordinateHelper } from '../helpers/coordinate-helper';
import { InfoLogger } from '../helpers/info-logger';
-import { PhoenixMenuNode } from '../managers/ui-manager/phoenix-menu/phoenix-menu-node';
+import { getLabelTitle } from '../helpers/labels';
+import { Cut } from '../lib/models/cut.model';
import { LoadingManager } from '../managers/loading-manager';
import { StateManager } from '../managers/state-manager';
-import { CoordinateHelper } from '../helpers/coordinate-helper';
-import { getLabelTitle } from '../helpers/labels';
+import { ThreeManager } from '../managers/three-manager/index';
import { DatGUIMenuUI } from '../managers/ui-manager/dat-gui-ui';
+import { UIManager } from '../managers/ui-manager/index';
+import { PhoenixMenuNode } from '../managers/ui-manager/phoenix-menu/phoenix-menu-node';
import { PhoenixMenuUI } from '../managers/ui-manager/phoenix-menu/phoenix-menu-ui';
-import * as _ from 'lodash';
+import type { EventDataLoader } from './event-data-loader';
+import { PhoenixObjects } from './objects/phoenix-objects';
/**
* Loader for processing and loading an event.
@@ -100,23 +100,24 @@ export class PhoenixLoader implements EventDataLoader {
* Get list of collections in the event data.
* @returns List of all collection names.
*/
- public getCollections(): string[] {
+ public getCollections(): { [key: string]: string[] } {
if (!this.eventData) {
- return [];
+ return {};
}
- const collections = [];
+ const collectionsByType: { [key: string]: string[] } = {};
+
for (const objectType in this.eventData) {
if (
this.eventData[objectType] &&
- typeof this.eventData[objectType] === 'object'
+ typeof this.eventData[objectType] == 'object'
) {
- for (const collection in this.eventData[objectType]) {
- collections.push(collection);
- }
+ collectionsByType[objectType] = Object.keys(
+ this.eventData[objectType],
+ ).sort();
}
}
- return collections;
+ return collectionsByType;
}
/**
diff --git a/packages/phoenix-ng/projects/phoenix-ui-components/lib/components/ui-menu/collections-info/collections-info-overlay/collections-info-overlay.component.html b/packages/phoenix-ng/projects/phoenix-ui-components/lib/components/ui-menu/collections-info/collections-info-overlay/collections-info-overlay.component.html
index 21562fa5..8c8f1b6c 100644
--- a/packages/phoenix-ng/projects/phoenix-ui-components/lib/components/ui-menu/collections-info/collections-info-overlay/collections-info-overlay.component.html
+++ b/packages/phoenix-ng/projects/phoenix-ui-components/lib/components/ui-menu/collections-info/collections-info-overlay/collections-info-overlay.component.html
@@ -21,9 +21,14 @@
(change)="changeCollection($event.target.value)"
>
-
+
(this.collections = this.eventDisplay.getCollections()),
- );
+ this.eventDisplay.listenToDisplayedEventChange(() => {
+ const collectionsGrouped: { [key: string]: string[] } =
+ this.eventDisplay.getCollections();
+ this.collections = Object.entries(collectionsGrouped).map(
+ ([type, collections]: [string, string[]]) => ({
+ type,
+ collections,
+ }),
+ );
+ });
+
this.activeObject = this.eventDisplay.getActiveObjectId();
this.activeObject.onUpdate((value: string) => {
if (document.getElementById(value)) {