Class: ContainerProfilesController
Instance Method Summary
collapse
#archivesspace, can_access?, permission_mappings, session_can?, session_repo, set_access_control, user_preferences
Instance Method Details
#create ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'frontend/app/controllers/container_profiles_controller.rb', line 47
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] = 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_record ⇒ Object
33
34
35
|
# File 'frontend/app/controllers/container_profiles_controller.rb', line 33
def current_record
@container_profile
end
|
#defaults ⇒ Object
97
98
99
100
101
102
103
104
105
106
|
# File 'frontend/app/controllers/container_profiles_controller.rb', line 97
def defaults
defaults = DefaultValues.get 'container_profile'
values = defaults ? defaults.form_values : {}
@container_profile = JSONModel(:container_profile).new(values)._always_valid!
@form_title = t("default_values.form_title.container_profile")
render "defaults"
end
|
#delete ⇒ Object
81
82
83
84
85
86
|
# File 'frontend/app/controllers/container_profiles_controller.rb', line 81
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
|
#edit ⇒ Object
42
43
44
|
# File 'frontend/app/controllers/container_profiles_controller.rb', line 42
def edit
@container_profile = JSONModel(:container_profile).find(params[:id])
end
|
#index ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'frontend/app/controllers/container_profiles_controller.rb', line 19
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), "#{t('container_profile._plural').downcase}." )
}
end
end
|
#new ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'frontend/app/controllers/container_profiles_controller.rb', line 9
def new
@container_profile = JSONModel(:container_profile).new._always_valid!
defaults = user_defaults('container_profile')
@container_profile.update(defaults.values) if defaults
render_aspace_partial :partial => "container_profiles/new" if inline?
end
|
#show ⇒ Object
37
38
39
|
# File 'frontend/app/controllers/container_profiles_controller.rb', line 37
def show
@container_profile = JSONModel(:container_profile).find(params[:id])
end
|
#typeahead ⇒ Object
89
90
91
92
93
94
95
|
# File 'frontend/app/controllers/container_profiles_controller.rb', line 89
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
|
#update ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'frontend/app/controllers/container_profiles_controller.rb', line 67
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
|
#update_defaults ⇒ Object
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'frontend/app/controllers/container_profiles_controller.rb', line 108
def update_defaults
begin
DefaultValues.from_hash({
"record_type" => "container_profile",
"lock_version" => params[:container_profile].delete('lock_version'),
"defaults" => cleanup_params_for_schema(
params[:container_profile],
JSONModel(:container_profile).schema)
}).save
flash[:success] = t("default_values.messages.defaults_updated")
redirect_to :controller => :container_profiles, :action => :defaults
rescue Exception => e
flash[:error] = e.message
redirect_to :controller => :container_profiles, :action => :defaults
end
end
|