From e784529c64e231244c6a411eaa8fbd72572d519f Mon Sep 17 00:00:00 2001 From: Serhii Pylypchuk Date: Mon, 5 Aug 2024 18:04:59 +0400 Subject: [PATCH] Update guides related to integration with Vue and React --- docs/guides/integration_with_react.md | 10 +- docs/guides/integration_with_vue.md | 230 ++++++++++++++------------ 2 files changed, 132 insertions(+), 108 deletions(-) diff --git a/docs/guides/integration_with_react.md b/docs/guides/integration_with_react.md index cde2d43..0197a35 100644 --- a/docs/guides/integration_with_react.md +++ b/docs/guides/integration_with_react.md @@ -115,7 +115,7 @@ export default function ToDoComponent(props) { return
-
+
} ~~~ @@ -173,8 +173,8 @@ import ToDo from "./ToDo"; import { getData } from "./data"; function App() { - const { tasks, users, projects } = getData(); - return ; + const { tasks, users, projects } = getData(); + return ; } export default App; @@ -212,7 +212,7 @@ export default function ToDoComponent(props) { return
-
+
} ~~~ @@ -250,7 +250,7 @@ export default function ToDoComponent(props) { return
-
+
} ~~~ diff --git a/docs/guides/integration_with_vue.md b/docs/guides/integration_with_vue.md index 88318ea..ddf6d59 100644 --- a/docs/guides/integration_with_vue.md +++ b/docs/guides/integration_with_vue.md @@ -64,18 +64,18 @@ Download the [**trial To Do List package**](/how_to_start/#installing-to-do-list ### Step 2. Component creation -Now you need to create a Vue component, to add a To Do List into the application. Create a new file in the ***src/components/*** directory and name it ***ToDo.vue***. +Now you need to create a Vue component, to add a To Do List with Toolbar into the application. Create a new file in the ***src/components/*** directory and name it ***ToDo.vue***. -#### Importing source files +#### Import source files -Open the ***ToDo.vue*** file and import ToDo source files. Note that: +Open the ***ToDo.vue*** file and import To Do List source files. Note that: - if you use PRO version and install the To Do List package from a local folder, the import paths look like this: ~~~html title="ToDo.vue" ~~~ @@ -85,65 +85,46 @@ Note that depending on the used package, the source files can be minified. In th ~~~html title="ToDo.vue" ~~~ In this tutorial you can see how to configure the **trial** version of To Do List. -#### Setting the container and adding To Do List +#### Setting containers and adding To Do List with Toolbar -To display To Do List on the page, you need to set the container to render the component inside. Check the code below: +To display To Do List with Toolbar on the page, you need to create containers for To Do List and Toolbar, and initialize these components using the corresponding constructors: -~~~html {7-9} title="ToDo.vue" +~~~html {2,7-8,10-14} title="ToDo.vue" - - -~~~ - -Then you need to render To Do List in the container. Use the `new ToDo()` constructor inside the `mounted()` method of Vue to initialize To Do List inside of the container: - -~~~html title="ToDo.vue" - - - -~~~ - -To clear the component as it has unmounted, use the `this.todo.destructor()` method and remove the container inside the `unmounted()` method of ***Vue.js***, as follows: - -~~~html {8-11} title="ToDo.vue" - ~~~ @@ -151,7 +132,7 @@ To clear the component as it has unmounted, use the `this.todo.destructor()` met To add data into the To Do List, you need to provide a data set. You can create the ***data.js*** file in the ***src/*** directory and add some data into it: -~~~jsx title="data.js" +~~~jsx {2,19,28,38} title="data.js" export function getData() { const tasks = [ { @@ -197,20 +178,20 @@ Then open the ***App.vue*** file, import data, and initialize it via the inner ` ~~~html {3,7-14,19} title="App.vue" ~~~ -Open the ***ToDo.vue*** file and apply the passed **props** to the To Do List configuration object: +Go to the ***ToDo.vue*** file and apply the passed **props** to the To Do List configuration object: -~~~html {4,8-10} title="ToDo.vue" +~~~html {6,10-12} title="ToDo.vue" - + ~~~ You can also use the [`parse()`](/api/methods/parse_method/) method inside the `mounted()` method of Vue to load data into To Do List: -~~~html {4,8-12} title="ToDo.vue" +~~~html {6,16-20} title="ToDo.vue" - + ~~~ +The `this.todo.parse(data)` method provides data reloading on each applied change. + Now the To Do List component is ready. When the element will be added to the page, it will initialize the To Do List object with data. You can provide necessary configuration settings as well. Visit our [To Do List API docs](/api/overview/configs_overview/) to check the full list of available properties. #### Handling events @@ -269,18 +288,23 @@ When a user makes some action in the To Do List, it invokes an event. You can us Open ***ToDo.vue*** and complete the `mounted()` method: -~~~html {7-9} title="ToDo.vue" +~~~html {8-10} title="ToDo.vue" @@ -309,7 +333,7 @@ export default { ~~~