Add place.

Fix bug.
This commit is contained in:
BoHung Chiu 2021-07-14 12:56:02 +08:00
parent ae7b337e6a
commit e172816c36
15 changed files with 182 additions and 47 deletions

View File

@ -52,7 +52,7 @@ class Admin::EventNewsController < OrbitAdminController
end end
def feed def feed
@table_feed_fields = ["event_news.feed_name", :tags, "event_news.rssfeed", "event_news.jsonfeed"] @table_feed_fields = ["event_news.feed_name", :tags, :categories, "event_news.rssfeed", "event_news.jsonfeed"]
@feeds = EventNewsFeed.all.asc(:created_at) @feeds = EventNewsFeed.all.asc(:created_at)
end end

View File

@ -28,6 +28,7 @@ class EventNewsController < ApplicationController
"event_news_files" => files, "event_news_files" => files,
"title" => a.title, "title" => a.title,
"speaker" => a.speaker, "speaker" => a.speaker,
"place" => a.place,
"host" => a.host, "host" => a.host,
"notes" => a.notes, "notes" => a.notes,
"source-site" => "", "source-site" => "",
@ -64,6 +65,7 @@ class EventNewsController < ApplicationController
"widget-title" =>t('event_news.event_news'), "widget-title" =>t('event_news.event_news'),
"title-head" => t('event_news.table.title'), "title-head" => t('event_news.table.title'),
"speaker-head" => t('event_news.speaker'), "speaker-head" => t('event_news.speaker'),
"place-head" => t('event_news.place'),
"host-head" => t('event_news.host'), "host-head" => t('event_news.host'),
"notes-head" => t('event_news.notes'), "notes-head" => t('event_news.notes'),
"event_date-head" => t('date_'), "event_date-head" => t('date_'),
@ -410,6 +412,7 @@ class EventNewsController < ApplicationController
"main_picture_description" => mpd, "main_picture_description" => mpd,
"title-head" => t('event_news.table.title'), "title-head" => t('event_news.table.title'),
"speaker-head" => t('event_news.speaker'), "speaker-head" => t('event_news.speaker'),
"place-head" => t('event_news.place'),
"host-head" => t('event_news.host'), "host-head" => t('event_news.host'),
"notes-head" => t('event_news.notes'), "notes-head" => t('event_news.notes'),
"event_date-head" => t('date_'), "event_date-head" => t('date_'),
@ -559,7 +562,8 @@ class EventNewsController < ApplicationController
"img_src" => img_src, "img_src" => img_src,
"img_description" => img_description, "img_description" => img_description,
"hide_class" => event_news.display_img? ? event_news.image_display_class : ' hide', "hide_class" => event_news.display_img? ? event_news.image_display_class : ' hide',
"alt_title" => desc "alt_title" => desc,
"place_text" => (event_news.place.present? rescue false) ? "#{I18n.t("event_news.place")}: #{event_news.place}" : ""
}, },
"impressionist" => (event_news.is_preview ? nil : event_news), "impressionist" => (event_news.is_preview ? nil : event_news),
"url_to_edit"=>url_to_edit "url_to_edit"=>url_to_edit
@ -627,7 +631,8 @@ class EventNewsController < ApplicationController
"updated_at" => (datetime.strftime('%Y-%m-%d %H:%M') rescue ""), "updated_at" => (datetime.strftime('%Y-%m-%d %H:%M') rescue ""),
"body" => event_news["text_translations"][locale], "body" => event_news["text_translations"][locale],
"image" => event_news["image"]["original"], "image" => event_news["image"]["original"],
"alt_title" => desc "alt_title" => desc,
"place_text" => (event_news["place"].present? rescue false) ? "#{I18n.t("event_news.place")}: #{event_news["place"]}" : ""
}, },
"impressionist" => nil, "impressionist" => nil,
"url_to_edit" => url_to_edit "url_to_edit" => url_to_edit
@ -688,6 +693,7 @@ class EventNewsController < ApplicationController
"event_news_files" => files, "event_news_files" => files,
"title" => a.title, "title" => a.title,
"speaker" => a.speaker, "speaker" => a.speaker,
"place" => a.place,
"host" => a.host, "host" => a.host,
"notes" => a.notes, "notes" => a.notes,
"source-site" => "", "source-site" => "",

