announcement_category edit

This commit is contained in:
unknown 2012-02-06 15:23:27 +08:00 committed by Christophe Vilayphiou
parent 65901edf6f
commit f097f83f2b
25 changed files with 286 additions and 122 deletions

View File

@ -1,3 +1,7 @@
$('.bulletin_urls_block a.delete').live('click', function(){
$(this).parents('.list_item').remove();
});
$('.bulletin_files_block a.delete').live('click', function(){ $('.bulletin_files_block a.delete').live('click', function(){
$(this).parents('.list_item').remove(); $(this).parents('.list_item').remove();
}); });

View File

@ -8,7 +8,6 @@ PrototypeR4::Application.routes.draw do
match '/site/update', :to => GithubApp match '/site/update', :to => GithubApp
match '/purchase/:type', :to => CentralServerExchangeApp match '/purchase/:type', :to => CentralServerExchangeApp
# routes for admin # routes for admin
namespace :admin do namespace :admin do
resources :assets resources :assets

View File

@ -4,10 +4,14 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationCon
def index def index
@bulletin_categorys = BulletinCategory.all @bulletin_categorys = BulletinCategory.all
@bulletin_category = BulletinCategory.new(:display => 'List')
@url = panel_announcement_back_end_bulletin_categorys_path
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
format.xml { render :xml => @bulletins } # format.xml { render :xml => @bulletins }
format.js
end end
end end
@ -18,25 +22,47 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationCon
respond_to do |format| respond_to do |format|
format.html # show.html.erb format.html # show.html.erb
format.xml { render :xml => @bulletin_category } # format.xml { render :xml => @bulletin_category }
format.js
end end
end end
# GET /bulletins/new # GET /bulletins/new
# GET /bulletins/new.xml # GET /bulletins/new.xml
def new def new
@bulletin_category = BulletinCategory.new @bulletin_category = BulletinCategory.new(:display => 'List')
respond_to do |format| respond_to do |format|
format.html # new.html.erb format.html # new.html.erb
format.xml { render :xml => @bulletin_category } # format.xml { render :xml => @bulletin_category }
format.js
end end
end end
def quick_edit
# debugger
@bulletin_category = BulletinCategory.find(params[:bulletin_category_id])
@url = panel_announcement_back_end_bulletin_category_path(@bulletin_category)
respond_to do |format|
format.js
end
end
# GET /bulletins/1/edit # GET /bulletins/1/edit
def edit def edit
@bulletin_category = BulletinCategory.find(params[:id]) @bulletin_category = BulletinCategory.find(params[:id])
@i18n_variable = @bulletin_category.i18n_variable @i18n_variable = @bulletin_category.i18n_variable
@url = panel_announcement_back_end_bulletin_category_path(@bulletin_category)
respond_to do |format|
format.html
format.js
end
end end
# POST /bulletins # POST /bulletins
@ -46,12 +72,14 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationCon
respond_to do |format| respond_to do |format|
if @bulletin_category.save if @bulletin_category.save
# format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin_category), :notice => t('announcement.create_bulletin_success')) } # format.html { redirect_to @bulletin_category, notice: 'Entry was successfully created.' }
format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url, :notice => t('announcement.create_bulletin_category_success')) } format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url, :notice => t('announcement.create_bulletin_category_success')) }
format.xml { render :xml => @bulletin_category, :status => :created, :location => @bulletin_category } # format.xml { render :xml => @bulletin_category, :status => :created, :location => @bulletin_category }
format.js
else else
format.html { render :action => "new" } format.html { render :action => "new" }
format.xml { render :xml => @bulletin_category.errors, :status => :unprocessable_entity } # format.xml { render :xml => @bulletin_category.errors, :status => :unprocessable_entity }
format.js { render action: "new" }
end end
end end
end end
@ -61,14 +89,18 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationCon
def update def update
@bulletin_category = BulletinCategory.find(params[:id]) @bulletin_category = BulletinCategory.find(params[:id])
@url = panel_announcement_back_end_bulletin_category_path(@bulletin_category)
respond_to do |format| respond_to do |format|
if @bulletin_category.update_attributes(params[:bulletin_category]) if @bulletin_category.update_attributes(params[:bulletin_category])
# format.html { redirect_to(panel_announcement_back_end_bulletin_category_url(@bulletin_category), :notice => t('bulletin_category.update_bulletin_category_success')) } # format.html { redirect_to(panel_announcement_back_end_bulletin_category_url(@bulletin_category), :notice => t('bulletin_category.update_bulletin_category_success')) }
format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url, :notice => t('bulletin_category.update_bulletin_category_success')) } format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url, :notice => t('bulletin_category.update_bulletin_category_success')) }
format.xml { head :ok } # format.xml { head :ok }
format.js
else else
format.html { render :action => "edit" } format.html { render :action => "edit" }
format.xml { render :xml => @bulletin_category.errors, :status => :unprocessable_entity } format.js { render :action => "edit" }
# format.xml { render :xml => @bulletin_category.errors, :status => :unprocessable_entity }
end end
end end
end end
@ -81,7 +113,8 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationCon
respond_to do |format| respond_to do |format|
format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url) } format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url) }
format.xml { head :ok } # format.xml { head :ok }
format.js
end end
end end
end end

