Class: ExtentCalculatorController

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

#reportObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'frontend/app/controllers/extent_calculator_controller.rb', line 5

def report
  if params['record_uri']
    results = JSONModel::HTTP::get_json("/extent_calculator", {'record_uri' => params['record_uri']})

    extent = if params['referrer'] && params['referrer'].match('/edit(\#.*)?\Z')
               extent = JSONModel(:extent).new
               extent.number = results['total_extent']
               if results['units']
                 units = results['volume'] ? 'cubic_' : 'linear_'
                 units += results['units']
                 extent.extent_type = units
               end
               container_cardinality = results['container_count'] == 1 ?
                                         I18n.t('extent_calculator.container_summary_type._singular') :
                                         I18n.t('extent_calculator.container_summary_type._plural')
               extent.container_summary = "(#{results['container_count']} #{container_cardinality})"
               extent
             end

    render_aspace_partial :partial => "extent_calculator/show_calculation", :locals => {:results => results, :extent => extent}
  else
    render_aspace_partial :partial => "extent_calculator/no_object"
  end
end