Adding resource category edit abilities
This commit is contained in:
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' %>
|
||||
Reference in New Issue
Block a user