Skip to content

Commit

Permalink
if submission status icon helper with the correct conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Nov 20, 2023
1 parent 5989728 commit ce2d73f
Showing 1 changed file with 45 additions and 6 deletions.
51 changes: 45 additions & 6 deletions app/helpers/ontologies_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def status_link(submission, latest = false, target = '')

def submission_status2string(data)
return '' if data[:submissionStatus].nil?

# Massage the submission status into a UI string
# submission status values, from:
# https://github.com/ncbo/ontologies_linked_data/blob/master/lib/ontologies_linked_data/models/submission_status.rb
Expand All @@ -172,7 +172,7 @@ def submission_status2string(data)
end
status.concat errors
return '' if status.empty?

'(' + status.join(', ') + ')'
end

Expand All @@ -181,16 +181,30 @@ def status_string(data)

submission_status2string(data)
end


def submission_status_ok?(status)
status.include?('Parsed') && !status.include?('Error')
end

def submission_status_error?(status)
!status.include?('Parsed') && status.include?('Error')
end

def submission_status_warning?(status)
status.include?('Parsed') && status.include?('Error')
end

def submission_status_icons(status)
if status.include?('Parsed') && !status.include?('Error Diff')
if submission_status_ok?(status)
"success-icon.svg"
elsif status.include?('Error Diff') && !status.include?('Parsed')
elsif submission_status_error?(status)
'error-icon.svg'
elsif status == '(Archived)'
'archive.svg'
else
elsif submission_status_warning?(status)
"alert-triangle.svg"
else
"info.svg"
end
end

Expand Down Expand Up @@ -306,6 +320,10 @@ def visits_chart_dataset(visits_data)
}].to_json
end

def submission_ready?(submission)
submission.nil? || Array(submission.submissionStatus).include?('RDF')
end

def sections_to_show
sections = ['summary']

Expand All @@ -317,6 +335,27 @@ def sections_to_show
end
sections
end

def not_ready_submission_alert(ontology: @ontology, submission: @submission)
if ontology.admin?(session[:user])
status = status_string(submission)
type = nil
message = nil
if submission_status_error?(status)
type = 'danger'
message = "The ontology processing failed, with the current statuses: #{status}"
elsif submission_status_warning?(status)
message = "The ontology parsing succeeded, but some processing steps failed, here are the current statuses: #{status}"
type = 'warning'

elsif !submission_ready?(submission)
type = 'info'
message = "The ontology is processing. Sections such as #{ontology_data_sections.join(', ')} will be available once processing is complete."
end
render Display::AlertComponent.new(message: message, type: type) if type
end
end

def dispaly_complex_text(definitions)
html = ""
definitions.each do |definition|
Expand Down

0 comments on commit ce2d73f

Please sign in to comment.