From db586f60f53bcd245a08a465a3e0de431597b2ba Mon Sep 17 00:00:00 2001 From: Brychu Date: Sun, 19 Nov 2023 13:03:04 +0100 Subject: [PATCH 1/9] Add docs for Stimulus controllers in Actions --- docs/2.0/stimulus-integration.md | 117 +++++++++++++++++++------------ docs/3.0/stimulus-integration.md | 117 +++++++++++++++++++------------ 2 files changed, 146 insertions(+), 88 deletions(-) diff --git a/docs/2.0/stimulus-integration.md b/docs/2.0/stimulus-integration.md index be249223..fecff652 100644 --- a/docs/2.0/stimulus-integration.md +++ b/docs/2.0/stimulus-integration.md @@ -1,6 +1,6 @@ --- feedbackId: 943 -version: '2.8' +version: "2.8" demoVideo: https://www.youtube.com/watch?v=ZMOz22FaAUg betaStatus: Beta --- @@ -127,6 +127,30 @@ export default class extends Controller { The possible values are `index`, `show`, `edit`, or `new` +## Assign Stimulus controllers to standalone actions + +Similarly as to resource, you can assign stimulus controller to a standalone action (action that has some embedded form). To do that you can use the `stimulus_controllers` option on the action file. + +```ruby +class ShowCurrentTime < Avo::BaseAction + self.stimulus_controllers = "city-in-country" +end +``` + +You can add more and separate them by a space character. + +```ruby +class CourseResource < Avo::BaseResource + self.stimulus_controllers = "course-resource select-field association-fields" +end +``` + +Unlike with the resource, Avo will not add a specific default controller for each type of the view (`index`, `show`, `edit`) as standalone actions are independent from the view type. + +The same way as for the resources, Avo will add stimulus target data attributes to [all field wrappers](#field-wrappers-as-targets) and [all input fields](#field-inputs-as-targets). + +The controllers will also, [as in case of resources](#all-controllers-receive-the-view-value), receive the `view` attribute in the DOM, so you can differentiate behavior of the controller based on that value in case you need it. + ## Attach HTML attributes Using the `html` option you can attach `style`, `classes`, and `data` attributes. The `style` attribute adds the `style` tag to your element, `classes` adds the `class` tag, and the `data` attribute the `data` tag to the element you choose. @@ -346,13 +370,13 @@ You can use the attributes together to make your fields more dynamic. ```js // toggle_fields_controller.js -import { Controller } from '@hotwired/stimulus' +import { Controller } from "@hotwired/stimulus"; export default class extends Controller { - static targets = ['skillsTagsWrapper'] // use the target Avo prepared for you + static targets = ["skillsTagsWrapper"]; // use the target Avo prepared for you toggleSkills() { - this.skillsTagsWrapperTarget.classList.toggle('hidden') + this.skillsTagsWrapperTarget.classList.toggle("hidden"); } } ``` @@ -519,48 +543,50 @@ end ``` ```js [course_resource_controller.js] -import { Controller } from '@hotwired/stimulus' +import { Controller } from "@hotwired/stimulus"; -const LOADER_CLASSES = 'absolute bg-gray-100 opacity-10 w-full h-full' +const LOADER_CLASSES = "absolute bg-gray-100 opacity-10 w-full h-full"; export default class extends Controller { - static targets = ['countryFieldInput', 'cityFieldInput', 'citySelectWrapper']; + static targets = ["countryFieldInput", "cityFieldInput", "citySelectWrapper"]; static values = { view: String, - } + }; // Te fields initial value - static initialValue + static initialValue; get placeholder() { - return this.cityFieldInputTarget.ariaPlaceholder + return this.cityFieldInputTarget.ariaPlaceholder; } set loading(isLoading) { if (isLoading) { // create a loader overlay - const loadingDiv = document.createElement('div') - loadingDiv.className = LOADER_CLASSES - loadingDiv.dataset.target = 'city-loader' + const loadingDiv = document.createElement("div"); + loadingDiv.className = LOADER_CLASSES; + loadingDiv.dataset.target = "city-loader"; // add the loader overlay - this.citySelectWrapperTarget.prepend(loadingDiv) - this.citySelectWrapperTarget.classList.add('opacity-50') + this.citySelectWrapperTarget.prepend(loadingDiv); + this.citySelectWrapperTarget.classList.add("opacity-50"); } else { // remove the loader overlay - this.citySelectWrapperTarget.querySelector('[data-target="city-loader"]').remove() - this.citySelectWrapperTarget.classList.remove('opacity-50') + this.citySelectWrapperTarget + .querySelector('[data-target="city-loader"]') + .remove(); + this.citySelectWrapperTarget.classList.remove("opacity-50"); } } async connect() { // Add the controller functionality only on forms - if (['edit', 'new'].includes(this.viewValue)) { - this.captureTheInitialValue() + if (["edit", "new"].includes(this.viewValue)) { + this.captureTheInitialValue(); // Trigger the change on load - await this.onCountryChange() + await this.onCountryChange(); } } @@ -569,31 +595,34 @@ export default class extends Controller { async onCountryChange() { if (this.hasCountryFieldInputTarget && this.countryFieldInputTarget) { // Get the country - const country = this.countryFieldInputTarget.value + const country = this.countryFieldInputTarget.value; // Dynamically fetch the cities for this country - const cities = await this.fetchCitiesForCountry(country) + const cities = await this.fetchCitiesForCountry(country); // Clear the select of options Object.keys(this.cityFieldInputTarget.options).forEach(() => { - this.cityFieldInputTarget.options.remove(0) - }) + this.cityFieldInputTarget.options.remove(0); + }); // Add blank option - this.cityFieldInputTarget.add(new Option(this.placeholder)) + this.cityFieldInputTarget.add(new Option(this.placeholder)); // Add the new cities cities.forEach((city) => { - this.cityFieldInputTarget.add(new Option(city, city)) - }) + this.cityFieldInputTarget.add(new Option(city, city)); + }); // Check if the initial value is present in the cities array and select it. // If not, select the first item - const currentOptions = Array.from(this.cityFieldInputTarget.options).map((item) => item.value) + const currentOptions = Array.from(this.cityFieldInputTarget.options).map( + (item) => item.value + ); if (currentOptions.includes(this.initialValue)) { - this.cityFieldInputTarget.value = this.initialValue + this.cityFieldInputTarget.value = this.initialValue; } else { // Select the first item - this.cityFieldInputTarget.value = this.cityFieldInputTarget.options[0].value + this.cityFieldInputTarget.value = + this.cityFieldInputTarget.options[0].value; } } } @@ -601,24 +630,24 @@ export default class extends Controller { // Private captureTheInitialValue() { - this.initialValue = this.cityFieldInputTarget.value + this.initialValue = this.cityFieldInputTarget.value; } async fetchCitiesForCountry(country) { if (!country) { - return [] + return []; } - this.loading = true + this.loading = true; const response = await fetch( - `${window.Avo.configuration.root_path}/resources/courses/cities?country=${country}`, - ) - const data = await response.json() + `${window.Avo.configuration.root_path}/resources/courses/cities?country=${country}` + ); + const data = await response.json(); - this.loading = false + this.loading = false; - return data + return data; } } ``` @@ -639,11 +668,11 @@ First, you need to have a JS entrypoint (ex: `avo.custom.js`) and have that load ```js // app/javascript/controllers/sample_controller.js -import { Controller } from '@hotwired/stimulus' +import { Controller } from "@hotwired/stimulus"; export default class extends Controller { connect() { - console.log("Hey from sample controller 👋") + console.log("Hey from sample controller 👋"); } } ``` @@ -652,14 +681,14 @@ export default class extends Controller { ```js // app/javascript/avo.custom.js -import SampleController from './controllers/sample_controller' +import SampleController from "./controllers/sample_controller"; // Hook into the stimulus instance provided by Avo -const application = window.Stimulus -application.register('course-resource', SampleController) +const application = window.Stimulus; +application.register("course-resource", SampleController); // eslint-disable-next-line no-console -console.log('Hi from Avo custom JS 👋') +console.log("Hi from Avo custom JS 👋"); ``` ### Use the controller in the Avo tool diff --git a/docs/3.0/stimulus-integration.md b/docs/3.0/stimulus-integration.md index 49abe210..f32c25b3 100644 --- a/docs/3.0/stimulus-integration.md +++ b/docs/3.0/stimulus-integration.md @@ -1,6 +1,6 @@ --- feedbackId: 943 -version: '2.8' +version: "2.8" demoVideo: https://www.youtube.com/watch?v=ZMOz22FaAUg betaStatus: Beta --- @@ -127,6 +127,30 @@ export default class extends Controller { The possible values are `index`, `show`, `edit`, or `new` +## Assign Stimulus controllers to standalone actions + +Similarly as to resource, you can assign stimulus controller to a standalone action (action that has some embedded form). To do that you can use the `stimulus_controllers` option on the action file. + +```ruby +class ShowCurrentTime < Avo::BaseAction + self.stimulus_controllers = "city-in-country" +end +``` + +You can add more and separate them by a space character. + +```ruby +class CourseResource < Avo::BaseResource + self.stimulus_controllers = "course-resource select-field association-fields" +end +``` + +Unlike with the resource, Avo will not add a specific default controller for each type of the view (`index`, `show`, `edit`) as standalone actions are independent from the view type. + +The same way as for the resources, Avo will add stimulus target data attributes to [all field wrappers](#field-wrappers-as-targets) and [all input fields](#field-inputs-as-targets). + +The controllers will also, [as in case of resources](#all-controllers-receive-the-view-value), receive the `view` attribute in the DOM, so you can differentiate behavior of the controller based on that value in case you need it. + ## Attach HTML attributes Using the `html` option you can attach `style`, `classes`, and `data` attributes. The `style` attribute adds the `style` tag to your element, `classes` adds the `class` tag, and the `data` attribute the `data` tag to the element you choose. @@ -346,13 +370,13 @@ You can use the attributes together to make your fields more dynamic. ```js // toggle_fields_controller.js -import { Controller } from '@hotwired/stimulus' +import { Controller } from "@hotwired/stimulus"; export default class extends Controller { - static targets = ['skillsTagsWrapper'] // use the target Avo prepared for you + static targets = ["skillsTagsWrapper"]; // use the target Avo prepared for you toggleSkills() { - this.skillsTagsWrapperTarget.classList.toggle('hidden') + this.skillsTagsWrapperTarget.classList.toggle("hidden"); } } ``` @@ -521,48 +545,50 @@ end ``` ```js [course_resource_controller.js] -import { Controller } from '@hotwired/stimulus' +import { Controller } from "@hotwired/stimulus"; -const LOADER_CLASSES = 'absolute bg-gray-100 opacity-10 w-full h-full' +const LOADER_CLASSES = "absolute bg-gray-100 opacity-10 w-full h-full"; export default class extends Controller { - static targets = ['countryFieldInput', 'cityFieldInput', 'citySelectWrapper']; + static targets = ["countryFieldInput", "cityFieldInput", "citySelectWrapper"]; static values = { view: String, - } + }; // Te fields initial value - static initialValue + static initialValue; get placeholder() { - return this.cityFieldInputTarget.ariaPlaceholder + return this.cityFieldInputTarget.ariaPlaceholder; } set loading(isLoading) { if (isLoading) { // create a loader overlay - const loadingDiv = document.createElement('div') - loadingDiv.className = LOADER_CLASSES - loadingDiv.dataset.target = 'city-loader' + const loadingDiv = document.createElement("div"); + loadingDiv.className = LOADER_CLASSES; + loadingDiv.dataset.target = "city-loader"; // add the loader overlay - this.citySelectWrapperTarget.prepend(loadingDiv) - this.citySelectWrapperTarget.classList.add('opacity-50') + this.citySelectWrapperTarget.prepend(loadingDiv); + this.citySelectWrapperTarget.classList.add("opacity-50"); } else { // remove the loader overlay - this.citySelectWrapperTarget.querySelector('[data-target="city-loader"]').remove() - this.citySelectWrapperTarget.classList.remove('opacity-50') + this.citySelectWrapperTarget + .querySelector('[data-target="city-loader"]') + .remove(); + this.citySelectWrapperTarget.classList.remove("opacity-50"); } } async connect() { // Add the controller functionality only on forms - if (['edit', 'new'].includes(this.viewValue)) { - this.captureTheInitialValue() + if (["edit", "new"].includes(this.viewValue)) { + this.captureTheInitialValue(); // Trigger the change on load - await this.onCountryChange() + await this.onCountryChange(); } } @@ -571,31 +597,34 @@ export default class extends Controller { async onCountryChange() { if (this.hasCountryFieldInputTarget && this.countryFieldInputTarget) { // Get the country - const country = this.countryFieldInputTarget.value + const country = this.countryFieldInputTarget.value; // Dynamically fetch the cities for this country - const cities = await this.fetchCitiesForCountry(country) + const cities = await this.fetchCitiesForCountry(country); // Clear the select of options Object.keys(this.cityFieldInputTarget.options).forEach(() => { - this.cityFieldInputTarget.options.remove(0) - }) + this.cityFieldInputTarget.options.remove(0); + }); // Add blank option - this.cityFieldInputTarget.add(new Option(this.placeholder)) + this.cityFieldInputTarget.add(new Option(this.placeholder)); // Add the new cities cities.forEach((city) => { - this.cityFieldInputTarget.add(new Option(city, city)) - }) + this.cityFieldInputTarget.add(new Option(city, city)); + }); // Check if the initial value is present in the cities array and select it. // If not, select the first item - const currentOptions = Array.from(this.cityFieldInputTarget.options).map((item) => item.value) + const currentOptions = Array.from(this.cityFieldInputTarget.options).map( + (item) => item.value + ); if (currentOptions.includes(this.initialValue)) { - this.cityFieldInputTarget.value = this.initialValue + this.cityFieldInputTarget.value = this.initialValue; } else { // Select the first item - this.cityFieldInputTarget.value = this.cityFieldInputTarget.options[0].value + this.cityFieldInputTarget.value = + this.cityFieldInputTarget.options[0].value; } } } @@ -603,24 +632,24 @@ export default class extends Controller { // Private captureTheInitialValue() { - this.initialValue = this.cityFieldInputTarget.value + this.initialValue = this.cityFieldInputTarget.value; } async fetchCitiesForCountry(country) { if (!country) { - return [] + return []; } - this.loading = true + this.loading = true; const response = await fetch( - `${window.Avo.configuration.root_path}/resources/courses/cities?country=${country}`, - ) - const data = await response.json() + `${window.Avo.configuration.root_path}/resources/courses/cities?country=${country}` + ); + const data = await response.json(); - this.loading = false + this.loading = false; - return data + return data; } } ``` @@ -641,11 +670,11 @@ First, you need to have a JS entrypoint (ex: `avo.custom.js`) and have that load ```js // app/javascript/controllers/sample_controller.js -import { Controller } from '@hotwired/stimulus' +import { Controller } from "@hotwired/stimulus"; export default class extends Controller { connect() { - console.log("Hey from sample controller 👋") + console.log("Hey from sample controller 👋"); } } ``` @@ -654,14 +683,14 @@ export default class extends Controller { ```js // app/javascript/avo.custom.js -import SampleController from './controllers/sample_controller' +import SampleController from "./controllers/sample_controller"; // Hook into the stimulus instance provided by Avo -const application = window.Stimulus -application.register('course-resource', SampleController) +const application = window.Stimulus; +application.register("course-resource", SampleController); // eslint-disable-next-line no-console -console.log('Hi from Avo custom JS 👋') +console.log("Hi from Avo custom JS 👋"); ``` ### Use the controller in the Avo tool From baa344317cb7ed89c06c1d4b202fdc450d447bf4 Mon Sep 17 00:00:00 2001 From: Brychu Date: Sun, 19 Nov 2023 17:36:03 +0100 Subject: [PATCH 2/9] Adjust the docs about the view value --- docs/2.0/stimulus-integration.md | 5 ++--- docs/3.0/stimulus-integration.md | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/2.0/stimulus-integration.md b/docs/2.0/stimulus-integration.md index fecff652..c73589d4 100644 --- a/docs/2.0/stimulus-integration.md +++ b/docs/2.0/stimulus-integration.md @@ -145,11 +145,10 @@ class CourseResource < Avo::BaseResource end ``` -Unlike with the resource, Avo will not add a specific default controller for each type of the view (`index`, `show`, `edit`) as standalone actions are independent from the view type. - The same way as for the resources, Avo will add stimulus target data attributes to [all field wrappers](#field-wrappers-as-targets) and [all input fields](#field-inputs-as-targets). -The controllers will also, [as in case of resources](#all-controllers-receive-the-view-value), receive the `view` attribute in the DOM, so you can differentiate behavior of the controller based on that value in case you need it. +Unlike with the resource, Avo will not add a specific default controller for each type of the view (`index`, `show`, `edit`) as standalone actions are independent from the view type. +Same way, the controllers will not receive the `view` attribute in the DOM, [as in case of resources](#all-controllers-receive-the-view-value). ## Attach HTML attributes diff --git a/docs/3.0/stimulus-integration.md b/docs/3.0/stimulus-integration.md index f32c25b3..d9534e67 100644 --- a/docs/3.0/stimulus-integration.md +++ b/docs/3.0/stimulus-integration.md @@ -145,11 +145,10 @@ class CourseResource < Avo::BaseResource end ``` -Unlike with the resource, Avo will not add a specific default controller for each type of the view (`index`, `show`, `edit`) as standalone actions are independent from the view type. - The same way as for the resources, Avo will add stimulus target data attributes to [all field wrappers](#field-wrappers-as-targets) and [all input fields](#field-inputs-as-targets). -The controllers will also, [as in case of resources](#all-controllers-receive-the-view-value), receive the `view` attribute in the DOM, so you can differentiate behavior of the controller based on that value in case you need it. +Unlike with the resource, Avo will not add a specific default controller for each type of the view (`index`, `show`, `edit`) as standalone actions are independent from the view type. +Same way, the controllers will not receive the `view` attribute in the DOM, [as in case of resources](#all-controllers-receive-the-view-value). ## Attach HTML attributes From 1be6499c92bdc60baa2e4ed0e535a153d98d5f34 Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Thu, 23 Nov 2023 16:41:06 +0200 Subject: [PATCH 3/9] feature: disable belongs_to creation from association --- docs/3.0/associations/belongs_to.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/3.0/associations/belongs_to.md b/docs/3.0/associations/belongs_to.md index 8bcb3297..ad78277f 100644 --- a/docs/3.0/associations/belongs_to.md +++ b/docs/3.0/associations/belongs_to.md @@ -62,6 +62,18 @@ Any string. +:::option `allow_creation` +Controls the creation link visibility on forms. + +#### Default + +`true` + +#### Possible values + +`true`, `false` +::: + ## Overview On the `Index` and `Show` views, Avo will generate a link to the associated record containing the [`@title`](./../resources.html#setting-the-title-of-the-resource) value. From 46121141c53d531db04f9ed7fc64bf786ae34533 Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Tue, 28 Nov 2023 12:40:21 +0200 Subject: [PATCH 4/9] upgrade version --- docs/3.0/upgrade.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/3.0/upgrade.md b/docs/3.0/upgrade.md index 753842b8..f08763c9 100644 --- a/docs/3.0/upgrade.md +++ b/docs/3.0/upgrade.md @@ -4,7 +4,7 @@ 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.0.1.beta24 to 3.0.1.beta25 +## Upgrade from 3.0.1.beta24 to 3.0.2 :::option Sidebar should be declared inside a panel We introduced the `main_panel` option and also refactored the way that fields are fetched from the resource, now we allow multiple sidebars per panel but each sidebar should be defined inside a `panel` or `main_panel` block. From 2c9883062fe67f7a217b84f20584f1c91e1ef5ca Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Tue, 28 Nov 2023 16:53:46 +0200 Subject: [PATCH 5/9] feature: logger --- docs/3.0/customization.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/3.0/customization.md b/docs/3.0/customization.md index 0be94fd6..a8131ebd 100644 --- a/docs/3.0/customization.md +++ b/docs/3.0/customization.md @@ -443,3 +443,22 @@ end ![](/assets/img/customization/skip_show_view.gif) +## Logger + +You may want to set a different output stream for avo logs, you can do that by returning it on a `config.logger` Proc + +```ruby +## == Logger == +config.logger = -> { + file_logger = ActiveSupport::Logger.new(Rails.root.join("log", "avo.log")) + + file_logger.datetime_format = "%Y-%m-%d %H:%M:%S" + file_logger.formatter = proc do |severity, time, progname, msg| + "[Avo] #{time}: #{msg}\n".tap do |i| + puts i + end + end + + file_logger +} +``` From 19d988414578e250b89cd00da88e8543118785b7 Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Mon, 4 Dec 2023 15:46:57 +0200 Subject: [PATCH 6/9] rename the option to `can_create` --- docs/3.0/associations/belongs_to.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/3.0/associations/belongs_to.md b/docs/3.0/associations/belongs_to.md index ad78277f..49c8f50b 100644 --- a/docs/3.0/associations/belongs_to.md +++ b/docs/3.0/associations/belongs_to.md @@ -62,7 +62,7 @@ Any string. -:::option `allow_creation` +:::option `can_create` Controls the creation link visibility on forms. #### Default From 4eefe1df416c6233333cf37c02fb633ff6420d16 Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Tue, 5 Dec 2023 10:56:53 +0200 Subject: [PATCH 7/9] fix v3 syntax --- docs/3.0/stimulus-integration.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/3.0/stimulus-integration.md b/docs/3.0/stimulus-integration.md index 7e607640..88c2e7c4 100644 --- a/docs/3.0/stimulus-integration.md +++ b/docs/3.0/stimulus-integration.md @@ -132,7 +132,7 @@ The possible values are `index`, `show`, `edit`, or `new` Similarly as to resource, you can assign stimulus controller to a standalone action (action that has some embedded form). To do that you can use the `stimulus_controllers` option on the action file. ```ruby -class ShowCurrentTime < Avo::BaseAction +class Avo::Actions::ShowCurrentTime < Avo::BaseAction self.stimulus_controllers = "city-in-country" end ``` @@ -140,8 +140,8 @@ end You can add more and separate them by a space character. ```ruby -class CourseResource < Avo::BaseResource - self.stimulus_controllers = "course-resource select-field association-fields" +class Avo::Actions::ShowCurrentTime < Avo::BaseAction + self.stimulus_controllers = "city-in-country select-field association-fields" end ``` From 9052ad90ce755fa8e2d4211478b2315bfb73b358 Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Tue, 5 Dec 2023 11:06:19 +0200 Subject: [PATCH 8/9] class fix --- docs/2.0/stimulus-integration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/2.0/stimulus-integration.md b/docs/2.0/stimulus-integration.md index cfda9d26..8a4067bc 100644 --- a/docs/2.0/stimulus-integration.md +++ b/docs/2.0/stimulus-integration.md @@ -140,7 +140,7 @@ end You can add more and separate them by a space character. ```ruby -class CourseResource < Avo::BaseResource +class ShowCurrentTime < Avo::BaseAction self.stimulus_controllers = "course-resource select-field association-fields" end ``` From ec4eb83b88b767c57bee7ca75ed861c948b0093a Mon Sep 17 00:00:00 2001 From: Brychu Date: Tue, 5 Dec 2023 16:13:57 +0100 Subject: [PATCH 9/9] Adjust docs about Stimulus controllers in Actions (#143) * Adjust docs - remove reference to standalone actions * Apply suggestions from code review * Update docs/3.0/stimulus-integration.md --------- Co-authored-by: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> --- docs/2.0/stimulus-integration.md | 8 ++++---- docs/3.0/stimulus-integration.md | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/2.0/stimulus-integration.md b/docs/2.0/stimulus-integration.md index 8a4067bc..c3f4f25e 100644 --- a/docs/2.0/stimulus-integration.md +++ b/docs/2.0/stimulus-integration.md @@ -127,9 +127,9 @@ export default class extends Controller { The possible values are `index`, `show`, `edit`, or `new` -## Assign Stimulus controllers to standalone actions +## Assign Stimulus controllers to actions -Similarly as to resource, you can assign stimulus controller to a standalone action (action that has some embedded form). To do that you can use the `stimulus_controllers` option on the action file. +Similarly as to resource, you can assign stimulus controller to an action. To do that you can use the `stimulus_controllers` option on the action file. ```ruby class ShowCurrentTime < Avo::BaseAction @@ -147,7 +147,7 @@ end The same way as for the resources, Avo will add stimulus target data attributes to [all field wrappers](#field-wrappers-as-targets) and [all input fields](#field-inputs-as-targets). -Unlike with the resource, Avo will not add a specific default controller for each type of the view (`index`, `show`, `edit`) as standalone actions are independent from the view type. +Unlike with the resource, Avo will not add a specific default controller for each type of the view (`index`, `show`, `edit`). Same way, the controllers will not receive the `view` attribute in the DOM, [as in case of resources](#all-controllers-receive-the-view-value). ## Attach HTML attributes @@ -680,7 +680,7 @@ export default class extends Controller { ```js // app/javascript/avo.custom.js -import SampleController from 'controllers/sample_controller' +import SampleController from "controllers/sample_controller"; // Hook into the stimulus instance provided by Avo const application = window.Stimulus; diff --git a/docs/3.0/stimulus-integration.md b/docs/3.0/stimulus-integration.md index 88c2e7c4..6fc846c2 100644 --- a/docs/3.0/stimulus-integration.md +++ b/docs/3.0/stimulus-integration.md @@ -127,9 +127,9 @@ export default class extends Controller { The possible values are `index`, `show`, `edit`, or `new` -## Assign Stimulus controllers to standalone actions +## Assign Stimulus controllers to actions -Similarly as to resource, you can assign stimulus controller to a standalone action (action that has some embedded form). To do that you can use the `stimulus_controllers` option on the action file. +Similarly as to resource, you can assign stimulus controller to an action. To do that you can use the `stimulus_controllers` option on the action file. ```ruby class Avo::Actions::ShowCurrentTime < Avo::BaseAction @@ -141,13 +141,13 @@ You can add more and separate them by a space character. ```ruby class Avo::Actions::ShowCurrentTime < Avo::BaseAction - self.stimulus_controllers = "city-in-country select-field association-fields" + self.stimulus_controllers = "course-resource select-field association-fields" end ``` The same way as for the resources, Avo will add stimulus target data attributes to [all field wrappers](#field-wrappers-as-targets) and [all input fields](#field-inputs-as-targets). -Unlike with the resource, Avo will not add a specific default controller for each type of the view (`index`, `show`, `edit`) as standalone actions are independent from the view type. +Unlike with the resource, Avo will not add a specific default controller for each type of the view (`index`, `show`, `edit`). Same way, the controllers will not receive the `view` attribute in the DOM, [as in case of resources](#all-controllers-receive-the-view-value). ## Attach HTML attributes @@ -682,7 +682,7 @@ export default class extends Controller { ```js // app/javascript/avo.custom.js -import SampleController from 'controllers/sample_controller' +import SampleController from "controllers/sample_controller"; // Hook into the stimulus instance provided by Avo const application = window.Stimulus;