View File

@ -14,8 +14,10 @@ class EventNewsFeedsController < ApplicationController
tags = @bf.tag_ids tags = @bf.tag_ids
if !tags.empty? if !tags.empty?
@event_news = EventNews.can_display_and_sorted.is_approved.filter_by_tags(tags) @event_news = EventNews.can_display_and_sorted.is_approved.filter_by_tags(tags)
else end
@event_news = [] categories = @bf.category_ids
if !categories.empty?
@event_news = @event_news.filter_by_categories(categories)
end end
else else
@event_news = [] @event_news = []
@ -74,21 +76,28 @@ class EventNewsFeedsController < ApplicationController
dt = params[:date] dt = params[:date]
if !bf.nil? if !bf.nil?
tags = bf.tag_ids tags = bf.tag_ids
if !tags.empty? categories = bf.category_ids
if !(categories.empty? && tags.empty?)
if !dt.nil? if !dt.nil?
dt = DateTime.parse(dt) dt = DateTime.parse(dt)
dtt = dt + 1.day dtt = dt + 1.day
event_news = EventNews.where(:postdate.gt => dt, :postdate.lt => dtt).can_display_and_sorted.is_approved.filter_by_tags(tags) event_news = EventNews.where(:postdate.gt => dt, :postdate.lt => dtt).can_display_and_sorted.is_approved
elsif !startdt.nil? && enddt.nil? elsif !startdt.nil? && enddt.nil?
startdt = DateTime.parse(startdt) startdt = DateTime.parse(startdt)
enddt = DateTime.now enddt = DateTime.now
event_news = EventNews.where(:postdate.gt => startdt, :postdate.lt => enddt).can_display_and_sorted.is_approved.filter_by_tags(tags) event_news = EventNews.where(:postdate.gt => startdt, :postdate.lt => enddt).can_display_and_sorted.is_approved
elsif !startdt.nil? && !enddt.nil? elsif !startdt.nil? && !enddt.nil?
startdt = DateTime.parse(startdt) startdt = DateTime.parse(startdt)
enddt = DateTime.parse(enddt) + 1.day enddt = DateTime.parse(enddt) + 1.day
event_news = EventNews.where(:postdate.gt => startdt, :postdate.lt => enddt).can_display_and_sorted.is_approved.filter_by_tags(tags) event_news = EventNews.where(:postdate.gt => startdt, :postdate.lt => enddt).can_display_and_sorted.is_approved
else else
event_news = EventNews.all.can_display_and_sorted.is_approved.filter_by_tags(tags) event_news = EventNews.all.can_display_and_sorted.is_approved
end
if !tags.empty?
event_news = event_news.filter_by_tags(tags)
end
if !categories.empty?
event_news = event_news.filter_by_categories(categories)
end end
else else
event_news = [] event_news = []
@ -96,7 +105,9 @@ class EventNewsFeedsController < ApplicationController
end end
all_anns = [] all_anns = []
tag_names = [] tag_names = []
category_titles = []
tag_ids = [] tag_ids = []
category_ids = []
event_news.each do |anns| event_news.each do |anns|
user = User.find(anns.create_user_id) rescue nil user = User.find(anns.create_user_id) rescue nil
if !user.nil? if !user.nil?
@ -106,9 +117,9 @@ class EventNewsFeedsController < ApplicationController
end end
a = {} a = {}
a["id"] = anns.uid a["id"] = anns.uid
translations_fields = ["title","subtitle","speaker","host","notes"] translations_fields = ["title","subtitle","speaker","place","host","notes"]
translations_fields.each do |translations_field| translations_fields.each do |translations_field|
a[translations_field+"_translations"] = anns.send(translations_field+"_translations") a[translations_field+"_translations"] = anns.send(translations_field+"_translations") rescue {}
end end
a["text_translations"] = {} a["text_translations"] = {}
a["text_translations"]["en"] = smart_convertor(anns.text_translations["en"]) if !anns.text_translations["en"].blank? a["text_translations"]["en"] = smart_convertor(anns.text_translations["en"]) if !anns.text_translations["en"].blank?
@ -122,6 +133,7 @@ class EventNewsFeedsController < ApplicationController
a["image"]["mobile"] = ("#{request.base_url}" + anns.image.mobile.url rescue "") a["image"]["mobile"] = ("#{request.base_url}" + anns.image.mobile.url rescue "")
a["img_src"] = a["image"]["thumb"] || "/assets/announcement-default.jpg" a["img_src"] = a["image"]["thumb"] || "/assets/announcement-default.jpg"
a["tags"] = [] a["tags"] = []
a["category"] = {}
a["author"] = author a["author"] = author
a["params"] = anns.to_param a["params"] = anns.to_param
a["event_news_links"] = [] a["event_news_links"] = []
@ -133,6 +145,12 @@ class EventNewsFeedsController < ApplicationController
end end
a["tags"] << {"name_translations" => tag.name_translations} a["tags"] << {"name_translations" => tag.name_translations}
end end
cat = anns.category
if (!category_ids.include?(cat.id.to_s) rescue false)
category_ids << cat.id.to_s
category_titles << {"title_translations" => cat.title_translations}
end
a["category"] = {"title_translations" => (cat.title_translations rescue {})}
anns.event_news_links.each do |bl| anns.event_news_links.each do |bl|
b = {} b = {}
b["url"] = bl.url b["url"] = bl.url
@ -154,7 +172,8 @@ class EventNewsFeedsController < ApplicationController
end end
{ {
"event_news" => all_anns, "event_news" => all_anns,
"tags" => tag_names "tags" => tag_names,
"categories" => category_titles
} }
end end
end end