View File

@ -120,19 +120,20 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { redirect_to(panel_announcement_back_end_bulletins_url) } format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.xml { head :ok } # format.xml { head :ok }
format.js
end end
end end
def top_edit # def top_edit
Bulletin.where(id: params[:id]).update_all( is_top: true ) # Bulletin.where(id: params[:id]).update_all( is_top: true )
respond_to do |format| # respond_to do |format|
format.html { redirect_to(panel_announcement_back_end_bulletins_url) } # format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.xml { head :ok } # format.xml { head :ok }
end # end
end # end
protected protected

View File

@ -6,15 +6,15 @@ class Bulletin
include Mongoid::MultiParameterAttributes include Mongoid::MultiParameterAttributes
# field :category_id, :type => Integer # field :category_id, :type => Integer
# field :title field :title
has_one :title_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy # has_one :title_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :subtitle_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy # has_one :subtitle_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :text_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy # has_one :text_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
# field :subtitle field :subtitle
# field :text field :text
field :postdate , :type => Date field :postdate , :type => Date
field :deadline , :type => Date field :deadline , :type => Date
field :url # field :url
field :create_user_id field :create_user_id
field :update_user_id field :update_user_id
@ -24,15 +24,18 @@ class Bulletin
belongs_to :bulletin_category belongs_to :bulletin_category
# embeds_many :bulletin_files embeds_many :bulletin_links, :cascade_callbacks => true
embeds_many :bulletin_files, :cascade_callbacks => true embeds_many :bulletin_files, :cascade_callbacks => true
# has_many :bulletin_files, :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_files, :allow_destroy => true
accepts_nested_attributes_for :bulletin_links, :allow_destroy => true
validates_presence_of :title_variable # validates_presence_of :title_variable
validates_presence_of :title
after_save :save_bulletin_links
after_save :save_bulletin_files after_save :save_bulletin_files
@ -79,6 +82,14 @@ class Bulletin
self.is_top self.is_top
end end
def save_bulletin_links
self.bulletin_links.each do |t|
if t.should_destroy
t.destroy
end
end
end
def save_bulletin_files def save_bulletin_files
self.bulletin_files.each do |t| self.bulletin_files.each do |t|
if t.should_destroy if t.should_destroy

View File

@ -5,8 +5,11 @@ class BulletinCategory
include Mongoid::Timestamps include Mongoid::Timestamps
# include Mongoid::MultiParameterAttributes # include Mongoid::MultiParameterAttributes
PAYMENT_TYPES = [ "List", "Picture" ]
field :key field :key
# field :name field :display
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
has_many :bulletins has_many :bulletins

View File

@ -0,0 +1,13 @@
class BulletinLink
include Mongoid::Document
include Mongoid::Timestamps
field :url
field :name
field :should_destroy, :type => Boolean
embedded_in :bulletin
end

View File

