From 3fc0063f9153dfb7048772a2f3bb92f2d39aa235 Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Wed, 17 Jul 2024 13:33:19 +0300 Subject: [PATCH 1/4] boolean dash when nil --- docs/3.0/upgrade.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/3.0/upgrade.md b/docs/3.0/upgrade.md index 05fb0393..98ed97d8 100644 --- a/docs/3.0/upgrade.md +++ b/docs/3.0/upgrade.md @@ -4,6 +4,12 @@ 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.10.6 to 3.10.7 +:::option Boolean field + +In versions lower than , boolean fields with a `nil` value were represented by a red X, which could be misleading. when a boolean field has a `nil` value, it is displayed with a dash (`—`) instead of a red X. +::: + From 8f0b87ea1d42a3f39aaabf813030ce1754b340b8 Mon Sep 17 00:00:00 2001 From: Icaro Ryan Souza Date: Thu, 18 Jul 2024 13:58:24 -0400 Subject: [PATCH 2/4] Add docs for `visible` option for `panel` (#248) * Add docs for visible option for panels * Update docs/3.0/resource-panels.md --------- Co-authored-by: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> --- docs/3.0/resource-panels.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/3.0/resource-panels.md b/docs/3.0/resource-panels.md index d74f388e..eeb3fa94 100644 --- a/docs/3.0/resource-panels.md +++ b/docs/3.0/resource-panels.md @@ -155,3 +155,18 @@ end ``` Index view + +:::option `visible` + +The `visible` option allows you to dynamically control the visibility of a panel and all its children based on certain conditions. + +This option is particularly useful when you need to show or hide entire sections of your resource at once without having to do it for each field. + +Example: +```ruby +panel name: "User information", visible: -> { resource.record.enabled? } do + field :first_name, as: :text + field :last_name, as: :text +end +``` +::: From 21a32f9f5b0b5d7b9febb160ae1ef2118fda489c Mon Sep 17 00:00:00 2001 From: binarygit <87677429+binarygit@users.noreply.github.com> Date: Fri, 19 Jul 2024 00:06:05 +0545 Subject: [PATCH 3/4] Provide info that you do not need to manually register an action before using it (#242) * Actions no longer need to be registered inside actions method * Update * Add note on warning * Update docs/3.0/customizable-controls.md * Update docs/3.0/customizable-controls.md --------- Co-authored-by: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> --- docs/3.0/customizable-controls.md | 3 ++- docs/3.0/upgrade.md | 45 +++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/docs/3.0/customizable-controls.md b/docs/3.0/customizable-controls.md index 4be45b42..66780736 100644 --- a/docs/3.0/customizable-controls.md +++ b/docs/3.0/customizable-controls.md @@ -201,7 +201,8 @@ action Avo::Actions::PublishPost, color: :fuchsia, icon: "heroicons/outline/eye" ::: -:::warning +:::warning WARNING (**NOT** applicable for versions greater than ) + When you use the `action` helper in any customizable block it will act only as a shortcut to display the action button, it will not also register it to the resource. You must manually register it with the `action` declaration. diff --git a/docs/3.0/upgrade.md b/docs/3.0/upgrade.md index 98ed97d8..21346f40 100644 --- a/docs/3.0/upgrade.md +++ b/docs/3.0/upgrade.md @@ -13,6 +13,51 @@ In versions lower than , boolean fields with a `nil` + +## Upgrade from 3.10 to 3.11 + +### Actions no longer need to be registered inside actions method + +Actions inside customizable blocks no longer need to be declared in the `actions` method. + +```ruby +# Before + +class Avo::Resources::Fish < Avo::BaseResource + self.title = :name + + self.show_controls = -> do + # In order to use it here + action Avo::Actions::ReleaseFish, style: :primary, color: :fuchsia, arguments: { + action_on_show_controls: "Will use this arguments" + } + end + + # 👇 Also declare it here 👇 + def actions + action Avo::Actions::ReleaseFish, style: :primary, color: :fuchsia, arguments: { + action_on_show_controls: "Will use this arguments" + } + end +end + +# After + +class Avo::Resources::Fish < Avo::BaseResource + self.title = :name + + self.show_controls = -> do + # In order to use it here + action Avo::Actions::ReleaseFish, style: :primary, color: :fuchsia, arguments: { + action_on_show_controls: "Will use this arguments" + } + end + + # 👇 No need to declare it here 👇 + def actions + end +end +``` ## Upgrade from 3.9.2 to 3.10 Deprecated [`fetch_labels`](fields/tags#fetch_labels) option in favor of [`format_using`](fields/tags#format_using) on tags field. From bc3f92b49c9446ff8e1035fdcf004d50057f841f Mon Sep 17 00:00:00 2001 From: Yash Singh Pathania <69065839+Yash-Singh-Pathania@users.noreply.github.com> Date: Fri, 19 Jul 2024 15:48:41 +0530 Subject: [PATCH 4/4] Documentation || Extending Avo::BaseResource (#247) * Documentation|| For Extending Avo::BaseResource * Apply suggestions from code review * Update docs/3.0/resources.md --------- Co-authored-by: Adrian Marin Co-authored-by: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> --- docs/3.0/resources.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/docs/3.0/resources.md b/docs/3.0/resources.md index 6189f1e9..c49c4223 100644 --- a/docs/3.0/resources.md +++ b/docs/3.0/resources.md @@ -367,6 +367,42 @@ 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. +## Extending `Avo::BaseResource` + + we have restructured the `Avo::BaseResource` to enhance user customization capabilities. The existing functionality has been moved to a new base class `Avo::Resources::Base`, and `Avo::BaseResource` is now left empty for user overrides. This allows users to easily add custom methods that all of their resources will inherit, without having to modify the internal base class. + +### How to Customize `Avo::BaseResource` + +You can customize `Avo::BaseResource` by creating your own version in your application. This custom resource can include methods and logic that you want all your resources to inherit. Here's an example to illustrate how you can do this: + +```ruby +# app/avo/base_resource.rb +module Avo + class BaseResource < Avo::Resources::Base + # Example custom method: make all number fields cast their values to float + def field(id, **args, &block) + if args[:as] == :number + args[:format_using] = -> { value.to_f } + end + + super(id, **args, &block) + end + end +end +``` + + +All your resources will now inherit from your custom `Avo::BaseResource`, allowing you to add common functionality across your admin interface. For instance, the above example ensures that all number fields in your resources will have their values cast to floats. You can add any other shared methods or customizations here, making it easier to maintain consistent behavior across all resources. + +### Your resource files + +Your resource file will still look the same as it did before. + +```ruby +# app/avo/resources/post_resource.rb +module Avo::Resources::Post < Avo::BaseResource + # Your existing configuration for the Post resource +end ## Resource Options