@@ -18,7 +18,7 @@ use yew::prelude::*;
1818use super :: aggregate_selector:: * ;
1919use super :: expression_toolbar:: * ;
2020use super :: InPlaceColumn ;
21- use crate :: components:: column_selector:: EmptyColumn ;
21+ use crate :: components:: column_selector:: { EmptyColumn , InvalidColumn } ;
2222use crate :: components:: viewer:: ColumnLocator ;
2323use crate :: config:: * ;
2424use crate :: custom_elements:: ColumnDropDownElement ;
@@ -30,6 +30,12 @@ use crate::session::*;
3030use crate :: utils:: ApiFuture ;
3131use crate :: * ;
3232
33+ enum ColumnState {
34+ Empty ,
35+ Invalid ,
36+ Named ( String ) ,
37+ }
38+
3339#[ derive( Properties , Clone ) ]
3440pub struct ActiveColumnProps {
3541 pub idx : usize ,
@@ -56,10 +62,11 @@ impl PartialEq for ActiveColumnProps {
5662
5763impl ActiveColumnProps {
5864 fn get_name ( & self ) -> Option < String > {
59- match & self . name {
60- ActiveColumnState :: DragOver ( _) => Some ( self . dragdrop . get_drag_column ( ) . unwrap ( ) ) ,
61- ActiveColumnState :: Column ( _, name) => Some ( name. to_owned ( ) ) ,
62- ActiveColumnState :: Required ( _) => None ,
65+ match & self . name . state {
66+ ActiveColumnStateData :: DragOver => Some ( self . dragdrop . get_drag_column ( ) . unwrap ( ) ) ,
67+ ActiveColumnStateData :: Column ( name) => Some ( name. to_owned ( ) ) ,
68+ ActiveColumnStateData :: Required => None ,
69+ ActiveColumnStateData :: Invalid => None ,
6370 }
6471 }
6572
@@ -237,18 +244,31 @@ impl Component for ActiveColumn {
237244 }
238245
239246 let name = match & ctx. props ( ) . name {
240- ActiveColumnState :: DragOver ( label) => {
247+ ActiveColumnState {
248+ label,
249+ state : ActiveColumnStateData :: DragOver ,
250+ } => {
241251 classes. push ( "dragover" ) ;
242252 outer_classes. push ( "dragover-container" ) ;
243253 classes. push ( "empty-named" ) ;
244254
245255 (
246256 label. clone ( ) ,
247- Some ( ctx. props ( ) . dragdrop . get_drag_column ( ) . unwrap ( ) ) ,
257+ ColumnState :: Named ( ctx. props ( ) . dragdrop . get_drag_column ( ) . unwrap ( ) ) ,
248258 )
249259 } ,
250- ActiveColumnState :: Column ( label, name) => ( label. clone ( ) , Some ( name. to_owned ( ) ) ) ,
251- ActiveColumnState :: Required ( label) => ( label. clone ( ) , None ) ,
260+ ActiveColumnState {
261+ label,
262+ state : ActiveColumnStateData :: Column ( name) ,
263+ } => ( label. clone ( ) , ColumnState :: Named ( name. to_owned ( ) ) ) ,
264+ ActiveColumnState {
265+ label,
266+ state : ActiveColumnStateData :: Required ,
267+ } => ( label. clone ( ) , ColumnState :: Empty ) ,
268+ ActiveColumnState {
269+ label,
270+ state : ActiveColumnStateData :: Invalid ,
271+ } => ( label. clone ( ) , ColumnState :: Invalid ) ,
252272 } ;
253273
254274 let ondragenter = ctx. props ( ) . ondragenter . reform ( move |event : DragEvent | {
@@ -263,7 +283,7 @@ impl Component for ActiveColumn {
263283
264284 let col_type = self . column_type ;
265285 match ( name, col_type) {
266- ( ( label, None ) , _) => {
286+ ( ( label, ColumnState :: Empty ) , _) => {
267287 classes. push ( "empty-named" ) ;
268288 let column_dropdown = ctx. props ( ) . column_dropdown . clone ( ) ;
269289 let on_select = ctx. link ( ) . callback ( ActiveColumnMsg :: New ) ;
@@ -284,11 +304,24 @@ impl Component for ActiveColumn {
284304 data-index={ ctx. props( ) . idx. to_string( ) }
285305 ondragenter={ ondragenter. clone( ) } >
286306
287- <EmptyColumn { column_dropdown } { exclude } { on_select } />
307+ <EmptyColumn { column_dropdown } { exclude } { on_select } />
308+ </div>
309+ }
310+ } ,
311+ ( ( label, ColumnState :: Invalid ) , _) => {
312+ classes. push ( "empty-named" ) ;
313+ html ! {
314+ <div
315+ class={ outer_classes }
316+ data-label={ label }
317+ data-index={ ctx. props( ) . idx. to_string( ) }
318+ ondragenter={ ondragenter. clone( ) } >
319+
320+ <InvalidColumn />
288321 </div>
289322 }
290323 } ,
291- ( ( label, Some ( name) ) , Some ( col_type) ) => {
324+ ( ( label, ColumnState :: Named ( name) ) , Some ( col_type) ) => {
292325 let remove_column = if self . is_required {
293326 None
294327 } else {
0 commit comments