Skip to content

Commit

Permalink
refactor: rename link_to_resource to link_to_record
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob committed Aug 29, 2023
1 parent 11e0011 commit 3fa7d56
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 35 deletions.
8 changes: 4 additions & 4 deletions docs/3.0/avo-2-avo-3-upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,8 @@ In Avo 3 you'll be able to insert resource tools in-between fields, tabs and pan
# Before
class Avo::Resources::User < Avo::BaseResource
def fields
field :id, as: :id, link_to_resource: true, sortable: false
field :email, as: :gravatar, link_to_resource: true, as_avatar: :circle, only_on: :index
field :id, as: :id, link_to_record: true, sortable: false
field :email, as: :gravatar, link_to_record: true, as_avatar: :circle, only_on: :index
end
tool Avo::ResourceTools::UserTool
Expand All @@ -629,8 +629,8 @@ end
# After
class Avo::Resources::User < Avo::BaseResource
def fields
field :id, as: :id, link_to_resource: true, sortable: false
field :email, as: :gravatar, link_to_resource: true, as_avatar: :circle, only_on: :index
field :id, as: :id, link_to_record: true, sortable: false
field :email, as: :gravatar, link_to_record: true, as_avatar: :circle, only_on: :index
tool Avo::ResourceTools::UserTool
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
:::option `link_to_resource`
:::option `link_to_record`
Wraps the content into an anchor that links to the resource.
:::
12 changes: 6 additions & 6 deletions docs/3.0/custom-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Avo::Resources::Project < Avo::BaseResource
self.title = :name
def fields
field :id, as: :id, link_to_resource: true
field :id, as: :id, link_to_record: true
field :progress, as: :progress_bar
end
end
Expand Down Expand Up @@ -106,14 +106,14 @@ We can verify that all components have the text field code. From here there are
module Avo
module Fields
class SuperTextField < BaseField
attr_reader :link_to_resource
attr_reader :link_to_record
attr_reader :as_html
attr_reader :protocol

def initialize(id, **args, &block)
super(id, **args, &block)

add_boolean_prop args, :link_to_resource
add_boolean_prop args, :link_to_record
add_boolean_prop args, :as_html
add_string_prop args, :protocol
end
Expand All @@ -125,14 +125,14 @@ end
module Avo
module Fields
class TextField < BaseField
attr_reader :link_to_resource
attr_reader :link_to_record
attr_reader :as_html
attr_reader :protocol

def initialize(id, **args, &block)
super(id, **args, &block)

add_boolean_prop args, :link_to_resource
add_boolean_prop args, :link_to_record
add_boolean_prop args, :as_html
add_string_prop args, :protocol
end
Expand Down Expand Up @@ -189,7 +189,7 @@ class Avo::Resources::Project < Avo::BaseResource
self.title = :name
def fields
field :id, as: :id, link_to_resource: true
field :id, as: :id, link_to_record: true
field :progress, as: :progress_bar, step: 10, display_value: true, value_suffix: "%"
end
end
Expand Down
10 changes: 5 additions & 5 deletions docs/3.0/field-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,19 +262,19 @@ field :updated_status, as: :status, failed_when: [:closed, :rejected, :failed],
field :body, as: :textarea, nullable: true, null_values: ['0', '', 'null', 'nil', nil]
```

## Link to resource
## Link to record

Sometimes, on the <Index /> view, you may want a field in the table to be a link to that resource so that you don't have to scroll to the right to click on the <Show /> icon. You can use `link_to_resource` to change a table cell to be a link to that resource.
Sometimes, on the <Index /> view, you may want a field in the table to be a link to that resource so that you don't have to scroll to the right to click on the <Show /> icon. You can use `link_to_record` to change a table cell to be a link to that record.

```ruby
# for id field
field :id, as: :id, link_to_resource: true
field :id, as: :id, link_to_record: true

# for text field
field :name, as: :text, link_to_resource: true
field :name, as: :text, link_to_record: true

# for gravatar field
field :email, as: :gravatar, link_to_resource: true
field :email, as: :gravatar, link_to_record: true
```

<img :src="('/assets/img/fields-reference/as-link-to-resource.jpg')" alt="As link to resource" class="border mb-4" />
Expand Down
4 changes: 2 additions & 2 deletions docs/3.0/fields/external_image.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Use any number to size the image.
Use any number to set the radius value.
:::

<!-- @include: ./../common/link_to_resource_common.md-->
<!-- @include: ./../common/link_to_record_common.md-->

## Use computed values

Expand All @@ -65,7 +65,7 @@ end
Another common place you could use it is in the grid `:cover` position.

```ruby
cover :logo, as: :external_image, link_to_resource: true do
cover :logo, as: :external_image, link_to_record: true do
"//logo.clearbit.com/#{URI.parse(record.url).host}?size=180"
rescue
nil
Expand Down
2 changes: 1 addition & 1 deletion docs/3.0/fields/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ field :avatar, as: :file, is_image: true
## Options

<!-- @include: ./../common/file_options_common.md-->
<!-- @include: ./../common/link_to_resource_common.md-->
<!-- @include: ./../common/link_to_record_common.md-->

<!-- @include: ./../common/file_other_common.md-->
2 changes: 1 addition & 1 deletion docs/3.0/fields/gravatar.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Set the default image if the email address was not found in Gravatar's database.
Any number in pixels. Remember that the size will influence the `Index` table row height.
:::

