fix announcement & links

This commit is contained in:
unknown 2012-03-23 18:04:11 +08:00
parent a755eb184b
commit 42519d9f78
40 changed files with 446 additions and 268 deletions

View File

@ -69,7 +69,6 @@
* limitations under the License. * limitations under the License.
* ========================================================= */ * ========================================================= */
!function( $ ){ !function( $ ){
"use strict" "use strict"
@ -130,6 +129,7 @@
var that = this var that = this
this.isShown = false this.isShown = false
//alert(this.isShown+":"+this.$element.attr('class'))
$('body').removeClass('modal-open') $('body').removeClass('modal-open')
@ -146,7 +146,6 @@
} }
/* MODAL PRIVATE METHODS /* MODAL PRIVATE METHODS
* ===================== */ * ===================== */

View File

@ -1,9 +1,9 @@
$('.bulletin_links_block a.remove_existing_record').live('click', function(){ $('.bulletin_links_block a.delete').live('click', function(){
//$(this).parents('.list_item').remove(); //$(this).parents('.list_item').remove();
$(this).parents('tr.list_item').remove(); $(this).parents('tr.list_item').remove();
}); });
$('.bulletin_files_block a.remove_existing_record').live('click', function(){ $('.bulletin_files_block a.delete').live('click', function(){
//$(this).parents('.list_item').remove(); //$(this).parents('.list_item').remove();
$(this).parents('tr.list_item').remove(); $(this).parents('tr.list_item').remove();
}); });
@ -11,5 +11,6 @@ $('.bulletin_files_block a.remove_existing_record').live('click', function(){
$('.action a.remove_existing_record').live('click', function(){ $('.action a.remove_existing_record').live('click', function(){
$(this).next('.should_destroy').attr('value', 1); $(this).next('.should_destroy').attr('value', 1);
//$("#bulletin_" + $(this).prev().attr('value')).hide(); //$("#bulletin_" + $(this).prev().attr('value')).hide();
$("tr#bulletin_" + $(this).prev().attr('value')).hide(); $("tr#bulletin_file_" + $(this).prev().attr('value')).hide();
$("tr#bulletin_link_" + $(this).prev().attr('value')).hide();
}); });

View File

@ -94,7 +94,7 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationCon
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 format.js
else else

View File

@ -0,0 +1,48 @@
class Panel::Announcement::BackEnd::BulletinFilesController < ApplicationController
layout 'new_admin'
def index
@bulletin_files = BulletinFile.all
respond_to do |format|
format.html # index.html.erb
# format.xml { render :xml => @bulletins }
format.js
end
end
# POST /bulletins
# POST /bulletins.xml
def create
@bulletin_file = BulletinFile.new(params[:bulletin_file])
respond_to do |format|
if @bulletin_file.save
format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js
else
format.html { render :action => "new" }
format.js { render action: "new" }
end
end
end
# PUT /bulletins/1
# PUT /bulletins/1.xml
def update
@bulletin_file = BulletinFile.find(params[:id])
respond_to do |format|
if @bulletin_file.update_attributes(params[:bulletin_file])
format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js
else
format.html { render :action => "edit" }
format.js { render :action => "edit" }
end
end
end
end

View File

@ -0,0 +1,49 @@
class Panel::Announcement::BackEnd::BulletinLinksController < ApplicationController
layout 'new_admin'
def index
@bulletin_links = BulletinLink.all
respond_to do |format|
format.html # index.html.erb
# format.xml { render :xml => @bulletins }
format.js
end
end
# POST /bulletins
# POST /bulletins.xml
def create
@bulletin_link = BulletinLink.new(params[:bulletin_link])
# @bulletin_link.bulletin_id = params[:bulletin_link][:bulletin_id]
respond_to do |format|
if @bulletin_link.save
format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js
else
format.html { render :action => "new" }
format.js { render action: "new" }
end
end
end
# PUT /bulletins/1
# PUT /bulletins/1.xml
def update
@bulletin_link = BulletinLink.find(params[:id])
respond_to do |format|
if @bulletin_link.update_attributes(params[:bulletin_link])
format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js
else
format.html { render :action => "edit" }
format.js { render :action => "edit" }
end
end
end
end

View File

@ -14,9 +14,15 @@ 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 @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.limit(1).desc("postdate")
@bulletin_categories = BulletinCategory.all @bulletin_categories = BulletinCategory.all
@bulletin_link = BulletinLink.new
@link_url = panel_announcement_back_end_bulletins_path
@bulletin_file = BulletinFile.new
@file_url = panel_announcement_back_end_bulletins_path
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
format.js format.js
@ -78,30 +84,58 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# POST /bulletins # POST /bulletins
# POST /bulletins.xml # POST /bulletins.xml
def create def create
@bulletin = Bulletin.new(params[:bulletin])
@bulletin.create_user_id = current_user.id if params[:bulletin_link]
@bulletin.update_user_id = current_user.id
@bulletin_link = BulletinLink.new(params[:bulletin_link])
respond_to do |format|
if @bulletin_link.save
format.js { render 'create_bulletin_link' }
end
end
elsif params[:bulletin_file]
@bulletin_file = BulletinFile.new(params[:bulletin_file])
respond_to do |format|
if @bulletin_file.save
format.js { render 'create_bulletin_file' }
end
end
else
@bulletin = Bulletin.new(params[:bulletin])
@bulletin.create_user_id = current_user.id
@bulletin.update_user_id = current_user.id
respond_to do |format|
if @bulletin.save
# format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('announcement.create_bulletin_success')) }
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) }
format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin }
format.js
else
format.html { render :action => "new" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
end
end
end
respond_to do |format|
if @bulletin.save
# format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('announcement.create_bulletin_success')) }
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) }
format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin }
else
format.html { render :action => "new" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
end
end
end end
def link_quick_add def link_quick_add
# debugger # debugger
@bulletin = Bulletin.find(params[:bulletin_id]) @bulletin_link = BulletinLink.new
@link_url = panel_announcement_back_end_bulletins_path @link_url = panel_announcement_back_end_bulletins_path
@bulletin_link.bulletin_id = params[:bulletin_id]
respond_to do |format| respond_to do |format|
format.js format.js
end end
@ -110,10 +144,39 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
def link_quick_edit def link_quick_edit
# debugger # debugger
@bulletin_link = BulletinLink.find(params[:bulletin_id])
@bulletin = Bulletin.find(params[:bulletin_id]) @link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
@link_url = panel_announcement_back_end_bulletin_path(@bulletin) # @bulletin = Bulletin.find(params[:bulletin_id])
# @link_url = panel_announcement_back_end_bulletin_path(@bulletin)
respond_to do |format|
format.js
end
end
def file_quick_add
# debugger
@bulletin_file = BulletinFile.new
@file_url = panel_announcement_back_end_bulletins_path
@bulletin_file.bulletin_id = params[:bulletin_id]
respond_to do |format|
format.js
end
end
def file_quick_edit
# debugger
@bulletin_file = BulletinFile.find(params[:bulletin_id])
@file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
respond_to do |format| respond_to do |format|
format.js format.js
@ -124,28 +187,61 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# PUT /bulletins/1 # PUT /bulletins/1
# PUT /bulletins/1.xml # PUT /bulletins/1.xml
def update def update
@bulletin = Bulletin.find(params[:id])
@bulletin.update_user_id = current_user.id if params[:bulletin_link]
# @bulletin.image.clear if params[:bulletin][:image_del] == '1' @bulletin_link = BulletinLink.find(params[:id])
# if params[:bulletin][:image_del] == '1'
# @bulletin.remove_image! @link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
# @bulletin.image_del = nil
# params[:bulletin][:image_del] = nil respond_to do |format|
# end if @bulletin_link.update_attributes(params[:bulletin_link])
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js { render 'update_bulletin_link' }
end
end
elsif params[:bulletin_file]
@bulletin_file = BulletinFile.find(params[:id])
@file_url = panel_announcement_back_end_bulletin_path(@bulletin_file)
respond_to do |format|
if @bulletin_file.update_attributes(params[:bulletin_file])
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js { render 'update_bulletin_file' }
end
end
else
@bulletin = Bulletin.find(params[:id])
@bulletin.update_user_id = current_user.id
# @bulletin.image.clear if params[:bulletin][:image_del] == '1'
# if params[:bulletin][:image_del] == '1'
# @bulletin.remove_image!
# @bulletin.image_del = nil
# params[:bulletin][:image_del] = nil
# end
respond_to do |format|
if @bulletin.update_attributes(params[:bulletin]) && @bulletin.save
# format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) }
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
format.js { render 'toggle_enable' }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
end
end
respond_to do |format|
if @bulletin.update_attributes(params[:bulletin]) && @bulletin.save
# format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) }
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
format.js { render 'toggle_enable' }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
end
end end
end end
# DELETE /bulletins/1 # DELETE /bulletins/1

View File

@ -23,14 +23,14 @@
</div> </div>
<div id="widget-title"> <div id="widget-title">
<%= f.label :display %> <%#= f.label :display %>
<%= f.radio_button :display, "List" %>List <%#= f.radio_button :display, "List" List%>
<%= f.radio_button :display, "Picture" %>Picture <%#= f.radio_button :display, "Picture" Picture%>
<br />顯示方式是設定在前台頁面時,資訊所呈現的樣式 <%# <br />顯示方式是設定在前台頁面時,資訊所呈現的樣式 %>
</div> </div>
<div class="form-actions"> <div class="form-actions">
<%= f.submit 'Submit/送出', :class=>'btn btn-primary' %> <%= f.submit t('submit'), :class=>'btn btn-primary' %>
</div> </div>
<% end %> <% end %>

View File

@ -1,13 +0,0 @@
<!-- <tr class="qe-block hide"> -->
<tr class="qe-block hide">
<td colspan="8">
<legend><%= t(:quick_edit) %></legend>
<%= form_for bulletin_category, :url => panel_announcement_back_end_bulletin_category_path(bulletin_category), :html => {:class => 'form-horizontal'} do |f| %>
<%= render :partial => "quick_edit_qe", :locals => { :f => f, :bulletin_category => bulletin_category } %>
<div class="form-actions">
<%= f.submit t(:submit), :class => 'btn btn-primary' %>
<%= f.submit t(:cancel), :class => 'btn', :type => 'reset' %>
</div>
<% end %>
</td>
</tr>

View File

@ -0,0 +1,51 @@
<% # encoding: utf-8 %>
<%= form_for(@bulletin_file, :remote => true, :url => @file_url) do |f| %>
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= (@bulletin_file.new_record? ? 'Add File' : 'Edit File') %></h3>
</div>
<div class="modal-body form-horizontal">
<div class="control-group">
<div class="controls">
<%= f.file_field :file %>
</div>
</div>
<%= f.fields_for :filetitle, (@bulletin_file.new_record? ? @bulletin_file.build_filetitle : @bulletin_file.filetitle ) do |f| %>
<% @site_valid_locales.each do |locale| %>
<div class="control-group">
<label for="file-<%= locale %>" class="control-label">Name <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls">
<%= f.text_field locale, :id => "file-#{locale}", :class => "input-xlarge" %>
</div>
</div>
<% end %>
<% end %>
<%= f.fields_for :description, (@bulletin_file.new_record? ? @bulletin_file.build_description : @bulletin_file.description ) do |f| %>
<% @site_valid_locales.each do |locale| %>
<div class="control-group">
<label for="file-<%= locale %>" class="control-label">Description <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls">
<%= f.text_field locale, :id => "file-#{locale}", :class => "input-xlarge" %>
</div>
</div>
<% end %>
<% end %>
</div>
<div class="modal-footer">
<%= hidden_field_tag 'bulletin_file[bulletin_id]', @bulletin_file.bulletin_id %>
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
</div>
<% end %>

View File

@ -1,17 +0,0 @@
<tr id="<%= "bulletin_#{bulletin_link2.id}" %>">
<td><%= link_to bulletin_link2.i18n_variable.zh_tw, bulletin_link2.url, :target => '_blank' %></td>
<td><%= link_to bulletin_link2.i18n_variable.en, bulletin_link2.url, :target => '_blank' %></td>
<td>
<a href="<%= panel_announcement_back_end_bulletin_link_quick_edit_path(bulletin_link2) %>#modal-link" data-toggle="modal" data-remote="true" class="action"><i class="icon-pencil"></i></a>
<span class="action">
<%= f.hidden_field :id %>
<a href class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
</span>
</td>
</tr>

View File

@ -1,39 +1,41 @@
<% # encoding: utf-8 %> <% # encoding: utf-8 %>
<%= form_for(@bulletin.bulletin_links, :remote => true, :url => @link_url) do |f| %> <%= form_for(@bulletin_link, :remote => true, :url => @link_url) do |f| %>
<div id="modal-link" class="modal hide fade">
<div class="modal-header"> <div class="modal-header">
<a class="close" data-dismiss="modal">×</a> <a class="close" data-dismiss="modal">×</a>
<h3>Add Link / Edit Link</h3> <h3><%= (@bulletin_link.new_record? ? 'Add Link' : 'Edit Link') %></h3>
</div> </div>
<div class="modal-body form-horizontal"> <div class="modal-body form-horizontal">
<div class="control-group"> <div class="control-group">
<label for="http" class="control-label">URL</label> <label for="http" class="control-label">URL</label>
<div class="controls"> <div class="controls">
<%= f.text_field :url %> <%= f.text_field :url %>
<span class="help-inline">Please correct the error</span>
</div> </div>
</div> </div>
<% @site_valid_locales.each do |locale| %> <%= f.fields_for :i18n_variable, (@bulletin_link.new_record? ? @bulletin_link.build_i18n_variable : @bulletin_link.i18n_variable) do |f| %>
<div class="control-group error"> <% @site_valid_locales.each do |locale| %>
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label> <div class="control-group">
<div class="controls"> <%= label_tag "link-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<input type="text" value="" id="link-<%= locale %>" class="input-xlarge"> <div class="controls">
<span class="help-inline">Please correct the error</span> <%#= f.text_field locale, :class => 'input-xxlarge' %>
<%= f.text_field locale %>
</div>
</div> </div>
</div> <% end %>
<% end %> <% end %>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<a class="btn btn-primary" href="#">Submit/確定</a> <%= hidden_field_tag 'bulletin_link[bulletin_id]', @bulletin_link.bulletin_id %>
<a class="btn" data-dismiss="modal" href="#">Cancel/取消</a> <%= f.submit t('submit'), :class=>'btn btn-primary' %>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
</div> </div>
</div>
<% end %> <% end %>

View File

@ -12,14 +12,6 @@
<%= label :is_checked_false, t('announcement.bulletin.fact_check_not_pass_reason') %> <%= label :is_checked_false, t('announcement.bulletin.fact_check_not_pass_reason') %>
<%= f.text_field :not_checked_reason %> <%= f.text_field :not_checked_reason %>
</div> </div>
<div class="field">
<%= f.label :image, t('announcement.image') %><br />
<%= f.file_field :image %>
<% if @bulletin.image.file %>
<%= check_box_tag 'bulletin[image_del]' %>
<%= t('announcement.刪除已上傳檔案') %>
<% end %>
</div>
<!--Widget start--> <!--Widget start-->
@ -200,7 +192,7 @@
<% @bulletin.bulletin_links.each_with_index do |bulletin_link, i| %> <% @bulletin.bulletin_links.each_with_index do |bulletin_link, i| %>
<%#= fields_for "bulletin[bulletin_links][]", bulletin_link do |f| %> <%#= fields_for "bulletin[bulletin_links][]", bulletin_link do |f| %>
<%= f.fields_for :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} %> <%= render :partial => 'form_bulletin_link', :object => bulletin_link, :locals => {:f => f, :i => i} %>
<% end %> <% end %>
<% end %> <% end %>
@ -246,7 +238,7 @@
<% @bulletin.bulletin_files.each_with_index do |bulletin_file, i| %> <% @bulletin.bulletin_files.each_with_index do |bulletin_file, i| %>
<%#= fields_for "bulletin[bulletin_files][]", bulletin_file do |f| %> <%#= fields_for "bulletin[bulletin_files][]", bulletin_file do |f| %>
<%= f.fields_for :bulletin_files, bulletin_file do |f| %> <%= f.fields_for :bulletin_files, bulletin_file do |f| %>
<%= render :partial => 'bulletin_file', :object => bulletin_file, :locals => {:f => f, :i => i} %> <%= render :partial => 'form_bulletin_file', :object => bulletin_file, :locals => {:f => f, :i => i} %>
<% end %> <% end %>
<% end %> <% end %>
@ -263,7 +255,8 @@
<!--Post End--> <!--Post End-->
<div class="form-actions"> <div class="form-actions">
<%= f.submit 'Submit/送出', :class=>'btn btn-primary' %> <%= f.submit t('submit'), :class=>'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div> </div>
</div> </div>
@ -277,13 +270,13 @@
var new_id = $(this).prev().attr('value'); var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_bulletin_links", "g"); var old_id = new RegExp("new_bulletin_links", "g");
$(this).prev().attr('value', parseInt(new_id) + 1); $(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'bulletin_link', f, :bulletin_links) %>").replace(old_id, new_id)); $(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_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");
$(this).prev().attr('value', parseInt(new_id) + 1); $(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id)); $(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id));
}); });
</script> </script>
<script type="text/javascript"> <script type="text/javascript">

