James McCool commited on
Commit
3cb74a3
·
1 Parent(s): 6aa8f95

Refactor player removal functionality in Handbuilder tab of Streamlit app to support multi-selection for improved user experience. Update feedback messages to reflect multiple players being removed and enhance state management during lineup updates.

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +16 -18
src/streamlit_app.py CHANGED
@@ -712,23 +712,6 @@ if selected_tab == 'Handbuilder':
712
  height=445,
713
  hide_index=True
714
  )
715
-
716
- # Remove Player button
717
- if st.button("Remove Selected Player from Lineup", key="remove_player_button"):
718
- # For removal, we can use a simple dropdown or text input
719
- if not filled_lineup.empty:
720
- player_to_remove = st.selectbox(
721
- "Select player to remove:",
722
- options=filled_lineup['Player'].tolist(),
723
- key="remove_player_selectbox"
724
- )
725
- if st.button("Confirm Remove", key="confirm_remove_button"):
726
- st.session_state['handbuilder_lineup'] = st.session_state['handbuilder_lineup'][
727
- st.session_state['handbuilder_lineup']['Player'] != player_to_remove
728
- ]
729
- st.success(f"Removed {player_to_remove} from lineup")
730
- else:
731
- st.warning("No players in lineup to remove")
732
 
733
  # --- SUMMARY ROW ---
734
  if not filled_lineup.empty:
@@ -789,7 +772,22 @@ if selected_tab == 'Handbuilder':
789
  """,
790
  unsafe_allow_html=True
791
  )
792
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
793
  # Optionally, add a button to clear the lineup
794
  clear_col, save_col, export_col, clear_saved_col, blank_col = st.columns([2, 2, 2, 2, 12])
795
  with clear_col:
 
712
  height=445,
713
  hide_index=True
714
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
715
 
716
  # --- SUMMARY ROW ---
717
  if not filled_lineup.empty:
 
772
  """,
773
  unsafe_allow_html=True
774
  )
775
+ # Remove Player button
776
+ if not filled_lineup.empty:
777
+ players_to_remove = st.multiselect(
778
+ "Select players to remove:",
779
+ options=filled_lineup['Player'].tolist(),
780
+ key="remove_player_multiselect"
781
+ )
782
+ if st.button("Confirm Remove", key="confirm_remove_button"):
783
+ st.session_state['handbuilder_lineup'] = st.session_state['handbuilder_lineup'][
784
+ ~st.session_state['handbuilder_lineup']['Player'].isin(players_to_remove)
785
+ ]
786
+ if players_to_remove:
787
+ st.success(f"Removed {', '.join(players_to_remove)} from lineup")
788
+ else:
789
+ st.warning("No players selected for removal")
790
+
791
  # Optionally, add a button to clear the lineup
792
  clear_col, save_col, export_col, clear_saved_col, blank_col = st.columns([2, 2, 2, 2, 12])
793
  with clear_col: