More resource tweaks
This commit is contained in:
parent
23dcb0715c
commit
a2cbcac798
|
@ -2,6 +2,10 @@ class ResourcesController < ApplicationController
|
|||
load_and_authorize_resource
|
||||
before_filter :authenticate_user!, :load_users
|
||||
|
||||
def index
|
||||
@featured_resource = @resources.where("picture_file_name IS NOT NULL").sample
|
||||
end
|
||||
|
||||
def create
|
||||
authorize! :create, @resource
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class Resource < ActiveRecord::Base
|
||||
attr_accessible :supercategory, :user_id, :category_id, :name, :serial, :specs, :status, :donatable, :picture, :picture_file_name, :picture_content_type, :picture_file_size, :picture_updated_at, :notes, :estimated_value
|
||||
attr_accessible :supercategory, :user_id, :category_id, :name, :serial, :specs, :status, :donatable, :picture, :picture_file_name, :picture_content_type, :picture_file_size, :picture_updated_at, :notes, :estimated_value, :disposed_at
|
||||
|
||||
belongs_to :owner, :class_name => "ToolshareUser" #TODO: remove owner
|
||||
belongs_to :user
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
float: left;
|
||||
margin-top: 5px;
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
#logo {
|
||||
margin-left: 15px;
|
||||
}
|
||||
}
|
||||
#content {
|
||||
margin: 1em;
|
||||
}
|
||||
|
@ -25,8 +30,19 @@
|
|||
<body>
|
||||
<nav class="navbar navbar-default" role="navigation">
|
||||
<div class="container-fluid">
|
||||
<ul class="nav navbar-nav">
|
||||
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#mainmenu-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a id="home_nav_link" href="/" title="Home"><img src="/assets/logo.png" id="logo" /></a>
|
||||
</div>
|
||||
|
||||
<div class="collapse navbar-collapse" id="mainmenu-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<%= link_to 'People', users_path if can? :read, User %>
|
||||
</li>
|
||||
|
@ -74,6 +90,7 @@
|
|||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="container-fluid" id="content">
|
||||
<div class="row">
|
||||
|
|
|
@ -34,6 +34,12 @@
|
|||
<br/>
|
||||
<%= f.text_field :status %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= f.label :disposed_at, "Disposed?" %><br />
|
||||
<%= f.date_select :disposed_at, include_blank: true %>
|
||||
</p>
|
||||
|
||||
<% if can? :assign_user, @resource %>
|
||||
<p>
|
||||
<%= f.label :user_id, "Owner" %>
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
<% if resource.user %>
|
||||
<span class="ownership">Owned by:<br/><%= resource.user.name %></span>
|
||||
<% end %>
|
||||
<% if resource.disposed_at %>
|
||||
<span class="disposed">Disposed:<br/><%= resource.disposed_at.to_date %></span>
|
||||
<% end %>
|
||||
<%= link_to(resource) do %>
|
||||
<%= image_tag(resource.picture.url(:thumb)) if resource.picture? %>
|
||||
<h4><%=h resource.name %></h4>
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
<h1>Lab Resources
|
||||
<%= link_to 'Add Resource', new_resource_path, :class => "btn btn-success" if can? :create, Resource %>
|
||||
</h1>
|
||||
|
||||
|
||||
<link href="/bootstrap/css/bootstrap-theme.min.css" type="text/css" />
|
||||
|
@ -9,10 +6,28 @@
|
|||
|
||||
<style>
|
||||
#accordion .thumbnail { height: 150px; position: relative; }
|
||||
#accordion .thumbnail .ownership { position: absolute; top: 1px; text-shadow: 0.1em 0.1em 0.2em white; font-weight: bold; left: 10px; }
|
||||
#accordion .thumbnail .ownership,
|
||||
#accordion .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; }
|
||||
#accordion .thumbnail .disposed { color: red; }
|
||||
#accordion .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 %>
|
||||
</h1>
|
||||
|
||||
<h3 class="col-sm-2">Featured item:</h3>
|
||||
<%= render @featured_resource %>
|
||||
|
||||
<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| %>
|
||||
|
@ -31,6 +46,7 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
|
|
|
@ -3,9 +3,13 @@
|
|||
<h2><%=h @resource.name %>
|
||||
<%= link_to 'Back', resources_path, class: "btn btn-default" %>
|
||||
<%= link_to 'Edit', edit_resource_path(@resource), class: "btn btn-primary" %>
|
||||
<%= link_to 'Delete', resource_path(@resource), {:confirm => 'Are you sure you want to delete this forever?', :method => :delete, :class => "btn btn-danger"} if can? :destroy, @resource %>
|
||||
</h2>
|
||||
|
||||
<% if @resource.user || @resource.owner %>
|
||||
<p>
|
||||
<b>Owner:</b>
|
||||
<%=h (@resource.user || @resource.owner).name %>
|
||||
</p>
|
||||
<% end %>
|
||||
<p>
|
||||
<b>Category:</b>
|
||||
<%=h @resource.category.name if !@resource.category.blank? %>
|
||||
|
@ -24,6 +28,11 @@
|
|||
<p>
|
||||
<b>Status/Location:</b>
|
||||
<%=h @resource.status %>
|
||||
|
||||
<% if @resource.disposed_at %>
|
||||
<b>Disposed:</b>
|
||||
<%=h @resource.disposed_at.to_date %>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
@ -43,3 +52,4 @@
|
|||
|
||||
|
||||
|
||||
<%= link_to 'Delete', resource_path(@resource), {:confirm => 'Are you sure you want to delete this forever?', :method => :delete, :class => "btn btn-danger"} if can? :destroy, @resource %>
|
||||
|
|
5
db/migrate/20140209104356_add_disposed_at_to_resource.rb
Normal file
5
db/migrate/20140209104356_add_disposed_at_to_resource.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddDisposedAtToResource < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :resources, :disposed_at, :datetime
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140209080523) do
|
||||
ActiveRecord::Schema.define(:version => 20140209104356) do
|
||||
|
||||
create_table "cards", :force => true do |t|
|
||||
t.string "card_number"
|
||||
|
@ -141,6 +141,7 @@ ActiveRecord::Schema.define(:version => 20140209080523) do
|
|||
t.datetime "updated_at"
|
||||
t.string "estimated_value"
|
||||
t.integer "user_id"
|
||||
t.datetime "disposed_at"
|
||||
end
|
||||
|
||||
create_table "settings", :force => true do |t|
|
||||
|
|
Loading…
Reference in New Issue
Block a user