View File

@ -57,6 +57,7 @@ module EventNewsHelper
"event_news_files" => files, "event_news_files" => files,
"title" => a.title, "title" => a.title,
"speaker" => a.speaker, "speaker" => a.speaker,
"place" => a.place,
"host" => a.host, "host" => a.host,
"notes" => a.notes, "notes" => a.notes,
"source-site" => "", "source-site" => "",
@ -121,6 +122,7 @@ module EventNewsHelper
"event_news_files" => files, "event_news_files" => files,
"title" => fa["title_translations"][locale], "title" => fa["title_translations"][locale],
"speaker" => (fa["speaker_translations"][locale].to_s rescue ""), "speaker" => (fa["speaker_translations"][locale].to_s rescue ""),
"place" => (fa["place_translations"][locale].to_s rescue ""),
"host" => (fa["host_translations"][locale].to_s rescue ""), "host" => (fa["host_translations"][locale].to_s rescue ""),
"notes" => (fa["notes_translations"][locale].to_s rescue ""), "notes" => (fa["notes_translations"][locale].to_s rescue ""),
"subtitle" => fa["subtitle_translations"][locale], "subtitle" => fa["subtitle_translations"][locale],

View File

@ -22,7 +22,7 @@ class EventNews
field :calendar_all_day,type: Boolean,default: false field :calendar_all_day,type: Boolean,default: false
field :calendar_type_id field :calendar_type_id
field :event_id field :event_id
field :place, type: String, localize: true
field :title, type: String, localize: true field :title, type: String, localize: true
field :speaker, type: String, localize: true field :speaker, type: String, localize: true
field :host, type: String, localize: true field :host, type: String, localize: true

View File

@ -5,5 +5,5 @@ class EventNewsFeed
field :title, as: :slug_title, type: String, localize: true field :title, as: :slug_title, type: String, localize: true
field :tag_ids, type: Array, default: [] field :tag_ids, type: Array, default: []
field :category_ids, type: Array, default: []
end end

View File

