Permalink
Browse files

Tried to use MasterFile.type

  • Loading branch information...
1 parent 10ffcb9 commit 1e328fbc50371cc00a84306c3884969b7de40964 @phuongdh phuongdh committed Aug 16, 2012
@@ -23,5 +23,5 @@
// Required by Blacklight
//= require jquery-ui
//= require_directory .
-//
+//= require jquery.ui.nestedSortable
//= require_self
@@ -13,6 +13,10 @@
margin-bottom: 18px;
}
+.sortable {
+ cursor: move;
+}
+
/** Use half of a line height for a more subtle offset */
.whitespace-half {
margin-bottom: 9px;
@@ -3,6 +3,7 @@
class DerivativesController < ApplicationController
# before_filter :enforce_access_controls
+ load_and_authorize_resource
skip_before_filter :verify_authenticity_token, :only => [:create]
before_filter :authenticate_user!, :only => [:create]
@@ -12,11 +13,11 @@ class DerivativesController < ApplicationController
# * the File Asset will use RELS-EXT to assert that it's a part of the specified container
# * the method will redirect to the container object's edit view after saving
def create
- if cannot? :create, Derivative
- flash[:notice] = "You do not have sufficient privileges to add derivative files"
- redirect_to root_path
- return
- end
+ # if cannot? :create, Derivative
+ # flash[:notice] = "You do not have sufficient privileges to add derivative files"
+ # redirect_to root_path
+ # return
+ # end
masterfile = MasterFile.find(params[:id])
if cannot? :edit, masterfile.container.pid
@@ -66,6 +66,8 @@ def create
end
@master_files << master_file = saveOriginalToHydrant(file)
+ master_file.type = @upload_format
+
if master_file.save
master_file = sendOriginalToMatterhorn(master_file, file, @upload_format)
media_object = MediaObject.find(master_file.container.pid)
@@ -113,7 +115,7 @@ def saveOriginalToHydrant file
FileUtils.cp file.tempfile, new_file_path
master_file = create_master_file_from_temp_path(new_file_path[public_dir_path.length - 1, new_file_path.length - 1])
-
+
notice = []
apply_depositor_metadata(master_file)
@@ -155,8 +157,8 @@ def sendOriginalToMatterhorn(master_file, file, upload_format)
def create_master_file_from_temp_path(path)
master_file = MasterFile.new
filename = path.split(/\//).last
- master_file.label = filename
master_file.url = path
+ master_file.label = File.basename(filename, File.extname(filename))
#master_file.description = "Original file uploaded"
return master_file
@@ -6,6 +6,7 @@ class MasterFile < FileAsset
delegate :description, to: :descMetadata
delegate :url, to: :descMetadata, at: [:identifier]
delegate :size, to: :descMetadata, at: [:extent]
+ delegate :type, to: :descMetadata
def derivatives_append(der)
der.add_relationship(:is_derivation_of, self)
@@ -3,26 +3,36 @@
<legend>File Upload</legend>
<% unless @masterfiles.nil? %>
-
+ <% if @masterfiles.count > 1 %>
+ <p>You have multiple files for this item. Are they sequential, versional or hierarchical?</p>
+ <div class="btn-group">
+ <button class="btn btn-success">Sequence</button>
+ <button class="btn">Versions</button>
+ <button class="btn">Hierarchy</button>
+ </div>
+ <p>
+ <% end %>
+
<table class="table table-striped">
- <thead>
- <th></th>
- <th>Title</th>
- <th>Filename</th>
- <th>Filesize</th>
- <th>Action</th>
- </thead>
- <tbody>
+ <thead>
+ <th></th>
+ <th>Title</th>
+ <th>Filename</th>
+ <th>Filesize</th>
+ <th>Action</th>
+ </thead>
+ <tbody class="sortable">
<% @masterfiles.each do |masterfile| %>
<tr>
<td>
<i class="icon-volume-up"></i>
+ <%= masterfile.type %>
</td>
<td>
- <%= text_field_tag "title", masterfile.descMetadata.title[0] %>
+ <%= text_field_tag "title", masterfile.label %>
</td>
<td>
- <a href="<%= masterfile.descMetadata.identifier[0] %>"><%= masterfile.descMetadata.title[0] %></a>
+ <a href="<%= masterfile.descMetadata.identifier[0] %>"><%= File.basename(masterfile.url.first) %></a>
</td>
<td>
<strong>(<%= number_to_human_size(masterfile.size) %>)</strong>
@@ -33,11 +43,11 @@
<% # On a Rails level this needs to be folded into the masterfiles
# controller's destroy method to help remove more vestiges of the
# catalog controller %>
- <%= button_to("Delete file",
+ <%= button_to("Delete",
master_file_path(masterfile.id),
:data => { :confirm => "Are you sure you want to delete this file?" },
:method => :delete,
- :class => "delete-button btn") %>
+ :class => "delete-button btn btn-mini btn-danger") %>
<% end %>
</td>
</tr>
@@ -77,5 +87,21 @@
<script>
/* Hide the alert dialog on the page loading if Javascript is enabled */
<% unless flash[:upload] %>$('#upload_format').hide();<% end %>
+ $('.sortable').sortable();
+ $('.sortable').disableSelection();
+
+ // $(".sortable").nestedSortable({
+ // placeholder: 'dropPlaceHolder',
+ // forcePlaceholderSize:true,
+ // handle: 'div',
+ // helper: 'clone',
+ // listType: 'tbody',
+ // items: 'tr',
+ // opacity: .6,
+ // revert: 250,
+ // tabSize: 25,
+ // tolerance: 'pointer',
+ // toleranceElement: '> div'
+ // }).disableSelection();
</script>
<% end %>
Oops, something went wrong.

0 comments on commit 1e328fb

Please sign in to comment.