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
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)
end

View File

@ -28,6 +28,7 @@ class EventNewsController < ApplicationController
"event_news_files" => files,
"title" => a.title,
"speaker" => a.speaker,
"place" => a.place,
"host" => a.host,
"notes" => a.notes,
"source-site" => "",
@ -64,6 +65,7 @@ class EventNewsController < ApplicationController
"widget-title" =>t('event_news.event_news'),
"title-head" => t('event_news.table.title'),
"speaker-head" => t('event_news.speaker'),
"place-head" => t('event_news.place'),
"host-head" => t('event_news.host'),
"notes-head" => t('event_news.notes'),
"event_date-head" => t('date_'),
@ -410,6 +412,7 @@ class EventNewsController < ApplicationController
"main_picture_description" => mpd,
"title-head" => t('event_news.table.title'),
"speaker-head" => t('event_news.speaker'),
"place-head" => t('event_news.place'),
"host-head" => t('event_news.host'),
"notes-head" => t('event_news.notes'),
"event_date-head" => t('date_'),
@ -559,7 +562,8 @@ class EventNewsController < ApplicationController
"img_src" => img_src,
"img_description" => img_description,
"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),
"url_to_edit"=>url_to_edit
@ -627,7 +631,8 @@ class EventNewsController < ApplicationController
"updated_at" => (datetime.strftime('%Y-%m-%d %H:%M') rescue ""),
"body" => event_news["text_translations"][locale],
"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,
"url_to_edit" => url_to_edit
@ -688,6 +693,7 @@ class EventNewsController < ApplicationController
"event_news_files" => files,
"title" => a.title,
"speaker" => a.speaker,
"place" => a.place,
"host" => a.host,
"notes" => a.notes,
"source-site" => "",

View File

@ -14,8 +14,10 @@ class EventNewsFeedsController < ApplicationController
tags = @bf.tag_ids
if !tags.empty?
@event_news = EventNews.can_display_and_sorted.is_approved.filter_by_tags(tags)
else
@event_news = []
end
categories = @bf.category_ids
if !categories.empty?
@event_news = @event_news.filter_by_categories(categories)
end
else
@event_news = []
@ -74,21 +76,28 @@ class EventNewsFeedsController < ApplicationController
dt = params[:date]
if !bf.nil?
tags = bf.tag_ids
if !tags.empty?
categories = bf.category_ids
if !(categories.empty? && tags.empty?)
if !dt.nil?
dt = DateTime.parse(dt)
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?
startdt = DateTime.parse(startdt)
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?
startdt = DateTime.parse(startdt)
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
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
else
event_news = []
@ -96,7 +105,9 @@ class EventNewsFeedsController < ApplicationController
end
all_anns = []
tag_names = []
category_titles = []
tag_ids = []
category_ids = []
event_news.each do |anns|
user = User.find(anns.create_user_id) rescue nil
if !user.nil?
@ -106,9 +117,9 @@ class EventNewsFeedsController < ApplicationController
end
a = {}
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|
a[translations_field+"_translations"] = anns.send(translations_field+"_translations")
a[translations_field+"_translations"] = anns.send(translations_field+"_translations") rescue {}
end
a["text_translations"] = {}
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["img_src"] = a["image"]["thumb"] || "/assets/announcement-default.jpg"
a["tags"] = []
a["category"] = {}
a["author"] = author
a["params"] = anns.to_param
a["event_news_links"] = []
@ -133,6 +145,12 @@ class EventNewsFeedsController < ApplicationController
end
a["tags"] << {"name_translations" => tag.name_translations}
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|
b = {}
b["url"] = bl.url
@ -154,7 +172,8 @@ class EventNewsFeedsController < ApplicationController
end
{
"event_news" => all_anns,
"tags" => tag_names
"tags" => tag_names,
"categories" => category_titles
}
end
end

View File

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

View File

@ -22,7 +22,7 @@ class EventNews
field :calendar_all_day,type: Boolean,default: false
field :calendar_type_id
field :event_id
field :place, type: String, localize: true
field :title, type: String, localize: true
field :speaker, 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 :tag_ids, type: Array, default: []
field :category_ids, type: Array, default: []
end

View File

@ -12,24 +12,47 @@
<% end %>
<hr />
<div class="tags">
<h4><%=t(:tags)%></h4>
<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| %>
<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" : "" %>'>
<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>
<a href="#" onclick="return false;">
<div>
<% @site_in_use_locales.each_with_index do |locale,index| %>
<span class="tag"><%= tag.name_translations[locale] %></span>
<% if index < (@site_in_use_locales.count - 1) %>
/
<% end %>
<% end %>
</a>
</li>
</div>
</label>
<% 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>
</fieldset>

View File

@ -42,6 +42,38 @@
</div>
</div>
</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>
<a href="/xhr/event_news/rssfeed/<%= feed.uid %>.rss" target="_blank">RSS Feed</a>
</td>

View File

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

View File

@ -355,6 +355,15 @@
<% end %>
</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-->
<div class="control-group input-host">
<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
row << t("event_news.event_date")
row1 << "date"
row2 << "Format: YYYY/MM/DD, Example: 2015/12/10"
row1 << "datetime"
row2 << "Format: YYYY/MM/DD HH:mm, Example: 2015/12/10 15:20"
row << t("event_news.start_date")
row1 << "date"
row2 << "Format: YYYY/MM/DD, Example: 2015/12/10"
row1 << "datetime"
row2 << "Format: YYYY/MM/DD HH:mm, Example: 2015/12/10 15:30"
row << t("event_news.end_date")
row1 << "date"
row2 << "Format: YYYY/MM/DD, Example: 2015/12/12"
row1 << "datetime"
row2 << "Format: YYYY/MM/DD HH:mm, Example: 2015/12/12 17:30"
row << t("top")
row1 << "boolean"
@ -142,6 +142,12 @@ wb.add_worksheet(name: "EventNewsModule") do |sheet|
row1 << "textfield"
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 row1

View File

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

View File

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

View File

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

View File

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