admin: move <main> to layout

This commit is contained in:
Mark Moser 2016-08-24 12:17:00 -05:00
parent 0058168c3e
commit 94ae3c9687
15 changed files with 89 additions and 114 deletions

View File

@ -1,11 +1,14 @@
<main class="intro_tpl">
<h1>Admin Login</h1>
<%
content_for :main_class, "intro_tpl"
%>
<% if flash[:error].present? %>
<h1>Admin Login</h1>
<% if flash[:error].present? %>
<div class="error"><%= flash[:error] %></div>
<% end %>
<% end %>
<%= form_for :auth, url: admin_login_path do |form| %>
<%= form_for :auth, url: admin_login_path do |form| %>
<div class="form-group">
<%= form.label :email %>
<%= form.email_field :email %>
@ -17,5 +20,4 @@
</div>
<%= submit_tag "Log in" %>
<% end %>
</main>
<% end %>

View File

@ -2,17 +2,14 @@
content_for :section_title, "Admin Dashboard"
%>
<main class="admin_tpl">
<section>
<section>
<h1>Quizzes</h1>
<%= render partial: 'admin/quiz/table_list', locals: { quizzes: @quizzes } %>
<%= link_to('New Quiz', admin_new_quiz_path, { class: 'btn' }) %>
</section>
</section>
<section>
<section>
<h1>Users</h1>
<%= render partial: 'admin/user/table_list', locals: { users: @users } %>
<%= link_to('New User', admin_new_user_path, { class: 'btn' }) %>
</section>
</main>
</section>

View File

@ -2,8 +2,5 @@
content_for :section_title, "Questions"
%>
<main class="admin_tpl">
<h1><%= @question.quiz.name %></h1>
<%= render partial: 'form', locals: {question: @question, action: admin_update_question_path } %>
</main>
<h1><%= @question.quiz.name %></h1>
<%= render partial: 'form', locals: {question: @question, action: admin_update_question_path } %>

View File

@ -2,11 +2,9 @@
content_for :section_title, "Questions"
%>
<main class="admin_tpl">
<% quizzes = @questions.group_by{ |q| q.quiz.name } %>
<% quizzes.each do |quiz, questions| %>
<% quizzes = @questions.group_by{ |q| q.quiz.name } %>
<% quizzes.each do |quiz, questions| %>
<h1><%= quiz %></h1>
<%= render partial: 'admin/question/table_list', locals: { questions: questions } %>
<%= link_to('Edit Quiz', admin_quiz_path(questions.first.quiz.to_i), { class: 'btn' }) %>
<% end %>
</main>
<% end %>

View File

@ -2,6 +2,4 @@
content_for :section_title, "New Question"
%>
<main class="admin_tpl">
<%= render partial: 'form', locals: {question: @question, action: admin_create_question_path } %>
</main>
<%= render partial: 'form', locals: {question: @question, action: admin_create_question_path } %>

View File

@ -2,8 +2,7 @@
content_for :section_title, "Question for #{@question.quiz.name}"
%>
<main class="admin_tpl">
<table cellspacing="0" cellpadding="0">
<table cellspacing="0" cellpadding="0">
<tr>
<th>Category</th>
<td><%= @question.category %></td>
@ -23,16 +22,15 @@
<%= label_tag 'question_active', 'Active' %>
</td>
</tr>
</table>
</table>
<strong>Question</strong>
<p><%= @question.question %></p>
<strong>Question</strong>
<p><%= @question.question %></p>
<%= fields_for @question do |fields| %>
<%= fields_for @question do |fields| %>
<%= render partial: "admin/question/#{@question.input_type}", locals: {question: @question, disable: true, fields: fields } %>
<% end %>
<% end %>
<%= link_to('Edit', admin_edit_question_path(@question.to_i), { class: 'btn' }) %>
<%= link_to('Edit', admin_edit_question_path(@question.to_i), { class: 'btn' }) %>
<%= link_to('View Quiz', admin_quiz_path(@question.quiz_id), { class: 'btn' }) %>
</main>
<%= link_to('View Quiz', admin_quiz_path(@question.quiz_id), { class: 'btn' }) %>

