Basic functions of announcement module

This commit is contained in:
manson 2014-05-01 16:41:00 +08:00
parent f23115bde5
commit 9448c519df
14 changed files with 803 additions and 39 deletions

View File

@ -1,21 +1,97 @@
class Admin::AnnouncementsController < ApplicationController # encoding: utf-8
class Admin::AnnouncementsController < OrbitAdminController
before_filter :setup_vars
def index
@tags = @module_app.tags
@categories = @module_app.categories
@statuses = []
@bulletins = Kaminari.paginate_array(Bulletin.order_by(sort).all).page(params[:page]).per(10)
@table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified]
@filter_fields = {
:status=>[{:title=>"is_top",:id=>"is_top"},{:title=>"is_hot",:id=>"is_hot"},{:title=>"is_hidden",:id=>"is_hidden"}],
:category=>@categories.map{|c| {:title=>c.title, :id=>c.id}},
:tags=>@tags.map{|tag| {:title=>tag.name, :id=>tag.id}}
}
end
def sort
unless params[:sort].blank?
case params[:sort]
when "status"
@sort = [[:is_top, params[:order]],
[:is_hot, params[:order]],
[:is_hidden,params[:order]]]
when "category"
@sort = {:category_id=>params[:order]}
when "title"
@sort = {:title=>params[:order]}
when "start_date"
@sort = {:postdate=>params[:order]}
when "end_date"
@sort = {:deadline=>params[:order]}
when "last_modified"
@sort = {:update_user_id=>params[:order]}
end
else
@sort = {:created_at=>'desc'}
end
@sort
end
def new def new
@announcement = Bulletin.new @tags =@module_app.tags
@categories = @module_app.categories
@statuses = []
@bulletin = Bulletin.new
end end
def create def create
@announcement = Bulletin.new(bulletin_params) bulletin = Bulletin.new(bulletin_params)
@announcement.save bulletin.create_user_id = current_user.id
bulletin.update_user_id = current_user.id
bulletin.save
redirect_to "/admin/announcements"
end end
def index def edit
@announcements = Bulletin.all @tags =@module_app.tags
@categories = @module_app.categories
@statuses = []
@bulletin = Bulletin.find(params[:id])
end
def update
uid = params[:id].split('-').last
bulletin = Bulletin.find_by(:uid=>uid)
bulletin_params[:tags] = bulletin_params[:tags].blank? ? [] : bulletin_params[:tags]
bulletin.update_attributes(bulletin_params)
bulletin.save
redirect_to "/admin/announcements"
end
def destroy
bulletin = Bulletin.find(params[:id])
bulletin.destroy
redirect_to "/admin/announcements"
end
def delete
if params[:ids]
bulletins = Bulletin.any_in(:uid => params[:ids]).destroy_all
end
redirect_to "/admin/announcements"
end end
private private
# Never trust parameters from the scary internet, only allow the white list through. def bulletin_params
def bulletin_params params.require(:bulletin).permit!
params.require(:bulletin).permit(title_translations: [:en, :zh_tw], body_translations: [:en, :zh_tw]) end
end
def setup_vars
@module_app = ModuleApp.where(:key=>"announcement").first
end
end end

View File

