Class: ContainerProfilesController

Inherits:
ApplicationController show all
Includes:
ExportHelper
Defined in:
frontend/app/controllers/container_profiles_controller.rb

Constant Summary

Constants included from Searchable

Searchable::ABSTRACT

Instance Method Summary collapse

Methods included from ExportHelper

#csv_response, #xml_response

Methods inherited from ApplicationController

#archivesspace, can_access?, permission_mappings, set_access_control

Methods included from JsonHelper

#merge_notes, #process_json_notes

Methods included from Searchable

#default_search_opts, #get_filter_years, #handle_results, #html_notes, #process_results, #process_search_results, #repo_context, #search_terms, #set_up_advanced_search, #set_up_and_run_search, #set_up_search, #strip_facet_fields

Methods included from HandleFaceting

#fetch_only_facets, #get_pretty_facet_value, #strip_facets

Methods included from ManipulateNode

#inheritance, #process_mixed_content, #strip_mixed_content

Instance Method Details

#createObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'frontend/app/controllers/container_profiles_controller.rb', line 43

def create
  handle_crud(:instance => :container_profile,
              :model => JSONModel(:container_profile),
              :on_invalid => ->() {
                return render_aspace_partial :partial => "container_profiles/new" if inline?
                return render :action => :new
              },
              :on_valid => ->(id) {
                if inline?
                  @container_profile.refetch
                  render :json => @container_profile.to_hash if inline?
                else
                  flash[:success] = I18n.t("container_profile._frontend.messages.created")
                  return redirect_to :controller => :container_profiles, :action => :new if params.has_key?(:plus_one)
                  redirect_to(:controller => :container_profiles, :action => :show, :id => id)
                end
              })
end

#current_recordObject



29
30
31
# File 'frontend/app/controllers/container_profiles_controller.rb', line 29

def current_record
  @container_profile
end

#deleteObject



77
78
79
80
81
82
# File 'frontend/app/controllers/container_profiles_controller.rb', line 77

def delete
  container_profile = JSONModel(:container_profile).find(params[:id])
  container_profile.delete

  redirect_to(:controller => :container_profiles, :action => :index, :deleted_uri => container_profile.uri)
end

#editObject



38
39
40
# File 'frontend/app/controllers/container_profiles_controller.rb', line 38

def edit
  @container_profile = JSONModel(:container_profile).find(params[:id])
end

#indexObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'frontend/app/controllers/container_profiles_controller.rb', line 15

def index
  respond_to do |format|
    format.html {
      @search_data = Search.for_type(session[:repo_id], "container_profile", params_for_backend_search.merge({"facet[]" => SearchResultData.CONTAINER_PROFILE_FACETS}))
    }
    format.csv {
      search_params = params_for_backend_search.merge({"facet[]" => SearchResultData.CONTAINER_PROFILE_FACETS})
      search_params["type[]"] = "container_profile"
      uri = "/repositories/#{session[:repo_id]}/search"
      csv_response( uri, Search.build_filters(search_params), "#{I18n.t('container_profile._plural').downcase}." )
    }
  end
end

#newObject



8
9
10
11
12
# File 'frontend/app/controllers/container_profiles_controller.rb', line 8

def new
  @container_profile = JSONModel(:container_profile).new._always_valid!

  render_aspace_partial :partial => "container_profiles/new" if inline?
end

#showObject



33
34
35
# File 'frontend/app/controllers/container_profiles_controller.rb', line 33

def show
  @container_profile = JSONModel(:container_profile).find(params[:id])
end

#typeaheadObject



85
86
87
88
89
90
91
# File 'frontend/app/controllers/container_profiles_controller.rb', line 85

def typeahead
  search_params = params_for_backend_search

  search_params = search_params.merge("sort" => "typeahead_sort_key_u_sort asc")

  render :json => Search.all(session[:repo_id], search_params)
end

#updateObject



63
64
65
66
67
68
69
70
71
72
73
74
# File 'frontend/app/controllers/container_profiles_controller.rb', line 63

def update
  handle_crud(:instance => :container_profile,
              :model => JSONModel(:container_profile),
              :obj => JSONModel(:container_profile).find(params[:id]),
              :replace => true,
              :on_invalid => ->() {
                return render :action => :edit
              },
              :on_valid => ->(id) {
                redirect_to(:controller => :container_profiles, :action => :show, :id => id)
              })
end