View File

@ -1,5 +1,5 @@
<tr id="<%= "bulletin_#{bulletin_file.id}" if !bulletin_file.new_record? %>" class='list_item'> <tr id="<%= "bulletin_file_#{form_bulletin_file.id}" if !form_bulletin_file.new_record? %>" class='list_item'>
<td> <td>
<div class="control-group"> <div class="control-group">
<div class="controls"> <div class="controls">
@ -8,7 +8,7 @@
</div> </div>
</td> </td>
<td> <td>
<%= f.fields_for :filetitle, (bulletin_file.new_record? ? bulletin_file.build_filetitle : 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| %> <% @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>
@ -20,7 +20,7 @@
<% end %> <% end %>
</td> </td>
<td> <td>
<%= f.fields_for :description, (bulletin_file.new_record? ? bulletin_file.build_description : 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| %> <% @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>
@ -33,11 +33,11 @@
</td> </td>
<td> <td>
<span class="action"> <span class="action">
<% if bulletin_file.new_record? %> <% if form_bulletin_file.new_record? %>
<a href class="remove_existing_record"><i class="icon-remove"></i></a> <a class="delete"><i class="icon-remove"></i></a>
<% else %> <% else %>
<%= f.hidden_field :id %> <%= f.hidden_field :id %>
<a href class="remove_existing_record"><i class="icon-remove"></i></a> <a class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<% end %> <% end %>
</span> </span>

View File

@ -1,5 +1,5 @@
<tr id="<%= "bulletin_#{bulletin_link.id}" if !bulletin_link.new_record? %>" class='list_item'> <tr id="<%= "bulletin_link_#{form_bulletin_link.id}" if !form_bulletin_link.new_record? %>" class='list_item'>
<td> <td>
<div class="control-group"> <div class="control-group">
@ -9,7 +9,7 @@
</div> </div>
</td> </td>
<td> <td>
<%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : 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| %> <% @site_valid_locales.each do |locale| %>
<div class="control-group"> <div class="control-group">
<div class="controls"> <div class="controls">
@ -25,11 +25,11 @@
</td> </td>
<td> <td>
<span class="action"> <span class="action">
<% if bulletin_link.new_record? %> <% if form_bulletin_link.new_record? %>
<a href class="remove_existing_record"><i class="icon-remove"></i></a> <a class="delete"><i class="icon-remove"></i></a>
<% else %> <% else %>
<%= f.hidden_field :id %> <%= f.hidden_field :id %>
<a href class="remove_existing_record"><i class="icon-remove"></i></a> <a class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<% end %> <% end %>
</span> </span>

View File

@ -0,0 +1,21 @@
<tr id="<%= dom_id list_bulletin_file %>">
<td><%= list_bulletin_file.file.file ? ( link_to list_bulletin_file.filetitle.zh_tw, list_bulletin_file.file.url, {:target => '_blank', :title => list_bulletin_file.description.zh_tw} ) : list_bulletin_file.filetitle.zh_tw %></td>
<td><%= list_bulletin_file.file.file ? ( link_to list_bulletin_file.filetitle.en, list_bulletin_file.file.url, {:target => '_blank', :title => list_bulletin_file.description.en} ) : list_bulletin_file.filetitle.en %></td>
<td>
<a href="<%= panel_announcement_back_end_bulletin_file_quick_edit_path(list_bulletin_file) %>#modal-file" data-toggle="modal" data-remote="true" class="action"><i class="icon-pencil"></i></a>
<span class="action">
<%= fields_for "bulletin[bulletin_files_attributes][]", list_bulletin_file, :index => list_bulletin_file_counter do |f| %>
<%= f.hidden_field :id %>
<a href class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil , :class => 'should_destroy' %>
<% end %>
</span>
</td>
</tr>

View File

@ -0,0 +1,19 @@
<tr id="<%= dom_id list_bulletin_link %>">
<td><%= link_to list_bulletin_link.i18n_variable.zh_tw, list_bulletin_link.url, :target => '_blank' %></td>
<td><%= link_to list_bulletin_link.i18n_variable.en, list_bulletin_link.url, :target => '_blank' %></td>
<td>
<a href="<%= panel_announcement_back_end_bulletin_link_quick_edit_path(list_bulletin_link) %>#modal-link" data-toggle="modal" data-remote="true" class="action"><i class="icon-pencil"></i></a>
<span class="action">
<%= fields_for "bulletin[bulletin_links_attributes][]", list_bulletin_link, :index => list_bulletin_link_counter do |f| %>
<%= f.hidden_field :id %>
<a href class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil , :class => 'should_destroy' %>
<% end %>
</span>
</td>
</tr>

View File

@ -12,51 +12,15 @@
<tfoot> <tfoot>
<tr> <tr>
<td style="text-align:center" colspan="3"> <td style="text-align:center" colspan="3">
<a class="btn btn-primary btn-small" href="#modal-file" data-toggle="modal"><i class="icon-plus icon-white"></i> ADD/新增</a> <a class="btn btn-primary btn-small" href="<%= panel_announcement_back_end_bulletin_file_quick_add_path(bulletin) %>#modal-file" data-toggle="modal" data-remote="true"><i class="icon-plus icon-white"></i> <%= t('add')%></a>
</td> </td>
</tr> </tr>
</tfoot> </tfoot>
<tbody> <tbody>
<tr> <%= render :partial => 'list_bulletin_file', :collection => bulletin.bulletin_files %>
<td>…</td>
<td>…</td>
<td><a href="#modal-file" data-toggle="modal" class="action"><i class="icon-pencil"></i></a><a href class="action"><i class="icon-remove"></i></a></td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div id="modal-file" class="modal hide fade">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Add File / Edit File</h3>
</div>
<div class="modal-body form-horizontal">
<div class="controls file-upload">
<label class="control-label btn" for="input-upload">
Browse
<input id="input-upload" class="upload" type="file" name="upload" onchange="document.getElementById('fn').innerHTML = this.value;">
</label>
<span id='fn' class="file-name"></span>
</div>
<div class="control-group">
<label for="file-zh-tw" class="control-label">Chinese</label>
<div class="controls">
<input type="text" value="" id="file-zh-tw" class="input-xlarge">
<span class="help-inline">Please correct the error</span>
</div>
</div>
<div class="control-group">
<label for="file-en" class="control-label">English</label>
<div class="controls">
<input type="text" value="" id="file-en" class="input-xlarge">
<span class="help-inline">Please correct the error</span>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-primary" href="#">Submit/確定</a>
<a class="btn" data-dismiss="modal" href="#">Cancel/取消</a>
</div>
</div>
</div> </div>
</div> </div>

View File

@ -1,7 +1,7 @@
<div id="qe-link" class="qe-edit-div hide"> <div id="qe-link" class="qe-edit-div hide">
<div id="widget-link"> <div id="widget-link">
<div class="control-group"> <div class="control-group">
<table class="table table-condensed"> <table id="bulletin_links" class="table table-condensed">
<thead> <thead>
<tr> <tr>
<th>Chinese</th> <th>Chinese</th>
@ -12,49 +12,16 @@
<tfoot> <tfoot>
<tr> <tr>
<td style="text-align:center" colspan="3"> <td style="text-align:center" colspan="3">
<a class="btn btn-primary btn-small" href="#modal-link" data-toggle="modal"><i class="icon-plus icon-white"></i> ADD/新增</a> <a class="btn btn-primary btn-small" href="<%= panel_announcement_back_end_bulletin_link_quick_add_path(bulletin) %>#modal-link" data-toggle="modal" data-remote="true"><i class="icon-plus icon-white"></i> <%= t('add')%></a>
</td> </td>
</tr> </tr>
</tfoot> </tfoot>
<tbody> <tbody>
<% bulletin.bulletin_links.each_with_index do |bulletin_link2, i| %> <%= render :partial => 'list_bulletin_link', :collection => bulletin.bulletin_links %>
<%= f.fields_for :bulletin_links, bulletin_link2 do |f| %>
<%= render :partial => 'bulletin_link2', :object => bulletin_link2, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
</tbody> </tbody>
</table> </table>
</div> </div>
<div id="modal-link" class="modal hide fade">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Add Link / Edit Link</h3>
</div>
<div class="modal-body form-horizontal">
<div class="control-group">
<label for="http" class="control-label">URL</label>
<div class="controls">
<input type="text" value="" id="http" class="input-xlarge">
<span class="help-inline">Please correct the error</span>
</div>
</div>
<% @site_valid_locales.each do |locale| %>
<div class="control-group error">
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls">
<input type="text" value="" id="link-<%= locale %>" class="input-xlarge">
<span class="help-inline">Please correct the error</span>
</div>
</div>
<% end %>
</div>
<div class="modal-footer">
<a class="btn btn-primary" href="#">Submit/確定</a>
<a class="btn" data-dismiss="modal" href="#">Cancel/取消</a>
</div>
</div>
</div> </div>
</div> </div>

View File

@ -0,0 +1,2 @@
$("#modal-file").modal('hide');
$('<%= j render :partial => 'list_bulletin_file', :collection => [@bulletin_file] %>').appendTo('#bulletin_files').hide().fadeIn();

View File

@ -0,0 +1,2 @@
$("#modal-link").modal('hide');
$('<%= j render :partial => 'list_bulletin_link', :collection => [@bulletin_link] %>').appendTo('#bulletin_links').hide().fadeIn();

View File

@ -4,4 +4,4 @@
<%= render :partial => 'form', :locals => {:f => f} %> <%= render :partial => 'form', :locals => {:f => f} %>
<% end %> <% end %>
<%= link_back %> <%#= link_back %>

View File

@ -0,0 +1 @@
$("#modal-file").html("<%= j render "bulletin_file_qe" %>");

View File

@ -0,0 +1 @@
$("#modal-file").html("<%= j render "bulletin_file_qe" %>");

View File

@ -2,6 +2,19 @@
<table id="bulettin_sort_list" class="table main-list"> <table id="bulettin_sort_list" class="table main-list">
<%= render 'bulletins' %> <%= render 'bulletins' %>
</table> </table>
<div id="bulletin_link_qe">
<div id="modal-link" class="modal fade">
<%= render :partial => "bulletin_link_qe" %>
</div>
</div>
<div id="bulletin_file_qe">
<div id="modal-file" class="modal fade">
<%= render :partial => "bulletin_file_qe" %>
</div>
</div>
<div class="form-actions"> <div class="form-actions">
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %> <%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %>
</div> </div>

View File

@ -0,0 +1 @@
$("#modal-link").html("<%= j render "bulletin_link_qe" %>");

View File

@ -1,2 +1 @@
//$.each($(".quick_edit"),function(obj){ $(this).remove(); }); $("#modal-link").html("<%= j render "bulletin_link_qe" %>");
$("#<%= "bulletin_#{bulletin_link2.id}" %>").append("<%= j render "bulletin_link_qe" %>");

View File

@ -1,5 +1,5 @@
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletins_path do |f| %> <%= form_for @bulletin, :url => panel_announcement_back_end_bulletins_path, :html => {:class => 'clear'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %> <%= render :partial => 'form', :locals => {:f => f} %>
<% end %> <% end %>
<%= link_back %> <%#= link_back %>

View File

@ -0,0 +1,2 @@
$("#modal-file").modal('hide');
$("#<%= dom_id @bulletin_file %>").replaceWith("<%= j render :partial => 'list_bulletin_file', :collection => [@bulletin_file] %>");

View File

@ -0,0 +1,2 @@
$("#modal-link").modal('hide');
$("#<%= dom_id @bulletin_link %>").replaceWith("<%= j render :partial => 'list_bulletin_link', :collection => [@bulletin_link] %>");

View File

@ -10,10 +10,22 @@ Rails.application.routes.draw do
resources :bulletins do resources :bulletins do
match "link_quick_add/:bulletin_id" => "bulletins#link_quick_add" ,:as => :link_quick_add match "link_quick_add/:bulletin_id" => "bulletins#link_quick_add" ,:as => :link_quick_add
match "link_quick_edit/:bulletin_id" => "bulletins#link_quick_edit" ,:as => :link_quick_edit match "link_quick_edit/:bulletin_id" => "bulletins#link_quick_edit" ,:as => :link_quick_edit
match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add
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, :controller => 'bulletin_categorys' do
match "quick_edit/:bulletin_category_id" => "bulletin_categorys#quick_edit" ,:as => :quick_edit match "quick_edit/:bulletin_category_id" => "bulletin_categorys#quick_edit" ,:as => :quick_edit
end end
resources :bulletin_links, :controller => 'bulletin_links' do
match "link_quick_edit/:bulletin_link_id" => "bulletin_links#link_quick_edit" ,:as => :link_quick_edit
end
resources :bulletin_files, :controller => 'bulletin_files' do
match "file_quick_edit/:bulletin_file_id" => "bulletin_files#file_quick_edit" ,:as => :file_quick_edit
end
resources :tags resources :tags
end end
namespace :front_end do namespace :front_end do

View File

@ -23,7 +23,8 @@
<div class="form-actions"> <div class="form-actions">
<%= f.submit 'Submit/送出', :class=>'btn btn-primary' %> <%= f.submit t('submit'), :class=>'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div> </div>
</div> </div>

View File

@ -1,7 +1,7 @@
<h1><%= t('page_content.editing_page_content') %></h1> <h1><%= t('page_content.editing_page_content') %></h1>
<%= form_for @page_context, :url => panel_page_content_back_end_page_context_path(@page_context) do |f| %> <%= form_for @page_context, :url => panel_page_content_back_end_page_context_path(@page_context), :html => {:class => 'clear'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %> <%= render :partial => 'form', :locals => {:f => f} %>
<% end %> <% end %>

View File

@ -36,19 +36,6 @@ class Panel::WebResource::BackEnd::WebLinkCategorysController < ApplicationContr
end end
end end
def quick_edit
# debugger
@web_link_category = WebLinkCategory.find(params[:web_link_category_id])
@url = panel_web_resource_back_end_web_link_category_path(@web_link_category)
respond_to do |format|
format.js
end
end
# GET /web_links/1/edit # GET /web_links/1/edit
def edit def edit
@web_link_category = WebLinkCategory.find(params[:id]) @web_link_category = WebLinkCategory.find(params[:id])

View File

@ -64,7 +64,7 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController
respond_to do |format| respond_to do |format|
if @web_link.save if @web_link.save
format.html { redirect_to(panel_web_resource_back_end_web_links_url, :notice => t('web_resource.create_web_resource_success')) } format.html { redirect_to(panel_web_resource_back_end_web_links_url) }
format.xml { render :xml => @web_link, :status => :created, :location => @web_link } format.xml { render :xml => @web_link, :status => :created, :location => @web_link }
else else
format.html { render :action => "new" } format.html { render :action => "new" }
@ -84,7 +84,7 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController
respond_to do |format| respond_to do |format|
if @web_link.update_attributes(params[:web_link]) if @web_link.update_attributes(params[:web_link])
format.html { redirect_to(panel_web_resource_back_end_web_links_url, :notice => t('web_resource.update_web_resource_success')) } format.html { redirect_to(panel_web_resource_back_end_web_links_url) }
format.js { render 'toggle_enable' } format.js { render 'toggle_enable' }
format.xml { head :ok } format.xml { head :ok }
else else

View File

@ -6,7 +6,7 @@
<div class="quick-edit"> <div class="quick-edit">
<ul class="nav nav-pills hide"> <ul class="nav nav-pills hide">
<li><%= link_to t('web_link_category.edit'), edit_panel_web_resource_back_end_web_link_category_path(web_link_category), :remote => true %></li> <li><%= link_to t('web_link_category.edit'), edit_panel_web_resource_back_end_web_link_category_path(web_link_category), :remote => true %></li>
<li><%= link_to t('web_link_category.delete'), panel_web_resource_back_end_web_link_category_quick_edit_path(web_link_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li> <li><%= link_to t('web_link_category.delete'), panel_web_resource_back_end_web_link_category_path(web_link_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
</ul> </ul>
</div> </div>
</td> </td>

View File

@ -25,12 +25,12 @@
<a class="action"><i title="Setting" class="icon-cog icon-white tip"></i></a> <a class="action"><i title="Setting" class="icon-cog icon-white tip"></i></a>
</div> </div>
<h3 class="widget-title"><i class="icons-tag icons-white"></i>Tags</h3> <h3 class="widget-title"><i class="icons-tag icons-white"></i>Tags</h3>
<div class="widget-content clear form-horizontal"> <div class="widget-content clear form-horizontal">
<% @tags.each do |tag| %> <% @tags.each do |tag| %>
<%= check_box_tag 'web_link[tag_ids][]', tag.id, @web_link.tag_ids.include?(tag.id)%> <%= check_box_tag 'web_link[tag_ids][]', tag.id, @web_link.tag_ids.include?(tag.id)%>
<%= tag[I18n.locale] %> <%= tag[I18n.locale] %>
<% end %> <% end %>
</div> </div>
</div> </div>
</div> </div>
@ -90,12 +90,15 @@
<% end %> <% end %>
</div> </div>
</div>
<!--Post End-->
<div class="form-actions">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
</div> </div>
<!--Post End-->
<div class="form-actions">
<%= f.submit 'Submit/送出', :class=>'btn btn-primary' %>
</div>

View File

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

View File

@ -1,16 +1,5 @@
<br />
<br />
<br />
<br />
<h1><%= t('web_resource.editing_web_resource') %></h1> <h1><%= t('web_resource.editing_web_resource') %></h1>
<%= form_for @web_link, :url => panel_web_resource_back_end_web_link_path(@web_link) do |f| %> <%= form_for @web_link, :url => panel_web_resource_back_end_web_link_path(@web_link), :html => {:class => 'clear'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %> <%= render :partial => 'form', :locals => {:f => f} %>
<% end %> <% end %>
<%= link_back %>
<br />
<br />
<br />
<br />

View File

@ -1,24 +1,9 @@
<br />
<br />
<br />
<br />
<% content_for :secondary do %>
<ul class="list">
<li><%= link_to t('web_link.index'), panel_web_resource_back_end_web_links_path, :class => 'seclink2' %></li>
</ul>
<% end -%>
<%= flash_messages %> <%= flash_messages %>
<h1><%= t('web_link.new_web_resource') %></h1> <h1><%= t('web_link.new_web_resource') %></h1>
<%= form_for @web_link, :url => panel_web_resource_back_end_web_links_path do |f| %> <%= form_for @web_link, :url => panel_web_resource_back_end_web_links_path, :html => {:class => 'clear'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %> <%= render :partial => 'form', :locals => {:f => f} %>
<% end %> <% end %>
<%= link_back %> <%#= link_back %>
<br />
<br />
<br />

View File

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