Class: RdeTemplatesController
Instance Method Summary
collapse
#archivesspace, can_access?, permission_mappings, set_access_control
Instance Method Details
#batch_delete ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'frontend/app/controllers/rde_templates_controller.rb', line 42
def batch_delete
params[:ids].each do |id|
template = JSONModel(:rde_template).find(id)
template.delete
end
redirect_to :action => 'index'
end
|
#create ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'frontend/app/controllers/rde_templates_controller.rb', line 6
def create
template_param = params['template']
if template_param.respond_to?(:to_unsafe_hash)
template_param = template_param.to_unsafe_hash
end
template = JSONModel(:rde_template).from_hash(template_param)
id = template.save
render :json => {id: id}
end
|
#index ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'frontend/app/controllers/rde_templates_controller.rb', line 21
def index
templates = JSONModel(:rde_template).all.map do |template|
{
:name => template.name,
:id => template.id,
:record_type => template.record_type
}
end
templates.sort_by! {|h| h[:name]} if user_prefs['rde_sort_alpha']
render :json => templates
end
|
#show ⇒ Object
35
36
37
38
39
|
# File 'frontend/app/controllers/rde_templates_controller.rb', line 35
def show
template = JSONModel(:rde_template).find(params[:id])
render :json => template
end
|