@lowdefy/docs 4.0.0-alpha.7 → 4.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/dist/operators/client/filter_default_value.js +55 -0
  2. package/{public/modules/connectDocsearch.js → dist/operatorsClient.js} +1 -19
  3. package/{templates/blocks/schemaTransformer.js → dist/types.js} +5 -10
  4. package/package.json +19 -3
  5. package/404.yaml +0 -26
  6. package/CHANGELOG.md +0 -697
  7. package/actions/CallMethod.yaml +0 -57
  8. package/actions/JsAction.yaml +0 -281
  9. package/actions/Link.yaml +0 -120
  10. package/actions/Login.yaml +0 -123
  11. package/actions/Logout.yaml +0 -44
  12. package/actions/Message.yaml +0 -68
  13. package/actions/Notification.yaml +0 -84
  14. package/actions/Request.yaml +0 -70
  15. package/actions/Reset.yaml +0 -42
  16. package/actions/ResetValidation.yaml +0 -102
  17. package/actions/ScrollTo.yaml +0 -100
  18. package/actions/SetGlobal.yaml +0 -78
  19. package/actions/SetState.yaml +0 -85
  20. package/actions/Throw.yaml +0 -89
  21. package/actions/Validate.yaml +0 -104
  22. package/actions/Wait.yaml +0 -40
  23. package/blocks/all_icons.yaml +0 -803
  24. package/blocks/container/Affix.yaml +0 -26
  25. package/blocks/container/Alert.yaml +0 -27
  26. package/blocks/container/Badge.yaml +0 -27
  27. package/blocks/container/Box.yaml +0 -27
  28. package/blocks/container/Card.yaml +0 -29
  29. package/blocks/container/Collapse.yaml +0 -38
  30. package/blocks/container/Comment.yaml +0 -43
  31. package/blocks/container/ConfirmModal.yaml +0 -36
  32. package/blocks/container/Descriptions.yaml +0 -51
  33. package/blocks/container/Drawer.yaml +0 -46
  34. package/blocks/container/Label.yaml +0 -28
  35. package/blocks/container/Modal.yaml +0 -46
  36. package/blocks/container/PageHCF.yaml +0 -28
  37. package/blocks/container/PageHCSF.yaml +0 -29
  38. package/blocks/container/PageHSCF.yaml +0 -29
  39. package/blocks/container/PageHeaderMenu.yaml +0 -52
  40. package/blocks/container/PageSHCF.yaml +0 -29
  41. package/blocks/container/PageSiderMenu.yaml +0 -53
  42. package/blocks/container/Result.yaml +0 -34
  43. package/blocks/container/Span.yaml +0 -27
  44. package/blocks/container/Spin.yaml +0 -27
  45. package/blocks/container/Tabs.yaml +0 -41
  46. package/blocks/container/Tooltip.yaml +0 -38
  47. package/blocks/display/Anchor.yaml +0 -25
  48. package/blocks/display/Avatar.yaml +0 -23
  49. package/blocks/display/Breadcrumb.yaml +0 -28
  50. package/blocks/display/Button.yaml +0 -43
  51. package/blocks/display/DangerousHtml.yaml +0 -62
  52. package/blocks/display/DangerousMarkdown.yaml +0 -46
  53. package/blocks/display/Divider.yaml +0 -23
  54. package/blocks/display/EChart.yaml +0 -53
  55. package/blocks/display/Html.yaml +0 -50
  56. package/blocks/display/Icon.yaml +0 -23
  57. package/blocks/display/Img.yaml +0 -40
  58. package/blocks/display/Markdown.yaml +0 -31
  59. package/blocks/display/MarkdownWithCode.yaml +0 -46
  60. package/blocks/display/Menu.yaml +0 -48
  61. package/blocks/display/Message.yaml +0 -34
  62. package/blocks/display/MobileMenu.yaml +0 -47
  63. package/blocks/display/Notification.yaml +0 -34
  64. package/blocks/display/Paragraph.yaml +0 -30
  65. package/blocks/display/Progress.yaml +0 -52
  66. package/blocks/display/Skeleton.yaml +0 -27
  67. package/blocks/display/Statistic.yaml +0 -35
  68. package/blocks/display/Title.yaml +0 -32
  69. package/blocks/input/AutoComplete.yaml +0 -30
  70. package/blocks/input/ButtonSelector.yaml +0 -36
  71. package/blocks/input/CheckboxSelector.yaml +0 -36
  72. package/blocks/input/CheckboxSwitch.yaml +0 -56
  73. package/blocks/input/ChromeColorSelector.yaml +0 -24
  74. package/blocks/input/CircleColorSelector.yaml +0 -24
  75. package/blocks/input/ColorSelector.yaml +0 -24
  76. package/blocks/input/CompactColorSelector.yaml +0 -24
  77. package/blocks/input/DateRangeSelector.yaml +0 -26
  78. package/blocks/input/DateSelector.yaml +0 -26
  79. package/blocks/input/DateTimeSelector.yaml +0 -28
  80. package/blocks/input/GithubColorSelector.yaml +0 -24
  81. package/blocks/input/MonthSelector.yaml +0 -26
  82. package/blocks/input/MultipleSelector.yaml +0 -117
  83. package/blocks/input/NumberInput.yaml +0 -24
  84. package/blocks/input/Pagination.yaml +0 -33
  85. package/blocks/input/ParagraphInput.yaml +0 -32
  86. package/blocks/input/PasswordInput.yaml +0 -48
  87. package/blocks/input/RadioSelector.yaml +0 -36
  88. package/blocks/input/RatingSlider.yaml +0 -24
  89. package/blocks/input/S3UploadButton.yaml +0 -28
  90. package/blocks/input/Selector.yaml +0 -98
  91. package/blocks/input/SliderColorSelector.yaml +0 -24
  92. package/blocks/input/SwatchesColorSelector.yaml +0 -24
  93. package/blocks/input/Switch.yaml +0 -24
  94. package/blocks/input/TextArea.yaml +0 -27
  95. package/blocks/input/TextInput.yaml +0 -59
  96. package/blocks/input/TitleInput.yaml +0 -32
  97. package/blocks/input/TwitterColorSelector.yaml +0 -24
  98. package/blocks/input/WeekSelector.yaml +0 -26
  99. package/blocks/list/ControlledList.yaml +0 -191
  100. package/blocks/list/List.yaml +0 -157
  101. package/blocks/list/TimelineList.yaml +0 -136
  102. package/body.html +0 -1
  103. package/concepts/blocks.yaml +0 -249
  104. package/concepts/cli.yaml +0 -173
  105. package/concepts/connections-and-requests.yaml +0 -114
  106. package/concepts/context-and-state.yaml +0 -82
  107. package/concepts/custom-blocks.yaml +0 -190
  108. package/concepts/custom-code.yaml +0 -197
  109. package/concepts/events-and-actions.yaml +0 -224
  110. package/concepts/hosting-files.yaml +0 -50
  111. package/concepts/layout.yaml +0 -1464
  112. package/concepts/lists.yaml +0 -162
  113. package/concepts/lowdefy-schema.yaml +0 -245
  114. package/concepts/operators.yaml +0 -66
  115. package/concepts/overview.yaml +0 -48
  116. package/concepts/secrets.yaml +0 -56
  117. package/connections/AWSS3.yaml +0 -228
  118. package/connections/AmazonRedshift.yaml +0 -75
  119. package/connections/AxiosHttp.yaml +0 -194
  120. package/connections/Elasticsearch.yaml +0 -378
  121. package/connections/GoogleSheet.yaml +0 -332
  122. package/connections/Knex.yaml +0 -181
  123. package/connections/KnexRequests.md +0 -121
  124. package/connections/MSSQL.yaml +0 -90
  125. package/connections/MariaDB.yaml +0 -77
  126. package/connections/MongoDB.yaml +0 -581
  127. package/connections/MySQL.yaml +0 -92
  128. package/connections/OracleDB.yaml +0 -73
  129. package/connections/PostgreSQL.yaml +0 -99
  130. package/connections/Redis.yaml +0 -147
  131. package/connections/SQLite.yaml +0 -94
  132. package/connections/SendGridMail.yaml +0 -113
  133. package/connections/Stripe.yaml +0 -139
  134. package/deployment/aws-lambda.yaml +0 -128
  135. package/deployment/docker.yaml +0 -118
  136. package/deployment/netlify.yaml +0 -69
  137. package/deployment/node-server.yaml +0 -111
  138. package/head.html +0 -7
  139. package/howto/generate-csv.yaml.njk +0 -252
  140. package/howto/generate-pdf.yaml.njk +0 -651
  141. package/howto/generateCsv/lowdefy.yaml +0 -64
  142. package/howto/generateCsv/public/csvMake.js +0 -27
  143. package/howto/generatePdf/inv_template.yaml +0 -200
  144. package/howto/generatePdf/lowdefy.yaml +0 -117
  145. package/howto/generatePdf/my_header.html +0 -1
  146. package/howto/generatePdf/public/logo_example.png +0 -0
  147. package/howto/generatePdf/public/modules/importUmd.js +0 -7
  148. package/howto/generatePdf/public/modules/pdfMake.js +0 -7
  149. package/howto/generatePdf/public/modules/vfs_fonts.js +0 -12
  150. package/howto/use-refrences.md +0 -5
  151. package/introduction.yaml +0 -100
  152. package/lowdefy.yaml +0 -66
  153. package/menus.yaml +0 -832
  154. package/operators/_actions.yaml +0 -123
  155. package/operators/_and.yaml +0 -90
  156. package/operators/_args.yaml +0 -79
  157. package/operators/_array.yaml +0 -326
  158. package/operators/_base64.yaml +0 -56
  159. package/operators/_change_case.yaml +0 -347
  160. package/operators/_date.yaml +0 -71
  161. package/operators/_diff.yaml +0 -75
  162. package/operators/_divide.yaml +0 -46
  163. package/operators/_eq.yaml +0 -67
  164. package/operators/_event.yaml +0 -103
  165. package/operators/_format.yaml +0 -209
  166. package/operators/_function.yaml +0 -66
  167. package/operators/_get.yaml +0 -108
  168. package/operators/_global.yaml +0 -107
  169. package/operators/_gt.yaml +0 -65
  170. package/operators/_gte.yaml +0 -65
  171. package/operators/_hash.yaml +0 -109
  172. package/operators/_if.yaml +0 -44
  173. package/operators/_if_none.yaml +0 -61
  174. package/operators/_index.yaml +0 -65
  175. package/operators/_input.yaml +0 -114
  176. package/operators/_js.yaml +0 -189
  177. package/operators/_json.yaml +0 -128
  178. package/operators/_list_contexts.yaml +0 -37
  179. package/operators/_location.yaml +0 -59
  180. package/operators/_log.yaml +0 -36
  181. package/operators/_lt.yaml +0 -65
  182. package/operators/_lte.yaml +0 -65
  183. package/operators/_math.yaml +0 -374
  184. package/operators/_media.yaml +0 -86
  185. package/operators/_menu.yaml +0 -81
  186. package/operators/_mql.yaml +0 -101
  187. package/operators/_ne.yaml +0 -77
  188. package/operators/_not.yaml +0 -47
  189. package/operators/_number.yaml +0 -157
  190. package/operators/_nunjucks.yaml +0 -73
  191. package/operators/_object.yaml +0 -193
  192. package/operators/_operator.yaml +0 -47
  193. package/operators/_or.yaml +0 -81
  194. package/operators/_product.yaml +0 -59
  195. package/operators/_random.yaml +0 -104
  196. package/operators/_ref.yaml +0 -266
  197. package/operators/_regex.yaml +0 -83
  198. package/operators/_request.yaml +0 -50
  199. package/operators/_secret.yaml +0 -74
  200. package/operators/_state.yaml +0 -114
  201. package/operators/_string.yaml +0 -283
  202. package/operators/_subtract.yaml +0 -38
  203. package/operators/_sum.yaml +0 -59
  204. package/operators/_switch.yaml +0 -51
  205. package/operators/_type.yaml +0 -92
  206. package/operators/_uri.yaml +0 -56
  207. package/operators/_url_query.yaml +0 -120
  208. package/operators/_user.yaml +0 -107
  209. package/operators/_uuid.yaml +0 -114
  210. package/operators/_var.yaml +0 -105
  211. package/operators/_yaml.yaml +0 -107
  212. package/pages.yaml +0 -227
  213. package/public/images/authors/gervwyk.jpeg +0 -0
  214. package/public/images/authors/sandile.jpeg +0 -0
  215. package/public/images/howto/header_generate_csv.jpg +0 -0
  216. package/public/images/howto/header_generate_pdf.jpg +0 -0
  217. package/public/logo_example.png +0 -0
  218. package/public/lowdefy_app_schema.png +0 -0
  219. package/public/modules/csvMake.js +0 -27
  220. package/public/modules/filterDefaultValue.js +0 -48
  221. package/public/modules/importUmd.js +0 -7
  222. package/public/modules/index.js +0 -5
  223. package/public/modules/pdfMake.js +0 -7
  224. package/public/modules/test/filterDefaultValue.test.js +0 -91
  225. package/public/modules/vfs_fonts.js +0 -12
  226. package/public/sitemap.xml +0 -1024
  227. package/templates/actions.yaml.njk +0 -68
  228. package/templates/blocks/defaultValueTransformer.js +0 -53
  229. package/templates/blocks/exampleTransformer.js +0 -81
  230. package/templates/blocks/layout.yaml +0 -114
  231. package/templates/blocks/propertiesFormTransformer.js +0 -419
  232. package/templates/blocks/propertiesGetterTransformer.js +0 -132
  233. package/templates/blocks/schema.yaml.njk +0 -42
  234. package/templates/blocks/style.yaml +0 -26
  235. package/templates/blocks/template.yaml.njk +0 -495
  236. package/templates/blog.yaml.njk +0 -221
  237. package/templates/cli_command.yaml.njk +0 -37
  238. package/templates/footer.yaml.njk +0 -604
  239. package/templates/general.yaml.njk +0 -124
  240. package/templates/generateSitemap.js +0 -41
  241. package/templates/header.yaml +0 -138
  242. package/templates/navigation_buttons.yaml +0 -68
  243. package/templates/operators.yaml.njk +0 -82
  244. package/templates/operatorsMethodTransformer.js +0 -119
  245. package/templates/test/array.test.js +0 -1335
  246. package/templates/test/boolean.test.js +0 -98
  247. package/templates/test/button.test.js +0 -166
  248. package/templates/test/color.test.js +0 -126
  249. package/templates/test/enum.test.js +0 -105
  250. package/templates/test/icon.test.js +0 -109
  251. package/templates/test/integer.test.js +0 -99
  252. package/templates/test/manual.test.js +0 -238
  253. package/templates/test/number.test.js +0 -99
  254. package/templates/test/object.test.js +0 -434
  255. package/templates/test/oneOf.test.js +0 -794
  256. package/templates/test/string.test.js +0 -98
  257. package/templates/test/yaml.test.js +0 -605
  258. package/tutorial/next-steps.yaml +0 -83
  259. package/tutorial/tutorial-actions-operators-config.yaml +0 -142
  260. package/tutorial/tutorial-actions-operators.yaml +0 -436
  261. package/tutorial/tutorial-add-blocks-config.yaml +0 -109
  262. package/tutorial/tutorial-add-blocks.yaml +0 -195
  263. package/tutorial/tutorial-create-page-config.yaml +0 -77
  264. package/tutorial/tutorial-create-page.yaml +0 -196
  265. package/tutorial/tutorial-deploy.yaml +0 -146
  266. package/tutorial/tutorial-requests-config.yaml +0 -186
  267. package/tutorial/tutorial-requests.yaml +0 -338
  268. package/tutorial/tutorial-start.yaml +0 -282
  269. package/users/login-and-logout.yaml +0 -164
  270. package/users/openid-connect.yaml +0 -84
  271. package/users/protected-pages.yaml +0 -67
  272. package/users/roles.yaml +0 -70
  273. package/users/user-object.yaml +0 -73
  274. package/users/users-introduction.yaml +0 -80
  275. package/version.yaml +0 -1
