fix: current_page metadata
This commit is contained in:
parent
aa991b3cd3
commit
fbb642e13d
6 changed files with 30 additions and 0 deletions
|
@ -2,6 +2,7 @@ class Api::V1::Accounts::ArticlesController < Api::V1::Accounts::BaseController
|
|||
before_action :portal
|
||||
before_action :check_authorization
|
||||
before_action :fetch_article, except: [:index, :create]
|
||||
before_action :set_current_page, only: [:index]
|
||||
|
||||
def index
|
||||
@articles = @portal.articles
|
||||
|
@ -49,4 +50,8 @@ class Api::V1::Accounts::ArticlesController < Api::V1::Accounts::BaseController
|
|||
:category_slug, :locale, :query, :page
|
||||
)
|
||||
end
|
||||
|
||||
def set_current_page
|
||||
@current_page = params[:page] || 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ class Api::V1::Accounts::CategoriesController < Api::V1::Accounts::BaseControlle
|
|||
before_action :portal
|
||||
before_action :check_authorization
|
||||
before_action :fetch_category, except: [:index, :create]
|
||||
before_action :set_current_page, only: [:index]
|
||||
|
||||
def index
|
||||
@categories = @portal.categories.search(params)
|
||||
|
@ -49,4 +50,8 @@ class Api::V1::Accounts::CategoriesController < Api::V1::Accounts::BaseControlle
|
|||
:name, :description, :position, :slug, :locale, :parent_category_id, :associated_category_id
|
||||
)
|
||||
end
|
||||
|
||||
def set_current_page
|
||||
@current_page = params[:page] || 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@ class Api::V1::Accounts::PortalsController < Api::V1::Accounts::BaseController
|
|||
|
||||
before_action :fetch_portal, except: [:index, :create]
|
||||
before_action :check_authorization
|
||||
before_action :set_current_page, only: [:index]
|
||||
|
||||
def index
|
||||
@portals = Current.account.portals
|
||||
|
@ -66,4 +67,8 @@ class Api::V1::Accounts::PortalsController < Api::V1::Accounts::BaseController
|
|||
def portal_member_params
|
||||
params.require(:portal).permit(:account_id, member_ids: [])
|
||||
end
|
||||
|
||||
def set_current_page
|
||||
@current_page = params[:page] || 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
json.payload do
|
||||
json.array! @articles, partial: 'article', as: :article
|
||||
end
|
||||
|
||||
json.meta do
|
||||
json.current_page @current_page
|
||||
json.articles_count @articles.size
|
||||
end
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
json.payload do
|
||||
json.array! @categories, partial: 'category', as: :category
|
||||
end
|
||||
|
||||
json.meta do
|
||||
json.current_page @current_page
|
||||
json.categories_count @categories.size
|
||||
end
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
json.payload do
|
||||
json.array! @portals, partial: 'portal', as: :portal
|
||||
end
|
||||
|
||||
json.meta do
|
||||
json.current_page @current_page
|
||||
json.portals_count @portals.size
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue