Skip to content

Commit

Permalink
fix project update and create errors display
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Jan 18, 2023
1 parent 5d71552 commit 3bd07fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
5 changes: 5 additions & 0 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,14 @@ def update
end
@project = projects.first
@project.update_from_params(project_params)
@user_select_list = LinkedData::Client::Models::User.all.map {|u| [u.username, u.id]}
@user_select_list.sort! {|a,b| a[1].downcase <=> b[1].downcase}
@usedOntologies = @project.ontologyUsed || []
@ontologies = LinkedData::Client::Models::Ontology.all
error_response = @project.update
if response_error?(error_response)
@errors = response_errors(error_response)
render :edit
else
flash[:notice] = 'Project successfully updated'
redirect_to project_path(@project.acronym)
Expand Down
19 changes: 5 additions & 14 deletions app/views/projects/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,12 @@
.enable-lists{style: "color:red; padding-left:10px;"}
%strong Errors On Form
%ul
- if @errors[:error].instance_of? OpenStruct
- errors_hash = @errors[:error].to_h.except :links, :context
- errors_hash.each do |field, error|
-# Highlight fields with errors.
<style>#project_#{field} { border: thin solid red; }</style>
- @errors = @errors[:error ] if @errors[:error]
%ul
- @errors.each do |key, message|
<style>#project_#{key} { border: thin solid red; }</style>
%li
-# Display error message to users.
- if error.instance_of? OpenStruct
- error_hash = error.to_h.except :links, :context
- error_hash.each do |f, e|
= "#{e}"
- else
= field
- else
= @errors.to_json
= message.values.join(',')
/ Override the bioportal.css for .required to avoid red text in the input fields.
:css
Expand Down

0 comments on commit 3bd07fb

Please sign in to comment.