lib/report_formatter/timeline.rb
# Generates the body of the timeline
Generates the body of the timeline
Generates the body of the timeline
def build_document_body
      mri = options.mri
      tz = mri.get_time_zone(Time.zone.name)
      unless mri.timeline[:last_unit].nil?
        @start_time = format_timezone(Time.now, tz, 'raw') - mri.timeline[:last_time].to_i.send(mri.timeline[:last_unit].downcase)
      end
      mri.extras ||= {} 
      if mri.extras[:browser_name] == "explorer" || mri.extras[:tl_preview]
        tl_xml = MiqXml.load("<data/>")
      else
        @events = []
      end
      tlfield = mri.timeline[:field].split("-") 
      if tlfield.first.include?(".")                    
        col = tlfield.first.split(".").last + "." + tlfield.last  
      else
        col = tlfield.last                             
      end
      mri.table.data.each_with_index do |row, _d_idx|
        tl_event(tl_xml ? tl_xml : nil, row, col)   
      end
      mri.extras[:tl_position] ||= format_timezone(Time.now, tz, 'raw') 
      if mri.extras[:browser_name] == "explorer" || mri.extras[:tl_preview]
        output << tl_xml.to_s
      else
        output << {:events => @events}.to_json
      end
    end
def build_document_body mri = options . mri tz = mri . get_time_zone ( Time . zone . name ) unless mri . timeline [ :last_unit ] . nil? @start_time = format_timezone ( Time . now , tz , 'raw' ) - mri . timeline [ :last_time ] . to_i . send ( mri . timeline [ :last_unit ] . downcase ) end mri . extras ||= { } if mri . extras [ :browser_name ] == "explorer" || mri . extras [ :tl_preview ] tl_xml = MiqXml . load ( "<data/>" ) else @events = [ ] end tlfield = mri . timeline [ :field ] . split ( "-" ) if tlfield . first . include? ( "." ) col = tlfield . first . split ( "." ) . last + "." + tlfield . last else col = tlfield . last end mri . table . data . each_with_index do | row , _d_idx | tl_event ( tl_xml ? tl_xml : nil , row , col ) end mri . extras [ :tl_position ] ||= format_timezone ( Time . now , tz , 'raw' ) if mri . extras [ :browser_name ] == "explorer" || mri . extras [ :tl_preview ] output << tl_xml . to_s else output << { :events => @events } . to_json end end
Generates the body of the timeline
Generates the body of the timeline
# Calculate the earliest time of events to show #       START of TIMELINE TIMEZONE Code #       END of TIMELINE TIMEZONE Code # Create hash to store :tl_position setting # Split the table and field # If table has a period (from a sub table) # use subtable.field # Not a subtable, just grab the field name # Add this row to the tl event xml #     START of TIMELINE TIMEZONE Code # If position not set, default to now #     END of TIMELINE TIMEZONE Code