Merge branch 'ntu' of https://github.com/Rulingcom/orbit into ntu
* '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:
commit
3875e8e79e
|
@ -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 %>
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -59,16 +59,16 @@
|
|||
|
||||
</td>
|
||||
<td>
|
||||
<span class="action">
|
||||
<% if form_bulletin_file.new_record? %>
|
||||
<a class="delete"><i class="icon-remove"></i></a>
|
||||
<% else %>
|
||||
<%= 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' %>
|
||||
<% end %>
|
||||
</span>
|
||||
<span class="action">
|
||||
<% if form_bulletin_file.new_record? %>
|
||||
<a class="delete"><i class="icon-remove"></i></a>
|
||||
<% else %>
|
||||
<%= 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 :_destroy, :value => nil, :class => 'should_destroy' %>
|
||||
<% end %>
|
||||
</span>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -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>
|
||||
|
|
Reference in New Issue