Adding resource category edit abilities
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
<div id="header">
|
||||
<a id="home_nav_link" href="/" title="Home"><img src="/assets/logo.png" id="logo" /></a>
|
||||
<%= link_to 'People', users_path if can? :read, User %>
|
||||
<%= link_to 'Tools & Resources', resources_path if can? :read, Resource %>
|
||||
<%= link_to 'Access Cards', cards_path if can? :manage, Card %>
|
||||
<% if can? :create, UserCertification %>
|
||||
<%= link_to 'Cert Classes', certifications_path if can? :read, Certification %>
|
||||
|
||||
@@ -10,6 +10,23 @@
|
||||
<link href="/bootstrap/css/bootstrap-theme.min.css" type="text/css" rel="stylesheet" />
|
||||
<script src="/bootstrap/js/bootstrap.min.js" type="text/javascript" ></script>
|
||||
|
||||
|
||||
<style>
|
||||
.thumbnail { height: 150px; position: relative; }
|
||||
.thumbnail .ownership,
|
||||
.thumbnail .disposed
|
||||
{ position: absolute; top: 1px;
|
||||
text-shadow:
|
||||
-1px -1px 0 #fff,
|
||||
1px -1px 0 #fff,
|
||||
-1px 1px 0 #fff,
|
||||
1px 1px 0 #fff;
|
||||
font-weight: bold; left: 10px; }
|
||||
.thumbnail .disposed { color: red; }
|
||||
.thumbnail h4 { position: absolute; bottom: 1px; margin-bottom: 1px; }
|
||||
</style>
|
||||
|
||||
|
||||
<style>
|
||||
#logo {
|
||||
height: 40px;
|
||||
|
||||
22
app/views/resource_categories/_form.html.erb
Normal file
22
app/views/resource_categories/_form.html.erb
Normal file
@@ -0,0 +1,22 @@
|
||||
<%= form_for @resource_category, :html => { :multipart => true } do |f| %>
|
||||
<% if @resource_category.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@resource_category.errors.count, "error") %> prohibited this resource from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @resource_category.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<p>
|
||||
<%= f.label :name %><br />
|
||||
<%= f.text_field :name %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.submit nil, class: "btn btn-primary" %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
10
app/views/resource_categories/_resource_category.html.erb
Normal file
10
app/views/resource_categories/_resource_category.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<li class="list-group-item row">
|
||||
<h4 class="col-xs-6">
|
||||
<%= resource_category.name %>
|
||||
<small>(<%= resource_category.resources.count %> associated)</small>
|
||||
</h4>
|
||||
<span class="col-xs-6 text-right">
|
||||
<%= link_to "Edit", [:edit, resource_category], class: "btn btn-primary" if can? :edit, resource_category %>
|
||||
<%= link_to 'Delete', resource_category, {:confirm => 'Are you sure you want to delete this forever?', :method => :delete, :class => "btn btn-danger"} if can? :destroy, resource_category %>
|
||||
</span>
|
||||
</li>
|
||||
4
app/views/resource_categories/edit.html.erb
Normal file
4
app/views/resource_categories/edit.html.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<h1>Edit Category
|
||||
<%= link_to 'Back', resource_categories_path, class: "btn btn-default" %>
|
||||
</h1>
|
||||
<%= render 'form' %>
|
||||
33
app/views/resource_categories/index.html.erb
Executable file
33
app/views/resource_categories/index.html.erb
Executable file
@@ -0,0 +1,33 @@
|
||||
<link href="/bootstrap/css/bootstrap-theme.min.css" type="text/css" />
|
||||
<link href="/bootstrap/css/bootstrap.min.css" type="text/css" />
|
||||
<script src="/bootstrap/js/bootstrap.min.js" type="text/javascript" ></script>
|
||||
|
||||
<style>
|
||||
.thumbnail { height: 150px; position: relative; }
|
||||
.thumbnail .ownership,
|
||||
.thumbnail .disposed
|
||||
{ position: absolute; top: 1px;
|
||||
text-shadow:
|
||||
-1px -1px 0 #fff,
|
||||
1px -1px 0 #fff,
|
||||
-1px 1px 0 #fff,
|
||||
1px 1px 0 #fff;
|
||||
font-weight: bold; left: 10px; }
|
||||
.thumbnail .disposed { color: red; }
|
||||
.thumbnail h4 { position: absolute; bottom: 1px; margin-bottom: 1px; }
|
||||
</style>
|
||||
|
||||
|
||||
<h1 class="col-sm-9">Resource Categories
|
||||
<%= link_to 'Back', resources_path, :class => "btn btn-default" if can? :read, Resource %>
|
||||
<%= link_to 'Add Category', new_resource_category_path, :class => "btn btn-success" if can? :create, ResourceCategory %>
|
||||
</h1>
|
||||
|
||||
<div class="col-sm-12">
|
||||
<ul class="list-group">
|
||||
<%= render @resource_categories.sort_by(&:name) %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
4
app/views/resource_categories/new.html.erb
Normal file
4
app/views/resource_categories/new.html.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<h1>New Category
|
||||
<%= link_to 'Back', resource_categories_path, class: "btn btn-default" %>
|
||||
</h1>
|
||||
<%= render 'form' %>
|
||||
@@ -12,8 +12,8 @@
|
||||
<% end %>
|
||||
|
||||
<p>
|
||||
<%= f.label :category_id %><br />
|
||||
<%= select(:resource, :category_id, options_from_collection_for_select(ResourceCategory.all.sort_by(&:name), :id, :name, @resource.category_id ) ) %>
|
||||
<%= f.label :resource_category_id, "Category" %><br />
|
||||
<%= select(:resource, :resource_category_id, options_from_collection_for_select(ResourceCategory.all.sort_by(&:name), :id, :name, @resource.resource_category_id ) ) %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :name %><br />
|
||||
|
||||
@@ -1,27 +1,6 @@
|
||||
|
||||
|
||||
<link href="/bootstrap/css/bootstrap-theme.min.css" type="text/css" />
|
||||
<link href="/bootstrap/css/bootstrap.min.css" type="text/css" />
|
||||
<script src="/bootstrap/js/bootstrap.min.js" type="text/javascript" ></script>
|
||||
|
||||
<style>
|
||||
.thumbnail { height: 150px; position: relative; }
|
||||
.thumbnail .ownership,
|
||||
.thumbnail .disposed
|
||||
{ position: absolute; top: 1px;
|
||||
text-shadow:
|
||||
-1px -1px 0 #fff,
|
||||
1px -1px 0 #fff,
|
||||
-1px 1px 0 #fff,
|
||||
1px 1px 0 #fff;
|
||||
font-weight: bold; left: 10px; }
|
||||
.thumbnail .disposed { color: red; }
|
||||
.thumbnail h4 { position: absolute; bottom: 1px; margin-bottom: 1px; }
|
||||
</style>
|
||||
|
||||
|
||||
<h1 class="col-sm-4">Lab Resources
|
||||
<%= link_to 'Add Resource', new_resource_path, :class => "btn btn-success" if can? :create, Resource %>
|
||||
<%= link_to 'Categories', resource_categories_path, :class => "btn btn-primary" if can? :read, ResourceCategory %>
|
||||
</h1>
|
||||
|
||||
<h3 class="col-sm-2">Featured item:</h3>
|
||||
@@ -30,14 +9,14 @@
|
||||
<div class="row">
|
||||
<% unless @resources.blank? %>
|
||||
<div class="panel-group col-sm-8" id="accordion">
|
||||
<% @resources.sort_by{|r| [r.category_name,r.name] }.group_by(&:category).each do |category,resources| %>
|
||||
<% @resources.sort_by{|r| [r.resource_category_name,r.name] }.group_by(&:resource_category).each do |resource_category,resources| %>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" data-toggle="collapse" data-parent="#accordion" href="#collapse_cat_<%= category.id %>">
|
||||
<div class="panel-heading" data-toggle="collapse" data-parent="#accordion" href="#collapse_cat_<%= resource_category.id %>">
|
||||
<h4 class="panel-title">
|
||||
<%= category.name %>
|
||||
<%= resource_category.name %>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="collapse_cat_<%= category.id %>" class="panel-collapse collapse">
|
||||
<div id="collapse_cat_<%= resource_category.id %>" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<%= render resources %>
|
||||
</div>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<% end %>
|
||||
<p>
|
||||
<b>Category:</b>
|
||||
<%=h @resource.category.name if !@resource.category.blank? %>
|
||||
<%=h @resource.resource_category.name if @resource.resource_category %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
<% if !@users.blank? %>
|
||||
<% @users.each do |user| %>
|
||||
<tr<%= " class='hidden'" if user.hidden? %>>
|
||||
<tr<%= ' class=hidden' if user.hidden? %>>
|
||||
<td><%= image_tag user.gravatar_url(:default => "http://members.heatsynclabs.org/assets/nil.png"), :class => :avatar %></td>
|
||||
<td><%= link_to user.name, user %></td>
|
||||
<td><%= raw(user.member_status_symbol) %></td>
|
||||
|
||||
Reference in New Issue
Block a user