Class: SpaceCalculatorController

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

#calculateObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'frontend/app/controllers/space_calculator_controller.rb', line 19

def calculate
  if params[:container_profile]
    @container_profile_ref = params[:container_profile][:ref]
  end

  if params[:location]
    # by location(s)
    @location_refs = ASUtils.wrap(params[:location]).map {|loc| loc[:ref]}.flatten.compact

    if @container_profile_ref && @location_refs
      @results = JSONModel::HTTP.get_json("/space_calculator/by_location", {
        'container_profile_uri' => @container_profile_ref,
        'location_uris[]' => @location_refs
      })
    end
  elsif params[:building]
    # by building
    building = params[:building]
    floor = params[:floor].blank? ? nil : params[:floor]
    room = params[:room].blank? ? nil : params[:room]
    area = params[:area].blank? ? nil : params[:area]

    @by_building = true

    if @container_profile_ref
      @results = JSONModel::HTTP.get_json("/space_calculator/by_building", {
        'container_profile_uri' => @container_profile_ref,
        'building' => building,
        'floor' => floor,
        'room' => room,
        'area' => area,
      })
    end
  end

  @selectable = params[:selectable] == "true"

  render_aspace_partial :partial => "space_calculator/results"
end

#showObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'frontend/app/controllers/space_calculator_controller.rb', line 5

def show
  @container_profile_ref = params[:container_profile_ref]

  unless @container_profile_ref.blank?
    @container_profile = JSONModel(:container_profile).find_by_uri(@container_profile_ref)
  end

  @buildings = JSONModel::HTTP.get_json("/space_calculator/buildings")

  @selectable = params[:selectable] == "true"

  render_aspace_partial :partial => "space_calculator/form"
end