@ -12,24 +12,47 @@
<% end %> <% end %>
<hr /> <hr />
<div class="tags"> <div class="tags">
<h4><%=t(:tags)%></h4>
<div id="tags-list"> <div id="tags-list">
<ul class="tags-groups checkbox-card module-tags"> <div class="tags-groups checkbox-card module-tags">
<% @module_app.tags.each do |tag| %> <% @module_app.tags.each do |tag| %>
<li class="filter-item module"> <label class="filter-item module <%= @event_news_feed.tag_ids.include?(tag.id.to_s) ? "active" : "" %>">
<p class='card pull-left <%= @event_news_feed.tag_ids.include?(tag.id.to_s) ? "active" : "" %>'> <p class='card pull-left <%= @event_news_feed.tag_ids.include?(tag.id.to_s) ? "active" : "" %>'>
<input type="checkbox" <%= @event_news_feed.tag_ids.include?(tag.id.to_s) ? "checked=checked" : "" %> class="tag-checkbox" value="<%= tag.id.to_s %>" name="event_news_feed[tag_ids][]"> <input type="checkbox" <%= @event_news_feed.tag_ids.include?(tag.id.to_s) ? "checked=checked" : "" %> class="tag-checkbox" value="<%= tag.id.to_s %>" name="event_news_feed[tag_ids][]">
</p> </p>
<a href="#" onclick="return false;"> <div>
<% @site_in_use_locales.each_with_index do |locale,index| %> <% @site_in_use_locales.each_with_index do |locale,index| %>
<span class="tag"><%= tag.name_translations[locale] %></span> <span class="tag"><%= tag.name_translations[locale] %></span>
<% if index < (@site_in_use_locales.count - 1) %> <% if index < (@site_in_use_locales.count - 1) %>
/ /
<% end %> <% end %>
<% end %> <% end %>
</a> </div>
</li> </label>
<% end %> <% end %>
</ul> </div>
</div>
</div>
<div class="categories">
<h4><%=t(:category)%></h4>
<div id="categories-list">
<div class="tags-groups checkbox-card module-categories">
<% @module_app.categories.each do |category| %>
<label class="filter-item module <%= @event_news_feed.category_ids.include?(category.id.to_s) ? "active" : "" %>">
<p class="card pull-left <%= @event_news_feed.category_ids.include?(category.id.to_s) ? "active" : "" %>">
<input type="checkbox" class="tag-checkbox" <%= @event_news_feed.category_ids.include?(category.id.to_s) ? "checked=checked" : "" %> value="<%= category.id.to_s %>" name="event_news_feed[category_ids][]">
</p>
<div>
<% @site_in_use_locales.each_with_index do |locale,index| %>
<span class="tag"><%= category.title_translations[locale] %></span>
<% if index < (@site_in_use_locales.count - 1) %>
/
<% end %>
<% end %>
</div>
</label>
<% end %>
</div>
</div> </div>
</div> </div>
</fieldset> </fieldset>

View File

@ -42,6 +42,38 @@
</div> </div>
</div> </div>
</td> </td>
<td>
<div class="categories">
<div id="categories-list">
<ul class="tags-groups checkbox-card module-categories">
<% categories_to_remove = [] %>
<% feed.category_ids.each do |c| %>
<% category = Category.find(c) rescue nil %>
<% if !category.nil? %>
<li class="filter-item module">
<a href="#" onclick="return false;">
<% @site_in_use_locales.each_with_index do |locale,index| %>
<span class="tag"><%= category.title_translations[locale] %></span>
<% if index < (@site_in_use_locales.count - 1) %>
/
<% end %>
<% end %>
</a>
</li>
<% else %>
<% categories_to_remove << c %>
<% end %>
<% end %>
<% if !categories_to_remove.blank?
categories_to_remove.each do |c|
feed.category_ids.delete(c)
end
feed.save
end %>
</ul>
</div>
</div>
</td>
<td> <td>
<a href="/xhr/event_news/rssfeed/<%= feed.uid %>.rss" target="_blank">RSS Feed</a> <a href="/xhr/event_news/rssfeed/<%= feed.uid %>.rss" target="_blank">RSS Feed</a>
</td> </td>

View File

