Added styling to file section

This commit is contained in:
Luke Barratt 2014-04-26 21:21:11 +01:00
parent 8014a0eac7
commit cf8f4e89af
4 changed files with 175 additions and 147 deletions

View file

@ -9,4 +9,38 @@
@include span-columns(12);
margin: em(20) 0;
}
}
}
/*
Files List
*/
#files {
.file {
@include span-columns(12);
padding-top: em(20);
margin-bottom: em(20);
position: relative;
border-top: em(3) solid $light-gray;
.actions {
position: absolute;
top: em(20);
right: 0;
}
.comments {
float: right;
i {
margin-right: em(10);
}
}
}
.controls {
@include span-columns(12);
margin-top: em(20);
}
}

View file

@ -1,59 +1,53 @@
<h1>Editing file</h1>
<h1>Editing File</h1>
<div class="wide box">
<%= form_for(@file) do |f| %>
<%= f.error_messages %>
<%= form_for(@file, html: { class: 'square' }) do |f| %>
<%= render 'shared/errors', messages: @file.errors.full_messages %>
<%= cascade @file, ["name", "size_s", "md5_s"] %>
<%= cascade @file, ["name", "size_s", "md5_s"] %>
<p>
<%= f.label :description %><br />
<%= f.text_field :description %>
</p>
<div class="fields horizontal">
<%= f.label :description %>
<%= f.text_field :description %>
</div>
<p>
<%= f.label :directory_id %><br />
<%= f.select :directory_id, Directory.all.collect{|c| ["#{c.path} - #{c.name}", c.id]} %>
</p>
<div class="fields horizontal">
<%= f.label :directory_id %>
<%= f.select :directory_id, Directory.all.collect { |c| ["#{c.path} - #{c.name}", c.id] } %>
</div>
<p>
<%= f.submit 'Update' %>
</p>
<% end %>
</div>
<div class="controls">
<%= f.submit 'Update' %>
</div>
<% end %>
<div class="wide box">
<h3>
Related Files
</h3>
<h3>Related Files</h3>
<table class="data">
<table class="striped">
<tr>
<th>Name</th>
<th>Size</th>
<th>Action</th>
</tr>
<% @file.related_files.each do |related| %>
<tr>
<th>Name</th>
<th>Size</th>
<th>Action</th>
<td>
<%= h related.name.filename %>
</td>
<td>
<%= related.size_s %> MB
</td>
<td>
<%= link_to "Remove", controller: "data_files", action: "delFile", id: @file, "related_id" => related %>
</td>
</tr>
<% @file.related_files.each do |related| %>
<tr>
<td>
<%= h related.name.filename %>
</td>
<td>
<%= related.size_s %> MB
</td>
<td>
<%= link_to "Remove", :controller => "data_files", :action => "delFile", :id => @file, "related_id" => related %>
</td>
</tr>
<% end %>
</table>
<%= form_for @file, :url => {:action => "addFile", :id => @file} do |f| %>
<p>
<%= f.select :related_id, @file.directory.files.not(@file).collect {|file| [file, file.id]} %>
<%= f.submit "Add" %>
</p>
<% end %>
</div>
</table>
<%= link_to 'Show', @file %>
<%= form_for @file, url: { action: "addFile", id: @file } do |f| %>
<div class="fields">
<%= f.select :related_id, @file.directory.files.not(@file).collect {|file| [file, file.id]} %>
</div>
<div class="controls">
<%= f.submit "Add" %>
</div>
<% end %>

View file

@ -1,26 +1,24 @@
<h1>New file</h1>
<h1 class="title">New File</h1>
<div class="wide box">
<%= form_for @file, :html => { :multipart => true } do |f| %>
<%= f.error_messages %>
<%= form_for @file, html: { multipart: true, class: 'square' } do |f| %>
<%= render 'shared/errors', messages: @file.errors.full_messages %>
<p>
<%= f.label :name %><br />
<%= f.file_field :name %>
</p>
<div class="fields horizontal">
<%= f.label :name %>
<%= f.file_field :name %>
</div>
<p>
<%= f.label :description %><br />
<%= f.text_field :description %>
</p>
<div class="fields horizontal">
<%= f.label :description %>
<%= f.text_field :description %>
</div>
<p>
<%= f.label :directory_id %><br />
<%= f.select :directory_id, Directory.all.collect{|c| ["#{c.path} - #{c.name}", c.id]} %>
</p>
<div class="fields horizontal">
<%= f.label :directory_id %>
<%= f.select :directory_id, Directory.all.collect{|c| ["#{c.path} - #{c.name}", c.id]} %>
</div>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
</div>
<div class="controls">
<%= f.submit 'Create File' %>
</div>
<% end %>

View file

