From 0d8f44400942aab16c4e027eadc18a5bc0210bcd Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 24 Sep 2015 23:43:47 +0800 Subject: [PATCH] a lot of changes and backend done... --- app/assets/images/no-layout.jpg | Bin 0 -> 3340 bytes app/assets/stylesheets/space.scss | 14 +- app/controllers/admin/spaces_controller.rb | 114 ++++++- app/models/floor_sub_unit.rb | 11 + app/models/floor_sub_unit_image.rb | 9 + app/models/floor_unit.rb | 8 +- app/views/admin/spaces/_floor.html.erb | 2 +- app/views/admin/spaces/_floor_unit.html.erb | 8 +- .../admin/spaces/_floor_unit_form.html.erb | 16 +- app/views/admin/spaces/_sub_unit.html.erb | 7 + .../admin/spaces/_sub_unit_form.html.erb | 83 +++++ app/views/admin/spaces/add_sub_unit.html.erb | 85 +++++ .../admin/spaces/edit_floor_unit.html.erb | 5 + app/views/admin/spaces/edit_sub_unit.html.erb | 85 +++++ app/views/admin/spaces/floor_layout.html.erb | 175 ++++++++-- app/views/admin/spaces/sub_units.html.erb | 12 + app/views/admin/spaces/unit_layout.html.erb | 306 ++++++++++++++++++ app/views/admin/spaces/units.html.erb | 2 +- config/locales/en.yml | 5 +- config/locales/zh_tw.yml | 5 +- config/routes.rb | 24 +- 21 files changed, 935 insertions(+), 41 deletions(-) create mode 100644 app/assets/images/no-layout.jpg create mode 100644 app/models/floor_sub_unit.rb create mode 100644 app/models/floor_sub_unit_image.rb create mode 100644 app/views/admin/spaces/_sub_unit.html.erb create mode 100644 app/views/admin/spaces/_sub_unit_form.html.erb create mode 100644 app/views/admin/spaces/add_sub_unit.html.erb create mode 100644 app/views/admin/spaces/edit_floor_unit.html.erb create mode 100644 app/views/admin/spaces/edit_sub_unit.html.erb create mode 100644 app/views/admin/spaces/sub_units.html.erb create mode 100644 app/views/admin/spaces/unit_layout.html.erb diff --git a/app/assets/images/no-layout.jpg b/app/assets/images/no-layout.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c83c1a78089842d9d9644ffd8894d9ff8d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tRrZNX} z?n(*ASH(qLAMsJW6P_~}Fz}mNC3R9BT>pYV^k1z?^iuKg9Ibk1PqVg8^kg92Uj%0* z>>01v%k8E~9rhN03Dv0|>XCie)D+l&g)6mdg>%Onn=G|#G^wSe_{6*0dPBxhf*ud= z%ay`ABZ!Y$Gi=J91#}#qeR{Te)n3PuHHKfrC0c5Fd8(%!Ij&2kgt(AMpw3<)EyMS6lVeVD4U{Dh`Rt`BZ}*Q7O7l8YUybACZvuolQN zuDCN97Wd^C-{a(oTgdfn$`;I1(ZKbTuljvl)hv2WBSWli3K3p@X3ck<&)59srNKBR zS7c{Vn3NUny(fIR?31|HWI2Aqgq{|fI-5|1R%O-P%Q&B*@J1^H?L=-&Uwc@D;_?+ zS#6zhxjolU>@~eTi2ju7nd2Y#Maz&Z2hXuWBar!bZdoyls|04hZ literal 0 HcmV?d00001 diff --git a/app/assets/stylesheets/space.scss b/app/assets/stylesheets/space.scss index 70fe933..32068e3 100644 --- a/app/assets/stylesheets/space.scss +++ b/app/assets/stylesheets/space.scss @@ -70,7 +70,7 @@ ul.apartments-area { padding-bottom: 0; transition-property: left, right, top; width: 150px; - height: 150px; + height: 170px; text-align: center; .apartment-img { @@ -79,10 +79,6 @@ ul.apartments-area { height: 125px; overflow: hidden; - &:hover { - height: 145px; - margin-bottom: 5px; - } } a{ @@ -132,6 +128,10 @@ ul#layout-canvas { width: 2px; height: 2px; background-color: rgba(0, 0, 0, .4); + + .selection-box-label{ + color: #fff; + } } .make-box-permanent{ @@ -152,6 +152,10 @@ ul#layout-canvas { } } +.floor-unit-title{ + text-align: center; +} + diff --git a/app/controllers/admin/spaces_controller.rb b/app/controllers/admin/spaces_controller.rb index 4c6394b..61bc34c 100644 --- a/app/controllers/admin/spaces_controller.rb +++ b/app/controllers/admin/spaces_controller.rb @@ -41,8 +41,8 @@ class Admin::SpacesController < OrbitAdminController end def delete_floor - floor = Floor.find_by(:uid => params[:floor_id].split("-").last) - floor.destroy + floor = Floor.find_by(:uid => params[:floor_id].split("-").last) rescue nil + floor.destroy if !floor.nil? render :json => {"success" => true}.to_json end @@ -60,12 +60,122 @@ class Admin::SpacesController < OrbitAdminController end end + def edit_floor_unit + @floor_unit = FloorUnit.find_by(:uid => params[:unit_id].split("-").last) rescue nil + @floor = @floor_unit.floor + end + + def update_floor_unit + floor_unit = FloorUnit.find(params[:unit_id]) rescue nil + if !floor_unit.nil? + floor_unit.update_attributes(floor_unit_params) + floor_unit.save + end + redirect_to "/admin/spaces/#{floor_unit.floor.building.to_param}/#{floor_unit.floor.to_param}/units" + end + + def save_floor_layout + floor = Floor.find(params[:floor_id]) rescue nil + if !floor.nil? + floor.layout = params[:layout_html] + floor.save + end + render :json => {"success" => true}.to_json + end + + def delete_floor_unit + floor_unit = FloorUnit.find_by(:uid => params[:unit_id].split("-").last) rescue nil + floor = floor_unit.floor + if !floor_unit.nil? + floor_unit.destroy + end + redirect_to "/admin/spaces/#{floor.building.to_param}/#{floor.to_param}/units" + + end + def units @floor = Floor.find_by(:uid => params[:floor_id].split("-").last) end + def sub_units + @floor_unit = FloorUnit.find_by(:uid => params[:unit_id].split("-").last) + end + + def add_sub_unit + @floor_unit = FloorUnit.find_by(:uid => params[:unit_id].split("-").last) rescue nil + @sub_unit = FloorSubUnit.new + end + + def edit_sub_unit + @sub_unit = FloorSubUnit.find_by(:uid => params[:sub_unit_id].split("-").last) rescue nil + end + + def update_sub_unit + sub_unit = FloorSubUnit.find(params[:floor_sub_unit_id]) rescue nil + if !sub_unit.nil? + p = sub_unit_params + p[:floor_sub_unit_images].concat(sub_unit.floor_sub_unit_images) if p[:floor_sub_unit_images].present? + sub_unit.update_attributes(p) + sub_unit.save + end + if params[:images_to_destroy].present? + params[:images_to_destroy].each do |id| + image = FloorSubUnitImage.find(id) rescue nil + image.destroy if !image.nil? + end + end + redirect_to "/admin/spaces/#{sub_unit.floor_unit.floor.to_param}/#{sub_unit.floor_unit.to_param}/sub_units" + end + + def upload_sub_unit_image + image = FloorSubUnitImage.new(image_params) + image.save + render :json => {"success" => true,"id" => image.id.to_s}.to_json + end + + def create_sub_unit + sub_unit = FloorSubUnit.new(sub_unit_params) + sub_unit.save + respond_to do |format| + format.html {redirect_to "/admin/spaces/#{sub_unit.floor_unit.floor.to_param}/#{sub_unit.floor_unit.to_param}/sub_units"} + format.js {render :json => {"success" => true, "unit" => {"id" => sub_unit.id.to_s, "title" => sub_unit.title}}.to_json} + end + end + + def unit_layout + @floor_unit = FloorUnit.find_by(:uid => params[:unit_id].split("-").last) rescue nil + end + + def save_unit_layout + floor_unit = FloorUnit.find(params[:unit_id]) rescue nil + if !floor_unit.nil? + floor_unit.layout = params[:layout_html] + floor_unit.save + end + render :json => {"success" => true}.to_json + end + + + private + def sub_unit_params + p = params.require(:floor_sub_unit).permit! + if p[:floor_sub_unit_images].present? + images = [] + p[:floor_sub_unit_images].each do |id| + image = FloorSubUnitImage.find(id) rescue nil + images << image if !image.nil? + end + p[:floor_sub_unit_images] = images + end + p + end + + def image_params + params.require(:floor_sub_unit_image).permit! + end + def floor_params params.require(:floor).permit! end diff --git a/app/models/floor_sub_unit.rb b/app/models/floor_sub_unit.rb new file mode 100644 index 0000000..a0d8c67 --- /dev/null +++ b/app/models/floor_sub_unit.rb @@ -0,0 +1,11 @@ +class FloorSubUnit + include Mongoid::Document + include Mongoid::Timestamps + include Slug + + field :title, as: :slug_title, localize: true + + has_many :floor_sub_unit_images, :autosave => true, :dependent => :destroy + belongs_to :floor_unit + +end \ No newline at end of file diff --git a/app/models/floor_sub_unit_image.rb b/app/models/floor_sub_unit_image.rb new file mode 100644 index 0000000..de0940e --- /dev/null +++ b/app/models/floor_sub_unit_image.rb @@ -0,0 +1,9 @@ +class FloorSubUnitImage + include Mongoid::Document + include Mongoid::Timestamps + + mount_uploader :image, ImageUploader + + belongs_to :floor_sub_unit + +end \ No newline at end of file diff --git a/app/models/floor_unit.rb b/app/models/floor_unit.rb index bf8dd24..30995d4 100644 --- a/app/models/floor_unit.rb +++ b/app/models/floor_unit.rb @@ -1,11 +1,15 @@ class FloorUnit include Mongoid::Document include Mongoid::Timestamps + include Slug - field :title + field :title, as: :slug_title + field :layout + belongs_to :floor + has_many :floor_sub_units - mount_uploader :layout, ImageUploader + mount_uploader :layout_image, ImageUploader end \ No newline at end of file diff --git a/app/views/admin/spaces/_floor.html.erb b/app/views/admin/spaces/_floor.html.erb index 035b99d..98b62e9 100644 --- a/app/views/admin/spaces/_floor.html.erb +++ b/app/views/admin/spaces/_floor.html.erb @@ -1,7 +1,7 @@ <%= floor.title %> - <% if !floor.floor_units.blank? %> + <% if !floor.layout_image.url.nil? %> Floor Layout <% end %> Edit Floor diff --git a/app/views/admin/spaces/_floor_unit.html.erb b/app/views/admin/spaces/_floor_unit.html.erb index 4e1c5e8..8ad35d2 100644 --- a/app/views/admin/spaces/_floor_unit.html.erb +++ b/app/views/admin/spaces/_floor_unit.html.erb @@ -1,8 +1,12 @@
  • - +
    - " > + " >

    <%= floor_unit.title %>

    + Edit | Delete + <% if !floor_unit.layout_image.thumb.url.nil? %> + | Layout + <% end %>
  • \ No newline at end of file diff --git a/app/views/admin/spaces/_floor_unit_form.html.erb b/app/views/admin/spaces/_floor_unit_form.html.erb index afb7ac9..338426c 100644 --- a/app/views/admin/spaces/_floor_unit_form.html.erb +++ b/app/views/admin/spaces/_floor_unit_form.html.erb @@ -25,10 +25,10 @@
    -
    +
    - <% if @floor_unit.layout.file %> - <%= image_tag @floor_unit.layout %> + <% if @floor_unit.layout_image.file %> + <%= image_tag @floor_unit.layout_image %> <% else %> <% end %> @@ -37,12 +37,12 @@ <%= t(:select_image) %> <%= t(:change) %> - <%= f.file_field :layout %> + <%= f.file_field :layout_image %> <%= t(:cancel) %>
    @@ -56,7 +56,11 @@
    - <%= f.hidden_field :floor_id, value: @floor.id %> + <% if params[:action] == "add_floor_unit" %> + <%= f.hidden_field :floor_id, value: @floor.id %> + <% elsif params[:action] == "edit_floor_unit" %> + <%= hidden_field_tag :unit_id, @floor_unit.id.to_s %> + <% end %> <%= f.submit t('submit'), class: 'btn btn-primary' %> <%= link_to t('cancel'), "/admin/spaces/#{@floor.building.to_param}/#{@floor.to_param}/units", :class=>"btn" %>
    \ No newline at end of file diff --git a/app/views/admin/spaces/_sub_unit.html.erb b/app/views/admin/spaces/_sub_unit.html.erb new file mode 100644 index 0000000..40838fd --- /dev/null +++ b/app/views/admin/spaces/_sub_unit.html.erb @@ -0,0 +1,7 @@ +
  • +
    + " > +
    +

    <%= sub_unit.title %>

    + Edit | Delete +
  • \ No newline at end of file diff --git a/app/views/admin/spaces/_sub_unit_form.html.erb b/app/views/admin/spaces/_sub_unit_form.html.erb new file mode 100644 index 0000000..cba9d77 --- /dev/null +++ b/app/views/admin/spaces/_sub_unit_form.html.erb @@ -0,0 +1,83 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/main-list" %> + <%= stylesheet_link_tag "lib/dropzone" %> + <%= stylesheet_link_tag "//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" %> + <%= stylesheet_link_tag "//cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.6/animate.min.css" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/dropzone" %> + <%= javascript_include_tag "validator" %> +<% end %> + +
    + + Uploading... +
    + + +
    + +
    + + +
    + + <% @site_in_use_locales.each do |locale| %> + <%= f.fields_for :title_translations do |f| %> +
    + <%= f.label :title.to_s + " (" + locale.to_s + ")", :class => "control-label muted" %> +
    + <%= f.text_field locale, placeholder: t("space.sub_unit_name"), data: {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"}, :value => @sub_unit.title_translations[locale.to_s] %> +
    +
    + <% end %> + <% end %> + +
    + +
    + <% if params[:action] == "edit_sub_unit" %> +
    + <% @sub_unit.floor_sub_unit_images.each do |image| %> +
    +
    +
    + +
    +
    + + +
    +
    +
    + <% end %> +
    + <% end %> +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    + + + +
    + <% if params[:action] == "add_sub_unit" %> + <%= f.hidden_field :floor_unit, :value => @floor_unit.id %> + <% elsif params[:action] == "edit_sub_unit" %> + <%= hidden_field_tag :floor_sub_unit_id, @sub_unit.id.to_s %> + <% end %> + <%= f.submit t('submit'), class: 'btn btn-primary', :id => "floor-sub-unit-form-btn" %> +
    \ No newline at end of file diff --git a/app/views/admin/spaces/add_sub_unit.html.erb b/app/views/admin/spaces/add_sub_unit.html.erb new file mode 100644 index 0000000..f0e80a9 --- /dev/null +++ b/app/views/admin/spaces/add_sub_unit.html.erb @@ -0,0 +1,85 @@ +<%= form_for @sub_unit, url: "/admin/space/create_sub_unit", html: {class: "form-horizontal main-forms"} do |f| %> +
    + <%= render :partial => "sub_unit_form", locals: {f: f} %> +
    +<% end %> + + \ No newline at end of file diff --git a/app/views/admin/spaces/edit_floor_unit.html.erb b/app/views/admin/spaces/edit_floor_unit.html.erb new file mode 100644 index 0000000..694306e --- /dev/null +++ b/app/views/admin/spaces/edit_floor_unit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @floor_unit, url: "/admin/space/update_floor_unit", html: {class: "form-horizontal main-forms"} do |f| %> +
    + <%= render :partial => "floor_unit_form", locals: {f: f} %> +
    +<% end %> \ No newline at end of file diff --git a/app/views/admin/spaces/edit_sub_unit.html.erb b/app/views/admin/spaces/edit_sub_unit.html.erb new file mode 100644 index 0000000..1bf74cd --- /dev/null +++ b/app/views/admin/spaces/edit_sub_unit.html.erb @@ -0,0 +1,85 @@ +<%= form_for @sub_unit, url: "/admin/space/update_sub_unit", html: {class: "form-horizontal main-forms edit_sub_unit_form"} do |f| %> +
    + <%= render :partial => "sub_unit_form", locals: {f: f} %> +
    +<% end %> + + \ No newline at end of file diff --git a/app/views/admin/spaces/floor_layout.html.erb b/app/views/admin/spaces/floor_layout.html.erb index 097f689..2cebf8c 100644 --- a/app/views/admin/spaces/floor_layout.html.erb +++ b/app/views/admin/spaces/floor_layout.html.erb @@ -5,26 +5,42 @@ <% content_for :page_specific_javascript do %> <%= javascript_include_tag "attrchange" %> <% end %> - -
    - -
    +
    +

    <%= @floor.title %>

    +
    +<% if @floor.layout == nil %> +
    + +
    +
    +<% else %> + <%= @floor.layout.html_safe %> +<% end %> +
    +
    + +
    +<% if !@floor.layout.nil? %> + +<% end %> diff --git a/app/views/admin/spaces/sub_units.html.erb b/app/views/admin/spaces/sub_units.html.erb new file mode 100644 index 0000000..3c196e0 --- /dev/null +++ b/app/views/admin/spaces/sub_units.html.erb @@ -0,0 +1,12 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "space" %> +<% end %> +
      + <%= render :partial => "sub_unit", :collection => @floor_unit.floor_sub_units %> +
    + + \ No newline at end of file diff --git a/app/views/admin/spaces/unit_layout.html.erb b/app/views/admin/spaces/unit_layout.html.erb new file mode 100644 index 0000000..007c5a8 --- /dev/null +++ b/app/views/admin/spaces/unit_layout.html.erb @@ -0,0 +1,306 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" %> + <%= stylesheet_link_tag "space" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "attrchange" %> +<% end %> +
    +

    <%= @floor_unit.title %>

    +
    +<% if @floor_unit.layout == nil %> +
    + +
    +
    +<% else %> + <%= @floor_unit.layout.html_safe %> +<% end %> +
    +
    + +
    +
    + +<% if !@floor_unit.layout.nil? %> + +<% end %> + + + + + + diff --git a/app/views/admin/spaces/units.html.erb b/app/views/admin/spaces/units.html.erb index 052b173..a52b029 100644 --- a/app/views/admin/spaces/units.html.erb +++ b/app/views/admin/spaces/units.html.erb @@ -2,7 +2,7 @@ <%= stylesheet_link_tag "space" %> <% end %>
      - <%= render :partial => "floor_unit", :collection => @floor.floor_units %> + <%= render :partial => "floor_unit", :collection => @floor.floor_units.asc(:title) %>
    diff --git a/config/locales/en.yml b/config/locales/en.yml index aa644fb..722cc62 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -9,4 +9,7 @@ en: simple_layout: Simple Layout detailed_layout: Detailed Layout floor_unit_name: Unit Name - save_layout: Save Layout \ No newline at end of file + save_layout: Save Layout + save_floor_layout: Save Layout + add_sub_units: Add SubUnit + sub_unit_name: SubUnit Name \ No newline at end of file diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 3b65da6..4cb42a3 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -9,4 +9,7 @@ zh_tw: simple_layout: Simple Layout detailed_layout: Detailed Layout floor_unit_name: Unit Name - save_layout: Save Layout \ No newline at end of file + save_layout: Save Layout + save_floor_layout: Save Layout + add_sub_units: Add SubUnit + sub_unit_name: SubUnit Name \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index ae4f3e7..eedab94 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,10 +6,30 @@ Rails.application.routes.draw do namespace :admin do post "space/add_floor", to: 'spaces#add_floor' post "space/update_floor", to: 'spaces#update_floor' - post "space/create_floor_unit", to: 'spaces#create_floor_unit' + post "space/save_floor_layout", to: 'spaces#save_floor_layout' + + post "space/create_floor_unit", to: 'spaces#create_floor_unit' + patch "space/update_floor_unit", to: 'spaces#update_floor_unit' + patch "space/update_sub_unit", to: 'spaces#update_sub_unit' + post "space/save_unit_layout", to: 'spaces#save_unit_layout' + + post "space/upload_sub_unit_image", to: 'spaces#upload_sub_unit_image' + post "space/create_sub_unit", to: 'spaces#create_sub_unit' + + get "spaces/:building_id/:floor_id/units", to: 'spaces#units' - get "spaces/floor/:floor_id/add_floor_unit", to: 'spaces#add_floor_unit' + get "spaces/floor/:floor_id/add_floor_unit", to: 'spaces#add_floor_unit' + get "spaces/floor/:floor_id/layout", to: 'spaces#floor_layout' + get "spaces/unit/:unit_id/layout", to: 'spaces#unit_layout' + + get "spaces/unit/:unit_id/edit", to: 'spaces#edit_floor_unit' + get "spaces/:floor_id/:unit_id/sub_units", to: 'spaces#sub_units' + + get "spaces/unit/:unit_id/add_sub_unit", to: 'spaces#add_sub_unit' + get "spaces/sub_unit/:sub_unit_id/edit", to: 'spaces#edit_sub_unit' + + delete "spaces/unit/:unit_id/delete", to: 'spaces#delete_floor_unit' delete "spaces/floor/:floor_id/delete", to: 'spaces#delete_floor' resources :spaces do get "floors"