diff --git a/app/controllers/api/v1/accounts/articles_controller.rb b/app/controllers/api/v1/accounts/articles_controller.rb index efe761501..f687c80f9 100644 --- a/app/controllers/api/v1/accounts/articles_controller.rb +++ b/app/controllers/api/v1/accounts/articles_controller.rb @@ -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 diff --git a/app/controllers/api/v1/accounts/categories_controller.rb b/app/controllers/api/v1/accounts/categories_controller.rb index c4491b2e2..bc18b61b8 100644 --- a/app/controllers/api/v1/accounts/categories_controller.rb +++ b/app/controllers/api/v1/accounts/categories_controller.rb @@ -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 diff --git a/app/controllers/api/v1/accounts/portals_controller.rb b/app/controllers/api/v1/accounts/portals_controller.rb index b081978b9..f994f6722 100644 --- a/app/controllers/api/v1/accounts/portals_controller.rb +++ b/app/controllers/api/v1/accounts/portals_controller.rb @@ -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 diff --git a/app/views/api/v1/accounts/articles/index.json.jbuilder b/app/views/api/v1/accounts/articles/index.json.jbuilder index 3e3364007..89634e32a 100644 --- a/app/views/api/v1/accounts/articles/index.json.jbuilder +++ b/app/views/api/v1/accounts/articles/index.json.jbuilder @@ -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 diff --git a/app/views/api/v1/accounts/categories/index.json.jbuilder b/app/views/api/v1/accounts/categories/index.json.jbuilder index 89fa05200..f73995c2c 100644 --- a/app/views/api/v1/accounts/categories/index.json.jbuilder +++ b/app/views/api/v1/accounts/categories/index.json.jbuilder @@ -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 diff --git a/app/views/api/v1/accounts/portals/index.json.jbuilder b/app/views/api/v1/accounts/portals/index.json.jbuilder index 3e4553382..2fb93d918 100644 --- a/app/views/api/v1/accounts/portals/index.json.jbuilder +++ b/app/views/api/v1/accounts/portals/index.json.jbuilder @@ -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