Class: CollectionManagementRecordsController

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

#createObject



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

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

                redirect_to :controller => :collection_management_records, :action => :index, :id => id
              })
end

#current_recordObject



11
12
13
# File 'frontend/app/controllers/collection_management_records_controller.rb', line 11

def current_record
  @collection_management
end

#editObject



24
25
26
# File 'frontend/app/controllers/collection_management_records_controller.rb', line 24

def edit
  @collection_management = JSONModel(:collection_management).find(params[:id], "resolve[]" => ["linked_records"])
end

#indexObject



7
8
9
# File 'frontend/app/controllers/collection_management_records_controller.rb', line 7

def index
  @search_data = JSONModel(:collection_management).all(:page => 1)
end

#newObject



19
20
21
22
# File 'frontend/app/controllers/collection_management_records_controller.rb', line 19

def new
  @collection_management = JSONModel(:collection_management).new._always_valid!
  @collection_management.linked_records = [{}]
end

#showObject



15
16
17
# File 'frontend/app/controllers/collection_management_records_controller.rb', line 15

def show
  @collection_management = JSONModel(:collection_management).find(params[:id], "resolve[]" => ["linked_records"])
end

#updateObject



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

def update
  handle_crud(:instance => :collection_management,
              :obj => JSONModel(:collection_management).find(params[:id]),
              :on_invalid => ->() { render :action => :edit },
              :on_valid => ->(id) {
                flash[:success] = I18n.t("collection_management._frontend.messages.updated")
                redirect_to :controller => :collection_management_records, :action => :index
              })
end