diff --git a/docs/2.0/resources.md b/docs/2.0/resources.md index cfff9c3e..4a1ea48e 100644 --- a/docs/2.0/resources.md +++ b/docs/2.0/resources.md @@ -567,3 +567,81 @@ end This tells Avo which resources you use and stops the eager-loading process on boot-time. This means that other resources that are not declared in this array will not show up in your app. + +:::option self.pagination + +This feature is designed for managing pagination. For example on large tables of data sometimes count is inefficient and unnecessary. + +By setting `self.pagination[:type]` to `:countless`, you can disable the pagination count on the index page. + +This is especially beneficial for large datasets, where displaying the total number of items and pages may have some performance impact. + +```ruby +# As block: +self.pagination = -> do + { + type: :default, + size: [1, 2, 2, 1], + } +end + +# Or as hash: +self.pagination = { + type: :default, + size: [1, 2, 2, 1], +} +``` + +The exposed pagination setting above have the default value for each key. + +### `type`

+ #### Possible values + `:default`, `:countless` + #### Default + `:default` + + +### `size`

+ #### Possible values + [Pagy docs - Control the page links](https://ddnexus.github.io/pagy/docs/how-to/#control-the-page-links) + #### Default + `[1, 2, 2, 1]` + +### Examples +#### Default +```ruby +self.pagination = -> do + { + type: :default, + size: [1, 2, 2, 1], + } +end +``` + +![Default pagination](/assets/img/resources/pagination/default.png) +

+ +#### Countless + +```ruby +self.pagination = -> do + { + type: :countless + } +end +``` + +![Countless pagination](/assets/img/resources/pagination/countless.png) +

+ +#### Countless and "pageless" +```ruby +self.pagination = -> do + { + type: :countless, + size: [] + } +end +``` +![Countless pagination size empty](/assets/img/resources/pagination/countless_empty_size.png) +::: diff --git a/docs/3.0/resources.md b/docs/3.0/resources.md index f4b678fd..4d9d7283 100644 --- a/docs/3.0/resources.md +++ b/docs/3.0/resources.md @@ -675,7 +675,8 @@ self.components = { This way you can choose the whatever namespace structure you want and you assure that the initializer is accepting the right arguments. -## Unscoped queries on `Index` +:::option self.index_query +### Unscoped queries on `Index` You might have a `default_scope` on your model that you don't want to be applied when you render the `Index` view. ```ruby{2} class Project < ApplicationRecord @@ -720,3 +721,81 @@ end ``` ![Alt text](/assets/img/cards_on_resource.png) + +:::option self.pagination + +This feature is designed for managing pagination. For example on large tables of data sometimes count is inefficient and unnecessary. + +By setting `self.pagination[:type]` to `:countless`, you can disable the pagination count on the index page. + +This is especially beneficial for large datasets, where displaying the total number of items and pages may have some performance impact. + +```ruby +# As block: +self.pagination = -> do + { + type: :default, + size: [1, 2, 2, 1], + } +end + +# Or as hash: +self.pagination = { + type: :default, + size: [1, 2, 2, 1], +} +``` + +The exposed pagination setting above have the default value for each key. + +### `type`

+ #### Possible values + `:default`, `:countless` + #### Default + `:default` + + +### `size`

+ #### Possible values + [Pagy docs - Control the page links](https://ddnexus.github.io/pagy/docs/how-to/#control-the-page-links) + #### Default + `[1, 2, 2, 1]` + +### Examples +#### Default +```ruby +self.pagination = -> do + { + type: :default, + size: [1, 2, 2, 1], + } +end +``` + +![Default pagination](/assets/img/resources/pagination/default.png) +

+ +#### Countless + +```ruby +self.pagination = -> do + { + type: :countless + } +end +``` + +![Countless pagination](/assets/img/resources/pagination/countless.png) +

+ +#### Countless and "pageless" +```ruby +self.pagination = -> do + { + type: :countless, + size: [] + } +end +``` +![Countless pagination size empty](/assets/img/resources/pagination/countless_empty_size.png) +::: diff --git a/docs/public/assets/img/resources/pagination/countless.png b/docs/public/assets/img/resources/pagination/countless.png new file mode 100644 index 00000000..aff40430 Binary files /dev/null and b/docs/public/assets/img/resources/pagination/countless.png differ diff --git a/docs/public/assets/img/resources/pagination/countless_empty_size.png b/docs/public/assets/img/resources/pagination/countless_empty_size.png new file mode 100644 index 00000000..95aeb10e Binary files /dev/null and b/docs/public/assets/img/resources/pagination/countless_empty_size.png differ diff --git a/docs/public/assets/img/resources/pagination/default.png b/docs/public/assets/img/resources/pagination/default.png new file mode 100644 index 00000000..5bece22c Binary files /dev/null and b/docs/public/assets/img/resources/pagination/default.png differ