1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- import '@material/mwc-fab' ;
1615import '@material/mwc-button' ;
1716import './filtered_images_ui' ;
1817import './filters_ui' ;
@@ -31,9 +30,7 @@ import {State} from './state';
3130@customElement ( 'batch-selection-ui' )
3231export class BatchSelectionUi extends LitElement {
3332 @property ( { attribute : false } ) state ! : State ;
34-
35- /** The selected batch. */
36- private batchSelection : BatchSelection | undefined = undefined ;
33+ @property ( { attribute : false } ) batchSelection ! : BatchSelection ;
3734
3835 @query ( 'filtered-images-ui' )
3936 private readonly filteredImagesUi : FilteredImagesUi | undefined ;
@@ -43,125 +40,36 @@ export class BatchSelectionUi extends LitElement {
4340 listen ( EventType . MATCHED_DATA_POINTS_CHANGED , ( ) => {
4441 this . filteredImagesUi ?. requestUpdate ( ) ;
4542 } ) ;
46- listen ( EventType . FILTERED_DATA_INFO_REQUEST , ( event ) => {
47- this . batchSelection = this . state . batchSelections [ event . detail . batchIndex ] ;
48- this . style . display = 'block' ;
49- this . requestUpdate ( ) ;
50- } ) ;
5143 }
5244
5345 override render ( ) {
54- if ( ! this . batchSelection ) return html `` ;
55-
56- const onClose = ( ) => {
57- this . batchSelection = undefined ;
58- this . style . display = 'none' ;
59- this . requestUpdate ( ) ;
60- } ;
61-
6246 const batchIndex = this . batchSelection . batch . index ;
6347 const onBatchInfoRequest = ( ) => {
6448 dispatch ( EventType . BATCH_INFO_REQUEST , { batchIndex} ) ;
65- onClose ( ) ;
6649 } ;
6750 const onMatchesInfoRequest = ( ) => {
6851 dispatch ( EventType . MATCHES_INFO_REQUEST , { batchIndex} ) ;
69- onClose ( ) ;
7052 } ;
7153
7254 return html `
73- <div id= "background" @click = ${ onClose } > </ div>
74- <div id= "dialog" @click = ${ ( e : Event ) => {
75- e . stopImmediatePropagation ( ) ;
76- } } >
77- <div class= "horizontalFlex" >
78- <filters- ui .state = ${ this . state }
79- .batchSelection = ${ this . batchSelection } >
80- </ filters- ui>
81- <filtered- images- ui .state = ${ this . state }
82- .batchSelection = ${ this . batchSelection } >
83- </ filtered- images- ui>
84- </ div>
85-
86- <div class= "buttons" >
87- <mwc- butto n
88- rais ed
89- icon= "info"
90- label = "Show metadata"
91- title= "Display the details of the batch"
92- @click = ${ onBatchInfoRequest } >
93- </ mwc- butto n>
94-
95- ${
96- batchIndex === this . state . referenceBatchSelectionIndex ?
97- // disabled mwc-button title does not appear. Use a div.
98- html `
99- <div title= "The reference batch cannot be matched with itself" >
100- <mwc- butto n
101- rais ed
102- icon= "join_inner"
103- label = "Show matches"
104- disabled >
105- </ mwc- butto n>
106- </ div>
107- ` :
108- html `
109- <mwc- butto n
110- rais ed
111- icon= "join_inner"
112- label = "Show matches"
113- title = "Display the matches between this batch and the reference batch"
114- @click = ${ onMatchesInfoRequest } >
115- </ mwc- butto n>
116- ` }
117- </ div>
118-
119- <mwc- fab id= "closeButton" icon = "close" title = "Close" @click = ${ onClose } >
120- </ mwc- fab>
55+ <div class= "horizontalFlex" >
56+ <filters- ui .state = ${ this . state } .batchSelection = ${ this . batchSelection } >
57+ </ filters- ui>
58+ <filtered- images- ui .state = ${ this . state }
59+ .batchSelection = ${ this . batchSelection } >
60+ </ filtered- images- ui>
12161 </ div> ` ;
12262 }
12363
12464 static override styles = css `
12565 : host {
126- display : none;
127- position : absolute;
128- z-index : 5 ;
129- left : 0 ;
130- top : 0 ;
131- bottom : 0 ;
132- right : 0 ;
133- }
134-
135- # background {
136- width : 100% ;
137- height : 100% ;
138- background-color : rgba (0 , 0 , 0 , 0.6 );
139- }
140-
141- # dialog {
142- background-color : var (--mdc-theme-surface );
143- position : absolute;
144- left : 40px ;
145- top : 40px ;
146- bottom : 40px ;
147- right : 40px ;
148- padding : 20px ;
149- box-shadow : 0 0 8px 0 rgba (0 , 0 , 0 , 0.2 );
150- border-radius : 16px ;
15166 display : flex;
15267 flex-direction : column;
153- /* Rely on margin:auto for distributing the space. */
15468 justify-content : flex-start;
15569 gap : 20px ;
15670 overflow : hidden;
15771 }
15872
159- # closeButton {
160- position : absolute;
161- top : 20px ;
162- right : 20px ;
163- }
164-
16573 .horizontalFlex {
16674 display : flex;
16775 flex-direction : row;
@@ -175,11 +83,5 @@ export class BatchSelectionUi extends LitElement {
17583 max-height : 100% ;
17684 flex : 1 ;
17785 }
178-
179- .buttons {
180- display : flex;
181- flex-direction : row;
182- justify-content : space-evenly;
183- }
18486 ` ;
18587}
0 commit comments