@@ -3,22 +3,22 @@ import { translate, get } from 'lit-translate';
3
3
4
4
import '@material/mwc-fab' ;
5
5
6
+ import './communication/subnetwork-editor.js' ;
6
7
import {
7
8
newWizardEvent ,
8
9
newActionEvent ,
9
10
createElement ,
11
+ isPublic ,
10
12
} from '../foundation.js' ;
11
- import { selectors , styles } from './communication/foundation.js' ;
12
- import './communication/subnetwork-editor.js' ;
13
- import { subNetworkWizard } from './communication/subnetwork-editor.js' ;
13
+ import { createSubNetworkWizard } from '../wizards/subnetwork.js' ;
14
14
15
15
/** An editor [[`plugin`]] for editing the `Communication` section. */
16
16
export default class CommunicationPlugin extends LitElement {
17
17
/** The document being edited as provided to plugins by [[`OpenSCD`]]. */
18
18
@property ( )
19
19
doc ! : XMLDocument ;
20
20
21
- createCommunication ( ) : void {
21
+ private createCommunication ( ) : void {
22
22
this . dispatchEvent (
23
23
newActionEvent ( {
24
24
new : {
@@ -30,21 +30,15 @@ export default class CommunicationPlugin extends LitElement {
30
30
}
31
31
32
32
/** Opens a [[`WizardDialog`]] for creating a new `SubNetwork` element. */
33
- openCreateSubNetworkWizard ( ) : void {
34
- if ( ! this . doc . querySelector ( selectors . Communication ) )
35
- this . createCommunication ( ) ;
33
+ private openCreateSubNetworkWizard ( ) : void {
34
+ const parent = this . doc . querySelector ( ':root > Communication' ) ;
35
+ if ( ! parent ) this . createCommunication ( ) ;
36
36
37
- this . dispatchEvent (
38
- newWizardEvent (
39
- subNetworkWizard ( {
40
- parent : this . doc . querySelector ( 'Communication' ) ! ,
41
- } )
42
- )
43
- ) ;
37
+ this . dispatchEvent ( newWizardEvent ( createSubNetworkWizard ( parent ! ) ) ) ;
44
38
}
45
39
46
40
render ( ) : TemplateResult {
47
- if ( ! this . doc ?. querySelector ( selectors . SubNetwork ) )
41
+ if ( ! this . doc ?. querySelector ( ':root > Communication > SubNetwork' ) )
48
42
return html `<h1>
49
43
<span style= "color: var(--base1)"
50
44
> ${ translate ( 'communication.missing' ) } </ span
@@ -55,29 +49,43 @@ export default class CommunicationPlugin extends LitElement {
55
49
@click = ${ ( ) => this . openCreateSubNetworkWizard ( ) }
56
50
> </ mwc- fab>
57
51
</ h1> ` ;
52
+
58
53
return html `<mwc- fab
59
54
extended
60
55
icon= "add"
61
56
label = "${ get ( 'subnetwork.wizard.title.add' ) } "
62
57
@click = ${ ( ) => this . openCreateSubNetworkWizard ( ) }
63
- > </ mwc- fab
64
- > ${ Array . from ( this . doc . querySelectorAll ( selectors . SubNetwork ) ?? [ ] ) . map (
65
- subnetwork =>
66
- html `<subnetwor k- edito r .element = ${ subnetwork } > </ subnetwor k- edito r> `
67
- ) } `;
58
+ > </ mwc- fab>
59
+ <section>
60
+ ${ Array . from ( this . doc . querySelectorAll ( 'SubNetwork' ) ?? [ ] )
61
+ . filter ( isPublic )
62
+ . map (
63
+ subnetwork =>
64
+ html `<subnetwor k- edito r
65
+ .element = ${ subnetwork }
66
+ > </ subnetwor k- edito r> `
67
+ ) }
68
+ </ section> ` ;
68
69
}
69
70
70
71
static styles = css `
71
- ${ styles }
72
+ : host {
73
+ width : 100vw ;
74
+ }
75
+
76
+ section {
77
+ outline : none;
78
+ padding : 8px 12px 16px ;
79
+ }
80
+
81
+ subnetwork-editor {
82
+ margin : 8px 12px 16px ;
83
+ }
72
84
73
85
mwc-fab {
74
86
position : fixed;
75
87
bottom : 32px ;
76
88
right : 32px ;
77
89
}
78
-
79
- : host {
80
- width: 100vw;
81
- }
82
90
` ;
83
91
}
0 commit comments