fix announcement link & files
This commit is contained in:
parent
00ab773942
commit
7d553acaec
|
@ -1,13 +1,15 @@
|
||||||
$('.bulletin_links_block a.delete').live('click', function(){
|
$('.bulletin_links_block a.remove_existing_record').live('click', function(){
|
||||||
$(this).parents('.list_item').remove();
|
//$(this).parents('.list_item').remove();
|
||||||
|
$(this).parents('tr.list_item').remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.bulletin_files_block a.delete').live('click', function(){
|
$('.bulletin_files_block a.remove_existing_record').live('click', function(){
|
||||||
$(this).parents('.list_item').remove();
|
//$(this).parents('.list_item').remove();
|
||||||
|
$(this).parents('tr.list_item').remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.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_" + $(this).prev().attr('value')).hide();
|
||||||
});
|
});
|
|
@ -13,7 +13,7 @@
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<%= content_tag :li, :class => active_for_controllers('users') do -%>
|
<%= 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 -%>
|
<% end -%>
|
||||||
|
|
||||||
<%= content_tag :li, :class => active_for_controllers('page_contexts') do -%>
|
<%= content_tag :li, :class => active_for_controllers('page_contexts') do -%>
|
||||||
|
|
|
@ -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
|
|
@ -15,7 +15,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
|
||||||
|
|
||||||
# @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
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
|
@ -1,36 +1,47 @@
|
||||||
|
|
||||||
<div id="<%= "bulletin_#{bulletin_file.id}" if !bulletin_file.new_record? %>" class='list_item'>
|
<tr id="<%= "bulletin_#{bulletin_file.id}" if !bulletin_file.new_record? %>" class='list_item'>
|
||||||
<div class="field">
|
<td>
|
||||||
<%= f.label :file %>
|
<div class="control-group">
|
||||||
<%#= file_field_tag 'bulletin[file]' %>
|
<div class="controls">
|
||||||
<%= f.file_field :file %>
|
<%= f.file_field :file %>
|
||||||
|
</div>
|
||||||
<%= f.label :file_title %>
|
</div>
|
||||||
<%#= f.text_field :filetitle %>
|
</td>
|
||||||
<%= f.fields_for :filetitle, (bulletin_file.new_record? ? bulletin_file.build_filetitle : bulletin_file.filetitle ) do |f| %>
|
<td>
|
||||||
<% @site_valid_locales.each do |locale| %>
|
<%= f.fields_for :filetitle, (bulletin_file.new_record? ? bulletin_file.build_filetitle : bulletin_file.filetitle ) do |f| %>
|
||||||
<%= I18nVariable.from_locale(locale) %>
|
<% @site_valid_locales.each do |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 %>
|
<% end %>
|
||||||
<% end %>
|
</td>
|
||||||
|
<td>
|
||||||
<%= f.label :file_description %>
|
<%= f.fields_for :description, (bulletin_file.new_record? ? bulletin_file.build_description : bulletin_file.description ) do |f| %>
|
||||||
<%#= f.text_field :description %>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
<%= f.fields_for :description, (bulletin_file.new_record? ? bulletin_file.build_description : bulletin_file.description ) do |f| %>
|
<div class="control-group">
|
||||||
<% @site_valid_locales.each do |locale| %>
|
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
|
||||||
<%= I18nVariable.from_locale(locale) %>
|
<div class="controls">
|
||||||
<%= f.text_field locale %>
|
<%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
</td>
|
||||||
|
<td>
|
||||||
<span class="action">
|
<span class="action">
|
||||||
<% if bulletin_file.new_record? %>
|
<% 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 %>
|
<% else %>
|
||||||
<%= f.hidden_field :id %>
|
<%= 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' %>
|
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
|
||||||
</div>
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,37 @@
|
||||||
|
|
||||||
<div id="<%= "bulletin_#{bulletin_link.id}" if !bulletin_link.new_record? %>" class='list_item'>
|
<tr id="<%= "bulletin_#{bulletin_link.id}" if !bulletin_link.new_record? %>" class='list_item'>
|
||||||
<div class="field">
|
|
||||||
|
<td>
|
||||||
<%= f.label :link_url %>
|
<div class="control-group">
|
||||||
<%= f.text_field :url %>
|
<div class="controls">
|
||||||
|
<%= f.text_field :url %>
|
||||||
<%= f.label :link_name %>
|
</div>
|
||||||
<%#= f.text_field :name %>
|
</div>
|
||||||
<%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %>
|
</td>
|
||||||
<% @site_valid_locales.each do |locale| %>
|
<td>
|
||||||
<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
|
<%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %>
|
||||||
<%= f.text_field locale, :style => "width:130px" %>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
<% end %>
|
<div class="control-group">
|
||||||
<% end %>
|
<div class="controls">
|
||||||
|
<%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
<span class="action">
|
<span class="action">
|
||||||
<% if bulletin_link.new_record? %>
|
<% 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 %>
|
<% else %>
|
||||||
<%= f.hidden_field :id %>
|
<%= 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' %>
|
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</td>
|
||||||
</div>
|
</tr>
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
<h3 class="widget-title"><i class="icons-picture icons-white"></i>Picture</h3>
|
<h3 class="widget-title"><i class="icons-picture icons-white"></i>Picture</h3>
|
||||||
<div class="widget-content clear">
|
<div class="widget-content clear">
|
||||||
<div class="control-group">
|
<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">
|
<div class="controls file-upload">
|
||||||
<label class="control-label btn" for="input-upload">
|
<label class="control-label btn" for="input-upload">
|
||||||
Browse/選擇檔案
|
Browse/選擇檔案
|
||||||
|
@ -144,27 +145,53 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div id='bulletin_links' class="bulletin_links_block <%= @class %>">
|
<div class="main-wiget">
|
||||||
|
<div id="widget-link" class="widget-box">
|
||||||
<div id='add_bulletin_link' class="info_input bulletin_links_block">
|
<div class="widget-action clear">
|
||||||
<h2>Bulletin links</h2>
|
<a class="action"><i title="Add a reference link" class="icon-exclamation-sign icon-white tip"></i></a>
|
||||||
<%= hidden_field_tag 'bulletin_link_field_count', @bulletin.bulletin_links.count %>
|
</div>
|
||||||
<a href="#" class="add"><%= t(:add) %></a>
|
<h3 class="widget-title"><i class="icons-link icons-white"></i>Link</h3>
|
||||||
</div>
|
<div class="widget-content">
|
||||||
|
<table class="table table-condensed">
|
||||||
<%#= render :partial => 'link', :locals => { :bulletin_links => @bulletin.bulletin_links , :f => f} %>
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>URL</th>
|
||||||
<% @bulletin.bulletin_links.each_with_index do |bulletin_link, i| %>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
<%#= fields_for "bulletin[bulletin_links][]", bulletin_link do |f| %>
|
<div class="control-group">
|
||||||
<%= f.fields_for :bulletin_links, bulletin_link do |f| %>
|
<th>Name - <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></th>
|
||||||
<%= render :partial => 'bulletin_link', :object => bulletin_link, :locals => {:f => f, :i => i} %>
|
<% end %>
|
||||||
<% end %>
|
<th class="span1"></th>
|
||||||
<% end %>
|
</tr>
|
||||||
|
</thead>
|
||||||
</div>
|
<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>
|
||||||
|
|
||||||
|
<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| %>
|
||||||
|
<%= f.fields_for :bulletin_links, bulletin_link do |f| %>
|
||||||
|
<%= render :partial => 'bulletin_link', :object => bulletin_link, :locals => {:f => f, :i => i} %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="main-wiget">
|
<div class="main-wiget">
|
||||||
|
@ -202,38 +229,60 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div id='bulletin_files' class="bulletin_files_block <%= @class %>">
|
<div class="main-wiget">
|
||||||
|
<div id="widget-file" class="widget-box">
|
||||||
<div id='add_bulletin_file' class="info_input bulletin_files_block">
|
<div class="widget-action clear">
|
||||||
<h2>Bulletin files</h2>
|
<a class="action"><i title="Added to the file" class="icon-exclamation-sign icon-white tip"></i></a>
|
||||||
<%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.count %>
|
</div>
|
||||||
<a href="#" class="add"><%= t(:add) %></a>
|
<h3 class="widget-title"><i class="icons-paperclip icons-white"></i>File</h3>
|
||||||
</div>
|
<div class="widget-content">
|
||||||
|
<table class="table table-condensed">
|
||||||
<%#= render :partial => 'file', :locals => { :bulletin_files => @bulletin.bulletin_files , :f => f} %>
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>File</th>
|
||||||
<% @bulletin.bulletin_files.each_with_index do |bulletin_file, i| %>
|
<th>Name</th>
|
||||||
<%#= fields_for "bulletin[bulletin_files][]", bulletin_file do |f| %>
|
<th><%= t('description') %></th>
|
||||||
<%= f.fields_for :bulletin_files, bulletin_file do |f| %>
|
<th class="span1"></th>
|
||||||
<%= render :partial => 'bulletin_file', :object => bulletin_file, :locals => {:f => f, :i => i} %>
|
</tr>
|
||||||
<% end %>
|
</thead>
|
||||||
<% end %>
|
<tfoot>
|
||||||
|
<tr>
|
||||||
</div>
|
<td style="text-align:center" colspan="4">
|
||||||
|
<div id='add_bulletin_file' class="info_input bulletin_files_block">
|
||||||
<br />
|
<%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.count %>
|
||||||
<br />
|
<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>
|
||||||
|
|
||||||
|
<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| %>
|
||||||
|
<%= f.fields_for :bulletin_files, bulletin_file do |f| %>
|
||||||
|
<%= render :partial => 'bulletin_file', :object => bulletin_file, :locals => {:f => f, :i => i} %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--Post End-->
|
<!--Post End-->
|
||||||
|
|
||||||
|
@ -252,13 +301,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);
|
||||||
$('#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(){
|
$('#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);
|
||||||
$('#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>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
|
@ -17,13 +17,11 @@
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% bulletin.bulletin_links.each_with_index do |blink, i| %>
|
<% bulletin.bulletin_links.each_with_index do |bulletin_link2, i| %>
|
||||||
<tr>
|
<%= f.fields_for :bulletin_links, bulletin_link2 do |f| %>
|
||||||
<td><%= link_to blink.i18n_variable.zh_tw, blink.url, :target => '_blank' %></td>
|
<%= render :partial => 'bulletin_link2', :object => bulletin_link2, :locals => {:f => f, :i => i} %>
|
||||||
<td><%= link_to blink.i18n_variable.en, blink.url, :target => '_blank' %></td>
|
<% end %>
|
||||||
<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>
|
<% end %>
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -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' %>
|
<%= 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>
|
||||||
|
|
||||||
|
<% content_for :page_specific_javascript do %>
|
||||||
|
<%= javascript_include_tag "bulletin_form" %>
|
||||||
|
<% end %>
|
|
@ -10,6 +10,7 @@ Rails.application.routes.draw do
|
||||||
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
|
||||||
resources :tags
|
resources :tags
|
||||||
end
|
end
|
||||||
namespace :front_end do
|
namespace :front_end do
|
||||||
|
|
Reference in New Issue