file_share 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -1,18 +1,26 @@
1
1
  <div id="file_attachments">
2
+ <% if orphans.present? && files.present? %>
2
3
  <div id="orphans" class="span-8">
3
- <h2>Orphaned Files (<em><%= @orphans.count %></em>)</h2>
4
- <%= render :partial => 'file_attachments/file_attachment', :collection => @orphans %>
4
+ <h2>Orphaned Files</h2>
5
+ <%= render :partial => 'file_attachments/file_attachment', :collection => orphans %>
5
6
  </div>
6
7
  <div id="files" class="span-8 last">
7
- <h2>Files (<em><%= @files.count %></em>)</h2>
8
- <% @files.group_by(&:attachable).each do |attachable, attached_files| %>
8
+ <h2>Attached Files</h2>
9
+ <% files.group_by(&:attachable).each do |attachable, attached_files| %>
9
10
  <div id="<%= "#{attachable.class}_#{attachable.id}" %>">
10
- <h3><%= link_to attachable.name, polymorphic_path(attachable) %> (<em><%= attached_files.count %></em>)</h3>
11
+ <h3><%= link_to attachable.name, polymorphic_path(attachable) %></h3>
11
12
  <%= render :partial => 'file_attachments/file_attachment', :collection => attached_files %>
12
13
  </div>
13
14
  <% end %>
14
15
  </div>
15
16
  <div style="clear:both;"></div>
17
+ <% else %>
18
+ <div id="files">
19
+ <% if files.present? || orphans.present? %>
20
+ <%= render :partial => 'file_attachments/file_attachment', :collection => files.present? ? files : orphans %>
21
+ <% end %>
22
+ </div>
23
+ <% end %>
16
24
  </div>
17
25
 
18
26
  <% if has_authorization?(:update, FileAttachment.new) %>
@@ -1,3 +1,5 @@
1
+ <% orphans ||= [] %>
2
+ <% files ||= [] %>
1
3
  <% content_for(:javascript) do %>
2
4
  <script type="text/javascript">
3
5
  jQuery.ajaxSetup({
@@ -7,11 +9,16 @@
7
9
  });
8
10
  function bindCallbacks(plupload) {
9
11
  plupload.bind('FileUploaded', function(up, file, response) {
10
- if( $('#file_container_select').val() ) {
11
- $("#" + $('#file_container_select').val() ).append(response.response);
12
- } else {
13
- $("#orphans").append(response.response);
12
+ var element_selector = '';
13
+ if( $('#file_container_select').val() &&
14
+ $("#"+$('#file_container_select').val())[0] ) {
15
+ element_selector = "#" + $('#file_container_select').val();
16
+ } else if( $("#orphans")[0] ) {
17
+ element_selector = "#orphans"
18
+ } else if( $("#files")[0] ) {
19
+ element_selector = "#files"
14
20
  }
21
+ $(element_selector).append(response.response);
15
22
  });
16
23
  plupload.bind('UploadProgress', function() {
17
24
  if( plupload.files.length == plupload.total.failed + plupload.total.uploaded ) {
@@ -79,9 +86,12 @@
79
86
 
80
87
  <% end %>
81
88
 
82
- <h3>Downloadable Resources<hr /></h3>
89
+ <h2>Downloadable Resources</h2>
83
90
 
84
- <%= render :partial => 'file_attachments/file_attachments' %>
91
+ <%= render :partial => 'file_attachments/file_attachments', :locals => {
92
+ :orphans => orphans,
93
+ :files => files
94
+ } %>
85
95
 
86
96
  <% if has_authorization?(:create, FileAttachment.new) %>
87
97
 
@@ -1 +1,4 @@
1
- <%= render :partial => 'file_attachments/plupload_with_listing', :locals => {:file_attachments => @file_attachments} %>
1
+ <%= render :partial => 'file_attachments/plupload_with_listing', :locals => {
2
+ :orphans => @orphans,
3
+ :files => @files
4
+ } %>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_share
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason LaPier