Module: Sufia::BatchEditsControllerBehavior
- Extended by:
- ActiveSupport::Concern
- Included in:
- BatchEditsController
- Defined in:
- lib/sufia/batch_edits_controller_behavior.rb
Instance Method Summary collapse
Instance Method Details
#after_update ⇒ Object
38 39 40 |
# File 'lib/sufia/batch_edits_controller_behavior.rb', line 38 def after_update redirect_to sufia.dashboard_index_path unless request.xhr? end |
#edit ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sufia/batch_edits_controller_behavior.rb', line 5 def edit super @generic_file = ::GenericFile.new @generic_file.depositor = current_user.user_key @terms = @generic_file.terms_for_editing - [:title, :format, :resource_type] # do we want to show the original values for anything... @show_file = ::GenericFile.new @show_file.depositor = current_user.user_key h = {} @names = [] = [] # For each of the files in the batch, set the attributes to be the concatination of all the attributes batch.each do |doc_id| gf = ::GenericFile.find(doc_id) gf.terms_for_editing.each do |key| h[key] ||= [] h[key] = (h[key] + gf.send(key)).uniq end @names << display_title(gf) = (+gf.).uniq end initialize_fields(h, @show_file) # map the permissions to parameter like input so that the assign will work # todo sort the access level some how... perm_param ={'user'=>{},'group'=>{"public"=>"1"}} .each{ |perm| perm_param[perm[:type]][perm[:name]] = perm[:access]} @show_file. = HashWithIndifferentAccess.new(perm_param) end |
#update ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/sufia/batch_edits_controller_behavior.rb', line 48 def update # keep the batch around if we are doing ajax calls batch_sav = batch.dup if request.xhr? catalog_index_path = sufia.dashboard_index_path type = params["update_type"] if (type == "update") #params["generic_file"].reject! {|k,v| (v.blank? || (v.respond_to?(:length) && v.length==1 && v.first.blank?))} super elsif (type == "delete_all") batch.each do |doc_id| gf = ::GenericFile.find(doc_id) gf.delete end clear_batch! after_update end # reset the batch around if we are doing ajax calls if request.xhr? self.batch = batch_sav.dup @key = params["key"] if (@key != "permissions") @vals = params["generic_file"][@key] else @vals = [""] end render :update_edit end end |
#update_document(obj) ⇒ Object
42 43 44 45 46 |
# File 'lib/sufia/batch_edits_controller_behavior.rb', line 42 def update_document(obj) super obj.date_modified = Time.now.ctime obj.set_visibility(params[:visibility]) end |