@@ -1,83 +0,0 @@
1
- # Copyright 2020-2021 Lowdefy, Inc
2
-
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
-
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- _ref:
16
- path: templates/general.yaml.njk
17
- vars:
18
- pageId: next-steps
19
- pageTitle: Next steps
20
- section: Tutorial
21
- prefetchPages:
22
- - overview
23
- filePath: tutorial/next-steps.yaml
24
- content:
25
- - id: body_next_steps
26
- type: MarkdownWithCode
27
- properties:
28
- content: |
29
- Congratulations! You have completed the tutorial and built a sort-of functioning app.
30
-
31
- To carry on from here, you have a couple of options
32
-
33
- ### Join the community
34
-
35
- At our [Github Discussions](https://github.com/lowdefy/lowdefy/discussions) page you can get help with any problems you have, share you ideas, ask questions, and show off the apps you have built.
36
-
37
- ### Understand the concepts
38
-
39
- To get a more in-depth understanding of how everything works, you can start [here](/overview).
40
-
41
- ### Play with blocks
42
-
43
- The docs have an interactive playground where you can adjust a block's properties and see how that affects the block in real time. Go look at what you can do with a [`Button`](/Button).
44
-
45
- ### Look at an example app
46
-
47
- One of the best ways to learn is by doing things for yourself. You can clone an example app that is similar to something you want to build, and start experimenting from there.
48
-
49
- ###### CRUD example
50
-
51
- This example shows patterns to implement a data admin app which allows users to view, create new, edit and delete data records.
52
-
53
- - [Example demo.](https://example-crud.lowdefy.com)
54
- - [App source code.](https://github.com/lowdefy/lowdefy-example-crud)
55
-
56
- ###### Survey example
57
-
58
- This is a simple customer survey example built with Lowdefy. With this example we demonstrate how simple it is to define a public webform and thank you page in Lowdefy.
59
-
60
- - [Example demo.](https://example-survey.lowdefy.com)
61
- - [App source code.](https://github.com/lowdefy/lowdefy-example-survey)
62
-
63
- ###### Case management (ticketing) system example
64
-
65
- This example focuses on building a rich UI for a hypothetical case management app, in a customer relations setting.
66
-
67
- - [Example demo.](https://example-case-management.lowdefy.com)
68
- - [App source code.](https://github.com/lowdefy/lowdefy-example-case-management)
69
-
70
- ###### Movies reporting example
71
-
72
- This example demonstrates useful patterns for building a BI report/dashboard pages in Lowdefy. It connects to a MongoDB database with the Atlas Movies sample dataset pre-loaded.
73
-
74
- - [Example demo.](https://example-reporting.lowdefy.com)
75
- - [App source code.](https://github.com/lowdefy/lowdefy-example-reporting)
76
-
77
- - _ref:
78
- path: templates/navigation_buttons.yaml
79
- vars:
80
- previous_page_title: Requests
81
- previous_page_id: tutorial-requests
82
- next_page_title: Lowdefy overview
83
- next_page_id: overview
@@ -1,142 +0,0 @@
1
- # Copyright 2020-2021 Lowdefy, Inc
2
-
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
-
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- _ref:
16
- path: templates/general.yaml.njk
17
- vars:
18
- pageId: tutorial-actions-operators-config
19
- pageTitle: Interactive pages config
20
- section: Tutorial
21
- filePath: tutorial/tutorial-actions-operators-config.yaml
22
- content:
23
- - id: body_config
24
- type: MarkdownWithCode
25
- properties:
26
- content: |
27
- ##### `lowdefy.yaml`
28
- ```yaml
29
- name: lowdefy-project-template
30
- version: CURRENT_LOWDEFY_VERSION
31
-
32
- menus:
33
- - id: default
34
- links:
35
- - id: new-ticket
36
- type: MenuLink
37
- properties:
38
- icon: AiOutlinedAlert
39
- title: New ticket
40
- pageId: new-ticket
41
- - id: welcome
42
- type: MenuLink
43
- properties:
44
- icon: AiOutlinedHome
45
- title: Home
46
- pageId: welcome
47
-
48
- pages:
49
- - _ref: new-ticket.yaml
50
- - id: welcome
51
- type: PageHeaderMenu
52
- #...
53
- ```
54
-
55
- ##### `new-ticket.yaml`
56
- ```yaml
57
- id: new-ticket
58
- type: PageHeaderMenu
59
- properties:
60
- title: New ticket # The title in the browser tab.
61
- layout:
62
- contentJustify: center # Center the contents of the page.
63
- blocks:
64
- - id: content_card
65
- type: Card
66
- layout:
67
- size: 800 # Set the size of the card so it does not fill the full screen.
68
- contentGutter: 16 # Make a 16px gap between all blocks in this card.
69
- blocks:
70
- - id: page_heading
71
- type: Title
72
- required: true
73
- properties:
74
- content: Log a ticket # Change the title on the page.
75
- level: 3 # Make the title a little smaller (an html `<h3>`).
76
- - id: ticket_title
77
- type: TextInput
78
- required: true
79
- properties:
80
- title: Title
81
- - id: ticket_type
82
- type: ButtonSelector
83
- required: true
84
- properties:
85
- title: Ticket type
86
- options: # Set the allowed options
87
- - Feature request
88
- - Bug report
89
- - Question
90
- - id: ticket_description
91
- type: TextArea
92
- properties:
93
- title: Description
94
- - id: confirm_restart
95
- type: ButtonSelector
96
- visible: # Test if block should be visible to the user
97
- _eq: # Equals operator
98
- - _state: ticket_type # Get the ticket_type value from state.
99
- - Bug report
100
- validate:
101
- # Show a warning that shows before validate is called
102
- # and does not block Validate action.
103
- - status: warning
104
- message: If you did not restart your device, we will ask you to restart it.
105
- pass:
106
- _eq:
107
- - _state: confirm_restart
108
- - Yes
109
- properties:
110
- title: Did you restart your device?
111
- label:
112
- colon: false # Hide the label colon
113
- options:
114
- - Yes
115
- - No
116
- - id: reset_button
117
- type: Button
118
- layout:
119
- span: 12 # Set the size of the button (span 12 of 24 columns)
120
- properties:
121
- title: Reset
122
- block: true # Make the button fill all the space available to it
123
- type: default # Make the button a plain button
124
- icon: AiOutlinedClear
125
- events:
126
- onClick:
127
- - id: reset
128
- type: Reset
129
- - id: submit_button
130
- type: Button
131
- layout:
132
- span: 12
133
- properties:
134
- title: Submit
135
- block: true
136
- type: primary # Make the button a primary button with color
137
- icon: AiOutlinedSave
138
- events:
139
- onClick:
140
- - id: validate
141
- type: Validate
142
- ```
@@ -1,436 +0,0 @@
1
- # Copyright 2020-2021 Lowdefy, Inc
2
-
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
-
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- _ref:
16
- path: templates/general.yaml.njk
17
- vars:
18
- pageId: tutorial-actions-operators
19
- pageTitle: 4. Interactive pages
20
- section: Tutorial
21
- filePath: tutorial/tutorial-actions-operators.yaml
22
- prefetchPages:
23
- - tutorial-requests
24
- content:
25
- - id: tutorial_video
26
- type: DangerousMarkdown
27
- properties:
28
- DOMPurifyOptions:
29
- ADD_TAGS:
30
- - iframe
31
- ADD_ATTR:
32
- - allowfullscreen
33
- - allow
34
- - frameborder
35
- content: |
36
- <iframe
37
- width="800"
38
- height="470"
39
- src="https://www.youtube.com/embed/s1qMpkxHa3Y" frameborder="0"
40
- allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
41
- </iframe>
42
- - id: body_reset
43
- type: MarkdownWithCode
44
- properties:
45
- content: |
46
- If you have been following along, you can continue with your current config. Else, you can find the config from the previous section [here](/tutorial-add-blocks-config).
47
-
48
- ## Configuring the reset button
49
-
50
- The reset button should reset all the user's inputs. To do this, we can add a reset action to the reset button.
51
-
52
- #### Step 4.1 - Configure the reset button
53
-
54
- Copy the following into the definition of the reset button:
55
-
56
- ##### `new-ticket.yaml`
57
- ```yaml
58
- id: new-ticket
59
- # ...
60
- blocks:
61
- - id: content_card
62
- # ...
63
- blocks:
64
- - id: page_heading
65
- # ...
66
- # ...
67
- # ...
68
- - id: reset_button
69
- type: Button
70
- layout:
71
- span: 12
72
- properties:
73
- title: Reset
74
- block: true
75
- type: default
76
- icon: AiOutlinedClear
77
- ################ -------- Copy from here -------- ################
78
- events:
79
- onClick:
80
- - id: reset
81
- type: Reset
82
- ################ -------- Copy to here ---------- ################
83
- - id: submit_button
84
- type: Button
85
- # ...
86
- ```
87
-
88
- If you add some inputs into the form and click the reset button, those inputs should be cleared.
89
-
90
- ### How it works
91
-
92
- Blocks can define events, which they can trigger when certain events happen on the page. You can then define a array of actions, that are executed sequentially when a block triggers an event. The button triggers an event called `onClick` when it gets clicked. We can add an array of action definitions that will be executed when this action is fired. We only added one action, the `Reset` action, that resets the page context to the state it was in when it first loaded.
93
-
94
- ## Required fields
95
-
96
- We should validate the data users are submitting to make sure our app has clean data and works as expected. The `ticket_title` and `ticket_type` fields should be compulsory, and the user should not be able to submit the ticket if they are not completed.
97
-
98
- #### Step 4.2 - Mark fields as required
99
-
100
- To make the fields required, add a required property to the input blocks like this:
101
-
102
- ```yaml
103
- - id: ticket_title
104
- type: TextInput
105
- required: true
106
- properties:
107
- title: Title
108
- ```
109
-
110
- A red star should appear next to each input field, looking like this:
111
- - id: example1
112
- type: TextInput
113
- required: true
114
- properties:
115
- title: Title
116
- - id: body_validate
117
- type: MarkdownWithCode
118
- properties:
119
- content: |
120
- We can now add a `Validate` action to the submit button. This will validate the inputs and give an error if any inputs are not filled in.
121
-
122
- #### Step 4.3 - Add a Validate action
123
-
124
- Add the validate action like this:
125
-
126
- ##### `new-ticket.yaml`
127
- ```yaml
128
- id: new-ticket
129
- # ...
130
- blocks:
131
- - id: content_card
132
- # ...
133
- blocks:
134
- - id: page_heading
135
- # ...
136
- # ...
137
- # ...
138
- - id: submit_button
139
- type: Button
140
- layout:
141
- span: 12
142
- properties:
143
- title: Submit
144
- block: true
145
- type: primary
146
- icon: AiOutlinedSave
147
- ################ -------- Copy from here -------- ################
148
- events:
149
- onClick:
150
- - id: validate
151
- type: Validate
152
- ################ -------- Copy to here ---------- ################
153
- ```
154
-
155
- Now if we click the submit button and all our inputs aren't complete, a message pops up saying we have validation errors on the page. All the fields that have not been completed are highlighted in red.
156
-
157
- The result should look and work like this. The examples in this tutorial are live versions of the tutorial app, so you can verify that they work like your own app.
158
- - id: example2
159
- type: PageHeaderMenu
160
- properties:
161
- style:
162
- minHeight: 300px
163
- menu:
164
- links: []
165
- blocks:
166
- - id: content_card
167
- type: Card
168
- layout:
169
- contentGutter: 16
170
- blocks:
171
- - id: page_heading
172
- type: Title
173
- properties:
174
- content: Log a ticket
175
- level: 3
176
- - id: ticket_title
177
- type: TextInput
178
- required: true
179
- properties:
180
- title: Title
181
- - id: ticket_type
182
- type: ButtonSelector
183
- required: true
184
- properties:
185
- title: Ticket type
186
- options:
187
- - Feature request
188
- - Bug report
189
- - Question
190
- - id: ticket_description
191
- type: TextArea
192
- properties:
193
- title: Description
194
- - id: reset_button
195
- type: Button
196
- layout:
197
- span: 12
198
- properties:
199
- title: Reset
200
- block: true
201
- type: default
202
- icon: AiOutlinedClear
203
- events:
204
- onClick:
205
- - id: reset
206
- type: Reset
207
- - id: submit_button
208
- type: Button
209
- layout:
210
- span: 12
211
- properties:
212
- title: Submit
213
- block: true
214
- type: primary
215
- icon: AiOutlinedSave
216
- events:
217
- onClick:
218
- - id: validate
219
- type: Validate
220
- - id: body_visible
221
- type: MarkdownWithCode
222
- properties:
223
- renderHtml: true
224
- content: |
225
- ### How it works
226
-
227
- The validate action we added to the submit button evaluates all the input blocks on the page, and gives an error if any of them fail the validation. This will also stop the execution of any actions after that action. This means we won't insert the data into our database later. The first time a validate action is called on a page it sets a flag that tells all the input blocks to show their validation errors.
228
-
229
- ## Hiding blocks
230
-
231
- We would like to ask users if they restarted their device if they want to create a bug report. To do this we will add a input block with a `visible` property. This property expects a boolean value, so we will use the [`_eq`](/_eq) [`operator`](/operators) to test if the ticket type is equal to `Bug report`
232
-
233
- #### Step 4.4 - Add a block with a visible condition
234
- Add the following [`ButtonSelector`](ButtonSelector) to your app.
235
-
236
- ##### `pages/new-ticket.yaml`
237
- ```yaml
238
- id: new-ticket
239
- # ...
240
- blocks:
241
- - id: content_card
242
- # ...
243
- blocks:
244
- # ...
245
- - id: ticket_description
246
- type: TextArea
247
- properties:
248
- title: Description
249
- ################ -------- Copy from here -------- ################
250
- - id: confirm_restart
251
- type: ButtonSelector
252
- visible: # Test if block should be visible to the user
253
- _eq: # Equals operator
254
- - _state: ticket_type # Get the ticket_type value from state.
255
- - Bug report
256
- properties:
257
- title: Did you restart your device?
258
- label:
259
- colon: false # Hide the label colon
260
- options:
261
- - Yes
262
- - No
263
- ################ -------- Copy to here ---------- ################
264
- - id: reset_button
265
- type: Button
266
- ```
267
-
268
- If you select the "Bug report" ticket type, the selector confirming if you restarted your device should appear.
269
-
270
- ### How it works
271
-
272
- If the visible field value is `false`, the block won't be rendered. To change this value while our app is running, we use an operator. Operators evaluate every time something in the app changes, like when a user provides an input.
273
-
274
- We used the [`_eq`](/_eq) operator to check the ticket type is 'Bug report'.
275
-
276
- To get the value of the `ticket_type` input, we use the [`_state`](/_state) operator. This get a value from the page's [`state`](/context-and-state). _The `state` is an object where data the app needs is stored_. All inputs automatically write their values to state, and you can also set values in `state` by using the [`SetState`](/SetState) action.
277
-
278
- ## Validation rules
279
-
280
- We would like to add a validation rule on the `confirm_restart` block to warn users that they should restart their device before creating a bug report.
281
-
282
- #### Step 4.5 - Add a validation rule
283
-
284
- Add the following to your app
285
- ##### `pages/new-ticket.yaml`
286
- ```yaml
287
- id: new-ticket
288
- # ...
289
- blocks:
290
- - id: content_card
291
- # ...
292
- blocks:
293
- # ...
294
- - id: confirm_restart
295
- type: ButtonSelector
296
- visible: # Test if block should be visible to the user
297
- _eq: # Equals operator
298
- - _state: ticket_type # Get the ticket_type value from state.
299
- - Bug report
300
- ################ ------- Copy from here -------- ################
301
- validate:
302
- # Show a warning that shows before validate is called
303
- # and does not block Validate action.
304
- - status: warning
305
- message: If you did not restart your device, we will ask you to restart it.
306
- pass:
307
- _eq:
308
- - _state: confirm_restart
309
- - Yes
310
- ################ -------- Copy to here ---------- ################
311
- properties:
312
- title: Did you restart your device?
313
- label:
314
- colon: false # Hide the label colon
315
- options:
316
- - Yes
317
- - No
318
- ```
319
-
320
- Your app should now show a warning message if `confirm_restart` is not yes.
321
-
322
- ### How it works
323
-
324
- The `validate` field contains an array of validation rules that can be evaluated using operators.
325
-
326
- If the pass field receives `true`, the rule passes and nothing happens. If the rule fails and the status is error, the `Validate` action will fail, like it did for required fields. If the status is warning, a warning will be shown to the user, but the `Validate` action will still pass.
327
-
328
- Your final new ticket page should look and work like this:
329
-
330
- - id: example3
331
- type: PageHeaderMenu
332
- properties:
333
- style:
334
- minHeight: 300px
335
- menu:
336
- links: []
337
- events:
338
- onInit:
339
- - id: init
340
- type: SetState
341
- params:
342
- example3_number_of_attendees: 2 - 3
343
- example3_ticket_type: Bug report
344
- blocks:
345
- - id: example3_content_card
346
- type: Card
347
- layout:
348
- contentGutter: 16
349
- blocks:
350
- - id: page_heading
351
- type: Title
352
- required: true
353
- properties:
354
- content: Log a ticket # Change the title on the page.
355
- level: 3 # Make the title a little smaller (an html `<h3>`).
356
- - id: ticket_title
357
- type: TextInput
358
- required: true
359
- properties:
360
- title: Title
361
- - id: ticket_type
362
- type: ButtonSelector
363
- required: true
364
- properties:
365
- title: Ticket type
366
- options: # Set the allowed options
367
- - Feature request
368
- - Bug report
369
- - Question
370
- - id: ticket_description
371
- type: TextArea
372
- properties:
373
- title: Description
374
- - id: confirm_restart
375
- type: ButtonSelector
376
- visible: # Test if block should be visible to the user
377
- _eq: # Equals operator
378
- - _state: ticket_type # Get the ticket_type value from state.
379
- - Bug report
380
- validate:
381
- - status: warning # Show a warning that shows before validate is called and does not block Validate action.
382
- message: If you did not restart your device, we will ask you to restart it.
383
- pass:
384
- _eq:
385
- - _state: confirm_restart
386
- - Yes
387
- properties:
388
- title: Did you restart your device?
389
- label:
390
- colon: false # Hide the label colon
391
- options:
392
- - Yes
393
- - No
394
- - id: reset_button
395
- type: Button
396
- layout:
397
- span: 12 # Set the size of the button (span 12 of 24 columns)
398
- properties:
399
- title: Reset
400
- block: true # Make the button fill all the space available to it
401
- type: default # Make the button a plain button
402
- icon: AiOutlinedClear
403
- events:
404
- onClick:
405
- - id: reset
406
- type: Reset
407
- - id: submit_button
408
- type: Button
409
- layout:
410
- span: 12
411
- properties:
412
- title: Submit
413
- block: true
414
- type: primary # Make the button a primary button with color
415
- icon: AiOutlinedSave
416
- events:
417
- onClick:
418
- - id: validate
419
- type: Validate
420
- - id: body_up_next
421
- type: MarkdownWithCode
422
- properties:
423
- content: |
424
- > You can find the final configuration files for this section [here](tutorial-actions-operators-config).
425
-
426
- ## Up next
427
-
428
- Our app doesn't save the form data anywhere when the submit button is clicked. In the next section we will set up a Google Sheets connection, and make a request to save the data in the sheet.
429
-
430
- - _ref:
431
- path: templates/navigation_buttons.yaml
432
- vars:
433
- previous_page_title: Adding blocks
434
- previous_page_id: tutorial-add-blocks
435
- next_page_title: Requests
436
- next_page_id: tutorial-requests