Class: RdeTemplatesController

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

Constant Summary

Constants included from Searchable

Searchable::ABSTRACT

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

Instance Method Details

#batch_deleteObject



41
42
43
44
45
46
47
48
# File 'frontend/app/controllers/rde_templates_controller.rb', line 41

def batch_delete
  params[:ids].each do |id|
    template = JSONModel(:rde_template).find(id)
    template.delete
  end

  redirect_to :action => 'index'
end

#createObject



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

#indexObject



21
22
23
24
25
26
27
28
29
30
31
# 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

  render :json => templates
end

#showObject



34
35
36
37
38
# File 'frontend/app/controllers/rde_templates_controller.rb', line 34

def show
  template = JSONModel(:rde_template).find(params[:id])

  render :json => template
end