From b7d4f2a74eb3953464f65701bcafd464f7fe8bd2 Mon Sep 17 00:00:00 2001 From: chiu Date: Thu, 1 Oct 2020 14:27:54 +0800 Subject: [PATCH] add content to sub unit --- app/assets/stylesheets/space-frontend.scss | 2 +- app/models/floor_sub_unit.rb | 2 +- .../admin/spaces/_sub_unit_form.html.erb | 13 +- modules/space/show.html.erb | 169 ++++++++++++++---- modules/space/unit.html.erb | 14 +- 5 files changed, 161 insertions(+), 39 deletions(-) diff --git a/app/assets/stylesheets/space-frontend.scss b/app/assets/stylesheets/space-frontend.scss index dbf57ba..dc16ca8 100644 --- a/app/assets/stylesheets/space-frontend.scss +++ b/app/assets/stylesheets/space-frontend.scss @@ -27,7 +27,7 @@ top: 50%; height: 100%; margin: auto; - + width: 100%; // overflow: hidden; transform: translate(-50%, -50%); } diff --git a/app/models/floor_sub_unit.rb b/app/models/floor_sub_unit.rb index a0d8c67..6cd98d9 100644 --- a/app/models/floor_sub_unit.rb +++ b/app/models/floor_sub_unit.rb @@ -4,7 +4,7 @@ class FloorSubUnit include Slug field :title, as: :slug_title, localize: true - + field :content, localize: true has_many :floor_sub_unit_images, :autosave => true, :dependent => :destroy belongs_to :floor_unit diff --git a/app/views/admin/spaces/_sub_unit_form.html.erb b/app/views/admin/spaces/_sub_unit_form.html.erb index 0f65b44..1895006 100644 --- a/app/views/admin/spaces/_sub_unit_form.html.erb +++ b/app/views/admin/spaces/_sub_unit_form.html.erb @@ -28,7 +28,7 @@ <% @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.label t(:title) + " (" + t(locale) + ")", :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] %>
@@ -68,6 +68,17 @@
+ + <% @site_in_use_locales.each do |locale| %> + <%= f.fields_for :content_translations do |f| %> +
+ <%= f.label t(:content) + " (" + t(locale) + ")", :class => "control-label muted" %> +
+ <%= f.text_area locale, placeholder: t(:content), :value => @sub_unit.content_translations[locale.to_s], :class=> 'ckeditor' %> +
+
+ <% end %> + <% end %> diff --git a/modules/space/show.html.erb b/modules/space/show.html.erb index 3ea406b..db27d77 100644 --- a/modules/space/show.html.erb +++ b/modules/space/show.html.erb @@ -16,7 +16,7 @@ - +
\ No newline at end of file diff --git a/modules/space/unit.html.erb b/modules/space/unit.html.erb index 1a16f89..d444b7e 100644 --- a/modules/space/unit.html.erb +++ b/modules/space/unit.html.erb @@ -34,14 +34,13 @@ var $controlIcon = null; var $collapse = null; - canvas.height(windowHeight); - cover.height(coverImageHeight); - layoutImage.height(coverImageHeight); + canvas.css('height',''); + cover.css('height','') + layoutImage.css('height',''); + layoutImage.css('width','100%'); tmpImg.src = layoutImage.attr('src') ; - tmpImg.onload = function() { - cover.width(layoutImage.width()); - }; + cover.css('width',''); $('.selection-box-btn-holder').remove(); @@ -55,6 +54,9 @@ var obj = data.sub_units.filter(function(x) { return x.id == id; }); + if (obj.length==0){ + return; + } var temp = $pin.clone(); temp.attr('href', obj[0].url); if (obj[0].url == "#") {