state_helper.rb revision 06cbff1e355ede78f5fa530b57a93e4dbc533840
2N/Amodule StateHelper
2N/A def retry_resource_chain
2N/A if resource.is_a?(Ontology)
2N/A [:retry_failed, *resource_chain]
2N/A elsif resource.is_a?(Theorem)
2N/A [:retry_failed, *resource_chain, resource]
2N/A elsif resource.is_a?(ProofAttempt)
2N/A [:retry_failed, *resource_chain, resource.theorem, resource]
2N/A else
2N/A [:retry_failed, *resource_chain]
2N/A end
2N/A end
2N/A
2N/A def state_tag(resource)
2N/A resource = resource.is_a?(Ontology) ? resource.current_version : resource
2N/A
2N/A html_opts = {
2N/A class: "evaluation-state",
2N/A data: {
2N/A klass: resource.class.to_s,
58N/A id: resource.id,
2N/A uri: locid_for(resource),
2N/A state: resource.state,
2N/A }
2N/A }
23N/A content_tag(:small, html_opts) do
23N/A state(resource)
23N/A end
23N/A end
23N/A
32N/A def state(resource)
32N/A html = content_tag(:span, resource.state)
32N/A
34N/A unless State::TERMINAL_STATES.include?(resource.state)
32N/A html << " " << image_tag('spinner-16x16.gif', class: 'spinner')
34N/A end
32N/A
32N/A if resource.state == 'failed' && resource.is_a?(Ontology)
58N/A version = resource.versions.last
32N/A
225N/A link = ' ('
225N/A link << link_to('error',
225N/A locid_for(resource, :ontology_versions),
225N/A :'data-original-title' => version.last_error,
225N/A class: 'help'
225N/A )
225N/A link << ')'
225N/A
225N/A html << content_tag(:span, link.html_safe, class: 'error')
225N/A end
2N/A
38N/A html
38N/A end
38N/Aend
38N/A