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



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'frontend/app/controllers/custom_report_templates_controller.rb', line 31

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



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'frontend/app/controllers/custom_report_templates_controller.rb', line 47

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



77
78
79
80
81
82
# File 'frontend/app/controllers/custom_report_templates_controller.rb', line 77

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
25
26
27
28
29
# File 'frontend/app/controllers/custom_report_templates_controller.rb', line 22

def index
  @search_data = JSONModel(:custom_report_template).all(
    page: selected_page,
    page_size: 50,
    sort_field: params.fetch(:sort, :name),
    sort_direction: params.fetch(:direction, :asc)
  )
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



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'frontend/app/controllers/custom_report_templates_controller.rb', line 61

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