@@ -18,15 +18,15 @@ import {
18
18
EditorAction ,
19
19
getValue ,
20
20
identity ,
21
- newActionEvent ,
22
21
newSubWizardEvent ,
23
- newWizardEvent ,
24
22
patterns ,
25
23
Replace ,
26
24
selector ,
27
25
Wizard ,
26
+ WizardAction ,
28
27
WizardActor ,
29
28
WizardInput ,
29
+ WizardMenuActor ,
30
30
} from '../../foundation.js' ;
31
31
import { createBDAWizard , editBDAWizard } from '../../wizards/bda.js' ;
32
32
import {
@@ -35,6 +35,18 @@ import {
35
35
unifyCreateActionArray ,
36
36
} from './foundation.js' ;
37
37
38
+ function remove ( element : Element ) : WizardMenuActor {
39
+ return ( ) : EditorAction [ ] => {
40
+ return [ { old : { parent : element . parentElement ! , element } } ] ;
41
+ } ;
42
+ }
43
+
44
+ function openAddBda ( parent : Element ) : WizardMenuActor {
45
+ return ( ) : WizardAction [ ] => {
46
+ return [ ( ) => createBDAWizard ( parent ) ] ;
47
+ } ;
48
+ }
49
+
38
50
function updateDATpyeAction ( element : Element ) : WizardActor {
39
51
return ( inputs : WizardInput [ ] ) : EditorAction [ ] => {
40
52
const id = getValue ( inputs . find ( i => i . label === 'id' ) ! ) ! ;
@@ -88,25 +100,19 @@ export function editDaTypeWizard(
88
100
label : get ( 'save' ) ,
89
101
action : updateDATpyeAction ( datype ) ,
90
102
} ,
103
+ menuActions : [
104
+ {
105
+ label : get ( 'remove' ) ,
106
+ icon : 'delete' ,
107
+ action : remove ( datype ) ,
108
+ } ,
109
+ {
110
+ label : get ( 'scl.DA' ) ,
111
+ icon : 'playlist_add' ,
112
+ action : openAddBda ( datype ) ,
113
+ } ,
114
+ ] ,
91
115
content : [
92
- html `< mwc-button
93
- icon ="delete "
94
- trailingIcon
95
- label ="${ translate ( 'remove' ) } "
96
- @click =${ ( e : MouseEvent ) => {
97
- e . target ! . dispatchEvent ( newWizardEvent ( ) ) ;
98
- e . target ! . dispatchEvent (
99
- newActionEvent ( {
100
- old : {
101
- parent : datype . parentElement ! ,
102
- element : datype ,
103
- reference : datype . nextSibling ,
104
- } ,
105
- } )
106
- ) ;
107
- } }
108
- fullwidth
109
- > </ mwc-button > ` ,
110
116
html `< wizard-textfield
111
117
label ="id "
112
118
helper ="${ translate ( 'scl.id' ) } "
@@ -124,44 +130,29 @@ export function editDaTypeWizard(
124
130
nullable
125
131
pattern ="${ patterns . normalizedString } "
126
132
> </ wizard-textfield > ` ,
127
- html `< mwc-button
128
- slot ="graphic "
129
- icon ="playlist_add "
130
- trailingIcon
131
- label ="${ translate ( 'scl.DA' ) } "
132
- @click =${ ( e : Event ) => {
133
- if ( datype )
134
- e . target ! . dispatchEvent (
135
- newSubWizardEvent ( createBDAWizard ( datype ) )
136
- ) ;
137
- } }
138
- > </ mwc-button >
139
- < mwc-list
140
- style ="margin-top: 0px; "
141
- @selected =${ ( e : SingleSelectedEvent ) => {
142
- const bdaIdentity = ( < ListItem > ( < List > e . target ) . selected ) . value ;
143
- const bda = doc . querySelector ( selector ( 'BDA' , bdaIdentity ) ) ;
133
+ html `< mwc-list
134
+ style ="margin-top: 0px; "
135
+ @selected =${ ( e : SingleSelectedEvent ) => {
136
+ const bdaIdentity = ( < ListItem > ( < List > e . target ) . selected ) . value ;
137
+ const bda = doc . querySelector ( selector ( 'BDA' , bdaIdentity ) ) ;
144
138
145
- if ( bda )
146
- e . target ! . dispatchEvent ( newSubWizardEvent ( editBDAWizard ( bda ) ) ) ;
147
- } }
148
- >
149
- ${ Array . from ( datype . querySelectorAll ( 'BDA' ) ) . map (
150
- bda =>
151
- html `< mwc-list-item
152
- twoline
153
- tabindex ="0 "
154
- value ="${ identity ( bda ) } "
155
- > < span > ${ bda . getAttribute ( 'name' ) } </ span
156
- > < span slot ="secondary "
157
- > ${ bda . getAttribute ( 'bType' ) === 'Enum' ||
158
- bda . getAttribute ( 'bType' ) === 'Struct'
159
- ? '#' + bda . getAttribute ( 'type' )
160
- : bda . getAttribute ( 'bType' ) } </ span
161
- > </ mwc-list-item
162
- > `
163
- ) }
164
- </ mwc-list > ` ,
139
+ if ( bda )
140
+ e . target ! . dispatchEvent ( newSubWizardEvent ( editBDAWizard ( bda ) ) ) ;
141
+ } }
142
+ >
143
+ ${ Array . from ( datype . querySelectorAll ( 'BDA' ) ) . map (
144
+ bda =>
145
+ html `< mwc-list-item twoline tabindex ="0 " value ="${ identity ( bda ) } "
146
+ > < span > ${ bda . getAttribute ( 'name' ) } </ span
147
+ > < span slot ="secondary "
148
+ > ${ bda . getAttribute ( 'bType' ) === 'Enum' ||
149
+ bda . getAttribute ( 'bType' ) === 'Struct'
150
+ ? '#' + bda . getAttribute ( 'type' )
151
+ : bda . getAttribute ( 'bType' ) } </ span
152
+ > </ mwc-list-item
153
+ > `
154
+ ) }
155
+ </ mwc-list > ` ,
165
156
] ,
166
157
} ,
167
158
] ;
0 commit comments