@ -12,24 +12,47 @@
<% end %> <% end %>
<hr /> <hr />
<div class="tags"> <div class="tags">
<h4><%=t(:tags)%></h4>
<div id="tags-list"> <div id="tags-list">
<ul class="tags-groups checkbox-card module-tags"> <div class="tags-groups checkbox-card module-tags">
<% @module_app.tags.each do |tag| %> <% @module_app.tags.each do |tag| %>
<li class="filter-item module"> <label class="filter-item module">
<p class="card pull-left"> <p class="card pull-left">
<input type="checkbox" class="tag-checkbox" value="<%= tag.id.to_s %>" name="event_news_feed[tag_ids][]"> <input type="checkbox" class="tag-checkbox" value="<%= tag.id.to_s %>" name="event_news_feed[tag_ids][]">
</p> </p>
<a href="#" onclick="return false;"> <div>
<% @site_in_use_locales.each_with_index do |locale,index| %> <% @site_in_use_locales.each_with_index do |locale,index| %>
<span class="tag"><%= tag.name_translations[locale] %></span> <span class="tag"><%= tag.name_translations[locale] %></span>
<% if index < (@site_in_use_locales.count - 1) %> <% if index < (@site_in_use_locales.count - 1) %>
/ /
<% end %> <% end %>
<% end %> <% end %>
</a> </div>
</li> </label>
<% end %> <% end %>
</ul> </div>
</div>
</div>
<div class="categories">
<h4><%=t(:category)%></h4>
<div id="categories-list">
<div class="tags-groups checkbox-card module-categories">
<% @module_app.categories.each do |category| %>
<label class="filter-item module">
<p class="card pull-left">
<input type="checkbox" class="tag-checkbox" value="<%= category.id.to_s %>" name="event_news_feed[category_ids][]">
</p>
<div>
<% @site_in_use_locales.each_with_index do |locale,index| %>
<span class="tag"><%= category.title_translations[locale] %></span>
<% if index < (@site_in_use_locales.count - 1) %>
/
<% end %>
<% end %>
</div>
</label>
<% end %>
</div>
</div> </div>
</div> </div>
</fieldset> </fieldset>

View File

