Skip to content

Commit

Permalink
Merge fcfbbde into 7c4f162
Browse files Browse the repository at this point in the history
  • Loading branch information
relf committed Apr 26, 2023
2 parents 7c4f162 + fcfbbde commit 58f936d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 31 deletions.
2 changes: 1 addition & 1 deletion app/controllers/design_projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def create
@design_project.set_owner(current_user)
redirect_to design_projects_url, notice: "Design project #{@design_project.name} was successfully created."
else
redirect_to new_design_project_url, error: "Something went wrong while creating #{@design_project.name}."
render :new
end
end
end
Expand Down
9 changes: 4 additions & 5 deletions app/helpers/analyses_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,20 @@ def badges(analysis)
res = ""
if analysis.is_metamodel_prototype?
res += '<span class="badge rounded-pill bg-success me-2" title="Analysis reference for a meta-model discipline">MM</span>'
elsif analysis.mono_disciplinary?
res += '<span class="badge rounded-pill bg-secondary me-2" title="Analysis has one discipline">DISC</span>'
end
if analysis.uq_mode?
res += '<span class="badge rounded-pill bg-info me-2" title="Analysis with uncertain inputs">UQ</span>'
end
if analysis.has_objective?
res += '<span class="badge rounded-pill bg-primary me-2" title="Analysis with optimization problem">OPTIM</span>'
end
if analysis.nesting_depth > 2
res += '<span class="badge rounded-pill bg-danger me-2" title="Analysis with more than 2 sub-analysis levels">DEEP</span>'
end
if analysis.packaged?
res += '<span class="badge rounded-pill bg-warning me-2" title="Analysis is packaged">PKG</span>'
end
if analysis.mono_disciplinary?
res += '<span class="badge rounded-pill bg-secondary me-2" title="Analysis has one discipline">DISC</span>'
if analysis.nesting_depth > 2
res += '<span class="badge rounded-pill bg-danger me-2" title="Analysis with more than 2 sub-analysis levels">DEEP</span>'
end
raw(res)
end
Expand Down
12 changes: 3 additions & 9 deletions app/views/analyses/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<%= form_for(analysis, url: (analysis.new_record? ? mdas_path : mda_path(@mda)), :html => { :multipart => true, :role => "form" }) do |f| %>
<% if @mda.errors.any? %>
<% @mda.errors.full_messages.each do |message| %>
<div class="alert <%= bootstrap_class_for :error %>" role="alert">
<a href="#" data-dismiss="alert" class="close">×</a>
<%= message %>
</div>
<% end %>
<% end %>
<%= form_for(analysis, url: (analysis.new_record? ? mdas_path : mda_path(analysis)), :html => { :multipart => true, :role => "form" }) do |f| %>
<%= render 'shared/alerts', object: analysis %>

<div class="row">
<div class=" col-4">
Expand Down
12 changes: 3 additions & 9 deletions app/views/design_projects/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<%= form_for(design_project, url: (design_project.new_record? ? design_projects_path : design_project_path(@design_project)), :html => { :multipart => true, :role => "form" }) do |f| %>
<% if @design_project.errors.any? %>
<% @design_project.errors.full_messages.each do |message| %>
<div class="alert <%= bootstrap_class_for :error %>" role="alert">
<a href="#" data-dismiss="alert" class="close">×</a>
<%= message %>
</div>
<% end %>
<% end %>
<%= form_for(design_project, url: (design_project.new_record? ? design_projects_path : design_project_path(@design_project))) do |f| %>
<%= render 'shared/alerts', object: design_project %>

<div class="row">
<div class=" col-4">
Expand Down
10 changes: 5 additions & 5 deletions app/views/design_projects/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

<thead>
<tr>
<th style="10%">Name</th>
<th style="10%">Owner</th>
<th style="30%">Description</th>
<th style="30%">Analyses</th>
<th style="20%">Actions</th>
<th style="width: 10%">Name</th>
<th style="width: 10%">Owner</th>
<th style="width: 30%">Description</th>
<th style="width: 30%">Analyses</th>
<th style="width: 20%">Actions</th>
</tr>
</thead>

Expand Down
8 changes: 8 additions & 0 deletions app/views/shared/_alerts.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% if object.errors.any? %>
<% object.errors.full_messages.each do |message| %>
<div class="alert <%= bootstrap_class_for :error %> alert-dismissible fade show" role="alert">
<%= message %>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<% end %>
<% end %>
4 changes: 2 additions & 2 deletions test/controllers/design_projects_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DesignProjectsControllerTest < ActionDispatch::IntegrationTest

test "name cannot be blank on creation" do
post design_projects_url, params: { design_project: { name: "" } }
assert_redirected_to new_design_project_url
assert_select 'div.alert-danger'
end

test "name cannot be duplicated" do
Expand All @@ -40,7 +40,7 @@ class DesignProjectsControllerTest < ActionDispatch::IntegrationTest
end
assert_difference("DesignProject.count", 0) do
post design_projects_url, params: { design_project: { name: "test" } }
assert_redirected_to new_design_project_url
assert_select 'div.alert-danger'
end
end

Expand Down

0 comments on commit 58f936d

Please sign in to comment.