Skip to content

Commit

Permalink
Merge branch 'main' of github.com:avo-hq/avodocs
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianthedev committed Nov 20, 2023
2 parents 5a319d7 + 181fdfe commit 2329360
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 1 deletion.
78 changes: 78 additions & 0 deletions docs/2.0/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<VersionReq version="2.45" />
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`<br><br>
#### Possible values
`:default`, `:countless`
#### Default
`:default`


### `size`<br><br>
#### 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)
<br><br>

#### Countless

```ruby
self.pagination = -> do
{
type: :countless
}
end
```

![Countless pagination](/assets/img/resources/pagination/countless.png)
<br><br>

#### Countless and "pageless"
```ruby
self.pagination = -> do
{
type: :countless,
size: []
}
end
```
![Countless pagination size empty](/assets/img/resources/pagination/countless_empty_size.png)
:::
81 changes: 80 additions & 1 deletion docs/3.0/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -720,3 +721,81 @@ end
```

![Alt text](/assets/img/cards_on_resource.png)

:::option self.pagination
<VersionReq version="2.45" />
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`<br><br>
#### Possible values
`:default`, `:countless`
#### Default
`:default`


### `size`<br><br>
#### 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)
<br><br>

#### Countless

```ruby
self.pagination = -> do
{
type: :countless
}
end
```

![Countless pagination](/assets/img/resources/pagination/countless.png)
<br><br>

#### Countless and "pageless"
```ruby
self.pagination = -> do
{
type: :countless,
size: []
}
end
```
![Countless pagination size empty](/assets/img/resources/pagination/countless_empty_size.png)
:::
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2329360

Please sign in to comment.