Module: BuildingsHelper

Defined in:
app/helpers/buildings_helper.rb

Overview

Helper module for working with buildings in your application.

Class Method Summary collapse

Class Method Details

.building_typesHash

Provides a list of building types with their corresponding codes and descriptions.

Returns:

  • (Hash)

    A hash of building types with codes as keys and descriptions as values.



23
24
25
26
27
28
29
30
31
32
33
# File 'app/helpers/buildings_helper.rb', line 23

def self.building_types
  {
    '-1-1' => '',
    '100' => 'Common Building',
    '150' => 'Duplex',
    '200' => 'Lowrise/Garden Apartment',
    '300' => 'Mid/High Rise',
    '400' => 'Row/Townhouse',
    '500' => 'Single Family '
  }
end

.get_building_name(building_id) ⇒ String

Gets the name of a building based on its ID.

Parameters:

  • building_id (Integer)

    The ID of the building to retrieve the name for.

Returns:

  • (String)

    The name of the building if found; otherwise, an empty string.



10
11
12
13
14
15
16
17
18
# File 'app/helpers/buildings_helper.rb', line 10

def self.get_building_name(building_id)
  building = Building.where(old_id: building_id)
      .or(Building.where(id: building_id)).first
  if building
    return building.building_name
  else
    return ''
  end
end

.new_nav_list(property_id) ⇒ Hash

Generates a navigation list for creating new buildings within a property.

Parameters:

  • property_id (Integer)

    The ID of the property for which new buildings are to be added.

Returns:

  • (Hash)

    A navigation list with step numbers and labels.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/helpers/buildings_helper.rb', line 39

def self.new_nav_list(property_id)
  {
    1 => {
      label: 'Properties',
      url: '/admin/properties/'
    },
    2 => {
      url: '/admin/properties/' + property_id.to_s,
      label: 'Buildings'
    },
    3 => {
      label: 'New Buildings'
    }
  }
end

.show_nav_list(property_id) ⇒ Hash

Generates a navigation list for displaying buildings within a property.

Parameters:

  • property_id (Integer)

    The ID of the property for which buildings are displayed.

Returns:

  • (Hash)

    A navigation list with step numbers and labels.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/helpers/buildings_helper.rb', line 59

def self.show_nav_list(property_id)
  {
    1 => {
      label: 'Properties',
      url: '/admin/properties/'
    },
    2 => {
      url: '/admin/properties/' + property_id.to_s,
      label: 'Buildings'
    },
    3 => {
      label: 'Units'
    }
  }
end