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,21 +1,23 @@
<main class="intro_tpl"> <%
<h1>Admin Login</h1> content_for :main_class, "intro_tpl"
%>
<% if flash[:error].present? %> <h1>Admin Login</h1>
<div class="error"><%= flash[:error] %></div>
<% end %>
<%= form_for :auth, url: admin_login_path do |form| %> <% if flash[:error].present? %>
<div class="form-group"> <div class="error"><%= flash[:error] %></div>
<%= form.label :email %> <% end %>
<%= form.email_field :email %>
</div>
<div class="form-group"> <%= form_for :auth, url: admin_login_path do |form| %>
<%= form.label :password %> <div class="form-group">
<%= form.password_field :password %> <%= form.label :email %>
</div> <%= form.email_field :email %>
</div>
<%= submit_tag "Log in" %> <div class="form-group">
<% end %> <%= form.label :password %>
</main> <%= form.password_field :password %>
</div>
<%= submit_tag "Log in" %>
<% end %>

View File

@ -2,17 +2,14 @@
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 } %> <%= link_to('New Quiz', admin_new_quiz_path, { class: 'btn' }) %>
<%= link_to('New Quiz', admin_new_quiz_path, { class: 'btn' }) %> </section>
</section>
<section> <section>
<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' }) %>
</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,37 +2,35 @@
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> <td><%= @question.category %></td>
<td><%= @question.category %></td> </tr>
</tr> <tr>
<tr> <th>Type</th>
<th>Type</th> <td><%= @question.input_type %></td>
<td><%= @question.input_type %></td> </tr>
</tr> <tr>
<tr> <th>Sort</th>
<th>Sort</th> <td><%= @question.sort %></td>
<td><%= @question.sort %></td> </tr>
</tr> <tr>
<tr> <th></th>
<th></th> <td>
<td> <%= check_box_tag 'question_active', nil, @question.active?, {disabled: true} %>
<%= check_box_tag 'question_active', nil, @question.active?, {disabled: true} %> <%= label_tag 'question_active', 'Active' %>
<%= label_tag 'question_active', 'Active' %> </td>
</td> </tr>
</tr> </table>
</table>
<strong>Question</strong> <strong>Question</strong>
<p><%= @question.question %></p> <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 } %> <%= 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' }) %> <%= 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>
<%= yield %> <main class="<%= content_for?(:main_class) ? yield(:main_class) : "admin_tpl" %>">
<%= render partial: "shared/generic_flash" %>
<%= yield %>
</main>
</div> </div>