admin views roughed in
This commit is contained in:
@ -1,7 +1,29 @@
|
||||
<%= form_for user, url: action do |f| %>
|
||||
<p>Name: <%= f.text_field :name %></p>
|
||||
<p>eMail: <%= f.email_field :email %></p>
|
||||
<p>Role: <%= f.text_field :role %></p>
|
||||
|
||||
<%= f.submit %>
|
||||
<% if flash[:error].present? %>
|
||||
<div class="error">
|
||||
<%= flash[:error] %>
|
||||
<p>
|
||||
<% user.errors.messages.each do |k,v| %>
|
||||
<%= "#{k.to_s} #{v.join(' and ')}" %><br />
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= form_for user, url: action do |form| %>
|
||||
<div class="form-group">
|
||||
<%= form.label :name, "Full Name" %>
|
||||
<%= form.text_field :name %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= form.label :email, "eMail" %>
|
||||
<%= form.email_field :email %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= form.label :role, "Role" %>
|
||||
<%= form.select :role, admin_role_options(user.role), include_blank: false %>
|
||||
</div>
|
||||
|
||||
<%= form.submit %>
|
||||
<% end %>
|
||||
|
17
app/views/admin/user/_table_list.html.erb
Normal file
17
app/views/admin/user/_table_list.html.erb
Normal file
@ -0,0 +1,17 @@
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>Email</th>
|
||||
<th>Role</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% users.each do |user| %>
|
||||
<tr>
|
||||
<td><%= link_to user.name, admin_user_path(user.to_i) %></td>
|
||||
<td><%= mail_to(user.email) %></td>
|
||||
<td><%= user.role %></td>
|
||||
<td><%= link_to 'edit', admin_edit_user_path(user.to_i), { class: 'btn tertiary-btn' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
@ -1,4 +1,7 @@
|
||||
<h1>Admin::Users#edit</h1>
|
||||
<p>Find me in app/views/admin/users/edit.html.erb</p>
|
||||
<%
|
||||
content_for :section_title, "Edit: #{@user.name}"
|
||||
%>
|
||||
|
||||
<%= render partial: 'form', locals: {user: @user, action: admin_update_user_path } %>
|
||||
<main class="summary_tpl">
|
||||
<%= render partial: 'form', locals: {user: @user, action: admin_update_user_path } %>
|
||||
</main>
|
||||
|
@ -1,2 +1,9 @@
|
||||
<h1>Admin::Users#index</h1>
|
||||
<p>Find me in app/views/admin/users/index.html.erb</p>
|
||||
<%
|
||||
content_for :section_title, "Users"
|
||||
%>
|
||||
|
||||
<main class="summary_tpl">
|
||||
<h1>Users</h1>
|
||||
<%= render partial: 'admin/user/table_list', locals: { users: @users } %>
|
||||
<%= link_to('New User', admin_new_user_path, { class: 'btn' }) %>
|
||||
</main>
|
||||
|
@ -1,4 +1,7 @@
|
||||
<h1>Admin::Users#new</h1>
|
||||
<p>Find me in app/views/admin/users/new.html.erb</p>
|
||||
<%
|
||||
content_for :section_title, "New User"
|
||||
%>
|
||||
|
||||
<%= render partial: 'form', locals: {user: @user, action: admin_create_user_path } %>
|
||||
<main class="summary_tpl">
|
||||
<%= render partial: 'form', locals: {user: @user, action: admin_create_user_path } %>
|
||||
</main>
|
||||
|
@ -1,6 +1,10 @@
|
||||
<h1>Admin::Users#view</h1>
|
||||
<p>Find me in app/views/admin/users/view.html.erb</p>
|
||||
<%
|
||||
content_for :section_title, "#{@user.name}"
|
||||
%>
|
||||
|
||||
<main>
|
||||
<%= @user.name %>
|
||||
<main class="summary_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>
|
||||
|
Reference in New Issue
Block a user