admin views roughed in

This commit is contained in:
Mark Moser
2016-08-18 18:22:57 -05:00
parent 430097b6ef
commit 63701c8247
29 changed files with 316 additions and 104 deletions

View File

@ -1,6 +1,29 @@
<%= form_for quiz, url: action do |f| %>
<p>Unit: <%= f.text_field :unit %></p>
<p>Dept: <%= f.text_field :dept %></p>
<%= f.submit %>
<% if flash[:error].present? %>
<div class="error">
<%= flash[:error] %>
<p>
<% quiz.errors.messages.each do |k,v| %>
<%= "#{k.to_s} #{v.join(' and ')}" %><br />
<% end %>
</p>
</div>
<% end %>
<%= form_for quiz, url: action do |form| %>
<div class="form-group">
<%= form.label :name, "Quiz Description" %>
<%= form.text_field :name %>
</div>
<div class="form-group">
<%= form.label :dept, 'Department' %>
<%= form.text_field :dept %>
</div>
<div class="form-group">
<%= form.label :unit, 'Unit' %>
<%= form.text_field :unit %>
</div>
<%= form.submit %>
<% end %>

View File

@ -0,0 +1,19 @@
<table cellspacing="0" cellpadding="0">
<tr>
<th>Name</th>
<th>Dept</th>
<th>Unit</th>
<th>Questions</th>
<th></th>
</tr>
<% quizzes.each do |quiz| %>
<tr>
<td><%= link_to quiz.name, admin_quiz_path(quiz.to_i) %></td>
<td><%= quiz.dept %></td>
<td><%= quiz.unit %></td>
<td><%= quiz.questions.count %></td>
<td><%= link_to 'edit', admin_edit_quiz_path(quiz.to_i), { class: 'btn tertiary-btn' } %></td>
</tr>
<% end %>
</table>

View File

@ -1,4 +1,7 @@
<h1>Admin::Quizes#edit</h1>
<p>Find me in app/views/admin/quizes/edit.html.erb</p>
<%
content_for :section_title, "Edit: #{@quiz.name}"
%>
<%= render partial: 'form', locals: { quiz: @quiz, action: admin_update_quiz_path } %>
<main class="summary_tpl">
<%= render partial: 'form', locals: { quiz: @quiz, action: admin_update_quiz_path } %>
</main>

View File

@ -1,2 +1,8 @@
<h1>Admin::Quizes#index</h1>
<p>Find me in app/views/admin/quizes/index.html.erb</p>
<%
content_for :section_title, "Quizzes"
%>
<main class="summary_tpl">
<%= render partial: 'admin/quiz/table_list', locals: { quizzes: @quizzes } %>
<%= link_to('New Quiz', admin_new_quiz_path, { class: 'btn' }) %>
</main>

View File

@ -1,4 +1,7 @@
<h1>Admin::Quizes#new</h1>
<p>Find me in app/views/admin/quizes/new.html.erb</p>
<%
content_for :section_title, "New Quiz"
%>
<%= render partial: 'form', locals: { quiz: @quiz, action: admin_create_quiz_path } %>
<main class="summary_tpl">
<%= render partial: 'form', locals: { quiz: @quiz, action: admin_create_quiz_path } %>
</main>

View File

@ -1,7 +1,10 @@
<h1>Admin::Quizes#view</h1>
<p>Find me in app/views/admin/quizes/view.html.erb</p>
<%
content_for :section_title, "#{@quiz.name}"
%>
<main>
<main class="summary_tpl">
<p><%= @quiz.name %></p>
<p><%= @quiz.dept %></p>
<p><%= @quiz.unit %></p>
<%= link_to('Edit', admin_edit_quiz_path(@quiz.to_i), { class: 'btn' }) %>
</main>