@ -0,0 +1,13 @@
<tr id="<%= dom_id bulletin_category %>">
<td><%= bulletin_category.key %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= bulletin_category.i18n_variable[locale] rescue nil %></td>
<% end %>
<td><%= bulletin_category.display %></td>
<td>
<%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %> |
<%= link_to t('bulletin_category.quick_edit'), panel_announcement_back_end_bulletin_category_quick_edit_path(bulletin_category), :remote => true %> |
<%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %>
</td>
</tr>

View File

@ -1,29 +1,37 @@
<% # encoding: utf-8 %>
<div class="bulletin_categorys"> <%= form_for(@bulletin_category, :remote => true, :url => @url) do |f| %>
<table border="0" cellspacing="0" cellpadding="0"> <%#= form_for(@bulletin_category, :remote => true, :url => panel_announcement_back_end_bulletin_category_path(@bulletin_category)) do |f| %>
<thead class="list_head">
<tr> <div class="field">
<td><%= t('bulletin_category.key') %></td> <%= f.label :key %><br />
<% @site_valid_locales.each do |locale| %> <%= f.text_field :key %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td> </div>
<% end %>
</tr> <div class="field">
</thead> <%= f.label :name %><br />
<tbody>
<tr class="list_item">
<td><%= f.text_field :key %>
<%= f.fields_for :i18n_variable, (@bulletin_category.new_record? ? @bulletin_category.build_i18n_variable : @bulletin_category.i18n_variable) do |f| %> <%= f.fields_for :i18n_variable, (@bulletin_category.new_record? ? @bulletin_category.build_i18n_variable : @bulletin_category.i18n_variable) do |f| %>
<% @site_valid_locales.each do |locale| %> <% @site_valid_locales.each do |locale| %>
<td><%= f.text_field locale, :style => "width:130px" %></td> <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= f.text_field locale, :style => "width:130px" %>
<% end %> <% end %>
<% end %> <% end %>
</tr> </div>
</tbody>
</table> <div class="field">
<%= f.label :display %> <br />
<%#= f.select :display, BulletinCategory::PAYMENT_TYPES, :prompt => 'Select a display method' %>
<%= f.radio_button :display, "List" %>List
<%#= f.label :display, 'list', :value => '1', :checked => @a %>
<%= f.radio_button :display, "Picture" %>Picture
<%#= f.label :display, 'picture', :value => '2', :checked => @b %>
<br />顯示方式是設定在前台頁面時,資訊所呈現的樣式
</div> </div>
<div class="actions"> <div class="actions">
<%= f.submit %> <%= f.submit %>
</div> </div>
<% end %>

View File