<!-- @include: ./../common/link_to_resource_common.md-->
<!-- @include: ./../common/link_to_record_common.md-->

## Using computed values

Expand Down
4 changes: 2 additions & 2 deletions docs/3.0/fields/id.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ license: community

# ID

The `id` field is used to show the record's id. By default, it's visible only on the `Index` and `Show` views. That is a good field to add the `as_link_to_resource` option to make it a shortcut to the record `Show` page.
The `id` field is used to show the record's id. By default, it's visible only on the `Index` and `Show` views. That is a good field to add the `link_to_record` option to make it a shortcut to the record `Show` page.

```ruby
field :id, as: :id
```

## Options

<!-- @include: ./../common/link_to_resource_common.md-->
<!-- @include: ./../common/link_to_record_common.md-->

2 changes: 1 addition & 1 deletion docs/3.0/fields/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ field :email,
`mailto`, `tel`, or any other string value you need to pass to it.
:::

<!-- @include: ./../common/link_to_resource_common.md-->
<!-- @include: ./../common/link_to_record_common.md-->

## Customization

Expand Down
2 changes: 1 addition & 1 deletion docs/3.0/gemfile-environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This way `bundler` is aware of them without having to specify it in the `Gemfile
bundle config set --global https://packager.dev/avo-hq/ xxx-xxx
```

<!-- @include: ./../common/link_to_resource_common.md-->
<!-- @include: ./../common/link_to_record_common.md-->

## 2. Export the variable before running `bundle install`

Expand Down
4 changes: 2 additions & 2 deletions docs/3.0/resource-sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ Using the `sidebar` block on a resource you may declare fields the same way you
```ruby
class Avo::Resources::User < Avo::BaseResource
def fields
field :id, as: :id, link_to_resource: true
field :id, as: :id, link_to_record: true
field :first_name, as: :text, placeholder: "John"
field :last_name, as: :text, placeholder: "Doe"

sidebar do
field :email, as: :gravatar, link_to_resource: true, as_avatar: :circle, only_on: :show
field :email, as: :gravatar, link_to_record: true, as_avatar: :circle, only_on: :show
field :active, as: :boolean, name: "Is active", only_on: :show
end
end
Expand Down
12 changes: 6 additions & 6 deletions docs/3.0/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Avo::Resources::Post < Avo::BaseResource
field :id, as: :id
field :name, as: :text, required: true
field :body, as: :trix, placeholder: "Add the post body here", always_show: false
field :cover_photo, as: :file, is_image: true, link_to_resource: true
field :cover_photo, as: :file, is_image: true, link_to_record: true
field :is_featured, as: :boolean
field :is_published, as: :boolean do
Expand Down Expand Up @@ -201,8 +201,8 @@ class Avo::Resources::User < Avo::BaseResource
self.title = :name

def fields
field :id, as: :id, link_to_resource: true
field :email, as: :gravatar, link_to_resource: true, as_avatar: :circle
field :id, as: :id, link_to_record: true
field :email, as: :gravatar, link_to_record: true, as_avatar: :circle
field :first_name, as: :text, required: true, placeholder: "John"
field :last_name, as: :text, required: true, placeholder: "Doe"
end
Expand All @@ -225,7 +225,7 @@ class Avo::Resources::Team < Avo::BaseResource
self.title = :name
def fields
field :id, as: :id, link_to_resource: true
field :id, as: :id, link_to_record: true
field :name, as: :text
field :users, as: :has_many
end
Expand All @@ -243,7 +243,7 @@ class Avo::Resources::TeamUser < Avo::BaseResource
self.title = :name

def fields
field :id, as: :id, link_to_resource: true
field :id, as: :id, link_to_record: true
field :name, as: :text
field :projects_count, as: :number
end
Expand All @@ -258,7 +258,7 @@ class Avo::Resources::Team < Avo::BaseResource
self.title = :name

def fields
field :id, as: :id, link_to_resource: true
field :id, as: :id, link_to_record: true
field :name, as: :text
field :users, as: :has_many, use_resource: Avo::Resources::TeamUser
end
Expand Down
6 changes: 3 additions & 3 deletions docs/3.0/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ When using the fields DSL for resources, all fields declared in the root will be
```ruby
class Avo::Resources::User < Avo::BaseResource
def fields
field :id, as: :id, link_to_resource: true
field :id, as: :id, link_to_record: true
field :email, as: :text, name: "User Email", required: true

panel name: "User information", description: "Some information about this user" do
Expand All @@ -44,7 +44,7 @@ By default, only the fields declared in the root will be visible on the `Index`
class Avo::Resources::User < Avo::BaseResource
def fields
# Only these fields will be visible on the `Index` view
field :id, as: :id, link_to_resource: true
field :id, as: :id, link_to_record: true
field :email, as: :text, name: "User Email", required: true
field :name, as: :text, only_on: :index do
"#{record.first_name} #{record.last_name}"
Expand All @@ -69,7 +69,7 @@ Tabs are a new layer of abstraction over panels. They enable you to group panels
```ruby
class Avo::Resources::User < Avo::BaseResource
def fields
field :id, as: :id, link_to_resource: true
field :id, as: :id, link_to_record: true
field :email, as: :text, name: "User Email", required: true

tabs do
Expand Down

0 comments on commit 3fa7d56

Please sign in to comment.