2015-09-25 06:32:59 +00:00
|
|
|
class SpacesController < ApplicationController
|
2020-09-18 06:39:31 +00:00
|
|
|
def index
|
|
|
|
params = OrbitHelper.params
|
|
|
|
page = Page.where(:page_id => params[:page_id]).first
|
|
|
|
buildings = Building.filter_by_categories.collect do |building|
|
|
|
|
floors = building.floors.desc(:title).collect do |floor|
|
|
|
|
image = (!floor.frontend_image.thumb.url.nil? ? floor.frontend_image.thumb.url : "/assets/default-floor.jpg")
|
|
|
|
link = floor.layout.nil? ? (floor.floor_units.empty? ? "#" : "/#{I18n.locale.to_s}#{page.url}/#{floor.floor_units.first.to_param}?method=unit") : OrbitHelper.url_to_show(floor.to_param)
|
|
|
|
{
|
|
|
|
"floor-title" => floor.title,
|
|
|
|
"floor-image" => image,
|
|
|
|
"alt-title" => floor.title,
|
|
|
|
"link_to_show" => link
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"building-title" => building.title,
|
|
|
|
"building-image" => building.image.url,
|
|
|
|
"alt-title" => building.title,
|
|
|
|
"floors" => floors
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
{
|
|
|
|
"buildings" => buildings,
|
|
|
|
"extras" => {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
params = OrbitHelper.params
|
|
|
|
floor = Floor.where(:uid => params[:uid]).first rescue nil
|
|
|
|
thumb_image = (!floor.frontend_image.thumb.url.nil? ? floor.frontend_image.thumb.url : "/assets/default-floor.jpg")
|
|
|
|
image = (!floor.frontend_image.mobile.url.nil? ? floor.frontend_image.mobile.url : "#")
|
2020-10-01 20:32:20 +00:00
|
|
|
page = Page.where(:page_id => params[:page_id]).first
|
|
|
|
site = Site.first
|
|
|
|
hover_color = (site.orbit_bar_submenu_background_color rescue nil) || 'null'
|
|
|
|
bg_color = (site.orbit_bar_background_color rescue nil) || 'null'
|
|
|
|
block_color = hex2rgba((site.orbit_bar_submenu_background_color rescue nil),0.3) || 'null'
|
2020-09-18 06:39:31 +00:00
|
|
|
{
|
|
|
|
"floor-title" => floor.title,
|
|
|
|
"floor-frontend-image-thumb" => thumb_image,
|
|
|
|
"floor-frontend-image" => image,
|
|
|
|
"image-alt" => floor.title,
|
|
|
|
"building-back-link" => "/" + I18n.locale.to_s + page.url,
|
|
|
|
"floor-layout" => floor.layout,
|
|
|
|
"floor-id" => floor.id.to_s,
|
2020-10-01 20:32:20 +00:00
|
|
|
"page-id" => page.page_id,
|
|
|
|
"hover_color" => hover_color,
|
|
|
|
"bg_color" => bg_color,
|
|
|
|
"block_color" => block_color,
|
|
|
|
"style_label" => style_label(bg_color,site.orbit_bar_text_color)
|
2020-09-18 06:39:31 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def floor_units
|
|
|
|
floor = Floor.find(params[:floor_id]) rescue nil
|
|
|
|
page = Page.where(:page_id => params[:page_id]).first rescue nil
|
|
|
|
units = []
|
|
|
|
if !floor.nil?
|
|
|
|
floor.floor_units.each do |unit|
|
|
|
|
url = "/#{I18n.locale.to_s}#{page.url}/#{unit.to_param}?method=unit" rescue "#"
|
|
|
|
units << {
|
|
|
|
"id" => unit.id.to_s,
|
|
|
|
"url" => url
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
render :json => {"success" => true, "units" => units}
|
|
|
|
end
|
|
|
|
|
|
|
|
def floor_sub_units
|
|
|
|
unit = FloorUnit.find(params[:unit_id]) rescue nil
|
|
|
|
page = Page.where(:page_id => params[:page_id]).first rescue nil
|
|
|
|
units = []
|
|
|
|
if !unit.nil?
|
|
|
|
unit.floor_sub_units.each do |subunit|
|
|
|
|
url = subunit.floor_sub_unit_images.empty? ? "#" : "/#{I18n.locale.to_s}#{page.url}/#{subunit.to_param}?method=showcase&layout=false" rescue "#"
|
|
|
|
units << {
|
|
|
|
"id" => subunit.id.to_s,
|
|
|
|
"url" => url
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
render :json => {"success" => true, "sub_units" => units}
|
|
|
|
end
|
|
|
|
|
|
|
|
def unit
|
|
|
|
params = OrbitHelper.params
|
|
|
|
unit = FloorUnit.where(:uid => params[:uid]).first rescue nil
|
|
|
|
page = Page.where(:page_id => params[:page_id]).first
|
|
|
|
layout = unit.layout.nil? ? "<div id='full-layout-canvas'><img href='<%= unit.layout_image.url %>' id='layout-image'></div>" : unit.layout
|
|
|
|
backlink = unit.floor.layout.nil? ? "/" + I18n.locale.to_s + page.url : "/" + I18n.locale.to_s + page.url + "/#{unit.floor.to_param}"
|
2020-10-01 20:32:20 +00:00
|
|
|
site = Site.first
|
|
|
|
hover_color = (site.orbit_bar_submenu_background_color rescue nil) || 'null'
|
|
|
|
bg_color = (site.orbit_bar_background_color rescue nil) || 'null'
|
|
|
|
block_color = hex2rgba((site.orbit_bar_submenu_background_color rescue nil),0.3) || 'null'
|
2020-09-18 06:39:31 +00:00
|
|
|
{
|
|
|
|
"unit-title" => unit.title,
|
|
|
|
"floor-back-link" => backlink,
|
|
|
|
"unit-layout" => layout,
|
|
|
|
"unit-id" => unit.id.to_s,
|
2020-10-01 20:32:20 +00:00
|
|
|
"page-id" => page.page_id,
|
|
|
|
"hover_color" => hover_color,
|
|
|
|
"bg_color" => bg_color,
|
|
|
|
"block_color" => block_color,
|
|
|
|
"style_label" => style_label(bg_color,site.orbit_bar_text_color)
|
2020-09-18 06:39:31 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def showcase
|
|
|
|
params = OrbitHelper.params
|
|
|
|
unit = FloorSubUnit.where(:uid => params[:uid]).first rescue nil
|
|
|
|
images = []
|
|
|
|
unit.floor_sub_unit_images.each do |image|
|
|
|
|
images << {
|
|
|
|
"image-thumb-url" => image.image.thumb.url,
|
|
|
|
"image-url" => image.image.url,
|
|
|
|
"alt-image" => unit.title
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"unit-images" => images,
|
|
|
|
"extras" => {
|
2020-10-01 20:32:20 +00:00
|
|
|
"unit-title" => unit.title,
|
|
|
|
"content" => unit.content || ''
|
2020-09-18 06:39:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
2020-10-01 20:32:20 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
def hex2rgba(my_hex,percent=1)
|
|
|
|
if my_hex
|
|
|
|
if my_hex[0] == '#'
|
|
|
|
my_hex = my_hex[1..-1]
|
|
|
|
end
|
|
|
|
rgb = my_hex.split(//).each_slice(my_hex.length/3).map{|v| v.join.to_i(16)}
|
|
|
|
"rgba(#{rgb[0]},#{rgb[1]},#{rgb[2]},#{percent})"
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def style_label(color1,color2)
|
|
|
|
if color1
|
|
|
|
"<style>
|
2020-10-02 06:42:40 +00:00
|
|
|
.s-space.show-space .selection-box-label.active{
|
2020-10-01 20:32:20 +00:00
|
|
|
background: #{color1} !important;
|
|
|
|
color: #{color2} !important;
|
|
|
|
}
|
|
|
|
.overlay .anchor{
|
|
|
|
border-color: #{color1} transparent transparent transparent !important;
|
|
|
|
}
|
|
|
|
</style>"
|
|
|
|
else
|
|
|
|
""
|
|
|
|
end
|
|
|
|
end
|
2015-10-13 10:28:29 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|