tinyforms/app/views/forms/show.html.erb
Yannick 2a59c19a38 Add form submissions pagination
Added pagy gem to enable pagination and added it's bulma template to the
form submissions page
2020-04-27 15:31:51 +02:00

75 lines
2.3 KiB
Plaintext

<div class="container">
<div class="is-pulled-right">
<%= link_to image_tag("#{@form.backend_name}-icon.svg", alt: @form.backend_name.humanize), @form.spreadsheet_url %>
</div>
<nav class="breadcrumb is-small has-bullet-separator" aria-label="breadcrumbs">
<ul>
<li>
<%= link_to forms_url do %>
<span class="icon is-small"><i class="fas fa-home" aria-hidden="true"></i></span>
Forms
<% end %>
</li>
<li><%= link_to "Settings", edit_form_url %></li>
<li><%= link_to "#{@form.backend_name.humanize} document", @form.spreadsheet_url %></li>
</ul>
</nav>
<h1 class="title">
<%= @form.title %>
</h1>
<% if @form.submissions.empty? %>
<div class="columns is-centered">
<div class="column is-two-thirds">
<h3 class="title">Setup your online form:</h3>
<p>
Your form submission URL: <code><%= submission_url(@form) %></code>
</p>
<p>
Set the <code>action</code> of your online form to this URL and make sure your fields have proper <code>name</code> attributes.
</p>
<h4 class="subtitle" style="margin-top:1em">Example:</h4>
<pre><code class="html">
<%= html_escape_once render('form_example', form: @form) %>
</code></pre>
<link rel="stylesheet" href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.0.0/build/styles/default.min.css">
<script src="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.0.0/build/highlight.min.js"></script>
<p>
Let us know if you need <%= link_to 'help', help_url %> - we also build the form for you!
</p>
</div>
</div>
<% else %>
<div class="box table-wrapper is-clearfix" style="clear:both">
<table class="submission-table table is-fullwidth is-striped is-hoverable">
<thead>
<tr>
<% @form.spreadsheet_headers.each do |value| %>
<th><%= value %></th>
<% end %>
</tr>
</thead>
<tbody>
<% @submissions.each do |submission| %>
<tr>
<% @form.spreadsheet_headers.each do |column| %>
<td><%= submission.data[column] %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
<%== pagy_bulma_nav(@pagy) %>
<% end %>
</div>