@ -0,0 +1,35 @@
<% # encoding: utf-8 %>
<div class="field">
<%= f.label :key %><br />
<%= f.text_field :key %>
</div>
<div class="field">
<%= f.label :name %><br />
<%= f.fields_for :i18n_variable, (@bulletin_category.new_record? ? @bulletin_category.build_i18n_variable : @bulletin_category.i18n_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= f.text_field locale, :style => "width:130px" %>
<% end %>
<% end %>
</div>
<div class="field">
<%= f.label :display %> <br />
<%#= f.select :display, BulletinCategory::PAYMENT_TYPES, :prompt => 'Select a display method' %>
<%= f.radio_button :display, "List" %>List
<%#= f.label :display, 'list', :value => '1', :checked => @a %>
<%= f.radio_button :display, "Picture" %>Picture
<%#= f.label :display, 'picture', :value => '2', :checked => @b %>
<br />顯示方式是設定在前台頁面時,資訊所呈現的樣式
</div>
<div class="actions">
<%= f.submit %>
</div>

View File

@ -0,0 +1,2 @@
$('<%= j render :partial => 'bulletin_category', :collection => [@bulletin_category] %>').appendTo('#bulletin_categorys').hide().fadeIn();
$("#new_bulletin_category")[0].reset();

View File

@ -0,0 +1 @@
$("#<%= dom_id @bulletin_category %>").remove();

View File

@ -0,0 +1 @@
$("#form > form").replaceWith("<%= j render "form" %>");

View File

@ -5,7 +5,7 @@
<br /> <br />
<br /> <br />
<ul class="list"> <ul class="list">
<li><%= link_to t('bulletin_category.new_announcement_class'), new_panel_announcement_back_end_bulletin_category_path, :class => 'seclink1' %></li> <li><%#= link_to t('bulletin_category.new_announcement_class'), new_panel_announcement_back_end_bulletin_category_path, :class => 'seclink1' %></li>
</ul> </ul>
<% end -%> <% end -%>
@ -17,28 +17,28 @@
<br /> <br />
<br /> <br />
<br /> <br />
<table> <table id="bulletin_categorys">
<tr> <tr>
<th><%= t('bulletin_category.key') %></th> <th><%= t('bulletin_category.key') %></th>
<% @site_valid_locales.each do |locale| %> <% @site_valid_locales.each do |locale| %>
<th><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></th> <th><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></th>
<% end %> <% end %>
<th><%= t('bulletin_category.display') %></th>
<th><%= t('bulletin.action') %></th> <th><%= t('bulletin.action') %></th>
</tr> </tr>
<% @bulletin_categorys.each do |post| %> <%# @bulletin_categorys.each do |post| %>
<tr> <%= render :partial => 'bulletin_category', :collection => @bulletin_categorys %>
<td><%= post.key %></td> <%# end %>
<% @site_valid_locales.each do |locale| %>
<td><%= post.i18n_variable[locale] rescue nil %></td>
<% end %>
<td>
<%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(post) %> |
<%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(post), :confirm => t('announcement.sure?'), :method => :delete %>
</td>
</tr>
<% end %>
</table> </table>
<br />
<br />
<br />
<br /> <br />
<h2>Add New</h2>
<div id="form"><%= render :partial => "form" %></div>

View File

@ -0,0 +1 @@
$("#form > form").replaceWith("<%= j render "form" %>");

View File

@ -0,0 +1,3 @@
$.each($(".quick_edit"),function(obj){ $(this).remove(); });
$("#<%= dom_id @bulletin_category %>").append("<div class='quick_edit'><%= j render "form" %></div>");
//$("#form > form").replaceWith("<%= j render "form" %>");

View File

@ -0,0 +1,4 @@
$("#<%= dom_id @bulletin_category %>").replaceWith("<%= j render :partial => 'bulletin_category', :collection => [@bulletin_category] %>");
<% @bulletin_category = BulletinCategory.new(:display => 'List') # reset for new form %>
$(".edit_bulletin_category").replaceWith("<%= j render "form" %>")
$(".new_bulletin_category")[0].reset();

View File

@ -0,0 +1,21 @@
<div id="<%= "bulletin_#{bulletin_link.id}" if !bulletin_link.new_record? %>" class='list_item'>
<div class="field">
<%= f.label :link_url %>
<%= f.text_field :url %>
<%= f.label :link_name %>
<%= f.text_field :name %>
<span class="action">
<% if bulletin_link.new_record? %>
<a href="#" class="delete"><%= t(:delete) %></a>
<% else %>
<%= f.hidden_field :id %>
<a href="#" class="remove_existing_record"><%= t(:delete) %></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>
</span>
</div>
</div>

View File

@ -0,0 +1,18 @@
<tr id="<%= dom_id post %>">
<td></td>
<td><%= post.bulletin_category.i18n_variable[I18n.locale] %></td>
<td><%#= link_to post.title, panel_announcement_front_end_bulletin_path(post) %>
<%= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
</td>
<td><%= post.postdate %></td>
<td><%= (post.deadline) ? post.deadline : t('bulletin.no_deadline') %></td>
<td>
<%= link_to t('bulletin.edit'), edit_panel_announcement_back_end_bulletin_path(post) %> |
<%= link_to t(:set_top), eval("panel_announcement_back_end_bulletin_path(post, :authenticity_token => form_authenticity_token, :bulletin => {:is_top => true})"), :remote => true, :method => :put, :id => "disable_#{post.id}", :style => "display:#{post.is_top? ? 'none' : ''}", :class => 'switch' %>
<%= link_to t(:cancel_top), eval("panel_announcement_back_end_bulletin_path(post, :authenticity_token => form_authenticity_token, :bulletin => {:is_top => false})"), :remote => true, :method => :put, :id => "enable_#{post.id}", :style => "display:#{post.is_top? ? '' : 'none'}", :class => 'switch' %>
| <%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(post), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %>
</td>
</tr>

View File

@ -18,35 +18,17 @@
<div class="field"> <div class="field">
<%= f.label :title %><br /> <%= f.label :title %><br />
<%#= f.text_field :title %> <%= f.text_field :title %>
<%= f.fields_for :title_variable, (@bulletin.new_record? ? @bulletin.build_title_variable : @bulletin.title_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= f.text_field locale, :style => "width:130px" %>
<% end %>
<% end %>
</div> </div>
<div class="field"> <div class="field">
<%= f.label :subtitle %><br /> <%= f.label :subtitle %><br />
<%#= f.text_area :subtitle, :rows => 10, :cols => 40 %> <%= f.text_area :subtitle, :rows => 10, :cols => 40 %>
<%= f.fields_for :subtitle_variable, (@bulletin.new_record? ? @bulletin.build_subtitle_variable : @bulletin.subtitle_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= f.text_area locale, :rows => 10, :cols => 40 %>
<% end %>
<% end %>
</div> </div>
<div class="field"> <div class="field">
<%= f.label :text %><br /> <%= f.label :text %><br />
<%#= f.text_area :text, :rows => 10, :cols => 40 %> <%= f.text_area :text, :rows => 10, :cols => 40 %>
<%= f.fields_for :text_variable, (@bulletin.new_record? ? @bulletin.build_text_variable : @bulletin.text_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= f.text_area locale, :rows => 10, :cols => 40 %>
<% end %>
<% end %>
</div> </div>
<div class="field"> <div class="field">
@ -62,11 +44,31 @@
</div> </div>
<div class="field"> <div class="field">
<%= f.label :url %><br /> <%#= f.label :url %><br />
<%= f.text_field :url, :size => 60 %> <%#= f.text_field :url, :size => 60 %>
</div> </div>
<div id='bulletin_links' class="bulletin_links_block <%= @class %>">
<div id='add_bulletin_link' class="info_input bulletin_links_block">
<h2>Bulletin links</h2>
<%= hidden_field_tag 'bulletin_link_field_count', @bulletin.bulletin_links.count %>
<a href="#" class="add"><%= t(:add) %></a>
</div>
<%#= render :partial => 'link', :locals => { :bulletin_links => @bulletin.bulletin_links , :f => f} %>
<% @bulletin.bulletin_links.each_with_index do |bulletin_link, i| %>
<%#= fields_for "bulletin[bulletin_links][]", bulletin_link do |f| %>
<%= f.fields_for :bulletin_links, bulletin_link do |f| %>
<%= render :partial => 'bulletin_link', :object => bulletin_link, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
</div>
<div id='bulletin_files' class="bulletin_files_block <%= @class %>"> <div id='bulletin_files' class="bulletin_files_block <%= @class %>">
@ -101,6 +103,12 @@
<% content_for :page_specific_javascript do %> <% content_for :page_specific_javascript do %>
<%= javascript_include_tag "bulletin_form" %> <%= javascript_include_tag "bulletin_form" %>
<script> <script>
$('#add_bulletin_link a.add').live('click', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_bulletin_links", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$('#bulletin_links').append(("<%= escape_javascript(add_attribute 'bulletin_link', f, :bulletin_links) %>").replace(old_id, new_id));
});
$('#add_bulletin_file a.add').live('click', function(){ $('#add_bulletin_file a.add').live('click', function(){
var new_id = $(this).prev().attr('value'); var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_bulletin_files", "g"); var old_id = new RegExp("new_bulletin_files", "g");

View File

@ -0,0 +1 @@
$("#<%= dom_id @bulletin %>").remove();

View File

@ -46,34 +46,16 @@
<table> <table>
<tr> <tr>
<th><%= t('bulletin.status') %></th> <th><%= t('bulletin.status') %></th>
<th><%= t('bulletin.postdate') %></th>
<th><%= t('bulletin.deadline') %></th>
<th><%= t('bulletin.category') %></th> <th><%= t('bulletin.category') %></th>
<th><%= t('bulletin.title') %></th> <th><%= t('bulletin.title') %></th>
<th><%= t('bulletin.postdate') %></th>
<th><%= t('bulletin.deadline') %></th>
<th><%= t('bulletin.action') %></th> <th><%= t('bulletin.action') %></th>
</tr> </tr>
<% @bulletins.each do |post| %> <% @bulletins.each do |post| %>
<tr> <%= render :partial => 'bulletins', :locals => {:post => post} %>
<td></td>
<td><%= post.postdate %></td>
<td><%= (post.deadline) ? post.deadline : t('bulletin.no_deadline') %></td>
<td><%= post.bulletin_category.i18n_variable[I18n.locale] %></td>
<td><%#= link_to post.title, panel_announcement_front_end_bulletin_path(post) %>
<%= link_to post.title_variable[I18n.locale], panel_announcement_back_end_bulletin_path(post) %>
</td>
<td>
<%= link_to t('bulletin.edit'), edit_panel_announcement_back_end_bulletin_path(post) %> |
<%= link_to t(:set_top), eval("panel_announcement_back_end_bulletin_path(post, :authenticity_token => form_authenticity_token, :bulletin => {:is_top => true})"), :remote => true, :method => :put, :id => "disable_#{post.id}", :style => "display:#{post.is_top? ? 'none' : ''}", :class => 'switch' %>
<%= link_to t(:cancel_top), eval("panel_announcement_back_end_bulletin_path(post, :authenticity_token => form_authenticity_token, :bulletin => {:is_top => false})"), :remote => true, :method => :put, :id => "enable_#{post.id}", :style => "display:#{post.is_top? ? '' : 'none'}", :class => 'switch' %>
| <%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(post), :confirm => t('announcement.sure?'), :method => :delete %>
</td>
</tr>
<% end %> <% end %>
</table> </table>
<br /> <br />

View File

@ -17,7 +17,7 @@
</li> </li>
<li> <li>
<b><%= t('announcement.title') %></b> <b><%= t('announcement.title') %></b>
<%= @bulletin.title_variable[I18n.locale] %> <%= @bulletin.title %>
</li> </li>
<li> <li>
<%#= image_tag(@bulletin.image.url, :size => "320x240") if @bulletin.image.file %> <%#= image_tag(@bulletin.image.url, :size => "320x240") if @bulletin.image.file %>
@ -25,11 +25,11 @@
</li> </li>
<li> <li>
<b><%= t('announcement.subtitle') %></b> <b><%= t('announcement.subtitle') %></b>
<%= @bulletin.subtitle_variable[I18n.locale] %> <%= @bulletin.subtitle %>
</li> </li>
<li> <li>
<b><%= t('announcement.text') %></b> <b><%= t('announcement.text') %></b>
<%= @bulletin.text_variable[I18n.locale] %> <%= @bulletin.text %>
</li> </li>
<li> <li>
<li> <li>

View File

@ -33,15 +33,15 @@
</li> </li>
<li> <li>
<li> <li>
<b><%= t('announcement.file') %></b> <b><%= t('announcement.link') %></b>
<% @bulletin.bulletin_files.each do | bfile | %> <% @bulletin.bulletin_links.each do | blink | %>
<%= link_to bfile.filetitle, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %> <%= link_to blink.name, blink.url, :target => '_blank' %>
<% end %> <% end %>
</li> </li>
<li> <li>
<% if @bulletin.url? %> <b><%= t('announcement.file') %></b>
<b><%= t('announcement.url') %></b> <% @bulletin.bulletin_files.each do | bfile | %>
<%= link_to @bulletin.url, @bulletin.url, :target => '_blank' %> <%= link_to bfile.filetitle, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %>
<% end %> <% end %>
</li> </li>
<li> <li>

View File

@ -5,7 +5,9 @@ Rails.application.routes.draw do
namespace :back_end do namespace :back_end do
root :to => "bulletins#index" root :to => "bulletins#index"
resources :bulletins resources :bulletins
resources :bulletin_categorys, :controller => 'bulletin_categorys' resources :bulletin_categorys, :controller => 'bulletin_categorys' do
match "quick_edit/:bulletin_category_id" => "bulletin_categorys#quick_edit" ,:as => :quick_edit
end
end end
namespace :front_end do namespace :front_end do
root :to => "bulletins#index" root :to => "bulletins#index"