fix announcement link & files

This commit is contained in:
unknown 2012-03-16 15:53:57 +08:00
parent 00ab773942
commit 7d553acaec
10 changed files with 200 additions and 112 deletions

View File

@ -1,13 +1,15 @@
$('.bulletin_links_block a.delete').live('click', function(){
$(this).parents('.list_item').remove();
$('.bulletin_links_block a.remove_existing_record').live('click', function(){
//$(this).parents('.list_item').remove();
$(this).parents('tr.list_item').remove();
});
$('.bulletin_files_block a.delete').live('click', function(){
$(this).parents('.list_item').remove();
$('.bulletin_files_block a.remove_existing_record').live('click', function(){
//$(this).parents('.list_item').remove();
$(this).parents('tr.list_item').remove();
});
$('.action a.remove_existing_record').live('click', function(){
$(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();
});

View File

@ -13,7 +13,7 @@
<% end -%>
<%= content_tag :li, :class => active_for_controllers('users') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), panel_web_resource_back_end_web_links_path %>
<%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), admin_users_path %>
<% end -%>
<%= content_tag :li, :class => active_for_controllers('page_contexts') do -%>

View File

@ -0,0 +1,14 @@
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

View File

@ -15,7 +15,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
# @bulletins = Bulletin.search(params[:search], params[:category_id])
# @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
respond_to do |format|

View File

@ -1,36 +1,47 @@
<div id="<%= "bulletin_#{bulletin_file.id}" if !bulletin_file.new_record? %>" class='list_item'>
<div class="field">
<%= f.label :file %>
<%#= file_field_tag 'bulletin[file]' %>
<tr id="<%= "bulletin_#{bulletin_file.id}" if !bulletin_file.new_record? %>" class='list_item'>
<td>
<div class="control-group">
<div class="controls">
<%= f.file_field :file %>
<%= f.label :file_title %>
<%#= f.text_field :filetitle %>
</div>
</div>
</td>
<td>
<%= f.fields_for :filetitle, (bulletin_file.new_record? ? bulletin_file.build_filetitle : bulletin_file.filetitle ) do |f| %>
<% @site_valid_locales.each do |locale| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale %>
<div class="control-group">
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls">
<%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %>
</div>
</div>
<% end %>
<% end %>
<%= f.label :file_description %>
<%#= f.text_field :description %>
</td>
<td>
<%= f.fields_for :description, (bulletin_file.new_record? ? bulletin_file.build_description : bulletin_file.description ) do |f| %>
<% @site_valid_locales.each do |locale| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale %>
<div class="control-group">
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls">
<%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %>
</div>
</div>
<% end %>
<% end %>
</td>
<td>
<span class="action">
<% if bulletin_file.new_record? %>
<a href="#" class="delete"><%= t(:delete) %></a>
<a href class="remove_existing_record"><i class="icon-remove"></i></a>
<% else %>
<%= f.hidden_field :id %>
<a href="#" class="remove_existing_record"><%= t(:delete) %></a>
<a href class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>
</span>
</div>
</div>
</td>
</tr>

View File

@ -1,27 +1,37 @@
<div id="<%= "bulletin_#{bulletin_link.id}" if !bulletin_link.new_record? %>" class='list_item'>
<div class="field">
<tr id="<%= "bulletin_#{bulletin_link.id}" if !bulletin_link.new_record? %>" class='list_item'>
<%= f.label :link_url %>
<td>
<div class="control-group">
<div class="controls">
<%= f.text_field :url %>
<%= f.label :link_name %>
<%#= f.text_field :name %>
</div>
</div>
</td>
<td>
<%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= f.text_field locale, :style => "width:130px" %>
<div class="control-group">
<div class="controls">
<%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %>
</div>
</div>
</td>
<td>
<% end %>
<% end %>
</td>
<td>
<span class="action">
<% if bulletin_link.new_record? %>
<a href="#" class="delete"><%= t(:delete) %></a>
<a href class="remove_existing_record"><i class="icon-remove"></i></a>
<% else %>
<%= f.hidden_field :id %>
<a href="#" class="remove_existing_record"><%= t(:delete) %></a>
<a href class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>
</span>
</div>
</div>
</td>
</tr>

View File

@ -13,7 +13,8 @@
<h3 class="widget-title"><i class="icons-picture icons-white"></i>Picture</h3>
<div class="widget-content clear">
<div class="control-group">
<img class="pull-left upload-picture" src="images/default-img.png" />
<img class="pull-left upload-picture" src="/assets/default-img.png" />
<div class="controls file-upload">
<label class="control-label btn" for="input-upload">
Browse/選擇檔案
@ -145,16 +146,37 @@
</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 class="main-wiget">
<div id="widget-link" class="widget-box">
<div class="widget-action clear">
<a class="action"><i title="Add a reference link" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-link icons-white"></i>Link</h3>
<div class="widget-content">
<table class="table table-condensed">
<thead>
<tr>
<th>URL</th>
<% @site_valid_locales.each do |locale| %>
<div class="control-group">
<th>Name - <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></th>
<% end %>
<th class="span1"></th>
</tr>
</thead>
<tfoot>
<tr>
<td style="text-align:center" colspan="4">
<div id='add_bulletin_link' class="info_input bulletin_links_block">
<%= hidden_field_tag 'bulletin_link_field_count', @bulletin.bulletin_links.count %>
<a class="add"><span class="btn btn-primary btn-small"><i class="icon-plus icon-white"></i> ADD/新增</span></a>
</div>
</td>
</tr>
</tfoot>
<tbody>
<%#= render :partial => 'link', :locals => { :bulletin_links => @bulletin.bulletin_links , :f => f} %>
<div id='bulletin_links' class="bulletin_links_block">
<% @bulletin.bulletin_links.each_with_index do |bulletin_link, i| %>
<%#= fields_for "bulletin[bulletin_links][]", bulletin_link do |f| %>
@ -165,6 +187,11 @@
</div>
</tbody>
</table>
</div>
</div>
</div>
<div class="main-wiget">
@ -202,7 +229,7 @@
</table>
</div>
<div id="bulletin_link_qe"><%= render :partial => "bulletin_link_qe" %></div>
<div id="bulletin_link_qe"><%#= render :partial => "bulletin_link_qe" %></div>
</div>
</div>
@ -210,16 +237,35 @@
<div id='bulletin_files' class="bulletin_files_block <%= @class %>">
<div class="main-wiget">
<div id="widget-file" class="widget-box">
<div class="widget-action clear">
<a class="action"><i title="Added to the file" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-paperclip icons-white"></i>File</h3>
<div class="widget-content">
<table class="table table-condensed">
<thead>
<tr>
<th>File</th>
<th>Name</th>
<th><%= t('description') %></th>
<th class="span1"></th>
</tr>
</thead>
<tfoot>
<tr>
<td style="text-align:center" colspan="4">
<div id='add_bulletin_file' class="info_input bulletin_files_block">
<h2>Bulletin files</h2>
<%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.count %>
<a href="#" class="add"><%= t(:add) %></a>
<a class="add"><span class="btn btn-primary btn-small"><i class="icon-plus icon-white"></i> ADD/新增</span></a>
</div>
</td>
</tr>
</tfoot>
<tbody>
<%#= render :partial => 'file', :locals => { :bulletin_files => @bulletin.bulletin_files , :f => f} %>
<div id='bulletin_files' class="bulletin_files_block">
<% @bulletin.bulletin_files.each_with_index do |bulletin_file, i| %>
<%#= fields_for "bulletin[bulletin_files][]", bulletin_file do |f| %>
@ -230,8 +276,11 @@
</div>
<br />
<br />
</tbody>
</table>
</div>
</div>
</div>
</div>
@ -252,13 +301,13 @@
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));
$(this).parents('table').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");
$(this).prev().attr('value', parseInt(new_id) + 1);
$('#bulletin_files').append(("<%= escape_javascript(add_attribute 'bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id));
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id));
});
</script>
<script type="text/javascript">

View File

@ -17,12 +17,10 @@
</tr>
</tfoot>
<tbody>
<% bulletin.bulletin_links.each_with_index do |blink, i| %>
<tr>
<td><%= link_to blink.i18n_variable.zh_tw, blink.url, :target => '_blank' %></td>
<td><%= link_to blink.i18n_variable.en, blink.url, :target => '_blank' %></td>
<td><a href="#modal-link" data-toggle="modal" class="action"><i class="icon-pencil"></i></a><a href class="action"><i class="icon-remove"></i></a></td>
</tr>
<% bulletin.bulletin_links.each_with_index do |bulletin_link2, i| %>
<%= f.fields_for :bulletin_links, bulletin_link2 do |f| %>
<%= render :partial => 'bulletin_link2', :object => bulletin_link2, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
</tbody>
</table>

View File

@ -7,3 +7,6 @@
<%= 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>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "bulletin_form" %>
<% end %>

View File

@ -10,6 +10,7 @@ Rails.application.routes.draw do
resources :bulletin_categorys, :controller => 'bulletin_categorys' do
match "quick_edit/:bulletin_category_id" => "bulletin_categorys#quick_edit" ,:as => :quick_edit
end
resources :bulletin_links
resources :tags
end
namespace :front_end do