Module: ZoomRangeConcern
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/controllers/concerns/zoom_range_concern.rb
Overview
ZoomRangeConcern
Handles chart zoom and column selection for filtering table data. When users zoom into a chart or click a chart column, this concern calculates the appropriate time boundaries for filtering the table while keeping the chart unchanged. Normalizes zoom times to hour/day boundaries based on the overall time range.
Instance Method Summary collapse
Instance Method Details
#setup_zoom_range(main_start_time, main_end_time) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/concerns/zoom_range_concern.rb', line 10 def setup_zoom_range(main_start_time, main_end_time) # Extract column selection parameter (but don't delete it yet - we need it for the view) selected_column_time = params[:selected_column_time] # Extract zoom parameters from params (this removes them from params) zoom_start = params.delete(:zoom_start_time) zoom_end = params.delete(:zoom_end_time) # Handle column selection with highest precedence for table filtering if selected_column_time column_start, column_end = normalize_column_time(selected_column_time.to_i, main_start_time, main_end_time) table_start_time = column_start table_end_time = column_end # Don't set zoom times for column selection - let chart show full range return [ zoom_start, zoom_end, table_start_time, table_end_time ] end # Normalize zoom times to beginning/end of day or hour like we do for main time range if zoom_start && zoom_end zoom_start, zoom_end = normalize_zoom_times(zoom_start.to_i, zoom_end.to_i) end # Calculate table times - use zoom if present, otherwise fallback to main times table_start_time = zoom_start || main_start_time table_end_time = zoom_end || main_end_time [ zoom_start, zoom_end, table_start_time, table_end_time ] end |