Class: Marty::PromiseView

Inherits:
Tree
  • Object
show all
Defined in:
app/components/marty/promise_view.rb

Constant Summary

Constants included from Permissions

Marty::Permissions::NETZKE_ENDPOINTS

Instance Method Summary collapse

Methods inherited from Tree

#child_components, #class_can?, #configure_form_window, #initialize, #linked_components

Methods included from Permissions

#can_call_endpoint?, #can_perform_action?, #can_perform_actions, #current_user_roles, extended, #has_any_perm?, #has_marty_permissions, #has_perm?

Constructor Details

This class inherits a constructor from Marty::Tree

Instance Method Details

#bbarObject



44
45
46
# File 'app/components/marty/promise_view.rb', line 44

def bbar
  [:clear, :cancel_job, '->', :refresh, :download]
end

#configure(c) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/components/marty/promise_view.rb', line 20

def configure(c)
  super

  c.title = I18n.t('jobs.promise_view')
  c.model = 'Marty::VwPromise'
  c.attributes = [
    { name: :title, xtype: :treecolumn },
    :user__login,
    :job_id,
    :priority,
    :start_dt,
    :end_dt,
    :total_time,
    :status,
    :cformat,
    :error,
    :timeout
  ]
  c.root_visible = false
  c.paging = :none
  c.bbar = bbar
  c.read_only = true
end

#get_records(params) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'app/components/marty/promise_view.rb', line 84

def get_records(params)
  search_scope = config[:live_search_scope] || :live_search
  res = Marty::VwPromise.children_for_id(params[:id], params[search_scope])

  # Fetch actual promise objects without results in advance to avoid N+1
  promises_without_status_ids = res.reject(&:status).map(&:id)
  promises_without_status = Marty::Promise.where(
    id: promises_without_status_ids
  )

  @results = promises_without_status.each_with_object({}) do |promise, hash|
    hash[promise.id] = promise.result.to_s
  end

  res
end