@@ -9,6 +9,7 @@ class AssetBrowserV2 {
99 this . openSvgAssetStudioV2 = this . openSvgAssetStudioV2 . bind ( this ) ;
1010 this . addAssetEntry = this . addAssetEntry . bind ( this ) ;
1111 this . currentSessionContext = null ;
12+ this . selectedAssetId = "" ;
1213 this . handleNavigationState = this . handleNavigationState . bind ( this ) ;
1314 window . addEventListener ( "popstate" , this . handleNavigationState ) ;
1415 window . addEventListener ( "pageshow" , this . handleNavigationState ) ;
@@ -127,6 +128,26 @@ class AssetBrowserV2 {
127128 document . getElementById ( "assetManagerV2ActionStatus" ) . textContent = message ;
128129 }
129130
131+ clearSelectedAssetDetails ( ) {
132+ document . getElementById ( "assetBrowserV2DetailsMessage" ) . textContent = "Select an asset entry to inspect its session metadata." ;
133+ document . getElementById ( "assetBrowserV2DetailId" ) . textContent = "-" ;
134+ document . getElementById ( "assetBrowserV2DetailLabel" ) . textContent = "-" ;
135+ document . getElementById ( "assetBrowserV2DetailKind" ) . textContent = "-" ;
136+ document . getElementById ( "assetBrowserV2DetailPath" ) . textContent = "-" ;
137+ }
138+
139+ renderSelectedAssetDetails ( assetEntry ) {
140+ if ( ! assetEntry ) {
141+ this . clearSelectedAssetDetails ( ) ;
142+ return ;
143+ }
144+ document . getElementById ( "assetBrowserV2DetailsMessage" ) . textContent = "Selected asset details." ;
145+ document . getElementById ( "assetBrowserV2DetailId" ) . textContent = assetEntry . id . trim ( ) ;
146+ document . getElementById ( "assetBrowserV2DetailLabel" ) . textContent = assetEntry . label . trim ( ) ;
147+ document . getElementById ( "assetBrowserV2DetailKind" ) . textContent = assetEntry . kind . trim ( ) ;
148+ document . getElementById ( "assetBrowserV2DetailPath" ) . textContent = assetEntry . path . trim ( ) ;
149+ }
150+
130151 normalizedAssetEntryFromForm ( ) {
131152 const id = typeof document . getElementById ( "assetManagerV2AddId" ) . value === "string" ? document . getElementById ( "assetManagerV2AddId" ) . value . trim ( ) : "" ;
132153 const label = typeof document . getElementById ( "assetManagerV2AddLabel" ) . value === "string" ? document . getElementById ( "assetManagerV2AddLabel" ) . value . trim ( ) : "" ;
@@ -150,6 +171,17 @@ class AssetBrowserV2 {
150171 document . getElementById ( "assetManagerV2AddPath" ) . value = "" ;
151172 }
152173
174+ selectedAssetEntryFromCatalogEntries ( entries ) {
175+ if ( ! Array . isArray ( entries ) ) {
176+ return null ;
177+ }
178+ if ( typeof this . selectedAssetId !== "string" || ! this . selectedAssetId . trim ( ) ) {
179+ return null ;
180+ }
181+ const selectedAssetEntry = entries . find ( ( entry ) => entry && typeof entry === "object" && ! Array . isArray ( entry ) && typeof entry . id === "string" && entry . id . trim ( ) === this . selectedAssetId ) ;
182+ return selectedAssetEntry || null ;
183+ }
184+
153185 addAssetEntry ( ) {
154186 if ( ! this . currentSessionContext || typeof this . currentSessionContext !== "object" || Array . isArray ( this . currentSessionContext ) ) {
155187 this . setActionStatus ( "Add blocked. No valid Asset Manager V2 session is loaded." ) ;
@@ -372,6 +404,10 @@ class AssetBrowserV2 {
372404 document . getElementById ( "assetBrowserV2InvalidState" ) . hidden = true ;
373405 document . getElementById ( "assetBrowserV2ValidState" ) . hidden = false ;
374406 this . currentSessionContext = this . cloneSessionValue ( sessionContext ) ;
407+ const selectedAssetEntry = this . selectedAssetEntryFromCatalogEntries ( assetCatalog . entries ) ;
408+ if ( ! selectedAssetEntry ) {
409+ this . selectedAssetId = "" ;
410+ }
375411
376412 document . getElementById ( "assetBrowserV2List" ) . replaceChildren ( ) ;
377413 assetCatalog . entries . forEach ( ( entry ) => {
@@ -386,28 +422,23 @@ class AssetBrowserV2 {
386422 assetMeta . textContent = `${ entry . kind . trim ( ) } | ${ entry . path . trim ( ) } ` ;
387423 assetItem . append ( assetName , assetMeta ) ;
388424 removeButton . textContent = `Remove ${ entry . id . trim ( ) } ` ;
425+ const entryIsSelected = typeof this . selectedAssetId === "string" && this . selectedAssetId . trim ( ) === entry . id . trim ( ) ;
426+ assetItem . setAttribute ( "aria-pressed" , entryIsSelected ? "true" : "false" ) ;
427+ assetItem . style . borderWidth = entryIsSelected ? "2px" : "" ;
428+ assetItem . style . borderStyle = entryIsSelected ? "solid" : "" ;
429+ assetItem . style . borderColor = entryIsSelected ? "#1f6feb" : "" ;
430+ assetItem . style . backgroundColor = entryIsSelected ? "#dbeafe" : "" ;
389431 assetItem . addEventListener ( "click" , ( ) => {
390- document . getElementById ( "assetBrowserV2Preview" ) . textContent = JSON . stringify (
391- {
392- id : entry . id . trim ( ) ,
393- label : entry . label . trim ( ) ,
394- kind : entry . kind . trim ( ) ,
395- path : entry . path . trim ( )
396- } ,
397- null ,
398- 2
399- ) ;
432+ this . selectedAssetId = entry . id . trim ( ) ;
433+ this . renderCatalog ( assetCatalog , sessionContext ) ;
400434 } ) ;
401435 removeButton . addEventListener ( "click" , ( ) => {
402436 this . removeAssetEntryById ( entry . id . trim ( ) ) ;
403437 } ) ;
404438 assetRow . append ( assetItem , removeButton ) ;
405439 document . getElementById ( "assetBrowserV2List" ) . appendChild ( assetRow ) ;
406440 } ) ;
407-
408- document . getElementById ( "assetBrowserV2Preview" ) . textContent = assetCatalog . entries . length === 0
409- ? "No assets are available in this session catalog."
410- : "Select an asset entry to inspect its session metadata." ;
441+ this . renderSelectedAssetDetails ( this . selectedAssetEntryFromCatalogEntries ( assetCatalog . entries ) ) ;
411442 }
412443
413444 renderMissing ( message ) {
@@ -422,7 +453,8 @@ class AssetBrowserV2 {
422453 document . getElementById ( "assetBrowserV2InvalidState" ) . hidden = true ;
423454 document . getElementById ( "assetBrowserV2ValidState" ) . hidden = true ;
424455 document . getElementById ( "assetBrowserV2List" ) . replaceChildren ( ) ;
425- document . getElementById ( "assetBrowserV2Preview" ) . textContent = "" ;
456+ this . selectedAssetId = "" ;
457+ this . clearSelectedAssetDetails ( ) ;
426458 this . currentSessionContext = null ;
427459 this . setActionStatus ( "No asset action yet." ) ;
428460 }
@@ -439,7 +471,8 @@ class AssetBrowserV2 {
439471 document . getElementById ( "assetBrowserV2InvalidState" ) . hidden = false ;
440472 document . getElementById ( "assetBrowserV2ValidState" ) . hidden = true ;
441473 document . getElementById ( "assetBrowserV2List" ) . replaceChildren ( ) ;
442- document . getElementById ( "assetBrowserV2Preview" ) . textContent = "" ;
474+ this . selectedAssetId = "" ;
475+ this . clearSelectedAssetDetails ( ) ;
443476 this . currentSessionContext = null ;
444477 this . setActionStatus ( "No asset action yet." ) ;
445478 }
0 commit comments