diff --git a/app/assets/images/default-floor.jpg b/app/assets/images/default-floor.jpg new file mode 100644 index 0000000..0adfe4f Binary files /dev/null and b/app/assets/images/default-floor.jpg differ diff --git a/app/controllers/spaces_controller.rb b/app/controllers/spaces_controller.rb index 162836d..3d4e479 100644 --- a/app/controllers/spaces_controller.rb +++ b/app/controllers/spaces_controller.rb @@ -1,8 +1,8 @@ class SpacesController < ApplicationController def index buildings = Building.all.collect do |building| - floors = building.floors.collect do |floor| - image = (!floor.layout_image.nil? ? floor.layout_image.url : "/assets/no-layout.jpg") + floors = building.floors.desc(:title).collect do |floor| + image = (!floor.frontend_image.thumb.url.nil? ? floor.frontend_image.thumb.url : "/assets/default-floor.jpg") { "floor-title" => floor.title, "floor-image" => image, @@ -20,9 +20,102 @@ class SpacesController < ApplicationController { "buildings" => buildings, - "extra" => { + "extras" => { } } end -end \ No newline at end of file + + 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 + + + + + + + diff --git a/app/views/admin/spaces/floor_layout.html.erb b/app/views/admin/spaces/floor_layout.html.erb index 2cebf8c..f52d54b 100644 --- a/app/views/admin/spaces/floor_layout.html.erb +++ b/app/views/admin/spaces/floor_layout.html.erb @@ -196,9 +196,8 @@ } }) } - return false; } - + return false; }) form.append(field); form.append(checkbox); diff --git a/app/views/admin/spaces/floors.html.erb b/app/views/admin/spaces/floors.html.erb index 10505bb..df64cc9 100644 --- a/app/views/admin/spaces/floors.html.erb +++ b/app/views/admin/spaces/floors.html.erb @@ -11,7 +11,7 @@
- <%= render :partial => "floor", :collection => @building.floors %> + <%= render :partial => "floor", :collection => @building.floors.asc(:title) %>