@ -1,93 +1,95 @@
<h1>Files</h1>
<h1 class="title">Files</h1>
<% active = 1; n = 1; %>
<%
active = 1
n = 1
%>
<div id="filesTab">
<ul id="filesTab-nav" class="tabs">
<div id="files" class="tabbed">
<ul id="files-nav" class="tabs">
<% @directories.each do |dir| %>
<li><a href="#dir_<%= dir.id %>"><%= h dir.name %></a></li>
<% end %>
</ul>
<div class="tabs">
<div class="tabbed-contents">
<% @directories.each do |dir| %>
<div class="box wide tab" id="dir_<%= dir.id %>">
<div class="tab" id="dir_<%= dir.id %>">
<%
if @directory.path.include?(dir.path)
dir = @directory
active = n
end
n = n + 1
%>
if @directory.path.include?(dir.path)
dir = @directory
active = n
end
n = n + 1
%>
<% if !dir.subdirs.ordered.empty? or dir.parent.id != Directory::ROOT %>
<h3>
Directories
</h3>
<% end %>
<% if dir.parent.id != Directory::ROOT %>
<div class="box sub wide">
<h3>
<%= link_to "Parent", dir.parent %>
</h3>
</div>
<% end %>
<% dir.subdirs.ordered.each do |subdir| %>
<div class="box sub wide">
<h3>
<%= namelink subdir %>
</h3>
</div>
<% end %>
<div></div>
<h3>
Files
</h3>
<% dir.files.unrelated.each do |file| %>
<div class="box sub wide">
<div class="left">
<h3>
<%= namelink file %>
</h3>
<p>
<b>Size: </b> <%= file.size_s %> MB, <b>Comments: </b> <%= file.comments.count %> <br />
<b>MD5: </b> <%= file.md5_s %><br />
</p>
<%= link_to "Direct Download", file.url, :class => "green" %>
<% if file.can_update? cuser %>
[ <%= link_to 'Edit', edit_data_file_path(file) %> ]
<% end; if file.can_destroy? cuser %>
[ <%= link_to 'Destroy', file, :confirm => 'Are you sure?', :method => :delete %> ]
<div class="directories">
<% if !dir.subdirs.ordered.empty? or dir.parent.id != Directory::ROOT %>
<h3>Directories</h3>
<% end %>
<div class="subdirectories">
<ul class="disc">
<% if dir.parent.id != Directory::ROOT %>
<li class="parent">
<%= link_to "Parent", dir.parent %>
</li>
<% end %>
<% dir.subdirs.ordered.each do |subdir| %>
<li><%= namelink subdir %></li>
<% end %>
</ul>
</div>
</div>
<div class="clear"></div>
<h3>Files</h3>
<% dir.files.unrelated.each do |file| %>
<div class="file">
<div class="actions">
<% if file.can_update? cuser %>
<%= link_to icon('pencil'), edit_data_file_path(file) %>
<% end %>
<% if file.can_destroy? cuser %>
<%= link_to icon('times'), file, confirm: 'Are you sure?', method: :delete %>
<% end %>
</div>
<h4><%= namelink file %></h4>
<p><strong>Size:</strong> <%= file.size_s %>MB</p>
<div class="comments">
<%= link_to file do %>
<%= icon('comments') %> Comments (<%= file.comments.count %>)
<% end %>
</div>
<%= link_to 'Download', file.url, class: 'button tiny' %>
</div>
<% end %>
<% if dir.files.empty? %>
<p>Empty directory.</p>
<% end %>
<% if cuser and cuser.admin? %>
<div class="controls">
<%= link_to "Edit Directory", edit_directory_path(dir), class: 'button' %>
<%= link_to "Delete Directory", dir, confirm: "Are you REALLY sure?", method: :delete, class: 'button' %>
<%= link_to "New Directory", { controller: "directories", action: "new", id: dir }, { class: 'button' } %>
<%= link_to "New File", { controller: "data_files", action: "new", id: dir }, { class: 'button' } %>
</div>
<% end %>
</div>
<% end %>
<% if dir.files.empty? %>
<p>Empty directory.</p>
<% end %>
<% if cuser and cuser.admin? %>
<p>
<%= link_to "Edit Directory", edit_directory_path(dir) %> |
<%= link_to "Delete Directory", dir, :confirm => "Are you REALLY sure?", :method => :delete %> |
<%= link_to "New Directory", :controller => "directories", :action => "new", :id => dir %> |
<%= link_to "New File", :controller => "data_files", :action => "new", :id => dir %>
</p>
<% end %>
</div>
<% end %>
</div>
</div>
</div>
<script type="text/javascript">
var tabber1 = new Yetii({ id: 'filesTab', active: <%= active %>});
</script>
<script type="text/javascript">
new Yetii({
id: 'files',
active: <%= active %>
});
</script>