announcement_category edit
This commit is contained in:
parent
65901edf6f
commit
f097f83f2b
|
@ -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(){
|
||||
$(this).parents('.list_item').remove();
|
||||
});
|
||||
|
|
|
@ -7,7 +7,6 @@ PrototypeR4::Application.routes.draw do
|
|||
match '/site/public_key', :to => CentralServerExchangeApp
|
||||
match '/site/update', :to => GithubApp
|
||||
match '/purchase/:type', :to => CentralServerExchangeApp
|
||||
|
||||
|
||||
# routes for admin
|
||||
namespace :admin do
|
||||
|
|
|
@ -4,10 +4,14 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationCon
|
|||
|
||||
def index
|
||||
@bulletin_categorys = BulletinCategory.all
|
||||
|
||||
@bulletin_category = BulletinCategory.new(:display => 'List')
|
||||
|
||||
@url = panel_announcement_back_end_bulletin_categorys_path
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xml { render :xml => @bulletins }
|
||||
# format.xml { render :xml => @bulletins }
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -18,25 +22,47 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationCon
|
|||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.xml { render :xml => @bulletin_category }
|
||||
# format.xml { render :xml => @bulletin_category }
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# GET /bulletins/new
|
||||
# GET /bulletins/new.xml
|
||||
def new
|
||||
@bulletin_category = BulletinCategory.new
|
||||
@bulletin_category = BulletinCategory.new(:display => 'List')
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @bulletin_category }
|
||||
# format.xml { render :xml => @bulletin_category }
|
||||
format.js
|
||||
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
|
||||
def edit
|
||||
@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
|
||||
|
||||
# POST /bulletins
|
||||
|
@ -46,12 +72,14 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationCon
|
|||
|
||||
respond_to do |format|
|
||||
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.xml { render :xml => @bulletin_category, :status => :created, :location => @bulletin_category }
|
||||
# format.xml { render :xml => @bulletin_category, :status => :created, :location => @bulletin_category }
|
||||
format.js
|
||||
else
|
||||
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
|
||||
|
@ -60,15 +88,19 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationCon
|
|||
# PUT /bulletins/1.xml
|
||||
def update
|
||||
@bulletin_category = BulletinCategory.find(params[:id])
|
||||
|
||||
@url = panel_announcement_back_end_bulletin_category_path(@bulletin_category)
|
||||
|
||||
respond_to do |format|
|
||||
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_categorys_url, :notice => t('bulletin_category.update_bulletin_category_success')) }
|
||||
format.xml { head :ok }
|
||||
# format.xml { head :ok }
|
||||
format.js
|
||||
else
|
||||
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
|
||||
|
@ -81,7 +113,8 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationCon
|
|||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url) }
|
||||
format.xml { head :ok }
|
||||
# format.xml { head :ok }
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -120,19 +120,20 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
|
||||
format.xml { head :ok }
|
||||
# format.xml { head :ok }
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def top_edit
|
||||
# def top_edit
|
||||
|
||||
Bulletin.where(id: params[:id]).update_all( is_top: true )
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
|
||||
format.xml { head :ok }
|
||||
end
|
||||
# Bulletin.where(id: params[:id]).update_all( is_top: true )
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
|
||||
# format.xml { head :ok }
|
||||
# end
|
||||
|
||||
end
|
||||
# end
|
||||
|
||||
|
||||
protected
|
||||
|
|
|
@ -6,15 +6,15 @@ class Bulletin
|
|||
include Mongoid::MultiParameterAttributes
|
||||
|
||||
# field :category_id, :type => Integer
|
||||
# field :title
|
||||
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 :text_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
||||
# field :subtitle
|
||||
# field :text
|
||||
field :title
|
||||
# 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 :text_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
||||
field :subtitle
|
||||
field :text
|
||||
field :postdate , :type => Date
|
||||
field :deadline , :type => Date
|
||||
field :url
|
||||
# field :url
|
||||
field :create_user_id
|
||||
field :update_user_id
|
||||
|
||||
|
@ -24,15 +24,18 @@ class Bulletin
|
|||
|
||||
belongs_to :bulletin_category
|
||||
|
||||
# embeds_many :bulletin_files
|
||||
embeds_many :bulletin_links, :cascade_callbacks => true
|
||||
embeds_many :bulletin_files, :cascade_callbacks => true
|
||||
|
||||
# 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
|
||||
|
||||
validates_presence_of :title_variable
|
||||
# validates_presence_of :title_variable
|
||||
validates_presence_of :title
|
||||
|
||||
after_save :save_bulletin_links
|
||||
after_save :save_bulletin_files
|
||||
|
||||
|
||||
|
@ -79,6 +82,14 @@ class Bulletin
|
|||
self.is_top
|
||||
end
|
||||
|
||||
def save_bulletin_links
|
||||
self.bulletin_links.each do |t|
|
||||
if t.should_destroy
|
||||
t.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def save_bulletin_files
|
||||
self.bulletin_files.each do |t|
|
||||
if t.should_destroy
|
||||
|
|
|
@ -5,8 +5,11 @@ class BulletinCategory
|
|||
include Mongoid::Timestamps
|
||||
# include Mongoid::MultiParameterAttributes
|
||||
|
||||
PAYMENT_TYPES = [ "List", "Picture" ]
|
||||
|
||||
field :key
|
||||
# field :name
|
||||
field :display
|
||||
|
||||
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
|
||||
|
||||
has_many :bulletins
|
||||
|
|
|
@ -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
|
|
@ -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>
|
|
@ -1,29 +1,37 @@
|
|||
<% # encoding: utf-8 %>
|
||||
|
||||
<div class="bulletin_categorys">
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<thead class="list_head">
|
||||
<tr>
|
||||
<td><%= t('bulletin_category.key') %></td>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<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| %>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<td><%= f.text_field locale, :style => "width:130px" %></td>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<%= form_for(@bulletin_category, :remote => true, :url => @url) do |f| %>
|
||||
<%#= form_for(@bulletin_category, :remote => true, :url => panel_announcement_back_end_bulletin_category_path(@bulletin_category)) do |f| %>
|
||||
|
||||
<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>
|
||||
|
||||
<% end %>
|
||||
|
|
@ -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>
|
||||
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$('<%= j render :partial => 'bulletin_category', :collection => [@bulletin_category] %>').appendTo('#bulletin_categorys').hide().fadeIn();
|
||||
$("#new_bulletin_category")[0].reset();
|
|
@ -0,0 +1 @@
|
|||
$("#<%= dom_id @bulletin_category %>").remove();
|
|
@ -0,0 +1 @@
|
|||
$("#form > form").replaceWith("<%= j render "form" %>");
|
|
@ -5,7 +5,7 @@
|
|||
<br />
|
||||
<br />
|
||||
<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>
|
||||
<% end -%>
|
||||
|
||||
|
@ -17,28 +17,28 @@
|
|||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<table>
|
||||
<table id="bulletin_categorys">
|
||||
<tr>
|
||||
<th><%= t('bulletin_category.key') %></th>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<th><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></th>
|
||||
<% end %>
|
||||
<th><%= t('bulletin_category.display') %></th>
|
||||
<th><%= t('bulletin.action') %></th>
|
||||
</tr>
|
||||
|
||||
<% @bulletin_categorys.each do |post| %>
|
||||
<tr>
|
||||
<td><%= post.key %></td>
|
||||
<% @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 %>
|
||||
<%# @bulletin_categorys.each do |post| %>
|
||||
<%= render :partial => 'bulletin_category', :collection => @bulletin_categorys %>
|
||||
<%# end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<h2>Add New</h2>
|
||||
<div id="form"><%= render :partial => "form" %></div>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$("#form > form").replaceWith("<%= j render "form" %>");
|
|
@ -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" %>");
|
|
@ -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();
|
|
@ -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>
|
|
@ -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>
|
|
@ -18,35 +18,17 @@
|
|||
|
||||
<div class="field">
|
||||
<%= f.label :title %><br />
|
||||
<%#= 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 %>
|
||||
<%= f.text_field :title %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :subtitle %><br />
|
||||
<%#= 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 %>
|
||||
<%= f.text_area :subtitle, :rows => 10, :cols => 40 %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :text %><br />
|
||||
<%#= 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 %>
|
||||
<%= f.text_area :text, :rows => 10, :cols => 40 %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
|
@ -62,11 +44,31 @@
|
|||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :url %><br />
|
||||
<%= f.text_field :url, :size => 60 %>
|
||||
<%#= f.label :url %><br />
|
||||
<%#= f.text_field :url, :size => 60 %>
|
||||
</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 %>">
|
||||
|
||||
|
@ -101,6 +103,12 @@
|
|||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "bulletin_form" %>
|
||||
<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(){
|
||||
var new_id = $(this).prev().attr('value');
|
||||
var old_id = new RegExp("new_bulletin_files", "g");
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$("#<%= dom_id @bulletin %>").remove();
|
|
@ -46,34 +46,16 @@
|
|||
<table>
|
||||
<tr>
|
||||
<th><%= t('bulletin.status') %></th>
|
||||
<th><%= t('bulletin.postdate') %></th>
|
||||
<th><%= t('bulletin.deadline') %></th>
|
||||
<th><%= t('bulletin.category') %></th>
|
||||
<th><%= t('bulletin.title') %></th>
|
||||
<th><%= t('bulletin.postdate') %></th>
|
||||
<th><%= t('bulletin.deadline') %></th>
|
||||
<th><%= t('bulletin.action') %></th>
|
||||
</tr>
|
||||
|
||||
<% @bulletins.each do |post| %>
|
||||
<tr>
|
||||
<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 %>
|
||||
|
||||
<%= render :partial => 'bulletins', :locals => {:post => post} %>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</li>
|
||||
<li>
|
||||
<b><%= t('announcement.title') %></b>
|
||||
<%= @bulletin.title_variable[I18n.locale] %>
|
||||
<%= @bulletin.title %>
|
||||
</li>
|
||||
<li>
|
||||
<%#= image_tag(@bulletin.image.url, :size => "320x240") if @bulletin.image.file %>
|
||||
|
@ -25,11 +25,11 @@
|
|||
</li>
|
||||
<li>
|
||||
<b><%= t('announcement.subtitle') %></b>
|
||||
<%= @bulletin.subtitle_variable[I18n.locale] %>
|
||||
<%= @bulletin.subtitle %>
|
||||
</li>
|
||||
<li>
|
||||
<b><%= t('announcement.text') %></b>
|
||||
<%= @bulletin.text_variable[I18n.locale] %>
|
||||
<%= @bulletin.text %>
|
||||
</li>
|
||||
<li>
|
||||
<li>
|
||||
|
|
|
@ -33,18 +33,18 @@
|
|||
</li>
|
||||
<li>
|
||||
<li>
|
||||
<b><%= t('announcement.link') %></b>
|
||||
<% @bulletin.bulletin_links.each do | blink | %>
|
||||
<%= link_to blink.name, blink.url, :target => '_blank' %>
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
<b><%= t('announcement.file') %></b>
|
||||
<% @bulletin.bulletin_files.each do | bfile | %>
|
||||
<%= link_to bfile.filetitle, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %>
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
<% if @bulletin.url? %>
|
||||
<b><%= t('announcement.url') %></b>
|
||||
<%= link_to @bulletin.url, @bulletin.url, :target => '_blank' %>
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
<b><%= t('announcement.張貼者') %></b>
|
||||
<%= User.find(@bulletin.create_user_id).name %>
|
||||
</li>
|
||||
|
|
|
@ -5,7 +5,9 @@ Rails.application.routes.draw do
|
|||
namespace :back_end do
|
||||
root :to => "bulletins#index"
|
||||
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
|
||||
namespace :front_end do
|
||||
root :to => "bulletins#index"
|
||||
|
|
Loading…
Reference in New Issue