@@ -292,6 +292,7 @@ def _qt_export_json(self):
292292 with json_file .open ("w" ) as f :
293293 curation_dict = check_json (self .controller .construct_final_curation ())
294294 json .dump (curation_dict , f , indent = 4 )
295+ self .controller .current_curation_saved = True
295296
296297 # PANEL
297298 def _panel_make_layout (self ):
@@ -469,6 +470,31 @@ def _panel_refresh(self):
469470 self .table_split .value = df
470471 self .table_split .selection = []
471472
473+ if not self .controller .current_curation_saved :
474+ self .ensure_save_warning_message ()
475+ else :
476+ self .ensure_no_message ()
477+
478+ def ensure_save_warning_message (self ):
479+
480+ if self .layout [0 ].name == 'curation_save_warning' :
481+ return
482+
483+ import panel as pn
484+
485+ alert_markdown = pn .pane .Markdown (
486+ f"""⚠️⚠️⚠️ Your curation is not saved""" ,
487+ hard_line_break = True ,
488+ styles = {"color" : "red" , "font-size" : "16px" },
489+ name = "curation_save_warning"
490+ )
491+
492+ self .layout .insert (0 , alert_markdown )
493+
494+ def ensure_no_message (self ):
495+ if self .layout [0 ].name == 'curation_save_warning' :
496+ self .layout .pop (0 )
497+
472498 def _panel_update_unit_visibility (self , event ):
473499 unit_dtype = self .controller .unit_ids .dtype
474500 if self .active_table == "delete" :
@@ -501,6 +527,7 @@ def _panel_unmerge(self, event):
501527
502528 def _panel_save_in_analyzer (self , event ):
503529 self .save_in_analyzer ()
530+ self .refresh ()
504531
505532 def _panel_generate_json (self ):
506533 # Get the path from the text input
@@ -511,36 +538,11 @@ def _panel_generate_json(self):
511538 with open (export_path , "w" ) as f :
512539 json .dump (curation_dict , f , indent = 4 )
513540
514- return export_path
515-
516- def _panel_get_delete_table_selection (self ):
517- selected_items = self .table_delete .selection
518- if len (selected_items ) == 0 :
519- return None
520- else :
521- return self .table_delete .value ["removed" ].values [selected_items ].tolist ()
522-
523- def _panel_get_merge_table_row (self ):
524- selected_items = self .table_merge .selection
525- if len (selected_items ) == 0 :
526- return None
527- else :
528- return selected_items
541+ self .controller .current_curation_saved = True
529542
530- def _panel_get_split_table_row (self ):
531- selected_items = self .table_split .selection
532- if len (selected_items ) == 0 :
533- return None
534- else :
535- return selected_items
543+ self .refresh ()
536544
537- def _panel_handle_shortcut (self , event ):
538- if event .data == "restore" :
539- self .restore_units ()
540- elif event .data == "unmerge" :
541- self .unmerge ()
542- elif event .data == "unsplit" :
543- self .unsplit ()
545+ return export_path
544546
545547 def _panel_submit_to_parent (self , event ):
546548 """Send the curation data to the parent window"""
@@ -572,6 +574,38 @@ def _panel_submit_to_parent(self, event):
572574
573575 # Update the hidden div with the JavaScript code
574576 self .data_div .object = js_code
577+ # Submitting to parent is a way to "save" the curation (the parent can handle it)
578+ self .controller .current_curation_saved = True
579+ self .refresh ()
580+
581+ def _panel_get_delete_table_selection (self ):
582+ selected_items = self .table_delete .selection
583+ if len (selected_items ) == 0 :
584+ return None
585+ else :
586+ return self .table_delete .value ["removed" ].values [selected_items ].tolist ()
587+
588+ def _panel_get_merge_table_row (self ):
589+ selected_items = self .table_merge .selection
590+ if len (selected_items ) == 0 :
591+ return None
592+ else :
593+ return selected_items
594+
595+ def _panel_get_split_table_row (self ):
596+ selected_items = self .table_split .selection
597+ if len (selected_items ) == 0 :
598+ return None
599+ else :
600+ return selected_items
601+
602+ def _panel_handle_shortcut (self , event ):
603+ if event .data == "restore" :
604+ self .restore_units ()
605+ elif event .data == "unmerge" :
606+ self .unmerge ()
607+ elif event .data == "unsplit" :
608+ self .unsplit ()
575609
576610 def _panel_on_unit_visibility_changed (self ):
577611 for table in [self .table_delete , self .table_merge , self .table_split ]:
0 commit comments