Add annc_dept setting.
This commit is contained in:
parent
f3d5e1371f
commit
4008b699e4
|
@ -294,7 +294,7 @@ Gem::Specification.new do |s|
|
||||||
s.license = "MIT"
|
s.license = "MIT"
|
||||||
s.metadata = {
|
s.metadata = {
|
||||||
"_require" => "#{File.expand_path("../app/models/announcement_setting", __FILE__)}",
|
"_require" => "#{File.expand_path("../app/models/announcement_setting", __FILE__)}",
|
||||||
"global_hash" => "{enable_manually_sort: (AnnouncementSetting.first.enable_manually_sort rescue false)}"
|
"global_hash" => "{enable_manually_sort: (AnnouncementSetting.first.enable_manually_sort rescue false),enable_annc_dept: (AnnouncementSetting.first.enable_annc_dept rescue false), annc_depts_translations: (AnnouncementSetting.first.annc_depts_translations rescue {})}"
|
||||||
}
|
}
|
||||||
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
|
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
|
||||||
s.test_files = Dir["test/**/*"]
|
s.test_files = Dir["test/**/*"]
|
||||||
|
|
|
@ -7,7 +7,20 @@ class AnnouncementsController < ApplicationController
|
||||||
Bulletin.instance_variable_set('@manually_sort',@manually_sort)
|
Bulletin.instance_variable_set('@manually_sort',@manually_sort)
|
||||||
#self.request = OrbitHelper.request
|
#self.request = OrbitHelper.request
|
||||||
end
|
end
|
||||||
|
def annc_depts_translations
|
||||||
|
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
|
||||||
|
OrbitHelper::SharedHash['announcement'][:annc_depts_translations] rescue AnnouncementSetting.first.annc_depts_translations
|
||||||
|
else
|
||||||
|
AnnouncementSetting.first.annc_depts_translations rescue {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def enable_annc_dept
|
||||||
|
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
|
||||||
|
OrbitHelper::SharedHash['announcement'][:enable_annc_dept] rescue AnnouncementSetting.first.enable_annc_dept
|
||||||
|
else
|
||||||
|
AnnouncementSetting.first.enable_annc_dept rescue false
|
||||||
|
end
|
||||||
|
end
|
||||||
def manually_sort
|
def manually_sort
|
||||||
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
|
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
|
||||||
OrbitHelper::SharedHash['announcement'][:enable_manually_sort] rescue AnnouncementSetting.first.enable_manually_sort
|
OrbitHelper::SharedHash['announcement'][:enable_manually_sort] rescue AnnouncementSetting.first.enable_manually_sort
|
||||||
|
@ -67,6 +80,11 @@ class AnnouncementsController < ApplicationController
|
||||||
sorted = []
|
sorted = []
|
||||||
total_pages = 0
|
total_pages = 0
|
||||||
end
|
end
|
||||||
|
annc_depts = []
|
||||||
|
tmp_enable_annc_dept = (enable_annc_dept rescue false)
|
||||||
|
if tmp_enable_annc_dept
|
||||||
|
annc_depts = annc_depts_translations[locale] rescue []
|
||||||
|
end
|
||||||
anns = sorted.collect do |a|
|
anns = sorted.collect do |a|
|
||||||
if a["source-site"].blank?
|
if a["source-site"].blank?
|
||||||
statuses = a.statuses_with_classname.collect do |status|
|
statuses = a.statuses_with_classname.collect do |status|
|
||||||
|
@ -78,7 +96,7 @@ class AnnouncementsController < ApplicationController
|
||||||
locale = OrbitHelper.get_site_locale.to_s
|
locale = OrbitHelper.get_site_locale.to_s
|
||||||
files = a.bulletin_files.to_fronted(locale)
|
files = a.bulletin_files.to_fronted(locale)
|
||||||
links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
|
links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
|
||||||
author = User.find(a.create_user_id).member_name rescue (User.find(a.create_user_id).member_profile.name rescue "")
|
author = tmp_enable_annc_dept ? annc_depts[a.annc_dept] : User.find(a.create_user_id).member_name rescue (User.find(a.create_user_id).member_profile.name rescue "")
|
||||||
desc = a.image_description
|
desc = a.image_description
|
||||||
desc = (desc.blank? ? "announcement image" : desc)
|
desc = (desc.blank? ? "announcement image" : desc)
|
||||||
link_to_show = a.is_external_link ? a.external_link : OrbitHelper.url_to_show(a.to_param)
|
link_to_show = a.is_external_link ? a.external_link : OrbitHelper.url_to_show(a.to_param)
|
||||||
|
@ -665,7 +683,12 @@ class AnnouncementsController < ApplicationController
|
||||||
} } rescue []
|
} } rescue []
|
||||||
files = announcement.bulletin_files.to_fronted(locale)
|
files = announcement.bulletin_files.to_fronted(locale)
|
||||||
links = announcement.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
|
links = announcement.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
|
||||||
update_user = announcement.update_user.member_profile.name rescue ""
|
update_user = ""
|
||||||
|
if enable_annc_dept
|
||||||
|
update_user = annc_depts_translations[locale][announcement.annc_dept] rescue ""
|
||||||
|
else
|
||||||
|
update_user = announcement.update_user.member_profile.name rescue ""
|
||||||
|
end
|
||||||
desc = announcement.image_description
|
desc = announcement.image_description
|
||||||
desc = (desc.nil? || desc == "" ? "announcement image" : desc)
|
desc = (desc.nil? || desc == "" ? "announcement image" : desc)
|
||||||
|
|
||||||
|
@ -873,6 +896,11 @@ class AnnouncementsController < ApplicationController
|
||||||
OrbitHelper.set_page_number(params[:page_no].to_i)
|
OrbitHelper.set_page_number(params[:page_no].to_i)
|
||||||
OrbitHelper.set_page_data_count((params[:data_count].blank? ? 10 : params[:data_count].to_i))
|
OrbitHelper.set_page_data_count((params[:data_count].blank? ? 10 : params[:data_count].to_i))
|
||||||
sorted,total_pages = get_sorted_annc
|
sorted,total_pages = get_sorted_annc
|
||||||
|
annc_depts = []
|
||||||
|
tmp_enable_annc_dept = (enable_annc_dept rescue false)
|
||||||
|
if tmp_enable_annc_dept
|
||||||
|
annc_depts = annc_depts_translations[locale] rescue []
|
||||||
|
end
|
||||||
anns = sorted.collect do |a|
|
anns = sorted.collect do |a|
|
||||||
if a["source-site"].blank?
|
if a["source-site"].blank?
|
||||||
statuses = a.statuses_with_classname.collect do |status|
|
statuses = a.statuses_with_classname.collect do |status|
|
||||||
|
@ -884,7 +912,7 @@ class AnnouncementsController < ApplicationController
|
||||||
locale = I18n.locale.to_s
|
locale = I18n.locale.to_s
|
||||||
files = a.bulletin_files.to_fronted(locale)
|
files = a.bulletin_files.to_fronted(locale)
|
||||||
links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
|
links = a.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
|
||||||
author = User.find(a.create_user_id).member_profile.name rescue ""
|
author = tmp_enable_annc_dept ? annc_depts[a.annc_dept] : User.find(a.create_user_id).member_profile.name rescue ""
|
||||||
desc = a.image_description
|
desc = a.image_description
|
||||||
desc = (desc.blank? ? "announcement image" : desc)
|
desc = (desc.blank? ? "announcement image" : desc)
|
||||||
link_to_show = (a.is_external_link ? a.external_link : OrbitHelper.url_to_show(a.to_param)) rescue ""
|
link_to_show = (a.is_external_link ? a.external_link : OrbitHelper.url_to_show(a.to_param)) rescue ""
|
||||||
|
|
|
@ -1,6 +1,27 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
class BulletinsController < ApplicationController
|
class BulletinsController < ApplicationController
|
||||||
before_filter :set_I18n
|
before_filter :set_I18n
|
||||||
|
def annc_depts_translations
|
||||||
|
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
|
||||||
|
OrbitHelper::SharedHash['announcement'][:annc_depts_translations] rescue AnnouncementSetting.first.annc_depts_translations
|
||||||
|
else
|
||||||
|
AnnouncementSetting.first.annc_depts_translations rescue {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def enable_annc_dept
|
||||||
|
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
|
||||||
|
OrbitHelper::SharedHash['announcement'][:enable_annc_dept] rescue AnnouncementSetting.first.enable_annc_dept
|
||||||
|
else
|
||||||
|
AnnouncementSetting.first.enable_annc_dept rescue false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def manually_sort
|
||||||
|
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
|
||||||
|
OrbitHelper::SharedHash['announcement'][:enable_manually_sort] rescue AnnouncementSetting.first.enable_manually_sort
|
||||||
|
else
|
||||||
|
AnnouncementSetting.first.enable_manually_sort rescue false
|
||||||
|
end
|
||||||
|
end
|
||||||
def get_bulletins
|
def get_bulletins
|
||||||
page = Page.where(:module => "announcement").first rescue nil
|
page = Page.where(:module => "announcement").first rescue nil
|
||||||
|
|
||||||
|
@ -9,7 +30,11 @@ class BulletinsController < ApplicationController
|
||||||
# 每頁顯示的則數
|
# 每頁顯示的則數
|
||||||
per_page = params[:per_page].blank? ? 10 : params[:per_page].to_i
|
per_page = params[:per_page].blank? ? 10 : params[:per_page].to_i
|
||||||
per_page = per_page > 0 ? per_page : 10
|
per_page = per_page > 0 ? per_page : 10
|
||||||
|
annc_depts = []
|
||||||
|
tmp_enable_annc_dept = (enable_annc_dept rescue false)
|
||||||
|
if tmp_enable_annc_dept
|
||||||
|
annc_depts = annc_depts_translations[locale] rescue []
|
||||||
|
end
|
||||||
I18n.locale = :zh_tw
|
I18n.locale = :zh_tw
|
||||||
if !params[:keyword].blank?
|
if !params[:keyword].blank?
|
||||||
keyword = Regexp.new(".*"+params[:keyword]+".*")
|
keyword = Regexp.new(".*"+params[:keyword]+".*")
|
||||||
|
@ -30,8 +55,12 @@ class BulletinsController < ApplicationController
|
||||||
bulletins = bulletins.where(:is_preview.in=>[false,nil])
|
bulletins = bulletins.where(:is_preview.in=>[false,nil])
|
||||||
bulletins = bulletins.where(:approved.ne => false , :rejected.ne => true)
|
bulletins = bulletins.where(:approved.ne => false , :rejected.ne => true)
|
||||||
bulletins = bulletins.where(:postdate.lt=>Time.now)
|
bulletins = bulletins.where(:postdate.lt=>Time.now)
|
||||||
bulletins = bulletins.desc( :is_top, :postdate).page(page_num).per(per_page)
|
if (manually_sort rescue false)
|
||||||
|
bulletins = bulletins.order({:is_top => -1, :sort_number => 1, :postdate => -1}).page(page_num).per(per_page)
|
||||||
|
else
|
||||||
|
bulletins = bulletins.desc( :is_top, :postdate).page(page_num).per(per_page)
|
||||||
|
end
|
||||||
|
bulletins = bulletins.to_a
|
||||||
bulletins = bulletins.collect do |b|
|
bulletins = bulletins.collect do |b|
|
||||||
image = request.protocol + request.host_with_port + b.image.url rescue nil
|
image = request.protocol + request.host_with_port + b.image.url rescue nil
|
||||||
|
|
||||||
|
@ -61,7 +90,7 @@ class BulletinsController < ApplicationController
|
||||||
text["en"] = (b.text_translations["en"].nil? ? "" :smart_convertor(b.text_translations["en"]))
|
text["en"] = (b.text_translations["en"].nil? ? "" :smart_convertor(b.text_translations["en"]))
|
||||||
text["zh_tw"] = (b.text_translations["zh_tw"].nil? ? "" : smart_convertor(b.text_translations["zh_tw"]))
|
text["zh_tw"] = (b.text_translations["zh_tw"].nil? ? "" : smart_convertor(b.text_translations["zh_tw"]))
|
||||||
|
|
||||||
author = User.find(b.create_user_id).member_profile.name rescue ""
|
author = tmp_enable_annc_dept ? annc_depts[b.annc_dept] : User.find(b.create_user_id).member_profile.name rescue ""
|
||||||
|
|
||||||
{
|
{
|
||||||
"id" => b.id.to_s,
|
"id" => b.id.to_s,
|
||||||
|
|
|
@ -14,6 +14,8 @@ class AnnouncementSetting
|
||||||
field :hot_text , type: String , localize: true
|
field :hot_text , type: String , localize: true
|
||||||
field :hidden_text , type: String , localize: true
|
field :hidden_text , type: String , localize: true
|
||||||
field :enable_manually_sort, type: Boolean, default: false
|
field :enable_manually_sort, type: Boolean, default: false
|
||||||
|
field :enable_annc_dept, type: Boolean, default: false
|
||||||
|
field :annc_depts, type: Array, default: [], localize: true
|
||||||
has_many :anns_status_settings, :autosave => true, :dependent => :destroy
|
has_many :anns_status_settings, :autosave => true, :dependent => :destroy
|
||||||
accepts_nested_attributes_for :anns_status_settings, :allow_destroy => true
|
accepts_nested_attributes_for :anns_status_settings, :allow_destroy => true
|
||||||
def self.check_limit_for_user(user_id, b_id = nil)
|
def self.check_limit_for_user(user_id, b_id = nil)
|
||||||
|
@ -34,10 +36,23 @@ class AnnouncementSetting
|
||||||
end
|
end
|
||||||
|
|
||||||
before_save do
|
before_save do
|
||||||
|
can_update_shared_hash = (defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash)
|
||||||
|
tmp_hash = {}
|
||||||
if self.enable_manually_sort_changed? && self.enable_manually_sort
|
if self.enable_manually_sort_changed? && self.enable_manually_sort
|
||||||
AnnsCache.all.delete
|
AnnsCache.all.delete
|
||||||
Bulletin.index({approved: -1,is_hidden: 1,is_preview: 1, is_top: -1,sort_number: 1,postdate: -1,_id: -1,deadline: -1}, { unique: false, background: true })
|
Bulletin.index({approved: -1,is_hidden: 1,is_preview: 1, is_top: -1,sort_number: 1,postdate: -1,_id: -1,deadline: -1}, { unique: false, background: true })
|
||||||
Bulletin.create_indexes
|
Bulletin.create_indexes
|
||||||
|
tmp_hash[:enable_manually_sort] = self.enable_manually_sort
|
||||||
|
end
|
||||||
|
if self.annc_depts_changed?
|
||||||
|
tmp_hash[:annc_depts_translations] = self.annc_depts_translations
|
||||||
|
end
|
||||||
|
if can_update_shared_hash
|
||||||
|
if tmp_hash.count != 0
|
||||||
|
tmp_hash[:enable_manually_sort] = self.enable_manually_sort if tmp_hash[:enable_manually_sort].nil?
|
||||||
|
tmp_hash[:annc_depts_translations] = self.annc_depts_translations if tmp_hash[:annc_depts_translations].nil?
|
||||||
|
OrbitHelper::SharedHash["announcement"] = ProcesssShareWraper.new(tmp_hash)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -115,6 +115,7 @@ class Bulletin
|
||||||
index({is_top: -1,postdate: -1, _id: -1}, { unique: false, background: true })
|
index({is_top: -1,postdate: -1, _id: -1}, { unique: false, background: true })
|
||||||
index({approved: -1,is_hidden: 1,is_preview: 1, is_top: -1,postdate: -1,_id: -1,deadline: -1}, { unique: false, background: true })
|
index({approved: -1,is_hidden: 1,is_preview: 1, is_top: -1,postdate: -1,_id: -1,deadline: -1}, { unique: false, background: true })
|
||||||
field :sort_number, type: Integer
|
field :sort_number, type: Integer
|
||||||
|
field :annc_dept, type: Integer
|
||||||
def get_org_model
|
def get_org_model
|
||||||
if self.is_preview
|
if self.is_preview
|
||||||
org_model = nil
|
org_model = nil
|
||||||
|
|
|
@ -11,6 +11,20 @@ class BulletinFeed
|
||||||
cache.regenerate
|
cache.regenerate
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def annc_depts_translations
|
||||||
|
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
|
||||||
|
OrbitHelper::SharedHash['announcement'][:annc_depts_translations] rescue AnnouncementSetting.first.annc_depts_translations
|
||||||
|
else
|
||||||
|
AnnouncementSetting.first.annc_depts_translations rescue {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def enable_annc_dept
|
||||||
|
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
|
||||||
|
OrbitHelper::SharedHash['announcement'][:enable_annc_dept] rescue AnnouncementSetting.first.enable_annc_dept
|
||||||
|
else
|
||||||
|
AnnouncementSetting.first.enable_annc_dept rescue false
|
||||||
|
end
|
||||||
|
end
|
||||||
def self.create_feed_cache(bulletin=nil,bulletin_feed=nil)
|
def self.create_feed_cache(bulletin=nil,bulletin_feed=nil)
|
||||||
Thread.new do
|
Thread.new do
|
||||||
if !bulletin.nil?
|
if !bulletin.nil?
|
||||||
|
@ -54,6 +68,11 @@ class BulletinFeed
|
||||||
base_url = Site.first.root_url if base_url.nil?
|
base_url = Site.first.root_url if base_url.nil?
|
||||||
uid = self.uid
|
uid = self.uid
|
||||||
bf = self
|
bf = self
|
||||||
|
annc_depts = []
|
||||||
|
tmp_enable_annc_dept = (enable_annc_dept rescue false)
|
||||||
|
if tmp_enable_annc_dept
|
||||||
|
annc_depts = annc_depts_translations[I18n.default_locale.to_s] rescue []
|
||||||
|
end
|
||||||
if !bf.nil?
|
if !bf.nil?
|
||||||
tags = bf.tag_ids
|
tags = bf.tag_ids
|
||||||
categories = bf.category_ids
|
categories = bf.category_ids
|
||||||
|
@ -121,11 +140,16 @@ class BulletinFeed
|
||||||
first_deadline = deadline
|
first_deadline = deadline
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
user = User.find(anns.create_user_id) rescue nil
|
author = ""
|
||||||
if !user.nil?
|
if tmp_enable_annc_dept
|
||||||
author = user.member_name || user.user_name
|
author = annc_depts[anns.annc_dept] rescue ""
|
||||||
else
|
else
|
||||||
author = ""
|
user = User.find(anns.create_user_id) rescue nil
|
||||||
|
if !user.nil?
|
||||||
|
author = user.member_name || user.user_name
|
||||||
|
else
|
||||||
|
author = ""
|
||||||
|
end
|
||||||
end
|
end
|
||||||
a = {}
|
a = {}
|
||||||
if more_url
|
if more_url
|
||||||
|
|
|
@ -90,7 +90,15 @@
|
||||||
|
|
||||||
<!-- Basic Module -->
|
<!-- Basic Module -->
|
||||||
<div class="tab-pane fade in active" id="basic">
|
<div class="tab-pane fade in active" id="basic">
|
||||||
|
<% if (AnnouncementSetting.first.enable_annc_dept rescue false) %>
|
||||||
|
<!-- Annc Dept -->
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted" for="annc_dept"><%= t("announcement.annc_dept") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.select("annc_dept", (options_for_select(AnnouncementSetting.first.annc_depts.to_a.map.with_index{|dept,i| [dept, i] },:selected => f.object.annc_dept) rescue []) , { include_blank: true, id: "annc_dept" }) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<!-- Category -->
|
<!-- Category -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted"><%= t(:category) %></label>
|
<label class="control-label muted"><%= t(:category) %></label>
|
||||||
|
|
|
@ -79,6 +79,9 @@
|
||||||
.td-delete{
|
.td-delete{
|
||||||
width: 10%;
|
width: 10%;
|
||||||
}
|
}
|
||||||
|
#annc_depts_block .tab-content{
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<%
|
<%
|
||||||
sub_managers = @module_app.sub_managers
|
sub_managers = @module_app.sub_managers
|
||||||
|
@ -163,6 +166,34 @@
|
||||||
<%= f.text_field :carousel_image_width %>
|
<%= f.text_field :carousel_image_width %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<%= f.label :enable_annc_dept, t("announcement.annc_dept"), :class => "control-label muted" %>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.check_box :enable_annc_dept, :id=>"enable_annc_dept" %><%= t("announcement.enable") %>
|
||||||
|
<div id="annc_depts_block" class="<%='hide' if !(f.object.enable_annc_dept) %>">
|
||||||
|
<% f.object.annc_depts.to_a.each_with_index do |dept, idx| %>
|
||||||
|
<div class="annc_dept">
|
||||||
|
<div class="tab-content">
|
||||||
|
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||||
|
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="annc_depts_<%=idx%>_<%= locale %>">
|
||||||
|
<%= f.fields_for :annc_depts_translations,f.object do |f| %>
|
||||||
|
<%= f.text_field "#{locale}][", :value => (f.object.annc_depts_translations[locale][idx] rescue ""), :placeholder=>t("announcement.annc_dept", :id=>nil) %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="btn-group" data-toggle="buttons-radio">
|
||||||
|
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||||
|
<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#annc_depts_<%=idx%>_<%= locale %>" data-toggle="tab"><%= t(locale.to_s) %></a>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<button class="remove_dept btn btn-danger" type="button">X</button>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<button class="add_dept btn btn-primary" type="button"><%= t(:add) %></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<%= f.label :only_manager_can_edit_status, t("announcement.only_manager_can_edit_status"), :class => "control-label muted" %>
|
<%= f.label :only_manager_can_edit_status, t("announcement.only_manager_can_edit_status"), :class => "control-label muted" %>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
@ -387,6 +418,25 @@
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
$(document).on("click",".remove_dept",function(){
|
||||||
|
if(window.confirm("Are you sure?"))
|
||||||
|
$(this).parents(".annc_dept").eq(0).remove();
|
||||||
|
})
|
||||||
|
$(".add_dept").click(function(){
|
||||||
|
var tmp_text = '<div class="annc_dept"><div class="tab-content">';
|
||||||
|
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||||
|
tmp_text += '<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="annc_depts_new_idx_<%= locale %>"><input name="announcement_setting[annc_depts_translations][<%=locale%>][]" placeholder="<%=t('announcement.annc_dept')%>" type="text" title="<%=t('announcement.annc_dept')%>"></div>';
|
||||||
|
<% end %>
|
||||||
|
tmp_text += '</div><div class="btn-group" data-toggle="buttons-radio">';
|
||||||
|
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||||
|
tmp_text += '<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#annc_depts_new_idx_<%=locale%>" data-toggle="tab"><%= t(locale.to_s) %></a>';
|
||||||
|
<% end %>
|
||||||
|
tmp_text += '</div><button class="remove_dept btn btn-danger" type="button">X</button></div';
|
||||||
|
$(this).before(tmp_text.replace(/new_idx/g,$(".annc_dept").length.toString()));
|
||||||
|
})
|
||||||
|
$("#enable_annc_dept").click(function(){
|
||||||
|
$("#annc_depts_block").toggleClass("hide");
|
||||||
|
})
|
||||||
$('label.checkbox input').click(function(){
|
$('label.checkbox input').click(function(){
|
||||||
if($(this).parent().hasClass('active'))
|
if($(this).parent().hasClass('active'))
|
||||||
$(this).parent().removeClass('active');
|
$(this).parent().removeClass('active');
|
||||||
|
|
|
@ -3,6 +3,7 @@ en:
|
||||||
feed: Feed
|
feed: Feed
|
||||||
import: Import
|
import: Import
|
||||||
announcement:
|
announcement:
|
||||||
|
annc_dept: Department
|
||||||
manually_sort: Manually Sort
|
manually_sort: Manually Sort
|
||||||
enable_manually_sort: Enable Manually Sort
|
enable_manually_sort: Enable Manually Sort
|
||||||
manual_update_sort: Manually Update Sort
|
manual_update_sort: Manually Update Sort
|
||||||
|
|
|
@ -4,6 +4,7 @@ zh_tw:
|
||||||
import: 匯入
|
import: 匯入
|
||||||
get_all_anncs_without_subannc: "選擇相關公告"
|
get_all_anncs_without_subannc: "選擇相關公告"
|
||||||
announcement:
|
announcement:
|
||||||
|
annc_dept: 公告單位
|
||||||
manually_sort: 手動排序
|
manually_sort: 手動排序
|
||||||
enable_manually_sort: 開啟手動排序
|
enable_manually_sort: 開啟手動排序
|
||||||
manual_update_sort: 手動更新排序
|
manual_update_sort: 手動更新排序
|
||||||
|
|
Loading…
Reference in New Issue