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,4 +1,7 @@
<main class="intro_tpl"> <%
content_for :main_class, "intro_tpl"
%>
<h1>Admin Login</h1> <h1>Admin Login</h1>
<% if flash[:error].present? %> <% if flash[:error].present? %>
@ -18,4 +21,3 @@
<%= submit_tag "Log in" %> <%= submit_tag "Log in" %>
<% end %> <% end %>
</main>

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,6 @@
content_for :section_title, "Question for #{@question.quiz.name}" content_for :section_title, "Question for #{@question.quiz.name}"
%> %>
<main class="admin_tpl">
<table cellspacing="0" cellpadding="0"> <table cellspacing="0" cellpadding="0">
<tr> <tr>
<th>Category</th> <th>Category</th>
@ -35,4 +34,3 @@
<%= 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' }) %> <%= link_to('View Quiz', admin_quiz_path(@question.quiz_id), { class: 'btn' }) %>
</main>

View File

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

View File

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

View File

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

View File

@ -2,14 +2,10 @@
content_for :section_title, "#{@quiz.name}" content_for :section_title, "#{@quiz.name}"
%> %>
<main class="admin_tpl">
<p><%= @quiz.name %></p> <p><%= @quiz.name %></p>
<p><%= @quiz.dept %></p> <p><%= @quiz.dept %></p>
<p><%= @quiz.unit %></p> <p><%= @quiz.unit %></p>
<%= link_to('Edit', admin_edit_quiz_path(@quiz.to_i), { class: 'btn' }) %> <%= link_to('Edit', admin_edit_quiz_path(@quiz.to_i), { class: 'btn' }) %>
</main>
<main class="summary_tpl">
<%= render partial: 'admin/question/table_list', locals: { questions: @quiz.questions, disable: true } %> <%= render partial: 'admin/question/table_list', locals: { questions: @quiz.questions, disable: true } %>
<%= link_to('New Question', admin_new_question_path, { class: 'btn' }) %> <%= link_to('New Question', admin_new_question_path, { class: 'btn' }) %>
</main>

View File

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

View File

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

View File

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

View File

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

View File

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