@ -1,11 +1,11 @@
class AnnouncementsController < ApplicationController class AnnouncementsController < ApplicationController
def index def index
announcements = Bulletin.filter_by_categories announcements = Bulletin.order_by(:created_at=>'desc').filter_by_categories
anns = announcements.collect do |a| anns = announcements.collect do |a|
{ {
"title" => a.title, "title" => a.title,
"body" => a.body, "body" => a.text,
"link_to_show" => OrbitHelper.url_to_show(a.to_param), "link_to_show" => OrbitHelper.url_to_show(a.to_param),
"more" => "More", "more" => "More",
} }
@ -17,11 +17,11 @@ class AnnouncementsController < ApplicationController
end end
def widget def widget
announcements = Bulletin.all announcements = Bulletin.order_by(:created_at=>'desc').filter_by_categories
anns = announcements.collect do |a| anns = announcements.collect do |a|
{ {
"title" => a.title, "title" => a.title,
"subtitle" => a.body, "subtitle" => a.text,
"link_to_show" => OrbitHelper.url_to_show(a.to_param), "link_to_show" => OrbitHelper.url_to_show(a.to_param),
"more" => "More", "more" => "More",
} }
@ -35,10 +35,10 @@ class AnnouncementsController < ApplicationController
def show def show
params = OrbitHelper.params params = OrbitHelper.params
announcement = Bulletin.find_by_param(params[:uid]) announcement = Bulletin.find_by(:uid=>params[:uid])
{ {
"title" => announcement.title, "title" => announcement.title,
"body" => announcement.body "body" => announcement.text
} }
end end

View File

@ -1,16 +1,41 @@
class Bulletin class Bulletin
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
include Impressionist::Impressionable
include OrbitModel::Status
include OrbitTag::Taggable include OrbitTag::Taggable
include OrbitCategory::Categorizable include OrbitCategory::Categorizable
include Slug include Slug
field :title, as: :slug_title, type: String, localize: true field :title, as: :slug_title, type: String, localize: true
field :body, type: String, localize: true field :subtitle, localize: true
field :uid, type: String field :text, localize: true
field :create_user_id
field :update_user_id
field :public, :type => Boolean, :default => true
field :postdate , :type => DateTime, :default => Time.now
field :deadline , :type => DateTime
def self.find_by_param(input) field :email_sent, :type => Boolean, :default => false
self.find_by(uid: input) field :email_sentdate , :type => DateTime
field :email_user_ids
field :other_mailaddress
mount_uploader :image, ImageUploader
has_many :bulletin_links, :autosave => true, :dependent => :destroy
has_many :bulletin_files, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :bulletin_files, :allow_destroy => true
accepts_nested_attributes_for :bulletin_links, :allow_destroy => true
def update_user
User.find(update_user_id) rescue nil
end
def update_user=(user)
self.update_user_id = user.id
end end
end end

View File

@ -0,0 +1,13 @@
class BulletinFile
include Mongoid::Document
include Mongoid::Timestamps
mount_uploader :file, AssetUploader
field :description, localize: true
field :title, localize: true
belongs_to :bulletin
end

View File

