Class: ContainerProfilesController

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

Constant Summary

FACETS =
["container_profile_width_u_sstr", "container_profile_height_u_sstr", "container_profile_depth_u_sstr", "container_profile_dimension_units_u_sstr"]

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from ApplicationController

can_access?, permission_mappings, set_access_control

Class Method Details

+ (Object) FACETS



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

def self.FACETS
  FACETS
end

Instance Method Details

- (Object) create



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'frontend/app/controllers/container_profiles_controller.rb', line 35

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

- (Object) delete



70
71
72
73
74
75
# File 'frontend/app/controllers/container_profiles_controller.rb', line 70

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

- (Object) edit



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

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

- (Object) index



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

def index
  @search_data = Search.for_type(session[:repo_id], "container_profile", params_for_backend_search.merge({"facet[]" => FACETS}))
end

- (Object) new



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

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

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

- (Object) show



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

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

- (Object) typeahead



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

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

- (Object) update



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'frontend/app/controllers/container_profiles_controller.rb', line 55

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