updates for space module

This commit is contained in:
IT 2015-10-13 18:28:29 +08:00
parent 2708b8ad28
commit 876c7df7c7
9 changed files with 109 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -1,8 +1,8 @@
class SpacesController < ApplicationController class SpacesController < ApplicationController
def index def index
buildings = Building.all.collect do |building| buildings = Building.all.collect do |building|
floors = building.floors.collect do |floor| floors = building.floors.desc(:title).collect do |floor|
image = (!floor.layout_image.nil? ? floor.layout_image.url : "/assets/no-layout.jpg") image = (!floor.frontend_image.thumb.url.nil? ? floor.frontend_image.thumb.url : "/assets/default-floor.jpg")
{ {
"floor-title" => floor.title, "floor-title" => floor.title,
"floor-image" => image, "floor-image" => image,
@ -20,9 +20,102 @@ class SpacesController < ApplicationController
{ {
"buildings" => buildings, "buildings" => buildings,
"extra" => { "extras" => {
} }
} }
end end
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 : "#")
page = Page.where(:module => OrbitHelper.this_module_app.key).first
{
"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,
"page-id" => page.page_id
}
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 = "/#{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(:module => OrbitHelper.this_module_app.key).first
{
"unit-title" => unit.title,
"floor-back-link" => "/" + I18n.locale.to_s + page.url + "/#{unit.floor.to_param}",
"unit-layout" => unit.layout,
"unit-id" => unit.id.to_s,
"page-id" => page.page_id
}
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" => {
"unit-title" => unit.title
}
}
end
end

View File

@ -196,9 +196,8 @@
} }
}) })
} }
return false;
} }
return false;
}) })
form.append(field); form.append(field);
form.append(checkbox); form.append(checkbox);

View File

@ -11,7 +11,7 @@
</tr> </tr>
</thead> </thead>
<tbody id="floor-list-table"> <tbody id="floor-list-table">
<%= render :partial => "floor", :collection => @building.floors %> <%= render :partial => "floor", :collection => @building.floors.asc(:title) %>
</tbody> </tbody>
</table> </table>
<div class="bottomnav clearfix"> <div class="bottomnav clearfix">

View File

@ -196,9 +196,10 @@
} }
}) })
} }
return false;
} }
return false;
}) })
form.append(field); form.append(field);
form.append(checkbox); form.append(checkbox);

View File

@ -0,0 +1,2 @@
<% OrbitHelper.render_css_in_head(["space.scss"]) %>
<%= render_view %>

View File

@ -0,0 +1 @@
<%= render_view %>

View File

@ -0,0 +1,2 @@
<% OrbitHelper.render_css_in_head(["space.scss"]) %>
<%= render_view %>

View File

@ -35,6 +35,9 @@ Rails.application.routes.draw do
get "floors" get "floors"
end end
end end
get "/xhr/spaces/get_floor_units", to: 'spaces#floor_units'
get "/xhr/spaces/get_floor_sub_units", to: 'spaces#floor_sub_units'
get "/xhr/spaces/showcase", to: 'spaces#showcase'
end end
end end