fix announcement & add lang tab

This commit is contained in:
unknown 2012-04-05 14:48:31 +08:00 committed by Christophe Vilayphiou
parent 1259d62249
commit d45725cf3b
12 changed files with 164 additions and 137 deletions

Binary file not shown.

Binary file not shown.

View File

@ -13,7 +13,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# @bulletins = Bulletin.search(params[:search], params[:category_id]) # @bulletins = Bulletin.search(params[:search], params[:category_id])
# @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]]) # @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]])
@bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all.desc("postdate").page(params[:page]).per(10) @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all
@bulletin_categories = BulletinCategory.all @bulletin_categories = BulletinCategory.all
@bulletin_link = BulletinLink.new @bulletin_link = BulletinLink.new

View File

@ -16,6 +16,15 @@ class BulletinFile
belongs_to :bulletin belongs_to :bulletin
# embedded_in :bulletin # embedded_in :bulletin
before_save :set_key
def filetitle
@filetitle ||= I18nVariable.first(:conditions => {:key => 'filetitle', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
end
def description
@description ||= I18nVariable.first(:conditions => {:key => 'description', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
end
protected protected

View File

@ -5,7 +5,6 @@
<div class="quick-edit"> <div class="quick-edit">
<ul class="nav nav-pills hide"> <ul class="nav nav-pills hide">
<li><%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %></li> <li><%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %></li>
<li><%= link_to t('bulletin_category.quick_edit'), panel_announcement_back_end_bulletin_category_quick_edit_path(bulletin_category), :remote => true %></li>
<li><%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li> <li><%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
</ul> </ul>
</div> </div>

View File

@ -1,3 +0,0 @@
$.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

@ -134,58 +134,45 @@
<%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %> <%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %>
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#chinese">Chinese</a></li> <% @site_valid_locales.each_with_index do |locale, i| %>
<li><a data-toggle="tab" href="#english">English</a></li> <li <%= ( i == 0 ) ? " class='active'" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div id="chinese" class="tab-pane active">
<div class="title"> <% @site_valid_locales.each_with_index do |locale, i| %>
<input type="text" placeholder="輸入標題" class="post-title">
</div> <div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
</div>
<div id="english" class="tab-pane">
<div class="title">
<input type="text" placeholder="Enter title here" class="post-title">
</div>
<div class="editor"></div>
<div class="editor"></div>
</div>
</div>
<div class="title"> <div class="title">
<%= f.label :title %> <%= f.label :title %>
<%= f.fields_for :title, (@bulletin.new_record? ? @bulletin.build_title : @bulletin.title ) do |f| %> <%= f.fields_for :title, (@bulletin.new_record? ? @bulletin.build_title : @bulletin.title ) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td>
<%= I18nVariable.from_locale(locale) %> <%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title' %> <%= f.text_field locale, :class=>'post-title' %>
</td>
<% end %>
<% end %> <% end %>
</div> </div>
<div class="editor"> <div class="title">
<%= f.label :subtitle %> <%= f.label :subtitle %>
<%= f.fields_for :subtitle, (@bulletin.new_record? ? @bulletin.build_subtitle : @bulletin.subtitle ) do |f| %> <%= f.fields_for :subtitle, (@bulletin.new_record? ? @bulletin.build_subtitle : @bulletin.subtitle ) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td>
<%= I18nVariable.from_locale(locale) %> <%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %> <%= f.text_area locale, :style=>"width:100%" %>
</td>
<% end %>
<% end %> <% end %>
</div> </div>
<div class="editor"> <div class="title">
<%= f.label :text %> <%= f.label :text %>
<%= f.fields_for :text, (@bulletin.new_record? ? @bulletin.build_text : @bulletin.text ) do |f| %> <%= f.fields_for :text, (@bulletin.new_record? ? @bulletin.build_text : @bulletin.text ) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td>
<%= I18nVariable.from_locale(locale) %> <%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %> <%= f.text_area locale, :style=>"width:100%" %>
</td>
<% end %> <% end %>
</div>
</div>
<% end %> <% end %>
</div> </div>
<div class="main-wiget"> <div class="main-wiget">
@ -202,11 +189,7 @@
<thead> <thead>
<tr> <tr>
<th>URL</th> <th>URL</th>
<% @site_valid_locales.each do |locale| %> <th>Name</th>
<div class="control-group">
<th>Name - <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></th>
</div>
<% end %>
<th class="span1"></th> <th class="span1"></th>
</tr> </tr>
</thead> </thead>

View File

@ -8,8 +8,14 @@
</div> </div>
</td> </td>
<td> <td>
<div class="tab-content">
<% @site_valid_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<%= f.fields_for :filetitle, (form_bulletin_file.new_record? ? form_bulletin_file.build_filetitle : form_bulletin_file.filetitle ) do |f| %> <%= f.fields_for :filetitle, (form_bulletin_file.new_record? ? form_bulletin_file.build_filetitle : form_bulletin_file.filetitle ) do |f| %>
<% @site_valid_locales.each do |locale| %>
<div class="control-group"> <div class="control-group">
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label> <label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls"> <div class="controls">
@ -17,11 +23,23 @@
</div> </div>
</div> </div>
<% end %> <% end %>
</div>
<% end %> <% end %>
</div>
</td> </td>
<td> <td>
<div class="tab-content">
<% @site_valid_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<%= f.fields_for :description, (form_bulletin_file.new_record? ? form_bulletin_file.build_description : form_bulletin_file.description ) do |f| %> <%= f.fields_for :description, (form_bulletin_file.new_record? ? form_bulletin_file.build_description : form_bulletin_file.description ) do |f| %>
<% @site_valid_locales.each do |locale| %>
<div class="control-group"> <div class="control-group">
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label> <label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls"> <div class="controls">
@ -29,7 +47,13 @@
</div> </div>
</div> </div>
<% end %> <% end %>
</div>
<% end %> <% end %>
</div>
</td> </td>
<td> <td>
<span class="action"> <span class="action">

View File

@ -9,18 +9,28 @@
</div> </div>
</td> </td>
<td> <td>
<div class="tab-content">
<% @site_valid_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<%= f.fields_for :i18n_variable, (form_bulletin_link.new_record? ? form_bulletin_link.build_i18n_variable : form_bulletin_link.i18n_variable) do |f| %> <%= f.fields_for :i18n_variable, (form_bulletin_link.new_record? ? form_bulletin_link.build_i18n_variable : form_bulletin_link.i18n_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<div class="control-group"> <div class="control-group">
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls"> <div class="controls">
<%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %> <%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %>
</div> </div>
</div> </div>
</td> <% end %>
<td>
</div>
<% end %> <% end %>
<% end %>
</div>
</td> </td>
<td> <td>

View File

@ -17,9 +17,7 @@ Rails.application.routes.draw do
match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit
end end
resources :bulletin_categorys, :controller => 'bulletin_categorys' do resources :bulletin_categorys
match "quick_edit/:bulletin_category_id" => "bulletin_categorys#quick_edit" ,:as => :quick_edit
end
resources :bulletin_links, :controller => 'bulletin_links' do resources :bulletin_links, :controller => 'bulletin_links' do
match "link_quick_edit/:bulletin_link_id" => "bulletin_links#link_quick_edit" ,:as => :link_quick_edit match "link_quick_edit/:bulletin_link_id" => "bulletin_links#link_quick_edit" ,:as => :link_quick_edit

View File

@ -9,16 +9,30 @@
<%= @page_context.page.i18n_variable[I18n.locale] %> <%= @page_context.page.i18n_variable[I18n.locale] %>
</div> </div>
<ul class="nav nav-tabs">
<% @site_valid_locales.each_with_index do |locale, i| %>
<li <%= ( i == 0 ) ? " class='active'" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul>
<div class="tab-content">
<% @site_valid_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<div class="title"> <div class="title">
<%= f.label :context %> <%= f.label :context %>
<%= f.fields_for :context, (@page_context.new_record? ? @page_context.build_context : @page_context.context ) do |f| %> <%= f.fields_for :context, (@page_context.new_record? ? @page_context.build_context : @page_context.context ) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td>
<%= I18nVariable.from_locale(locale) %> <%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %> <%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %>
</td>
<% end %> <% end %>
</div>
</div>
<% end %> <% end %>
</div> </div>

View File

@ -45,49 +45,42 @@
<%= f.label :category %> <%= f.label :category %>
<%= f.select :web_link_category_id, @web_link_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ]} %> <%= f.select :web_link_category_id, @web_link_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ]} %>
<div class="btn-group pull-right"> <ul class="nav nav-tabs">
<a class="btn dropdown-toggle" href="#" data-toggle="dropdown"> <% @site_valid_locales.each_with_index do |locale, i| %>
English <li <%= ( i == 0 ) ? " class='active'" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<span class="caret"></span> <% end %>
</a>
<ul class="dropdown-menu">
<li><a href="#">English</a></li>
<li><a href="#">Chinese</a></li>
<li><a href="#">Japanese</a></li>
<li><a href="#">French</a></li>
<li><a href="#">German</a></li>
<!--<li class="divider"></li>
<li><a href="#">Separated link</a></li>-->
</ul> </ul>
</div>
<div class="tab-content">
<% @site_valid_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<div class="title"> <div class="title">
<%= f.label :name %> <%= f.label :name %>
<%= f.fields_for :name, (@web_link.new_record? ? @web_link.build_name : @web_link.name ) do |f| %> <%= f.fields_for :name, (@web_link.new_record? ? @web_link.build_name : @web_link.name ) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td>
<%= I18nVariable.from_locale(locale) %> <%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title' %> <%= f.text_field locale, :class=>'post-title' %>
</td>
<% end %> <% end %>
<% end %>
</div>
<div class="title">
<%= f.label :url %>
<%= f.text_field :url %>
</div> </div>
<div class="title"> <div class="title">
<%= f.label :describe %> <%= f.label :describe %>
<%= f.fields_for :context, (@web_link.new_record? ? @web_link.build_context : @web_link.context ) do |f| %> <%= f.fields_for :context, (@web_link.new_record? ? @web_link.build_context : @web_link.context ) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td>
<%= I18nVariable.from_locale(locale) %> <%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%" %> <%= f.text_area locale, :style=>"width:100%" %>
</td>
<% end %> <% end %>
</div>
</div>
<% end %> <% end %>
</div>
<div class="title">
<%= f.label :url %>
<%= f.text_field :url %>
</div> </div>
</div> </div>