diff --git a/docs/2.0/resources.md b/docs/2.0/resources.md index 26643317..cfff9c3e 100644 --- a/docs/2.0/resources.md +++ b/docs/2.0/resources.md @@ -309,7 +309,7 @@ end You might want to display information about the current resource to your users. Then, using the `description` class attribute, you can add some text to the `Index`, `Show`, `Edit`, and `New` views. -Avo message +Avo message There are two ways of setting the description. The quick way as a `string` and the more customizable way as a `block`. @@ -502,7 +502,7 @@ Avo.configure do |config| end ``` -Buttons on footer +Buttons on footer ## Customize what happens after a record is created/edited @@ -535,7 +535,7 @@ class CommentResource < Avo::BaseResource end ``` -Hide the record selector. +Hide the record selector. ## Link to child resource (STI) diff --git a/docs/3.0/resources.md b/docs/3.0/resources.md index 85948d10..2797d90e 100644 --- a/docs/3.0/resources.md +++ b/docs/3.0/resources.md @@ -16,17 +16,16 @@ All resources are located in the `app/avo/resources` directory. bin/rails generate model car make:string mileage:integer ``` -Running this command will generate the standard Rails files (model, controller, etc.) and `Car` resource and `CarsController` for Avo. +Running this command will generate the standard Rails files (model, controller, etc.) and `Avo::Resources::Car` & `Avo::CarsController` for Avo. The auto-generated resource file will look like this: ```ruby class Avo::Resources::Car < Avo::BaseResource - self.title = :id self.includes = [] - # self.search_query = -> do - # query.ransack(id_eq: params[:q], m: "or").result(distinct: false) - # end + # self.search = { + # query: -> { query.ransack(id_eq: params[:q], m: "or").result(distinct: false) } + # } def fields field :id, as: :id @@ -36,7 +35,7 @@ class Avo::Resources::Car < Avo::BaseResource end ``` -This behavior can be ommited by using the argument `--skip-avo-resource`. For example if we want to generate a `Car` model but no Avo counterpart we should use the following command: +This behavior can be omitted by using the argument `--skip-avo-resource`. For example if we want to generate a `Car` model but no Avo counterpart we should use the following command: ```bash bin/rails generate model car make:string kms:integer --skip-avo-resource @@ -53,11 +52,10 @@ This command will generate the `Post` resource file in `app/avo/resources/post.r ```ruby # app/avo/resources/post.rb class Avo::Resources::Post < Avo::BaseResource - self.title = :id self.includes = [] - # self.search_query = -> do - # query.ransack(id_eq: params[:q], m: "or").result(distinct: false) - # end + # self.search = { + # query: -> { query.ransack(id_eq: params[:q], m: "or").result(distinct: false) } + # } def fields field :id, as: :id @@ -105,11 +103,10 @@ end ```ruby [app/avo/resource/post.rb] class Avo::Resources::Post < Avo::BaseResource - self.title = :id self.includes = [] - # self.search_query = -> do - # query.ransack(id_eq: params[:q], m: "or").result(distinct: false) - # end + # self.search = { + # query: -> { query.ransack(id_eq: params[:q], m: "or").result(distinct: false) } + # } def fields field :id, as: :id @@ -396,7 +393,7 @@ end If you don't have a `title`, `name`, or `label` attribute in the database, you can add a getter method to your model where you compose the name. -```ruby{2} +```ruby{3,8-10} # app/avo/resources/comment.rb class Avo::Resources::Comment < Avo::BaseResource self.title = :tiny_name @@ -414,7 +411,7 @@ end If you prefer not to use any record methods and instead compute the resource's title directly within the resource itself, you can accomplish this by assigning a lambda function to the `title` class attribute. You'll have access to `resource` and `record`. -```ruby{2} +```ruby{3-5} # app/avo/resources/comment.rb class Avo::Resources::Comment < Avo::BaseResource self.title = -> { @@ -427,7 +424,7 @@ end You might want to display information about the current resource to your users. Then, using the `description` class attribute, you can add some text to the `Index`, `Show`, `Edit`, and `New` views. -Avo message +Avo message There are two ways of setting the description. The quick way as a `string` and the more customizable way as a `block`. @@ -529,7 +526,7 @@ end When you get started, the sidebar will be auto-generated for you with all the [dashboards](./dashboards), resources, and [custom tools](./custom-tools). However, you may have resources that should not appear on the sidebar, which you can hide using the `visible_on_sidebar` option. -```ruby{3} +```ruby{2} class Avo::Resources::TeamMembership < Avo::BaseResource self.visible_on_sidebar = false end @@ -555,7 +552,7 @@ Avo.configure do |config| end ``` -Buttons on footer +Buttons on footer ::: @@ -594,7 +591,7 @@ class Avo::Resources::Comment < Avo::BaseResource end ``` -Hide the record selector. +Hide the record selector. ::: :::option `self.link_to_child_resource` diff --git a/docs/public/assets/img/resources/buttons_on_footer.jpg b/docs/public/assets/img/resources/buttons_on_footer.jpg deleted file mode 100644 index a5b27a8c..00000000 Binary files a/docs/public/assets/img/resources/buttons_on_footer.jpg and /dev/null differ diff --git a/docs/public/assets/img/resources/buttons_on_footer.png b/docs/public/assets/img/resources/buttons_on_footer.png new file mode 100644 index 00000000..14eeb5dd Binary files /dev/null and b/docs/public/assets/img/resources/buttons_on_footer.png differ diff --git a/docs/public/assets/img/resources/description.jpg b/docs/public/assets/img/resources/description.jpg deleted file mode 100644 index 46a723d6..00000000 Binary files a/docs/public/assets/img/resources/description.jpg and /dev/null differ diff --git a/docs/public/assets/img/resources/description.png b/docs/public/assets/img/resources/description.png new file mode 100644 index 00000000..ac16e1e6 Binary files /dev/null and b/docs/public/assets/img/resources/description.png differ diff --git a/docs/public/assets/img/resources/record_selector.jpg b/docs/public/assets/img/resources/record_selector.jpg deleted file mode 100644 index a2892c0d..00000000 Binary files a/docs/public/assets/img/resources/record_selector.jpg and /dev/null differ diff --git a/docs/public/assets/img/resources/record_selector.png b/docs/public/assets/img/resources/record_selector.png new file mode 100644 index 00000000..1e68629a Binary files /dev/null and b/docs/public/assets/img/resources/record_selector.png differ