class AdminModule::Pages::WorkflowDetailTaskAddlDetailPage

Public Instance Methods

cancel() click to toggle source
# File lib/admin_module/pages/workflow_detail_task_addl_detail_page.rb, line 64
def cancel
  self.cancel_button
end
clear_data() click to toggle source
# File lib/admin_module/pages/workflow_detail_task_addl_detail_page.rb, line 46
def clear_data
  clear_tasks_details

  self
end
get_data() click to toggle source
# File lib/admin_module/pages/workflow_detail_task_addl_detail_page.rb, line 36
def get_data
  get_tasks_details
end
save() click to toggle source
# File lib/admin_module/pages/workflow_detail_task_addl_detail_page.rb, line 52
def save
  # If there are no tasks, the error span will be populated and the Save
  # button will not be available.
  # In this case, click the Cancel button and move on.
  if error_span? && error_span.include?('No task defined')
    self.cancel_button
    return
  end

  self.save_button
end
set_data(data) click to toggle source
# File lib/admin_module/pages/workflow_detail_task_addl_detail_page.rb, line 40
def set_data data
  set_tasks_details data

  self
end

Private Instance Methods

capture_details() click to toggle source

Build a list of objects containing task detail data.

We use this method even though we don’t need to (for get_xxx) because we’ll need the captured field ids for setting values.

# File lib/admin_module/pages/workflow_detail_task_addl_detail_page.rb, line 149
def capture_details
  details = []

  Nokogiri::HTML(@browser.html).css("#ctl00_cntPlh_gvTask>tbody>tr").each do |tr|
    # Skip the header row
    next if tr['class'] == 'GridHeader'

    detail = TaskDetail.new
    detail.sequence = tr.css("td:nth-child(1)").text
    detail.name = tr.css("td:nth-child(2)").text
    detail.predecessors = tr.css("td:nth-child(3)>input").text
    detail.pred_id = tr.css("td:nth-child(3)>input")[0]['id']
    detail.regenerate = tr.css("td:nth-child(4)>input")[0]['checked'] == 'checked'
    detail.reg_id = tr.css("td:nth-child(4)>input")[0]['id']

    details << detail
  end # css

  details
end
clear_tasks_details() click to toggle source
# File lib/admin_module/pages/workflow_detail_task_addl_detail_page.rb, line 110
def clear_tasks_details
  capture_details.each do |item|
    # set the predecessors field to blank
    txt = text_field_elements(id: item.pred_id)[0]
    txt.value = ''

    # Clear the checkbox field
    ck = checkbox_elements(id: item.reg_id)[0]
    ck.uncheck
  end

  self
end
details_table() click to toggle source
# File lib/admin_module/pages/workflow_detail_task_addl_detail_page.rb, line 70
def details_table
  table_elements[0].table_elements[1]
end
get_tasks_details() click to toggle source
# File lib/admin_module/pages/workflow_detail_task_addl_detail_page.rb, line 74
def get_tasks_details
  details = Hash.new

  capture_details.each do |item|
    details[item.name] = item.to_hsh
  end

  details
end
set_tasks_details(details) click to toggle source
# File lib/admin_module/pages/workflow_detail_task_addl_detail_page.rb, line 84
def set_tasks_details details
  capture_details.each do |item|
    details.each do |dtl|
      if dtl[:name] == item.name
        # We've found a match, get the field
        txt = text_field_elements(id: item.pred_id)[0]
        # set the predecessors field to the stored value
        txt.value = dtl[:predecessors]

        # Get the checkbox field
        ck = checkbox_elements(id: item.reg_id)[0]
        # Check/uncheck it
        if dtl[:regenerate]
          ck.check
        else
          ck.uncheck
        end

        break
      end
    end
  end

  self
end