Skip to content

Commit

Permalink
Show page
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielVajnagi committed Dec 2, 2024
1 parent f934abb commit 46df6fb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
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

Check warning on line 13 in app/controllers/account/calculators_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/account/calculators_controller.rb#L13

Added line #L13 was not covered by tests
end

def new
Expand Down
44 changes: 36 additions & 8 deletions app/views/account/calculators/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,51 @@
<% end %>

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

<div class="calc-details mb-6">
<span class="showpage-text"><%= t('.slug') %>:</span>
<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),
<%= 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),

<%= button_to account_calculator_path(@calculator.slug, locale: I18n.locale),
method: :delete,
data: { turbo_confirm: t('.confirm_delete') },
data: { turbo_confirm: t('.confirm_delete') },
class: "btn btn-danger" do %>
<%= t('.delete') %>
<% end %>
Expand Down

0 comments on commit 46df6fb

Please sign in to comment.