@ -0,0 +1,24 @@
require 'uri'
class BulletinLink
include Mongoid::Document
include Mongoid::Timestamps
field :url
field :title, localize: true
belongs_to :bulletin
before_validation :add_http
validates :url, :presence => true, :format => /\A(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?\Z/i
protected
def add_http
unless self.url[/^http:\/\//] || self.url[/^https:\/\//]
self.url = 'http://' + self.url
end
end
end

View File

@ -0,0 +1,342 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/modal-preview" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<%= javascript_include_tag "member-selection" %>
<% end %>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li>
<li><a href="#status" data-toggle="tab"><%= t(:status) %></a></li>
<li><a href="#tag" data-toggle="tab"><%= t(:tags) %></a></li>
<li><a href="#imageupload" data-toggle="tab"><%= t(:image) %></a></li>
<li><a href="#mail-group" data-toggle="tab"><%= t('announcement.email_reminder')%></a></li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<!-- Category -->
<div class="control-group">
<label class="control-label muted"><%= t(:category) %></label>
<div class="controls">
<%= f.select :category_id, @categories.collect{|t| [ t.title, t.id ]} %>
</div>
</div>
<!-- Date Time Picker -->
<div class="control-group">
<label class="control-label muted"><%= t(:start) %></label>
<div class="controls">
<%= f.datetime_picker :postdate, :no_label => true %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t(:end) %></label>
<div class="controls">
<%= f.datetime_picker :deadline, :no_label => true %>
</div>
</div>
</div>
<!-- Status Module -->
<%# if show_form_status_field(@bulletin) %>
<div class="tab-pane fade" id="status">
<!-- Status -->
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @bulletin.is_top? %>">
<%= f.check_box :is_top %> <%= t(:top) %>
</label>
<label class="checkbox inline btn <%= 'active' if @bulletin.is_hot? %>">
<%= f.check_box :is_hot %> <%= t(:hot) %>
</label>
<label class="checkbox inline btn <%= 'active' if @bulletin.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
<%# end %>
<!-- Tag Module -->
<div class="tab-pane fade" id="tag">
<!-- Tag -->
<div class="control-group">
<label class="control-label muted"><%= t(:tags) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<% @tags.each do |tag| %>
<label class="checkbox inline btn <%= 'active' if @bulletin.tags.include?(tag) %>">
<%= check_box_tag 'bulletin[tags][]', tag.id, @bulletin.tags.include?(tag) %> <%= tag.name %>
</label>
<% end %>
</div>
</div>
</div>
<!-- Images Module -->
<div class="tab-pane fade" id="imageupload">
<!-- Images Upload -->
<div class="control-group">
<label class="control-label muted"><%= t(:image) %></label>
<div class="controls">
<div class="fileupload fileupload-new clearfix <%= 'fileupload-edit' if @bulletin.image.file %>" data-provides="fileupload">
<div class="fileupload-new thumbnail pull-left">
<% if @bulletin.image.file %>
<%= image_tag @bulletin.image %>
<% else %>
<img src="http://www.placehold.it/50x50/EFEFEF/AAAAAA" />
<% end %>
</div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<span class="btn btn-file">
<span class="fileupload-new"><%= t(:select_image) %></span>
<span class="fileupload-exists"><%= t(:change) %></span>
<%= f.file_field :image %>
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn btn-danger fileupload-remove">
<%= f.check_box :remove_image %><%= t(:remove) %>
</label>
</div>
</div>
</div>
</div>
</div>
<!-- Mail Group Module -->
<div class="tab-pane fade" id="mail-group">
<!-- Mail Group -->
<div class="control-group">
<label class="control-label muted"><%= t("announcement.email_to") %></label>
<div class="controls">
<label class="checkbox inline">
<%= check_box_tag('bulletin[email_sent]', '1', (!@bulletin.email_sent.blank? ? true : false), :id=>'remind-check') %><%= t('announcement.activate_email_reminder')%>
</label>
<div class="content-box">
<p>
<%#= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'bulletin[email_user_ids][]', users: @email_users} %>
</p>
</div>
</div>
</div>
<div class="control-group">
<label class="control-label muted"></label>
<div class="controls">
<div class="content-box">
<span class="help-block"><%= "#{t("announcement.other_mailaddress")}(#{t("announcement.other_mailaddress_note")})"%> </span>
<%= f.text_area :other_mailaddress, :class=>"span12", :cols=>"25", :rows=>"10" %>
</div>
</div>
</div>
<div class="content-box">
<div class="control-group">
<label class="control-label muted"><%= t("announcement.email_sentdate") %></label>
<div class="controls">
<%#= f.datetime_picker :email_sentdate, :no_label => true %>
</div>
</div>
</div>
</div>
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% Site.first.in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% Site.first.in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- Title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t(:title) %></label>
<div class="controls">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t(:title), value: (@bulletin.title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- Sub Title -->
<div class="control-group input-subtitle">
<label class="control-label muted"><%= t(:subtitle) %></label>
<div class="controls">
<div class="textarea">
<%= f.fields_for :subtitle_translations do |f| %>
<%= f.text_area locale, rows: 2, class: "input-block-level", value: (@bulletin.subtitle_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<!-- Content -->
<div class="control-group input-content">
<label class="control-label muted"><%= t(:content) %></label>
<div class="controls">
<div class="textarea">
<%= f.fields_for :text_translations do |f| %>
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@bulletin.text_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
</div>
<% end %>
<!-- Link -->
<div class="control-group">
<label class="control-label muted"><%= t(:link) %></label>
<div class="controls add-input">
<!-- Exist -->
<% if @bulletin && !@bulletin.bulletin_links.blank? %>
<div class="exist">
<% @bulletin.bulletin_links.each_with_index do |bulletin_link, i| %>
<%= f.fields_for :bulletin_links, bulletin_link do |f| %>
<%= render :partial => 'form_link', :object => bulletin_link, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'bulletin_link_field_count', @bulletin.bulletin_links.count %>
<a id="add_link" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
<!-- File -->
<div class="control-group">
<label class="control-label muted"><%= t(:file_) %></label>
<div class="controls">
<!-- Exist -->
<% if @bulletin && !@bulletin.bulletin_files.blank? %>
<div class="exist">
<% @bulletin.bulletin_files.each_with_index do |bulletin_file, i| %>
<%= f.fields_for :bulletin_files, bulletin_file do |f| %>
<%= render :partial => 'form_file', :object => bulletin_file, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.count %>
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= button_tag t("preview"), id: "button_for_preview", name: "commit", class: 'btn post_preview', type: :button, url: admin_announcements_path %>
<%= link_to t('cancel'), admin_announcements_path, :class=>"btn" %>
</div>
<% content_for :page_specific_javascript do %>
<script>
$(function() {
$(document).on('click', '#add_link', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_bulletin_links", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_link', f, :bulletin_links) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.tab-content').children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
formTip();
});
$(document).on('click', '#add_file', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_bulletin_files", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :bulletin_files) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
});
formTip();
});
$(document).on('click', '.delete_link', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.delete_file', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
$('#remind-check').prop('checked') ? '':$('.content-box').addClass('hide')
$('#remind-check').on('change', function() {
$(this).prop('checked') ? $('.content-box').removeClass('hide'):$('.content-box').addClass('hide')
})
});
</script>
<% end %>

View File

@ -0,0 +1,55 @@
<% if form_file.new_record? %>
<div class="fileupload fileupload-new start-line" data-provides="fileupload">
<% else %>
<div class="fileupload fileupload-exist start-line" data-provides="fileupload">
<% if form_file.file.blank? %>
<%= t(:no_file) %>
<% else %>
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
<% end %>
<% end %>
<div class="input-prepend input-append">
<label>
<span class="add-on btn btn-file" title='<%= t(:file_) %>'>
<i class="icons-paperclip"></i>
<%= f.file_field :file %>
</span>
<div class="uneditable-input input-medium">
<i class="icon-file fileupload-exists"></i>
<span class="fileupload-preview"><%= (form_file.new_record? || form_file.file.blank?) ? t(:select_file) : t(:change_file) %></span>
</div>
</label>
<span class="add-on icons-pencil" title='<%= t(:alternative) %>'></span>
<span class="tab-content">
<% Site.first.in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t(:alternative), :value => (form_file.title_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
<span class="add-on icons-pencil" title='<%= t(:description) %>'></span>
<span class="tab-content">
<% Site.first.in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :description_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t(:description), :value => (form_file.description_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
</span>
<% if form_file.new_record? %>
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<a class="icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>
</div>

View File

@ -0,0 +1,26 @@
<div class="input-prepend input-append start-line">
<span class="add-on icons-link" title="<%= t(:url) %>"></span>
<%= f.text_field :url, class: "input-large", placeholder: t(:url) %>
<span class="add-on icons-pencil" title="<%= t(:url_alt) %>"></span>
<span class="tab-content">
<% Site.first.in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, :class => "input-large", placeholder: t(:url_alt), :value => (form_link.title_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
<% if form_link.new_record? %>
<span class="delete_link add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<a class="icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>

View File

@ -0,0 +1,5 @@
<%= form_for @bulletin, url: admin_announcement_path(@bulletin), html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render :partial => 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -1,3 +1,95 @@
<% @announcements.each do |a|%> <script type="text/javascript">
<%= a.title %> url = "";
<% end %> filters = [];
filter = "";
$(".accordion-inner a").click(function(){
if(window.location.search==""){
filters = [];
}else{
filters = window.location.search.replace('?','').split('&');
}
filter = $(this).attr("href").split('?')[1];
if( (index = filters.indexOf(filter) ) > -1){
filters.splice(index,1);
}else{
filters.push(filter);
}
if(filters.length==0){
url = window.location.origin+window.location.pathname
}else{
url = window.location.origin+window.location.pathname+'?'+filters.join('&');
}
window.location.assign(url);
return false;
});
</script>
<% content_for :right_nav do %>
<ul class="nav nav-pills filter-nav pull-right">
<% @filter_fields.keys.each do |field| %>
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-<%= field %>" data-toggle="collapse" data-parent="#filter" class="accordion-toggle"><%= t(field) %></a>
</div>
</li>
<% end %>
</ul>
<div class="filter-group accordion-group">
<% @filter_fields.keys.each do |field| %>
<div class="accordion-body collapse" id="collapse-<%= field %>">
<div class="accordion-inner pagination-right" data-toggle="buttons-checkbox">
<% @filter_fields[field].each do |val| %>
<%= link_to t(val[:title]), "?filters[#{field}][]=#{val[:id]}", :class => "btn btn-small #{is_filter_active?(field, val[:id])}" %>
<% end %>
</div>
<div class="filter-clear">
<a href="" class="btn btn-link btn-small"><i class="icons-cycle"></i> <%= t(:clear) %></a>
</div>
</div>
<% end %>
</div>
<% end %>
<table class="table main-list">
<thead>
<tr class="sort-header">
<% @table_fields.each do |f| %>
<%= thead(f) %>
<% end %>
</tr>
</thead>
<tbody>
<% @bulletins.each do |b| %>
<tr>
<td><%= b.status_for_table %></td>
<td><%= b.category.title %></td>
<td>
<a href="/news/<%=b.id.to_s%>"><%= b.title %></a>
<div class="quick-edit">
<ul class="nav nav-pills">
<li><a href="/admin/announcements/<%=b.id.to_s%>/edit"><%= t(:edit) %></a></li>
<li><a href="#" class="detail-row"><%= t(:detail) %></a></li>
<li><a href="#" class="delete text-error" rel="/admin/announcements/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
</ul>
</div>
</td>
<td><%= format_value b.postdate %></td>
<td><%= format_value b.deadline %></td>
<td><%= b.update_user.user_name %></td>
</tr>
<% end %>
</tbody>
</table>
<%=
content_tag :div, class: "bottomnav clearfix" do
content_tag :div, paginate(@bulletins), class: "pagination pagination-centered"
end
%>
<%= render 'layouts/delete_modal', delete_options: @delete_options %>

View File

@ -1,15 +1,5 @@
<%= form_for @announcement, url: {action: "create"} do |f| %> <%= form_for @bulletin, url: admin_announcements_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<% I18n.available_locales.each do |locale| %> <fieldset>
Title <%= locale.to_s %>: <%= render :partial => 'form', locals: {f: f} %>
<%= f.fields_for :title_translations do |n| %> </fieldset>
<%= n.text_field locale %>
<% end %>
Body <%= locale.to_s %>:
<%= f.fields_for :body_translations do |n| %>
<%= n.text_area locale %>
<% end %>
<% end %>
<%= f.submit "Create Announcement" %>
<% end %> <% end %>

View File

@ -1,3 +1,50 @@
en: en:
announcement: announcement:
announcement: Announcement add_new: Add New
all_articles: All Articles
announcement: Announcement
approval_setting: Approval Setting
approve_bulletin_fail: Approval Fail
approve_bulletin_success: Approve Successfully
bulletins: Bulletins
categories: Categories
create_bulletin_success: Create Bulletin Successfully
create_bulletin_category_success: Create Category Successfully
date: Announcement Date
default_widget:
bulletin_category_with_title: Bulletin Category with Title
postdate: Post Date
subtitle: Subtitle
title: Title
editing_announcement: Edit Announcement
editing_announcement_category: Edit Category
file: Attachment
file_description: File Description
file_name: File Name
frontend:
bulletins: Announcement front-end
search_result: Search result
link_name: Link Name
new_bulletin_category: New Bulletin Category
picture: Cover Picture
search: Search
selected_file: Select File
update_bulletin_category_success: Update Category Successfully
url: URL
widget:
bulletins_and_web_links: Differential Nav.
index: Index
search: Search
email_reminder: Email Reminder
activate_email_reminder: Activate Email Reminder
email_sentdate: Email Time
email_to: Email To
mail_subject: this is an announcement reminder from【%{site_title}】
other_mailaddress: Other Email
other_mailaddress_note: Divide different email accounts with ","
mail_hi: Hi
mail_url_view: This email is the reminder of an announcement, please click the link for the details
mail_source: Source
mail_time: Time
image_upload_size_note: The following recommendations %{image_upload_size} upload size

View File

@ -3,4 +3,51 @@ zh_tw:
announcement: announcement:
add_new: 新建 add_new: 新建
all_articles: 文章列表 all_articles: 文章列表
announcement: 公告 announcement: 公告
approval_setting: 審核設定
approve_bulletin_fail: 審核失敗
approve_bulletin_success: 審核成功
bulletins: 公告
categories: 類別
create_bulletin_success: 建立公告成功
create_bulletin_category_success: 建立類別成功
date: 起迄日期
default_widget:
bulletin_category_with_title: 公告類別及標題
postdate: 張貼日期
subtitle: 副標題
title: 標題
editing_announcement: 編輯類別
editing_announcement_category: 編輯類別
error:
no_avilb_cate_for_posting: 沒有可以張貼的類別
file: 附加檔案
file_description: 檔案描述
file_name: 檔案名稱
frontend:
bulletins: 公告前台
search_result: 搜尋結果頁
link_name: 連結名稱
new_bulletin_category: 新增公告類別
picture: 刊頭圖片
search: 搜尋
selected_file: 選擇檔案
update_bulletin_category_success: 更新類別成功
url: 連結位置
widget:
bulletins_and_web_links: 分眾頁籤
index: 索引
search: 搜尋
more: 更多+
email_reminder: 寄送提醒
activate_email_reminder: 開啟寄送提醒
email_sentdate: 寄送時間
email_to: 寄送對象
other_mailaddress: 其他Mail
other_mailaddress_note: 輸入多組mail時,請用","逗號隔開
mail_subject: 來自【%{site_title}】的公告事件提醒
mail_hi: 您好
mail_url_view: 此封信件為公告事件提醒,請點選以下連結詳細觀看
mail_source: 來源
mail_time: 時間
image_upload_size_note: 建議檔案小於%{image_upload_size}

View File

@ -12,7 +12,29 @@ module Announcement
head_label_i18n 'announcement.announcement', icon_class: "icons-megaphone" head_label_i18n 'announcement.announcement', icon_class: "icons-megaphone"
active_for_controllers ({:private=>['announcements']}) active_for_controllers ({:private=>['announcements']})
head_link_path "admin_announcements_path" head_link_path "admin_announcements_path"
context_link 'announcement.all_articles',
:link_path=>"admin_announcements_path" ,
:priority=>1,
:active_for_action=>{:bulletins=>:index},
:available_for => [:all]
context_link 'announcement.add_new',
:link_path=>"new_admin_announcement_path" ,
:priority=>2,
:active_for_action=>{:bulletins=>:new},
:available_for => [:sub_manager]
# context_link 'announcement.categories',
# :link_path=>"admin_announcement_path(get_module_app)" ,
# :priority=>3,
# :active_for_category => 'Announcement',
# :available_for => [:manager]
# context_link 'tags',
# :link_path=>"admin_announcement_path(module_app_id: get_module_app)" ,
# :priority=>4,
# :active_for_tag => 'Announcement',
# :available_for => [:manager]
end end
end end
end end
end end