@@ -9,30 +9,33 @@ import {updateDocumentInOpenSCD} from "../compas/foundation.js";
9
9
import "../compas/CompasOpen.js" ;
10
10
11
11
export default class CompasOpenMenuPlugin extends LitElement {
12
- async run ( ) : Promise < void > {
13
- this . dispatchEvent ( newWizardEvent ( openCompasWizard ( ) ) ) ;
12
+ parent ! : HTMLElement ;
13
+
14
+ private openCompasWizard ( parent : HTMLElement ) : Wizard {
15
+ async function openDoc ( parent : Element , event : DocRetrievedEvent ) : Promise < void > {
16
+ updateDocumentInOpenSCD ( event . detail . doc , event . detail . docName ) ;
17
+ parent . dispatchEvent ( newWizardEvent ( ) ) ;
18
+ }
19
+
20
+ return [
21
+ {
22
+ title : get ( 'compas.open.title' ) ,
23
+ content : [
24
+ html `< compas-open @docRetrieved =${ ( event : DocRetrievedEvent ) => {
25
+ parent . dispatchEvent ( newPendingStateEvent ( openDoc ( parent , event ) ) ) ;
26
+ } } >
27
+ </ compas-open >
28
+ ` ,
29
+ ] ,
30
+ } ,
31
+ ] ;
14
32
}
15
- }
16
33
17
- function openCompasWizard ( ) : Wizard {
18
- async function openDoc ( element : Element , sclDocument : Document , docName ?: string ) : Promise < void > {
19
- updateDocumentInOpenSCD ( sclDocument , docName ) ;
20
- element . dispatchEvent ( newWizardEvent ( ) ) ;
34
+ firstUpdated ( ) : void {
35
+ this . parent = this . parentElement ! ;
21
36
}
22
37
23
- return [
24
- {
25
- title : get ( 'compas.open.title' ) ,
26
- content : [
27
- html `< compas-open @docRetrieved =${ ( evt : DocRetrievedEvent ) => {
28
- const element = evt . detail . element ;
29
- const doc = evt . detail . doc ;
30
- const docName = evt . detail . docName ;
31
- element . dispatchEvent ( newPendingStateEvent ( openDoc ( element , doc , docName ) ) ) ;
32
- } } >
33
- </ compas-open >
34
- ` ,
35
- ] ,
36
- } ,
37
- ] ;
38
+ async run ( ) : Promise < void > {
39
+ this . dispatchEvent ( newWizardEvent ( this . openCompasWizard ( this . parent ) ) ) ;
40
+ }
38
41
}
0 commit comments