Skip to content

Commit

Permalink
Merge branch 'main' of github.com:avo-hq/docs.avohq.io
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianthedev committed Nov 19, 2024
2 parents 1ae4b6e + e74db0d commit 4c810ec
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 10 deletions.
29 changes: 19 additions & 10 deletions docs/3.0/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -736,20 +736,29 @@ Here's an example of how you can define actions dividers:

```ruby
def actions
action Avo::Actions::ToggleInactive
action Avo::Actions::ToggleAdmin
divider
action Avo::Actions::Sub::DummyAction
action Avo::Actions::DownloadFile
divider
action Avo::Actions::Test::NoConfirmationRedirect
action Avo::Actions::Test::CloseModal
end
action Avo::Actions::ToggleInactive
action Avo::Actions::ToggleAdmin
divider
action Avo::Actions::Sub::DummyAction
action Avo::Actions::DownloadFile
divider
action Avo::Actions::Test::NoConfirmationRedirect
action Avo::Actions::Test::CloseModal
end
```
<Image src="/assets/img/action_divider.png" width="306" height="325" alt="" />

<Option name="`label`">
You can pass a `label` option to display that text

The `label` option can be used to display specific text on dividers, enhancing usability by adding context to each section.

```ruby
def actions
action Avo::Actions::ToggleAdmin
divider label: "New section"
action Avo::Actions::Sub::DummyAction
end
```
</Option>

## Icon
Expand Down
4 changes: 4 additions & 0 deletions docs/3.0/customizable-controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ end

Within the `list` block, the only permitted elements are `link_to` and `action`. For both `link_to` and `action`, you can include an optional `icon` parameter.

:::info
<VersionReq version="3.14.1" /> [`divider`](actions.html#divider) is also permitted within the `list` block.
:::

In addition to the `icon`, the `link_to` element can accept additional parameters such as `target: :_blank` or `rel: "noopener"`, or any other extra arguments you may want to provide for the link. These extra arguments help define specific behaviors for the link, like opening it in a new tab or ensuring security best practices are followed.

</Option>
Expand Down
23 changes: 23 additions & 0 deletions docs/3.0/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -567,3 +567,26 @@ end

<Image src="/assets/img/3_0/customization/click-row-to-view-record.gif" width="" height="" alt="Click to view record in Avo" />
</Option>

## Associations lookup list limit

<Option name="`associations_lookup_list_limit`">

<VersionReq version="3.14.1" />

By default, there is a limit of a 1000 records per query when listing the association options. This limit ensures that the page will not crash due to large collections.
Use `associations_lookup_list_limit` configuration to change the limit value.

```ruby{3}
# config/initializers/avo.rb
Avo.configure do |config|
config.associations_lookup_list_limit = 1000
end
```

The message `There are more records available.` is shown when the limit is reached. To localize the message you can use `I18n.translate("avo.more_records_available")`.

Using [searchable](./associations/belongs_to.html#searchable) is recommended for listing unlimited records with better performance and user experience.

<Image src="/assets/img/customization/associations-lookup-list-limit.png" width="2466" height="1098" alt="Associations lookup list limit configuration" />
</Option>
62 changes: 62 additions & 0 deletions docs/3.0/fields/radio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
version: '3.15.0'
license: community
---

# Radio

<Image src="/assets/img/fields/radio.png" width="425" height="87" alt="Radio field" />

The `Radio` field is used to render radio buttons. It's useful when only one value can be selected in a given options group.

### Field declaration example
Below is an example of declaring a `radio` field for a role:

```ruby
field :role,
as: :radio,
name: "User role",
options: {
admin: "Administrator",
manager: "Manager",
writer: "Writer"
}
```

<Option name="`options`">

The `options` attribute accepts either a `Hash` or a proc, allowing the incorporation of custom logic. Within this block, you gain access to all attributes of [`Avo::ExecutionContext`](../execution-context) along with the `record`, `resource`, `view` and `field`.

This attribute represents the options that should be displayed in the radio buttons.

#### Default value

Empty `Hash`.

```ruby
{}
```

#### Possible values

Any `Hash`. The keys represent the value that will be persisted and the values are the visible labels. Example:

```ruby
options: {
admin: "Administrator",
manager: "Manager",
writer: "Writer"
}
```

Or a `Proc`:

```ruby
options: -> do
record.roles.each_with_object({}) do |role, hash|
hash[role.id] = role.name.humanize
end
end
```

</Option>
3 changes: 3 additions & 0 deletions docs/3.0/fields/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ field :type, as: :select, options: { 'Large container': :large, 'Medium containe
## Options

<Option name="`options`">

A `Hash` representing the options that should be displayed in the select. The keys represent the labels, and the values represent the value stored in the database.

The options get cast as `ActiveSupport::HashWithIndifferentAccess` objects if they are a `Hash`.
Expand All @@ -28,6 +29,7 @@ The options get cast as `ActiveSupport::HashWithIndifferentAccess` objects if th
</Option>

<Option name="`enum`">

Set the select options as an Active Record [enum](https://edgeapi.rubyonrails.org/classes/ActiveRecord/Enum.html). You may use `options` or `enum`, not both.

```ruby{3,10}
Expand Down Expand Up @@ -71,6 +73,7 @@ end
</Option>

<Option name="`include_blank`">

## Include blank

The `Select` field also has the `include_blank` option. That can have three values.
Expand Down
8 changes: 8 additions & 0 deletions docs/3.0/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
We'll update this page when we release new Avo 3 versions.

If you're looking for the Avo 2 to Avo 3 upgrade guide, please visit [the dedicated page](./avo-2-avo-3-upgrade).
## Upgrade from 3.14.0 to 3.14.1

We’ve introduced the [`associations_lookup_list_limit`](customization.html#associations_lookup_list_limit) configuration option to prevent crashing when listing associations on large collections. The new default limit is set to a `1000` records.

```ruby
config.associations_lookup_list_limit = 1000
```

## Upgrade from 3.13.6 to 3.13.7

The `implicit_authorization` option has been renamed to `explicit_authorization` to better align with the feature's functionality. The underlying logic remains unchanged, so you only need to perform a rename if you're already using it.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/assets/img/fields/radio.png
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 4c810ec

Please sign in to comment.