View File

@ -2,6 +2,4 @@
content_for :section_title, "Edit: #{@quiz.name}"
%>
<main class="admin_tpl">
<%= render partial: 'form', locals: { quiz: @quiz, action: admin_update_quiz_path } %>
</main>
<%= render partial: 'form', locals: { quiz: @quiz, action: admin_update_quiz_path } %>

View File

@ -2,7 +2,5 @@
content_for :section_title, "Quizzes"
%>
<main class="admin_tpl">
<%= render partial: 'admin/quiz/table_list', locals: { quizzes: @quizzes } %>
<%= link_to('New Quiz', admin_new_quiz_path, { class: 'btn' }) %>
</main>
<%= render partial: 'admin/quiz/table_list', locals: { quizzes: @quizzes } %>
<%= link_to('New Quiz', admin_new_quiz_path, { class: 'btn' }) %>

View File

@ -2,6 +2,4 @@
content_for :section_title, "New Quiz"
%>
<main class="admin_tpl">
<%= render partial: 'form', locals: { quiz: @quiz, action: admin_create_quiz_path } %>
</main>
<%= render partial: 'form', locals: { quiz: @quiz, action: admin_create_quiz_path } %>

View File

@ -2,14 +2,10 @@
content_for :section_title, "#{@quiz.name}"
%>
<main class="admin_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>
<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 class="summary_tpl">
<%= render partial: 'admin/question/table_list', locals: { questions: @quiz.questions, disable: true } %>
<%= link_to('New Question', admin_new_question_path, { class: 'btn' }) %>
</main>
<%= render partial: 'admin/question/table_list', locals: { questions: @quiz.questions, disable: true } %>
<%= link_to('New Question', admin_new_question_path, { class: 'btn' }) %>

View File

@ -2,6 +2,4 @@
content_for :section_title, "Edit: #{@user.name}"
%>
<main class="admin_tpl">
<%= render partial: 'form', locals: {user: @user, action: admin_update_user_path } %>
</main>
<%= render partial: 'form', locals: {user: @user, action: admin_update_user_path } %>

View File

@ -2,8 +2,6 @@
content_for :section_title, "Users"
%>
<main class="admin_tpl">
<h1>Users</h1>
<%= render partial: 'admin/user/table_list', locals: { users: @users } %>
<%= link_to('New User', admin_new_user_path, { class: 'btn' }) %>
</main>
<h1>Users</h1>
<%= render partial: 'admin/user/table_list', locals: { users: @users } %>
<%= link_to('New User', admin_new_user_path, { class: 'btn' }) %>

View File

@ -2,6 +2,4 @@
content_for :section_title, "New User"
%>
<main class="admin_tpl">
<%= render partial: 'form', locals: {user: @user, action: admin_create_user_path } %>
</main>
<%= render partial: 'form', locals: {user: @user, action: admin_create_user_path } %>

View File

@ -2,9 +2,7 @@
content_for :section_title, "#{@user.name}"
%>
<main class="admin_tpl">
<p><%= @user.name %></p>
<p><%= mail_to(@user.email) %></p>
<p><%= @user.role %></p>
<%= link_to('Edit', admin_edit_user_path(@user.to_i), { class: 'btn' }) %>
</main>
<p><%= @user.name %></p>
<p><%= mail_to(@user.email) %></p>
<p><%= @user.role %></p>
<%= link_to('Edit', admin_edit_user_path(@user.to_i), { class: 'btn' }) %>

View File

@ -30,7 +30,10 @@
</div>
</header>
<main class="<%= content_for?(:main_class) ? yield(:main_class) : "admin_tpl" %>">
<%= render partial: "shared/generic_flash" %>
<%= yield %>
</main>
</div>