@ -355,6 +355,15 @@
<% end %> <% end %>
</div> </div>
</div> </div>
<!-- Place-->
<div class="control-group input-speaker">
<label class="control-label muted"><%= t("event_news.place") %></label>
<div class="controls">
<%= f.fields_for :place_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("event_news.place"), value: (@event_news.place_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- Host--> <!-- Host-->
<div class="control-group input-host"> <div class="control-group input-host">
<label class="control-label muted"><%= t("event_news.host") %></label> <label class="control-label muted"><%= t("event_news.host") %></label>

View File

@ -37,16 +37,16 @@ wb.add_worksheet(name: "EventNewsModule") do |sheet|
row2 << t row2 << t
row << t("event_news.event_date") row << t("event_news.event_date")
row1 << "date" row1 << "datetime"
row2 << "Format: YYYY/MM/DD, Example: 2015/12/10" row2 << "Format: YYYY/MM/DD HH:mm, Example: 2015/12/10 15:20"
row << t("event_news.start_date") row << t("event_news.start_date")
row1 << "date" row1 << "datetime"
row2 << "Format: YYYY/MM/DD, Example: 2015/12/10" row2 << "Format: YYYY/MM/DD HH:mm, Example: 2015/12/10 15:30"
row << t("event_news.end_date") row << t("event_news.end_date")
row1 << "date" row1 << "datetime"
row2 << "Format: YYYY/MM/DD, Example: 2015/12/12" row2 << "Format: YYYY/MM/DD HH:mm, Example: 2015/12/12 17:30"
row << t("top") row << t("top")
row1 << "boolean" row1 << "boolean"
@ -142,6 +142,12 @@ wb.add_worksheet(name: "EventNewsModule") do |sheet|
row1 << "textfield" row1 << "textfield"
row2 << "Seperate with ';' with respective to the links in the link columns. Example : example1; example2" row2 << "Seperate with ';' with respective to the links in the link columns. Example : example1; example2"
row << t("event_news.place") + "-" + t("en")
row1 << "textfield"
row2 << ""
row << t("event_news.place") + "-" + t("zh_tw")
row1 << "textfield"
row2 << ""
sheet.add_row row, :style => heading sheet.add_row row, :style => heading
sheet.add_row row1 sheet.add_row row1

View File

@ -39,16 +39,16 @@ wb.add_worksheet(name: "EventNewsModule") do |sheet|
row2 << t row2 << t
row << t("event_news.event_date") row << t("event_news.event_date")
row1 << "date" row1 << "datetime"
row2 << "Format: YYYY/MM/DD, Example: 2015/12/10" row2 << "Format: YYYY/MM/DD HH:mm, Example: 2015/12/10 15:20"
row << t("event_news.start_date") row << t("event_news.start_date")
row1 << "date" row1 << "datetime"
row2 << "Format: YYYY/MM/DD, Example: 2015/12/10" row2 << "Format: YYYY/MM/DD HH:mm, Example: 2015/12/10 15:30"
row << t("event_news.end_date") row << t("event_news.end_date")
row1 << "date" row1 << "datetime"
row2 << "Format: YYYY/MM/DD, Example: 2015/12/12" row2 << "Format: YYYY/MM/DD HH:mm, Example: 2015/12/12 17:30"
row << t("top") row << t("top")
row1 << "boolean" row1 << "boolean"
@ -144,6 +144,12 @@ wb.add_worksheet(name: "EventNewsModule") do |sheet|
row1 << "textfield" row1 << "textfield"
row2 << "Seperate with ';' with respective to the links in the link columns. Example : example1; example2" row2 << "Seperate with ';' with respective to the links in the link columns. Example : example1; example2"
row << t("event_news.place") + "-" + t("en")
row1 << "textfield"
row2 << ""
row << t("event_news.place") + "-" + t("zh_tw")
row1 << "textfield"
row2 << ""
sheet.add_row row, :style => heading sheet.add_row row, :style => heading
sheet.add_row row1 sheet.add_row row1
@ -157,9 +163,9 @@ wb.add_worksheet(name: "EventNewsModule") do |sheet|
t << tags.to_a.index(tag) t << tags.to_a.index(tag)
end end
row << t.join(",") row << t.join(",")
row << (anns.event_date.strftime("%Y/%m/%d") rescue "") row << (anns.event_date.strftime("%Y/%m/%d %H:%M") rescue "")
row << (anns.postdate.strftime("%Y/%m/%d") rescue "") row << (anns.postdate.strftime("%Y/%m/%d %H:%M") rescue "")
row << (anns.deadline.strftime("%Y/%m/%d") rescue "") row << (anns.deadline.strftime("%Y/%m/%d %H:%M") rescue "")
row << (anns.is_top? ? 1 : 0) row << (anns.is_top? ? 1 : 0)
row << (anns.is_hot? ? 1 : 0) row << (anns.is_hot? ? 1 : 0)
row << (anns.is_hidden? ? 1 : 0) row << (anns.is_hidden? ? 1 : 0)
@ -199,6 +205,8 @@ wb.add_worksheet(name: "EventNewsModule") do |sheet|
row << t.join(";") row << t.join(";")
t = files.collect{|l|l.title_translations["zh_tw"]} t = files.collect{|l|l.title_translations["zh_tw"]}
row << t.join(";") row << t.join(";")
row << anns.place_translations["en"]
row << anns.place_translations["zh_tw"]
sheet.add_row row sheet.add_row row
end end

View File

@ -2,6 +2,7 @@ en:
module_name: module_name:
event_news: Event News event_news: Event News
event_news: event_news:
place: Place
cover_image_display_setting: Cover Image display setting cover_image_display_setting: Cover Image display setting
full_width: Full width full_width: Full width
up_left_corner: Up-left corner up_left_corner: Up-left corner

View File

@ -2,6 +2,7 @@ zh_tw:
module_name: module_name:
event_news: 活動公告 event_news: 活動公告
event_news: event_news:
place: 地點
cover_image_display_setting: 封面圖片顯示設定 cover_image_display_setting: 封面圖片顯示設定
full_width: 滿版呈現 full_width: 滿版呈現
up_left_corner: 左上角 up_left_corner: 左上角

View File

@ -17,11 +17,16 @@
</span> </span>
</li> </li>
<li class="s-annc__extra_info-wrap s-annc__meta--item "> <li class="s-annc__extra_info-wrap s-annc__meta--item ">
<span style="display: inline-block;">
<span>{{speaker-head}}:</span> <span>{{speaker-head}}:</span>
<span>{{speaker}}</span> <span>{{speaker}}</span>
<span>&nbsp;/&nbsp;<span> </span>
<span>&nbsp;/&nbsp;</span>
<span style="display: inline-block;">
<span>{{host-head}}:</span> <span>{{host-head}}:</span>
<span>{{host}}</span> <span>{{host}}</span>
</span>
<div>{{place_text}}</div>
</li> </li>
</ul> </ul>