Fix channel title update and display bug.
This commit is contained in:
parent
1ce77b43e1
commit
967f158612
|
@ -106,8 +106,8 @@ class Admin::FeedsController < OrbitAdminController
|
|||
@filter_fields = {}
|
||||
@filter_fields['feed.source'] = SiteFeed.all.pluck(:channel_title,:remote_site_url).collect do |a,b|
|
||||
tp = (a.blank? || a[I18n.locale].blank?) ? b.gsub(/http:\/\/|https:\/\//,'').gsub(/\./,'-') : a[I18n.locale]
|
||||
{:title => tp,:id => tp}
|
||||
end
|
||||
tp
|
||||
end.uniq.map{|tp| {:title => tp,:id => tp}}
|
||||
@filter_fields['feed.module_name'] = SiteFeed.all.map{|s| s.channel_key}.uniq.map do |key|
|
||||
{:title => I18n.t("module_name.#{key}"),:id => key}
|
||||
end
|
||||
|
@ -195,7 +195,7 @@ class Admin::FeedsController < OrbitAdminController
|
|||
site_feeds = SiteFeed.where(:remote_site_url => params["url"])
|
||||
site_feeds.each do |sf|
|
||||
sf.channel_title_translations = params["channel_title_translations"]
|
||||
sf.instance_variable_set(:@skip_callback)
|
||||
sf.instance_variable_set(:@skip_callback, true)
|
||||
sf.save
|
||||
sf.sync_data_to_annc
|
||||
end
|
||||
|
|
|
@ -4,35 +4,34 @@
|
|||
<div>
|
||||
<h3>Channel and feeds</h3>
|
||||
</div>
|
||||
<% in_use_locales = ([I18n.locale] + (I18n.available_locales - [I18n.locale])) %>
|
||||
<div class="accordion channel-accordion" id="feedAccordion">
|
||||
<% @school_urls.each_with_index do |url,index| %>
|
||||
<div class="accordion-group channel-accordion-group">
|
||||
<div class="accordion-heading channel-accordion-heading">
|
||||
<% first_record = @site_feeds[url].first %>
|
||||
<a class="accordion-toggle channel-accordion-toggle collapsed" data-toggle="collapse" data-parent="#feedAccordion" href="#channel_<%= index.to_s %>">
|
||||
<span class="channel-url"><%= url %></span>
|
||||
<% if !@site_feeds[url].first.channel_title.nil? && @site_feeds[url].first.channel_title != "" %>
|
||||
<span class="channel-source-name label"><%= @site_feeds[url].first.channel_title %></span>
|
||||
<% end %>
|
||||
<span class="channel-source-name label <%= 'hide' if first_record.channel_title.blank? %>">
|
||||
<%= first_record.channel_title %>
|
||||
</span>
|
||||
</a>
|
||||
<div class="dropdown channel-dropdown">
|
||||
<a class="channel-edit-form btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">Edit</a>
|
||||
<a class="channel-save-form btn btn-primary dropdown-toggle hide" data-toggle="dropdown" href="#">Save</a>
|
||||
<ul class="dropdown-menu channel-dropdown-menu" role="menu" aria-labelledby="dLabel">
|
||||
<form class="form-horizontal channel-form-horizontal" method="post" action="/admin/feeds/channel_title" data-remote="true">
|
||||
<form class="form-<%= first_record.id %> form-horizontal channel-form-horizontal" method="post" action="/admin/feeds/channel_title" data-remote="true">
|
||||
<h5>Source name</h5>
|
||||
<div class="control-group channel-control-group">
|
||||
<label class="control-label channel-label" for="inputEnglish">English</label>
|
||||
<div class="controls channel-controls">
|
||||
<input type="text" id="inputEnglish" placeholder="Source" name="channel_title_translations[en]">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group channel-control-group">
|
||||
<label class="control-label channel-label" for="inputChinese">Chinese</label>
|
||||
<div class="controls channel-controls">
|
||||
<input type="text" id="inputChinese" placeholder="Source" name="channel_title_translations[zh_tw]">
|
||||
</div>
|
||||
<input type="hidden" name="url" value="<%= url %>" >
|
||||
</div>
|
||||
<% channel_title_translations = first_record.channel_title_translations %>
|
||||
<% in_use_locales.each do |l| %>
|
||||
<div class="control-group channel-control-group">
|
||||
<label class="control-label channel-label" for="<%= first_record.id %>-input<%=l%>"><%=t(l)%></label>
|
||||
<div class="controls channel-controls">
|
||||
<input type="text" id="<%= first_record.id %>-input<%=l%>" placeholder="Source" name="channel_title_translations[<%=l%>]" value="<%=channel_title_translations[l]%>">
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<input type="hidden" name="url" value="<%= url %>">
|
||||
</form>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -70,6 +69,15 @@
|
|||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$('.channel-form-horizontal').bind('ajax:success', function(evt, data, status, xhr){
|
||||
var title = data['title'];
|
||||
var el = $(this).parents('.accordion-heading').find('.channel-source-name');
|
||||
if(title && title.length > 0){
|
||||
el.text(data["title"]).removeClass('hide');
|
||||
}else{
|
||||
el.text(data["title"]).addClass('hide');
|
||||
}
|
||||
})
|
||||
$(".disable-feed-btn").on("click",function(){
|
||||
var disable = null,
|
||||
el = $(this),
|
||||
|
|
Loading…
Reference in New Issue