Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show page #1001

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/account/calculators_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def index
end

def show
# TODO: fill it
@calculator = resource
end

def new
Expand Down
58 changes: 57 additions & 1 deletion app/views/account/calculators/show.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,57 @@
<%= render "shared/under_construction" %>
<div class="main-show-container">
<%= link_to account_calculators_path, class: "back-arrow" do %>
<%= inline_svg "icons/arrow-left.svg", class: "z-1 mr-2 mb-0.5" %>
<span class="text-sm"><%= t('buttons.back') %></span>
<% end %>

<div class="calc-details mb-4">
<span class="text-lg showpage-text"><%= t('.name') %>:</span>
<p class="text-2xl font-extrabold"> <%= @calculator.name %> </p>
</div>

<div class="calc-details mb-4">
<span class="text-lg showpage-text"><%= t('.slug') %>:</span>
<p class="font-bold"> <%= @calculator.slug %> </p>
</div>

<!-- Display Fields -->
<div class="calc-details mb-4">
<h3 class="text-lg showpage-text"><%= t('.fields') %>:</h3>
<% @calculator.fields.each do |field| %>
<div class="field mb-3">
<div class="field-details">
<span class="font-bold"><%= field.label %></span>
<span class="italic"> (<%= field.var_name %>)<br></span>
</div>
</div>
<% end %>
</div>

<!-- Display Formulas -->
<div class="calc-details mb-4">
<h3 class="text-lg showpage-text"><%= t('.formulas') %>:</h3>
<% @calculator.formulas.each do |formula| %>
<div class="formula mb-3">
<div class="formula-details">
<span class="font-bold"><%= formula.label %></span>
<span class="italic"> (<%= formula.expression %>)<br></span>
<span class="font-semibold"><%= t('.unit') %>:</span>
<span><%= formula.unit %></span>
</div>
</div>
<% end %>
</div>

<div class="showpage-buttons">
<%= link_to t('.edit'),
edit_account_calculator_path(@calculator.slug, locale: I18n.locale),
class: "btn btn-green" %>

<%= button_to account_calculator_path(@calculator.slug, locale: I18n.locale),
method: :delete,
data: { turbo_confirm: t('.confirm_delete') },
class: "btn btn-danger" do %>
<%= t('.delete') %>
<% end %>
</div>
</div>
11 changes: 11 additions & 0 deletions spec/requests/account/calculators_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,15 @@
end
end
end

describe "GET /account/calculators/:slug" do
it "renders the calculator's show page correctly" do
get account_calculator_path(calculator.slug, locale: locale)

expect(response).to have_http_status(:ok)
expect(response).to render_template(:show)
expect(response.body).to include(calculator.en_name)
expect(response.body).to include(calculator.slug)
end
end
end
Loading