Class: Datum::Admin::RecordListsController
- Inherits:
-
BaseController
- Object
- BaseController
- Datum::Admin::RecordListsController
- Defined in:
- app/controllers/datum/admin/record_lists_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #edit_columns ⇒ Object
- #find ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #row ⇒ Object
- #run ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #update_columns ⇒ Object
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 |
# File 'app/controllers/datum/admin/record_lists_controller.rb', line 25 def create @record_list = @data_record.record_lists.build(record_list_params) @record_list.save redirect_to data_record_record_lists_url(@data_record) end |
#destroy ⇒ Object
74 75 76 77 |
# File 'app/controllers/datum/admin/record_lists_controller.rb', line 74 def destroy @record_list.destroy redirect_to data_record_record_lists_url(@data_record), notice: 'Export file was successfully destroyed.' end |
#edit ⇒ Object
48 49 |
# File 'app/controllers/datum/admin/record_lists_controller.rb', line 48 def edit end |
#edit_columns ⇒ Object
56 57 |
# File 'app/controllers/datum/admin/record_lists_controller.rb', line 56 def edit_columns end |
#find ⇒ Object
32 33 34 35 |
# File 'app/controllers/datum/admin/record_lists_controller.rb', line 32 def find @record_list = @data_record.record_lists.find_or_create_by(parameters: params.permit(*@data_record.parameters.keys).to_h) @record_list.run unless @record_list.done end |
#index ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/datum/admin/record_lists_controller.rb', line 9 def index extra_params = params.fetch(:q, {}).permit(@data_record.parameters.keys) extra_params.reject! { |_, value| value.blank? } if extra_params.present? query = { parameters: extra_params.to_unsafe_hash } else query = {} end @record_lists = @data_record.record_lists.where(query).page(params[:page]) end |
#new ⇒ Object
21 22 23 |
# File 'app/controllers/datum/admin/record_lists_controller.rb', line 21 def new @record_list = @data_record.record_lists.build end |
#row ⇒ Object
63 64 65 66 67 |
# File 'app/controllers/datum/admin/record_lists_controller.rb', line 63 def row send_data @record_list.to_row_pdf.render, filename: @record_list.pdf_file_name, type: 'application/pdf' end |
#run ⇒ Object
69 70 71 72 |
# File 'app/controllers/datum/admin/record_lists_controller.rb', line 69 def run @record_list.run redirect_back fallback_location: data_record_record_lists_url(@data_record) end |
#show ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/datum/admin/record_lists_controller.rb', line 37 def show disposition = params[:disposition] || 'inline' respond_to do |format| format.html format.js format.csv { send_data @record_list.to_csv, filename: @record_list.csv_file_name, type: 'application/csv' } format.pdf { send_data @record_list.to_pdf, filename: @record_list.pdf_file_name, disposition: disposition, type: 'application/pdf' } format.xlsx { send_data @record_list.to_xlsx, filename: @record_list.file_name(self.formats[0]), type: 'application/xlsx' } end end |
#update ⇒ Object
51 52 53 54 |
# File 'app/controllers/datum/admin/record_lists_controller.rb', line 51 def update @record_list.update(record_list_params) redirect_to data_record_record_lists_url(@data_record) end |
#update_columns ⇒ Object
59 60 61 |
# File 'app/controllers/datum/admin/record_lists_controller.rb', line 59 def update_columns @record_list.update(columns: columns_params) end |