add paginator for announcements page
This commit is contained in:
parent
bba15315c4
commit
7a113e94bd
|
@ -86,14 +86,18 @@ class Admin::FeedsController < OrbitAdminController
|
||||||
@filter_fields['feed.module_name'] = SiteFeed.all.map{|s| s.channel_key}.uniq.map do |key|
|
@filter_fields['feed.module_name'] = SiteFeed.all.map{|s| s.channel_key}.uniq.map do |key|
|
||||||
{:title => I18n.t("module_name.#{key}"),:id => key}
|
{:title => I18n.t("module_name.#{key}"),:id => key}
|
||||||
end
|
end
|
||||||
|
@max_content_count = 100
|
||||||
|
@page_no = params[:page].to_i
|
||||||
|
@page_no = 1 if @page_no==0
|
||||||
|
@skip_count = (@page_no-1)*@max_content_count
|
||||||
@module_name = params[:filters][:module_name].to_a rescue []
|
@module_name = params[:filters][:module_name].to_a rescue []
|
||||||
@module_name = SiteFeed.all.map{|s| s.channel_key}.uniq if @module_name == []
|
@module_name = SiteFeed.all.map{|s| s.channel_key}.uniq if @module_name == []
|
||||||
@all_feed_annc = SiteFeedAnnc.where(:channel_key.in => @module_name).order(created_at: 1).to_a rescue []
|
@all_feed_annc = SiteFeedAnnc.where(:channel_key.in => @module_name).order(created_at: 1).to_a rescue []
|
||||||
@source = params[:filters][:source] rescue []
|
@source = params[:filters][:source] rescue []
|
||||||
@keywords = params[:keywords] rescue nil
|
@keywords = params[:keywords] rescue nil
|
||||||
if request.xhr?
|
if request.xhr?
|
||||||
render :partial => "announcements"
|
render :partial => "announcements"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def get_category_list
|
def get_category_list
|
||||||
app_key = params[:channel]
|
app_key = params[:channel]
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<% data_count = 0
|
||||||
|
total_count = 0
|
||||||
|
%>
|
||||||
<% @all_feed_annc.each do |feed_annc| %>
|
<% @all_feed_annc.each do |feed_annc| %>
|
||||||
<% feed_name = available_locales.collect{|v| feed_annc[:feed_name][v]}.join(' / ') %>
|
<% feed_name = available_locales.collect{|v| feed_annc[:feed_name][v]}.join(' / ') %>
|
||||||
<% if @source.blank? || (@source.include?(feed_annc.channel_title) rescue false) || @source.include?(feed_annc.remote_site_url.to_s.gsub(/http:\/\/|https:\/\//,'').gsub(/\./,'-')) %>
|
<% if @source.blank? || (@source.include?(feed_annc.channel_title) rescue false) || @source.include?(feed_annc.remote_site_url.to_s.gsub(/http:\/\/|https:\/\//,'').gsub(/\./,'-')) %>
|
||||||
|
@ -16,35 +19,39 @@
|
||||||
<% annc_title = available_locales.collect{|v| annc['title_translations'][v]}.join('/') %>
|
<% annc_title = available_locales.collect{|v| annc['title_translations'][v]}.join('/') %>
|
||||||
<% annc_tags = annc['tags'].collect{|tmp| available_locales.collect{|v| tmp['name_translations'][v]}.join(' / ')} %>
|
<% annc_tags = annc['tags'].collect{|tmp| available_locales.collect{|v| tmp['name_translations'][v]}.join(' / ')} %>
|
||||||
<% if @keywords.blank? || search_all_words(Nokogiri.HTML(annc_title).text()+' '+feed_name+' '+annc_tags.join(' '),@keywords) %>
|
<% if @keywords.blank? || search_all_words(Nokogiri.HTML(annc_title).text()+' '+feed_name+' '+annc_tags.join(' '),@keywords) %>
|
||||||
<tr data-annc-feed-id='<%= feed_annc.id.to_s %>' data-annc-uid='<%= annc['id'].to_s %>'>
|
<% if total_count >= @skip_count && data_count < @max_content_count %>
|
||||||
<td>
|
<% data_count += 1 %>
|
||||||
<span class="channel-source-name label"><%= (feed_annc.channel_title.include?("translation missing") || feed_annc.channel_title.blank?) ? t("feed.source") : feed_annc.channel_title %></span>
|
<tr data-annc-feed-id='<%= feed_annc.id.to_s %>' data-annc-uid='<%= annc['id'].to_s %>'>
|
||||||
<br>
|
<td>
|
||||||
<%= feed_name %>
|
<span class="channel-source-name label"><%= (feed_annc.channel_title.include?("translation missing") || feed_annc.channel_title.blank?) ? t("feed.source") : feed_annc.channel_title %></span>
|
||||||
</td>
|
<br>
|
||||||
<td>
|
<%= feed_name %>
|
||||||
<ul>
|
</td>
|
||||||
<li>
|
<td>
|
||||||
<a class='annc_title'><%= annc_title.html_safe %></a>
|
<ul>
|
||||||
</li>
|
<li>
|
||||||
<li style="display: flex;width: 100%;flex-wrap: wrap;">
|
<a class='annc_title'><%= annc_title.html_safe %></a>
|
||||||
<%= check_box_tag nil,nil,feed_annc[:top_list].include?(annc['id']),'class' => 'is_top' %>
|
</li>
|
||||||
<%= check_box_tag nil,nil,feed_annc[:hot_list].include?(annc['id']),'class' => 'is_hot' %>
|
<li style="display: flex;width: 100%;flex-wrap: wrap;">
|
||||||
</li>
|
<%= check_box_tag nil,nil,feed_annc[:top_list].include?(annc['id']),'class' => 'is_top' %>
|
||||||
</ul>
|
<%= check_box_tag nil,nil,feed_annc[:hot_list].include?(annc['id']),'class' => 'is_hot' %>
|
||||||
</td>
|
</li>
|
||||||
<td>
|
</ul>
|
||||||
<%= annc_tags.join('<br>').html_safe %>
|
</td>
|
||||||
</td>
|
<td>
|
||||||
<td>
|
<%= annc_tags.join('<br>').html_safe %>
|
||||||
<% display_flag = feed_annc[:hidden_annc].count==0 || feed_annc[:hidden_annc].exclude?(annc['id']) ? true : false %>
|
</td>
|
||||||
<% if display_flag %>
|
<td>
|
||||||
<button class='btn-info hidden_btn'><%= t('is_hidden') %></button>
|
<% display_flag = feed_annc[:hidden_annc].count==0 || feed_annc[:hidden_annc].exclude?(annc['id']) ? true : false %>
|
||||||
<% else %>
|
<% if display_flag %>
|
||||||
<button class='btn-primary display_btn'><%= t('feed.display') %></button>
|
<button class='btn-info hidden_btn'><%= t('is_hidden') %></button>
|
||||||
<% end %>
|
<% else %>
|
||||||
</td>
|
<button class='btn-primary display_btn'><%= t('feed.display') %></button>
|
||||||
</tr>
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% total_count += 1 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -61,4 +68,9 @@
|
||||||
process_annc(this)
|
process_annc(this)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
<%=
|
||||||
|
content_tag :div, class: "bottomnav clearfix" do
|
||||||
|
content_tag(:div, paginate(Kaminari.paginate_array([]).page(1).per(1),total_pages: (total_count/@max_content_count.to_f).ceil,current_page: @page_no), class: "pagination pagination-centered")
|
||||||
|
end
|
||||||
|
%>
|
|
@ -8,6 +8,9 @@
|
||||||
a{
|
a{
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
#main-wrap {
|
||||||
|
margin-bottom: 5em;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
|
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
|
||||||
<script src="/assets/feeds/bootstrap-toggle.min.js"></script>
|
<script src="/assets/feeds/bootstrap-toggle.min.js"></script>
|
||||||
|
|
Loading…
Reference in New Issue