Class: LocationProfilesController

Inherits:
ApplicationController show all
Defined in:
frontend/app/controllers/location_profiles_controller.rb

Constant Summary collapse

FACETS =
["location_profile_width_u_sstr", "location_profile_height_u_sstr", "location_profile_depth_u_sstr", "location_profile_dimension_units_u_sstr"]

Constants included from Searchable

Searchable::ABSTRACT

Class Method Summary collapse

Instance Method Summary collapse

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

Class Method Details

.FACETSObject



9
10
11
# File 'frontend/app/controllers/location_profiles_controller.rb', line 9

def self.FACETS
  FACETS
end

Instance Method Details

#createObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'frontend/app/controllers/location_profiles_controller.rb', line 40

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

#current_recordObject



25
26
27
# File 'frontend/app/controllers/location_profiles_controller.rb', line 25

def current_record
  @location_profile
end

#deleteObject



74
75
76
77
78
79
# File 'frontend/app/controllers/location_profiles_controller.rb', line 74

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

  redirect_to(:controller => :location_profiles, :action => :index, :deleted_uri => location_profile.uri)
end

#editObject



35
36
37
# File 'frontend/app/controllers/location_profiles_controller.rb', line 35

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

#indexObject



20
21
22
# File 'frontend/app/controllers/location_profiles_controller.rb', line 20

def index
  @search_data = Search.global(params_for_backend_search.merge({"facet[]" => FACETS}), "location_profile")
end

#newObject



13
14
15
16
17
# File 'frontend/app/controllers/location_profiles_controller.rb', line 13

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

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

#showObject



30
31
32
# File 'frontend/app/controllers/location_profiles_controller.rb', line 30

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

#typeaheadObject



82
83
84
# File 'frontend/app/controllers/location_profiles_controller.rb', line 82

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

#updateObject



60
61
62
63
64
65
66
67
68
69
70
71
# File 'frontend/app/controllers/location_profiles_controller.rb', line 60

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