@@ -16,6 +16,7 @@ import { Button } from '@material/mwc-button';
16
16
import { ListItem } from '@material/mwc-list/mwc-list-item' ;
17
17
18
18
import './data-set-element-editor.js' ;
19
+ import './report-control-element-editor.js' ;
19
20
import '../../filtered-list.js' ;
20
21
import { FilteredList } from '../../filtered-list.js' ;
21
22
@@ -27,22 +28,41 @@ import { styles } from './foundation.js';
27
28
export class ReportControlEditor extends LitElement {
28
29
/** The document being edited as provided to plugins by [[`OpenSCD`]]. */
29
30
@property ( { attribute : false } )
30
- doc ! : XMLDocument ;
31
+ set doc ( newDoc : XMLDocument ) {
32
+ if ( this . _doc === newDoc ) return ;
33
+
34
+ this . selectedDataSet = undefined ;
35
+ this . selectedReportControl = undefined ;
36
+
37
+ this . _doc = newDoc ;
38
+
39
+ this . requestUpdate ( ) ;
40
+ }
41
+ get doc ( ) : XMLDocument {
42
+ return this . _doc ;
43
+ }
44
+ private _doc ! : XMLDocument ;
31
45
32
46
@state ( )
33
- selectedReportControl ?: Element | null ;
47
+ selectedReportControl ?: Element ;
48
+ @state ( )
49
+ selectedDataSet ?: Element | null ;
34
50
35
51
@query ( '.selectionlist' ) selectionList ! : FilteredList ;
36
52
@query ( 'mwc-button' ) selectReportControlButton ! : Button ;
37
53
38
54
private selectReportControl ( evt : Event ) : void {
39
55
const id = ( ( evt . target as FilteredList ) . selected as ListItem ) . value ;
40
56
const reportControl = this . doc . querySelector ( selector ( 'ReportControl' , id ) ) ;
57
+ if ( ! reportControl ) return ;
58
+
59
+ this . selectedReportControl = reportControl ;
41
60
42
- if ( reportControl ) {
43
- this . selectedReportControl = reportControl . parentElement ?. querySelector (
44
- `DataSet[name="${ reportControl . getAttribute ( 'datSet' ) } "]`
45
- ) ;
61
+ if ( this . selectedReportControl ) {
62
+ this . selectedDataSet =
63
+ this . selectedReportControl . parentElement ?. querySelector (
64
+ `DataSet[name="${ this . selectedReportControl . getAttribute ( 'datSet' ) } "]`
65
+ ) ;
46
66
( evt . target as FilteredList ) . classList . add ( 'hidden' ) ;
47
67
this . selectReportControlButton . classList . remove ( 'hidden' ) ;
48
68
}
@@ -52,8 +72,13 @@ export class ReportControlEditor extends LitElement {
52
72
if ( this . selectedReportControl !== undefined )
53
73
return html `<div class= "elementeditorcontainer" >
54
74
<data- set- element- edito r
55
- .element = ${ this . selectedReportControl }
75
+ .doc = ${ this . doc }
76
+ .element = ${ this . selectedDataSet ! }
56
77
> </ data- set- element- edito r>
78
+ <repor t- control- element- edito r
79
+ .doc = ${ this . doc }
80
+ .element = ${ this . selectedReportControl }
81
+ > </ repor t- control- element- edito r>
57
82
</ div> ` ;
58
83
59
84
return html `` ;
@@ -120,5 +145,30 @@ export class ReportControlEditor extends LitElement {
120
145
121
146
static styles = css `
122
147
${ styles }
148
+
149
+ .elementeditorcontainer {
150
+ flex : 65% ;
151
+ margin : 4px 8px 4px 4px ;
152
+ background-color : var (--mdc-theme-surface );
153
+ overflow-y : scroll;
154
+ display : grid;
155
+ grid-gap : 12px ;
156
+ padding : 8px 12px 16px ;
157
+ grid-template-columns : repeat (3 , 1fr );
158
+ }
159
+
160
+ data-set-element-editor {
161
+ grid-column : 1 / 2 ;
162
+ }
163
+
164
+ report-control-element-editor {
165
+ grid-column : 2 / 4 ;
166
+ }
167
+
168
+ @media (max-width : 950px ) {
169
+ .elementeditorcontainer {
170
+ display : block;
171
+ }
172
+ }
123
173
` ;
124
174
}
0 commit comments