* 'ntu' of https://github.com/Rulingcom/orbit:
  Fix deleting links and files in bulletin
  Add lost file for widget option
This commit is contained in:
Rueshyna 2013-01-02 10:10:53 +08:00
commit 3875e8e79e
6 changed files with 32 additions and 67 deletions

View File

@ -0,0 +1,13 @@
<% if (@module_app && @module_app.widget_options) %>
<%= label_tag('widget_options') %>
<% if @module_app.widget_options.has_key? @part.widget_path%>
<% @module_app.widget_options[@part.widget_path].each do |key,options| %>
<%= label_tag(t(@module_app.widget_options_fields_i18n[@part.widget_path][key]))%>
<%= select_tag "page_part[widget_options][#{key}]", options_for_select(options,(@part.widget_options[key] rescue nil)) %>
<!-- (@part[:widget_field][i][0] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) ) -->
<% end %>
<% end %>
<% end %>

View File

@ -207,31 +207,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# PUT /bulletins/1.xml
def update
if params[:bulletin_link]
@bulletin_link = BulletinLink.find(params[:id])
@link_url = panel_announcement_back_end_bulletin_path(@bulletin_link)
respond_to do |format|
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])
@ -362,10 +337,10 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
def clean_values
if params[:bulletin]
params[:bulletin][:bulletin_links_attributes].each_with_index do |link, index|
params[:bulletin][:bulletin_links_attributes].delete(index.to_s) if link[1]['url'].blank? and link[1]['title'].blank?
params[:bulletin][:bulletin_links_attributes].delete(index.to_s) if link[1]['url'].blank? and link[1]['title_translations'].blank?
end rescue nil
params[:bulletin][:bulletin_files_attributes].each_with_index do |link, index|
params[:bulletin][:bulletin_files_attributes].delete(index.to_s) if link[1]['file'].blank? and link[1]['title'].blank?
params[:bulletin][:bulletin_files_attributes].delete(index.to_s) if link[1]['file'].blank? and link[1]['title_translations'].blank?
end rescue nil
end
end

View File

@ -51,7 +51,7 @@ class Bulletin
validates :title, :at_least_one => true
before_save :check_deadline, :update_avliable_language, :clean_values
before_save :check_deadline, :update_avliable_language, :clean_values#, :save_bulletin_links, :save_bulletin_files
searchable do
text :titles do

View File

@ -253,39 +253,16 @@
<p><%= t("sys.limit_of_upload_file_size",:best_size => '3MB') %></p>
<p><%= t("sys.preview_only_for_img") %></p>
</div>
<div>
<table class="table table-condensed">
<thead>
<tr>
<th>File Name</th>
<th class="span2">Chinese</th>
<th class="span2">English</th>
<th class="span1"></th>
</tr>
</thead>
<tfoot>
<tr>
<td>File Name</td>
<td><input type="checkbox" id="optionsCheckbox" value="true" disabled /></td>
<td><input type="checkbox" id="optionsCheckbox" value="true" disabled checked /></td>
<td><a class="action" data-toggle="modal" href="#modal-link"><i class="icon-pencil"></i></a><a class="action" href=""><i class="icon-remove"></i></a></td>
</tr>
</tfoot>
<tbody id="messages">
</tbody>
</table>
</div>
</td>
</tr>
</tfoot>
<tbody>
<%# @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| %>
<%#= f.fields_for :bulletin_files do |f| %>
<%#= render :partial => 'form_bulletin_file', :object => bulletin_file, :locals => {:f => f, :i => i} %>
<%# end %>
<%# end %>
<%= f.fields_for :bulletin_files, bulletin_file do |f| %>
<%= render :partial => 'form_bulletin_file', :object => bulletin_file, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
</tbody>
</table>

View File

@ -66,7 +66,7 @@
<%= f.hidden_field :id %>
<%= hidden_field_tag :tr, (dom_id form_bulletin_file) %>
<a class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>
</span>

View File

@ -41,7 +41,7 @@
<%= f.hidden_field :id %>
<%= hidden_field_tag :tr, (dom_id form_bulletin_link) %>
<a class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>
</span>
</td>