From 876c7df7c702d9917ef30739bec5281e2900a922 Mon Sep 17 00:00:00 2001 From: Rulingcom Date: Tue, 13 Oct 2015 18:28:29 +0800 Subject: [PATCH] updates for space module --- app/assets/images/default-floor.jpg | Bin 0 -> 4316 bytes app/controllers/spaces_controller.rb | 101 ++++++++++++++++++- app/views/admin/spaces/floor_layout.html.erb | 3 +- app/views/admin/spaces/floors.html.erb | 2 +- app/views/admin/spaces/unit_layout.html.erb | 3 +- app/views/spaces/show.html.erb | 2 + app/views/spaces/showcase.html.erb | 1 + app/views/spaces/unit.html.erb | 2 + config/routes.rb | 3 + 9 files changed, 109 insertions(+), 8 deletions(-) create mode 100644 app/assets/images/default-floor.jpg create mode 100644 app/views/spaces/show.html.erb create mode 100644 app/views/spaces/showcase.html.erb create mode 100644 app/views/spaces/unit.html.erb diff --git a/app/assets/images/default-floor.jpg b/app/assets/images/default-floor.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0adfe4fdaa8da5efaf756c4c1ebfc3076aede085 GIT binary patch literal 4316 zcma)7c{J3E`~Hl<82cDPc4DT*GTF1tOv)A-rEH_FNP{e6lwBB0WXZl-HOnZ4U-z8fz4zbmbIyCtd!FaK`ycP&=-~_?c0SPE4FJr{P5@lMe>hwL zVCU|*cm@F=fc-b^3IK;|06*5%=f+LIwdFShI%ERT0O)@Q+kXK6i~kR21A%_4zwKY) ze{~L902mj51G>N<7{CStfnlISI*{VL^E>an^J z>2)#nTNOFoCR!8rZ@GVRAC3dOV9@Wzz%T#}9K;7Es2J${5xjV0Gyb}C!?Bvqdv51< z82VglpOWWWZenwjTh*7vk|s4|@YBl=l+p_m4ROlx{n|JWr`T*%F`LX7$@~bdq~!>$ z6rz#X+D6XzD|zD;XG*dgA)n*|Q2>3HVF0OjuBY`_qGAPsl(&$f?AsNE;*1Jax73eo z%rb-AZLFpJ$mph%G0DT0!)tPLA!O+x_9PtGtZUYof3pNKrg1^|>I7(CZW&KdGJA>v zDQBW&A%b;Y7%NWl^)}R#2n)tXA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zv<5w_^ z!lLw6)J%KO33d8Yvn5K(Jy|{?Pg}GgN>YU@FmzjT;L_ULw=a8G-}M&WEp!-3F6NAZ za}@-46M^SqB4S6`vV#krmiDSm+4Ui+vn=r@NY7Dem*lJHDpvJe^vr$AW%YrvJ>sN~ zSL}Lpyn(+&9;pdds{YA>AL)xc^NPaLcTvXU+Hu4ry_se5C`$Vjdd(7bdgJ9q1U&n% zqmW>)m4|N)-qyN#5)erhSwff)l^mH<7I%d@TMl~Ls5`hTk!xvU#iY6k7E$*tl=L9K z_^B8p2w|9>2_y#}cQ2NE$68TZkM-^WtUre~^#~Z9;KUb^t2uNOo1_f4L@0jd5!yJ{ zTZ1yHS;BD5TVXb3aW3e(c6G*%!aktag(mT+m4w)BtIQ zjIM6~@Dd1+v~VlBBOKAmBZ-JvO-=CzE_`A$X611XHLR^__7+sX+8U!LsErbk?lHH= z3rqeyaK^xMxjnK=NeYJmG6bpM*WNTg91wU_K(8tNJW@YYfxhHf^}`O#{1GN z7hfaClXI%pFzDNsZM>BtL1eUgP5EJLnlP0p&EQI&wQhsE`SY#JlT6%SD$S7j>vHDtsOs$SZ0Z(0N+&oJD1p(5vYC z)v&>CcKPG-zUcFVjWnFikj#d%g3P@$2P7f|+E*o0ty7fHUMG yLJ2;A>zGtH(u-2JU- 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) %>
diff --git a/app/views/admin/spaces/unit_layout.html.erb b/app/views/admin/spaces/unit_layout.html.erb index 007c5a8..b630b93 100644 --- a/app/views/admin/spaces/unit_layout.html.erb +++ b/app/views/admin/spaces/unit_layout.html.erb @@ -196,9 +196,10 @@ } }) } - return false; } + return false; + }) form.append(field); form.append(checkbox); diff --git a/app/views/spaces/show.html.erb b/app/views/spaces/show.html.erb new file mode 100644 index 0000000..d6abf63 --- /dev/null +++ b/app/views/spaces/show.html.erb @@ -0,0 +1,2 @@ +<% OrbitHelper.render_css_in_head(["space.scss"]) %> +<%= render_view %> \ No newline at end of file diff --git a/app/views/spaces/showcase.html.erb b/app/views/spaces/showcase.html.erb new file mode 100644 index 0000000..648b75c --- /dev/null +++ b/app/views/spaces/showcase.html.erb @@ -0,0 +1 @@ +<%= render_view %> \ No newline at end of file diff --git a/app/views/spaces/unit.html.erb b/app/views/spaces/unit.html.erb new file mode 100644 index 0000000..d6abf63 --- /dev/null +++ b/app/views/spaces/unit.html.erb @@ -0,0 +1,2 @@ +<% OrbitHelper.render_css_in_head(["space.scss"]) %> +<%= render_view %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index eedab94..2085741 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,6 +35,9 @@ Rails.application.routes.draw do get "floors" 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