Class: CustomReportTemplatesController

Inherits:
ApplicationController show all
Defined in:
frontend/app/controllers/custom_report_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

#copyObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'frontend/app/controllers/custom_report_templates_controller.rb', line 26

def copy
  handle_crud(:instance => :custom_report_template,
              :model => JSONModel(:custom_report_template),
              :obj => JSONModel(:custom_report_template).find(params[:id]).dup,
              :replace => false,
              :copy => true,
              :on_invalid => ->() {
                render :action => :edit
              },
              :on_valid => ->(id) {
                flash[:success] = I18n.t("custom_report_template._frontend.messages.copied")
                return redirect_to :controller => :custom_report_templates, :action => :new if params.has_key?(:plus_one)
                redirect_to(:controller => :custom_report_templates, :action => :edit, :id => id)
              })
end

#createObject



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'frontend/app/controllers/custom_report_templates_controller.rb', line 42

def create
  fix_params
  handle_crud(:instance => :custom_report_template,
              :model => JSONModel(:custom_report_template),
              :on_invalid => ->() {
                render :action => "new"
              },
              :on_valid => ->(id) {
                flash[:success] = I18n.t("custom_report_template._frontend.messages.created")
                return redirect_to :controller => :custom_report_templates, :action => :new if params.has_key?(:plus_one)
                redirect_to(:controller => :custom_report_templates, :action => :index)
              })
end

#current_recordObject



14
15
16
# File 'frontend/app/controllers/custom_report_templates_controller.rb', line 14

def current_record
  @custom_report_template
end

#deleteObject



72
73
74
75
76
77
# File 'frontend/app/controllers/custom_report_templates_controller.rb', line 72

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

  redirect_to(:controller => :custom_report_templates, :action => :index, :deleted_uri => custom_report_template.uri)
end

#editObject



10
11
12
# File 'frontend/app/controllers/custom_report_templates_controller.rb', line 10

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

#indexObject



22
23
24
# File 'frontend/app/controllers/custom_report_templates_controller.rb', line 22

def index
  @search_data = JSONModel(:custom_report_template).all(:page => selected_page)
end

#newObject



6
7
8
# File 'frontend/app/controllers/custom_report_templates_controller.rb', line 6

def new
  @custom_report_template = JSONModel(:custom_report_template).new._always_valid!
end

#showObject



18
19
20
# File 'frontend/app/controllers/custom_report_templates_controller.rb', line 18

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

#updateObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'frontend/app/controllers/custom_report_templates_controller.rb', line 56

def update
  fix_params
  handle_crud(:instance => :custom_report_template,
              :model => JSONModel(:custom_report_template),
              :obj => JSONModel(:custom_report_template).find(params[:id]),
              :replace => true,
              :on_invalid => ->() {
                render :action => :edit
              },
              :on_valid => ->(id) {
                flash[:success] = I18n.t("custom_report_template._frontend.messages.updated")
                return redirect_to :controller => :custom_report_templates, :action => :new if params.has_key?(:plus_one)
                redirect_to(:controller => :custom_report_templates, :action => :index)
              })
end