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>
|
||||||
|
<td>
|
||||||
<%= f.fields_for :filetitle, (bulletin_file.new_record? ? bulletin_file.build_filetitle : bulletin_file.filetitle ) do |f| %>
|
<%= f.fields_for :filetitle, (bulletin_file.new_record? ? bulletin_file.build_filetitle : bulletin_file.filetitle ) do |f| %>
|
||||||
<% @site_valid_locales.each do |locale| %>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
<%= I18nVariable.from_locale(locale) %>
|
<div class="control-group">
|
||||||
<%= f.text_field locale %>
|
<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>
|
||||||
<%= f.label :file_description %>
|
<td>
|
||||||
<%#= f.text_field :description %>
|
|
||||||
<%= f.fields_for :description, (bulletin_file.new_record? ? bulletin_file.build_description : bulletin_file.description ) do |f| %>
|
<%= f.fields_for :description, (bulletin_file.new_record? ? bulletin_file.build_description : bulletin_file.description ) do |f| %>
|
||||||
<% @site_valid_locales.each do |locale| %>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
<%= I18nVariable.from_locale(locale) %>
|
<div class="control-group">
|
||||||
<%= f.text_field locale %>
|
<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>
|
||||||
<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">
|
|
||||||
|
|
||||||
<%= f.label :link_url %>
|
<td>
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
<%= f.text_field :url %>
|
<%= f.text_field :url %>
|
||||||
|
</div>
|
||||||
<%= f.label :link_name %>
|
</div>
|
||||||
<%#= f.text_field :name %>
|
</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, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %>
|
||||||
<% @site_valid_locales.each do |locale| %>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
|
<div class="control-group">
|
||||||
<%= f.text_field locale, :style => "width:130px" %>
|
<div class="controls">
|
||||||
|
<%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% 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/選擇檔案
|
||||||
|
@ -145,16 +146,37 @@
|
||||||
</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 %>
|
|
||||||
<a href="#" class="add"><%= t(:add) %></a>
|
|
||||||
</div>
|
</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| %>
|
<% @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| %>
|
||||||
|
@ -165,6 +187,11 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="main-wiget">
|
<div class="main-wiget">
|
||||||
|
@ -202,7 +229,7 @@
|
||||||
</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>
|
||||||
|
@ -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 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 %>
|
|
||||||
<a href="#" class="add"><%= t(:add) %></a>
|
|
||||||
</div>
|
</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">
|
||||||
|
<%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.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 => '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| %>
|
<% @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| %>
|
||||||
|
@ -230,8 +276,11 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br />
|
</tbody>
|
||||||
<br />
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -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,12 +17,10 @@
|
||||||
</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>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue