feat: Backend changes for article and categories ordering (#6655)

This commit is contained in:
Tejaswini Chile
2023-03-13 17:39:07 +05:30
committed by GitHub
parent 2e95d3a173
commit 8f4d4798c2
13 changed files with 37 additions and 18 deletions

View File

@@ -4,6 +4,7 @@ json.title article.title
json.content article.content
json.description article.description
json.status article.status
json.position article.position
json.account_id article.account_id
json.last_updated_at article.updated_at

View File

@@ -6,7 +6,7 @@
</a>
</h3>
<span class="text-slate-500">
<%= render 'public/api/v1/portals/article_count', article_count: category.articles.published.size %>
<%= render 'public/api/v1/portals/article_count', article_count: category.articles.published.order(position: :asc).size %>
</span>
</div>
<div class="py-4 w-full mt-2 flex-grow">
@@ -15,7 +15,7 @@
<p class="text-sm text-slate-500"><%= I18n.t('public_portal.common.no_articles') %></p>
</div>
<% else %>
<% category.articles.published.take(5).each do |article| %>
<% category.articles.published.order(position: :asc).take(5).each do |article| %>
<a
class="text-slate-800 hover:underline leading-8"
href="/hc/<%= portal.slug %>/<%= category.locale %>/<%= category.slug %>/<%= article.id %>"

View File

@@ -7,7 +7,7 @@
</a>
</h3>
<span class="text-slate-500">
<%= render 'public/api/v1/portals/article_count', article_count: category.articles.published.size %>
<%= render 'public/api/v1/portals/article_count', article_count: category.articles.published.order(position: :asc).size %>
</span>
</div>
<div class="py-4 w-full mt-2 flex-grow">
@@ -16,7 +16,7 @@
<p class="text-sm text-slate-500"><%= I18n.t('public_portal.common.no_articles') %></p>
</div>
<% else %>
<% category.articles.published.take(5).each do |article| %>
<% category.articles.published.order(position: :asc).take(5).each do |article| %>
<div class="flex justify-between content-center h-8 my-1">
<a
class="text-slate-800 hover:underline leading-8"

View File

@@ -1,7 +1,7 @@
<%= render "public/api/v1/portals/hero", portal: @portal %>
<div class="max-w-5xl w-full flex-grow mx-auto py-8 px-4">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-x-32 gap-y-0 lg:gap-y-12">
<% @portal.categories.where(locale: @locale).joins(:articles).where(articles:{ status: :published }).group('categories.id').each do |category| %>
<% @portal.categories.where(locale: @locale).joins(:articles).where(articles:{ status: :published }).order(position: :asc).group('categories.id').each do |category| %>
<%= render "public/api/v1/portals/category-block", category: category, portal: @portal %>
<% end %>
</div>