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 Apr 15, 2024
2 parents 7db1fe5 + c7b009d commit 514fe03
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ const config = {
],
"/2.0/": [
{
text: "Getting started",
text: "Avo 2",
items: [
{text: "Intro", link: "/2.0/index.html"},
{text: "Avo, Rails & Hotwire", link: "/2.0/rails-and-hotwire.html"},
Expand Down
32 changes: 32 additions & 0 deletions docs/.vitepress/theme/components/TopBar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<script setup>
import { onMounted, onUnmounted } from 'vue'
onMounted(() => {
document.documentElement.style.setProperty('--vp-layout-top-height', '3rem')
})
onUnmounted(() => {
document.documentElement.style.removeProperty('--vp-layout-top-height')
})
</script>

<template>
<section>
<slot />
</section>
</template>

<style scoped>
section {
display: grid;
place-items: center;
height: var(--vp-layout-top-height);
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: var(--vp-z-index-layout-top);
background-color: var(--vp-button-brand-bg);
color: var(--vp-button-brand-text);
}
</style>
14 changes: 14 additions & 0 deletions docs/.vitepress/theme/components/TopBarWrapper.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script setup>
import { computed } from 'vue'
import { useData } from 'vitepress'
import VersionAlertBar from "./VersionAlertBar.vue"
const { page } = useData();
const showVersionAlertBar = computed(() => page.value.relativePath.includes('2.0'));
</script>

<template>
<VersionAlertBar v-if="showVersionAlertBar" />
</template>
20 changes: 20 additions & 0 deletions docs/.vitepress/theme/components/VersionAlertBar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<script setup>
import TopBar from "./TopBar.vue"
</script>

<template>
<TopBar>
<p>You are browsing docs for Avo 2: go to <a href="/3.0/">Avo 3</a></p>
</TopBar>
</template>

<style scoped>
a {
font-weight: bold;
text-decoration: underline;
}
a:hover {
text-decoration: none;
}
</style>
2 changes: 2 additions & 0 deletions docs/.vitepress/theme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import VersionReq from "../theme/components/VersionReq.vue"
import Version from "../theme/components/Version.vue"
import DemoVideo from "../theme/components/DemoVideo.vue"
import Demo from "../theme/components/Demo.vue"
import TopBarWrapper from "../theme/components/TopBarWrapper.vue"
import PageHeader from "../theme/components/PageHeader.vue"
import AsideOutlineAfter from "../theme/components/AsideOutlineAfter.vue"
import BetaStatus from "../theme/components/BetaStatus.vue"
Expand Down Expand Up @@ -52,6 +53,7 @@ export default {
},
Layout() {
return h(DefaultTheme.Layout, null, {
"layout-top": () => h(TopBarWrapper),
"doc-before": () => h(PageHeader),
"aside-outline-after": () => h(AsideOutlineAfter),
})
Expand Down
1 change: 1 addition & 0 deletions docs/3.0/associations/belongs_to.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
version: '1.0'
license: community
field_type: 'belongs_to'
---

# Belongs to
Expand Down
1 change: 1 addition & 0 deletions docs/3.0/associations/has_one.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
version: '1.0'
license: community
field_type: 'has_one'
---

:::warning
Expand Down
7 changes: 7 additions & 0 deletions docs/3.0/common/associations_attach_scope_option_common.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ Pass in a block where you attach scopes to the `query` object and `parent` objec
The `attach_scope` will not filter the records in the listing from `has_many` or `has_and_belongs_to_many` associations.
Use [`scope`](#scope) or a [Pundit policy `Scope`](./../authorization#scopes) for that.
:::

```ruby-vue{3}
field :members,
as: :{{ $frontmatter.field_type }},
attach_scope: -> { query.where.not(team_id: parent.id) }
```
In this example, in the `attach_scope`, we ensure that when attaching members to a team, only those who are not already members will appear in the list of options.
27 changes: 20 additions & 7 deletions docs/3.0/fields/boolean_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ You may want to compute the values on the fly for your `BooleanGroup` field. You
class Avo::Resources::Project < Avo::BaseResource
field :features,
as: :boolean_group,
options: -> do
options: -do
record.features.each_with_object({}) do |feature, hash|
hash[feature.id] = feature.name.humanize
end
Expand All @@ -63,23 +63,36 @@ The output value must be a hash as described above.
}
```

Before version 3.7.0 Avo would override the whole attribute with only the payload sent from the client.

:::warning
The final value in the database column will be overwritten, The options will not be appended.
```json
// Before update.
{
"feature_enabled": true,
"another_feature_enabled": false,
"something_else": "some_value" // this will disappear
}
// After update.
{
"feature_enabled": true,
"another_feature_enabled": false,
}
```

Version 3.7.0 and up will only update the keys that you send from the client.

```json
// this
// Before update.
{
"feature_enabled": true,
"another_feature_enabled": false,
"something_else": "some_value" // this will disappear
"something_else": "some_value" // this will be kept
}

// becomes
// After update.
{
"feature_enabled": true,
"another_feature_enabled": false,
"something_else": "some_value"
}
```
:::
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,9 @@ camelcase-css@^2.0.1:
integrity sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==

caniuse-lite@^1.0.30001370, caniuse-lite@^1.0.30001373:
version "1.0.30001546"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001546.tgz"
integrity sha512-zvtSJwuQFpewSyRrI3AsftF6rM0X80mZkChIt1spBGEvRglCrjTniXvinc8JKRoqTwXAgvqTImaN9igfSMtUBw==
version "1.0.30001608"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001608.tgz"
integrity sha512-cjUJTQkk9fQlJR2s4HMuPMvTiRggl0rAVMtthQuyOlDWuqHXqN8azLq+pi8B2TjwKJ32diHjUqRIKeFX4z1FoA==

chokidar@^3.5.3:
version "3.5.3"
Expand Down

0 comments on commit 514fe03

Please sign in to comment.