Skip to content

Commit 8c25343

Browse files
OJ423gitbook-bot
authored andcommitted
GITBOOK-134: Internal Link Fixes
1 parent 15adbe3 commit 8c25343

File tree

9 files changed

+380
-102
lines changed

9 files changed

+380
-102
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Use TDB Documents
2+

document-ui-sdk/ui-geoJSON/documents-user-interface-geoJSON.md

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
---
2-
description: Understand how <FrameViewer/> can load geoJSON to display geographic data structures in Create, Edit or View Mode
2+
description: >-
3+
Understand how <FrameViewer/> can load geoJSON to display geographic data
4+
structures in Create, Edit or View Mode
35
---
46

5-
## Demo
6-
Click here **[**Playground**](https://documents-ui-playground-geojson.terminusdb.com/Feature)** to view ``<FrameViewier/>`` demo in Create, edit or view mode.
7+
# UI SDK GeoJSON
78

8-
### GeoJSON schema
9-
Below is the schema for loading geoJSON into a TerminusDB data product.
9+
#### Demo
10+
11+
Click here [**Playground**](https://documents-ui-playground-geojson.terminusdb.com/Feature) to view `<FrameViewier/>` demo in Create, edit or view mode.
1012

13+
### GeoJSON Schema
1114

15+
Below is the schema for loading geoJSON into a TerminusDB data product.
1216

1317
```
1418
[
@@ -180,9 +184,9 @@ Below is the schema for loading geoJSON into a TerminusDB data product.
180184
]
181185
```
182186

183-
## GeoJSON Frames
187+
### GeoJSON Frames
184188

185-
The equivalent geoJSON frame that can be retrieved from ``getSchemaFrame()`` call
189+
The equivalent geoJSON frame that can be retrieved from `getSchemaFrame()` call
186190

187191
```json
188192
{
@@ -480,17 +484,13 @@ The equivalent geoJSON frame that can be retrieved from ``getSchemaFrame()`` cal
480484
}
481485
```
482486

483-
<<<<<<< HEAD
484-
#### Demo
485-
Click here **[**Demo**](https://documents-ui-playground-geojson.terminusdb.com/FeatureCollection)** to view ``<FrameViewier/>`` with geoJSON data.
486-
=======
487-
## Demo
488-
Take a look at the [**Demo Playground**](https://documents-ui-playground-geojson.terminusdb.com/) to view ``<FrameViewier/>`` with geoJSON data.
489-
>>>>>>> 2fae9cb51a7cf619fa160fb4154f03dd8eed5c06
487+
### **Demo**
490488

491-
## Example
489+
Take a look at the [**Demo Playground**](https://documents-ui-playground-geojson.terminusdb.com/) to view `<FrameViewier/>` with geoJSON data.
492490

493-
This example shows how to load a `FeartureCollection` into ``<FrameViewier/>``.
491+
### Example
492+
493+
This example shows how to load a `FeartureCollection` into `<FrameViewier/>`.
494494

495495
> Note: In View mode we display the map view of geoJSONs using react-leaflets under the hood.
496496
@@ -503,9 +503,3 @@ import { FrameViewer } from '@terminusdb/terminusdb-documents-ui'
503503
mode={"Create"} // mode
504504
type={"FeartureCollection"}/> // type of document
505505
```
506-
507-
508-
509-
510-
511-
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
---
2+
description: Create UIs directly from TerminusDB's schema
3+
---
4+
5+
# Use the Document UI SDK
6+
7+
Use the TerminusDB documents User Interface (UI) utility `terminusdb-documents-ui` to automatically generate customizable user interfaces for the document definitions in your TerminusDB schema. The utility takes frames as input and outputs forms in HTML format. A frame is the JSON structure of a JSON document, including the document's inherited properties and IRIs.
8+
9+
### Install and import
10+
11+
Install the utility from `npm`:
12+
13+
```
14+
npm install @terminusdb/terminusdb-documents-ui --save
15+
```
16+
17+
Import the `FrameViewer` component into your code:
18+
19+
```
20+
import {FrameViewer} from '@terminusdb/terminusdb-documents-ui'
21+
```
22+
23+
### The FrameViewer object
24+
25+
Use the `FrameViewer` object of `terminusdb-documents-ui` to configure, customize, and display your forms. `FrameViewer` supports several parameters and functions.
26+
27+
#### FrameViewer parameters
28+
29+
| **Parameter** | **Description** |
30+
| ------------- | ------------------------------------------------------------------------------------------------------------ |
31+
| `frame` | The JSON frame structure of a TerminusDB schema. |
32+
| `uiFrame` | JSON UI properties to customize the appearance of a form. |
33+
| `type` | The document type definition in your schema to display the form for. |
34+
| `mode` | Form modes - `Create`, `Edit`, or `View`. |
35+
| `formData` | The data entered into or provided for a form. Specify `formData` in `Edit` and `View` modes to display data. |
36+
| `hideSubmit` | Hide the `Submit` button to show view-only data. |
37+
38+
#### FrameViewer functions
39+
40+
| **Function** | **Description** |
41+
| --------------- | ---------------------------------------------------------------------------------------------------- |
42+
| `onSubmit` | A customizable JavaScrpt (JS) callback function to process data submitted via a form. |
43+
| `onChange` | A customizable JS callback function to process data when form data is changed. |
44+
| `onSelect` | JS callback function to retrieve the selected values from a `Select` component. |
45+
| `onTraverse` | Return the ID of a document on a click event. Useful for binding an `onClick` event with a document. |
46+
| `FieldTemplate` | Customize the appearance of a form. |
47+
48+
### FrameViewer common usage
49+
50+
A common use of `terminusdb-documents-ui` is as follows:
51+
52+
1. Set up a Webpack.
53+
2. Use the [TerminusDB JavaScript client](../../guides/reference-guides/javascript-client-reference/woqlclient.md).
54+
3. Use the client function `getSchemaFrame` to retrieve frame data from a TerminusDB database.
55+
4. Set custom values and behaviour for `FrameViewer` parameters and functions as required.
56+
5. Call `FrameViewer` to display frame data in the specified form.
57+
58+
### Get schema frame data from a database
59+
60+
A basic example below to get started with a TerminusDB JavaScript client.
61+
62+
```javascript
63+
const TerminusDBClient = require("@terminusdb/terminusdb-client");
64+
65+
import {FrameViewer} from '@terminusdb/terminusdb-documents-ui'
66+
67+
try {
68+
let type = "Person" // type is the a document class of interest
69+
let frames = await woqlClient.getSchemaFrame(type, woqlClient.db())
70+
console.log(`Frames generated from ${woqlClient.db()}`, frames)
71+
} catch(err) {
72+
console.log("Error fetching frames", err)
73+
}
74+
```
75+
76+
### FrameViewer usage step-by-step
77+
78+
Use three simple steps - input, configure, and output:
79+
80+
[Step 1. Create frame data](./#step-1.-create-frame-data)
81+
82+
[Step 2. Configure properties and functions](./#step-2.-configure-properties-and-functions)
83+
84+
[Step 3. Generate the form](./#step-3.-generate-the-form)
85+
86+
#### Step 1. Create frame data
87+
88+
For simplicity, all examples use the `frames` definition below consisting of one document `Person`.
89+
90+
```javascript
91+
let frames = {
92+
"@context": {
93+
"@base": "terminusdb:///data/",
94+
"@schema": "terminusdb:///schema#",
95+
"@type": "@context"
96+
},
97+
"Person": {
98+
"@key": {
99+
"@type": "Random"
100+
},
101+
"@type": "Class",
102+
"DOB": "xsd:dateTime",
103+
"active": "xsd:boolean",
104+
"age": "xsd:decimal",
105+
"name": "xsd:string"
106+
}
107+
}
108+
109+
// The document to display the frame for.
110+
111+
let type = "Person"
112+
```
113+
114+
#### Step 2. Configure properties and functions
115+
116+
The example below generates an empty frame for the attributes of the `Person` document. The callback function `handleSubmit` displays any user-entered form data. Add functionality to `handleSubmit` to suit your requirements. The `uiFrames` parameter in the example adds customizations for your forms. See Customize the looks and feel of frames for details.
117+
118+
```javascript
119+
// Create a place holder for the "Person" "name" property.
120+
121+
let uiFrames = {
122+
"name" : {
123+
"placeholder": "Please enter a name ..."
124+
}
125+
}
126+
127+
// Mode "Create" displays an empty frame.
128+
129+
let mode = "Create"
130+
131+
// Callback to display form data.
132+
133+
function handleSubmit(data) {
134+
console.log("Form data: ", data)
135+
}
136+
```
137+
138+
#### Step 3. Generate the form
139+
140+
Generate the form using the properties and functions defined in the previous step.
141+
142+
```javascript
143+
// Generate the form.
144+
145+
return <FrameViewer
146+
frame = {frames}
147+
uiFrame = {uiFrames}
148+
type = {type}
149+
onSelect = {handleSelect}
150+
mode = {mode}
151+
onSubmit = {handleSubmit}/>
152+
```
153+
154+
**Screen-print/s of the output:**
155+
156+
![](../../.gitbook/assets/documents-ui-get-started-01.PNG)
157+
158+
### FrameViewer modes
159+
160+
The `FrameViewer` object supports three modes:
161+
162+
* [Create](./#create-mode)
163+
* [Edit](./#edit-mode)
164+
* [View](./#view-mode)
165+
166+
#### Create mode
167+
168+
The `Create` mode displays an empty frame as demonstrated in the previous example.
169+
170+
#### Edit mode
171+
172+
The `Edit` mode displays populated and empty frames. This mode requires the `formData` parameter.
173+
174+
```javascript
175+
// Mode "Edit" displays a frame with editable data.
176+
177+
let mode = "Edit"
178+
179+
// Add form data to populate the frame.
180+
181+
let formData = {
182+
"@id": "Person/John%20Doe",
183+
"@type": "Person",
184+
first_name: "John",
185+
last_name: "Doe",
186+
age: "17",
187+
active: true,
188+
DOB: "2022-03-31T10:01:11.000Z"
189+
}
190+
191+
// Callback to display form data.
192+
193+
function handleSubmit(data) {
194+
console.log("Form data: ", data)
195+
}
196+
197+
// Generate the form with formData paramter.
198+
199+
return <FrameViewer
200+
frame = {frames}
201+
type = {type}
202+
onSelect = {handleSelect}
203+
mode = {mode}
204+
formData = {formData}
205+
onSubmit = {handleSubmit}/>
206+
```
207+
208+
**Screen-print/s of the output:**
209+
210+
![](<../../.gitbook/assets/documents-ui-get-started-02 (2).PNG>)
211+
212+
#### View Mode
213+
214+
The `View` mode displays populated frames for view-only - the **Submit** button is automatically hidden. If the `formData` parameter is omitted, an empty form is displayed.
215+
216+
```javascript
217+
// Mode "View" displays populated frames.
218+
219+
let mode = "View"
220+
221+
// Add form data to populate the frame.
222+
223+
let formData = {
224+
"@id": "Person/John%20Doe",
225+
"@type": "Person",
226+
first_name: "John",
227+
last_name: "Doe",
228+
age: "17",
229+
active: true,
230+
DOB: "2022-03-31T10:01:11.000Z"
231+
}
232+
233+
// Callback to display form data.
234+
235+
function handleSubmit(data) {
236+
console.log("Form data: ", data)
237+
}
238+
239+
// Generate the form with formData paramter.
240+
241+
return <FrameViewer
242+
frame = {frames}
243+
type = {type}
244+
onSelect = {handleSelect}
245+
mode = {mode}
246+
formData = {formData}
247+
onSubmit = {handleSubmit}/>
248+
```
249+
250+
**Screen-print/s of the output:**
251+
252+
![](<../../.gitbook/assets/documents-ui-get-started-03 (1).PNG>)
253+
254+
### Further Reading
255+
256+
The Document UI SDK reference guide:
257+
258+
[**Documents UI SDK data types**](documents-user-interface-data-types.md).
259+
260+
[**Documents UI SDK customization**](documents-user-interface-customization.md)**.**
261+
262+
[**Documents UI SDK Geographic Maps**](documents-user-interface-geographic-maps.md)**.**
263+
264+
[**TerminusDB JavaScript client reference guide**](../../guides/reference-guides/javascript-client-reference/woqlclient.md)**.**
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# UI SDK Data Types
2+

guides/reference-guides/document-ui-templates/components/EditDocumentComponent.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# Edit Document Component
2-
The `EditDocumentComponent` allows you to edit an existing document using the [FrameViewer](../document-ui-sdk.md) component.
1+
# Edit Documents
2+
3+
The `EditDocumentComponent` allows you to edit an existing document using the [FrameViewer](../../../../document-ui-sdk/use-the-document-ui-sdk/) component.
34

45
## Installation
56

@@ -10,18 +11,21 @@ Install the dependencies from npm
1011
npm install @terminusdb/terminusdb-react-table
1112
npm install @terminusdb/terminusdb-documents-ui-templates
1213
```
14+
1315
## Properties
14-
| Properties |Description |
15-
|--|--|
16-
|type|The document type|
17-
|documentJson|The document object|
18-
|documentID|The document ID|
19-
|frames|The database Class Frame, or object of all class frames |
20-
|closeButtonClick|A function that acts as a callback when the panel exit `x` button is clicked|
21-
|updateDocument| A function that acts as a callback when the `submit` button is clicked|
22-
|SearchComponent| A react component used as search component |
16+
17+
| Properties | Description |
18+
| ---------------- | ---------------------------------------------------------------------------- |
19+
| type | The document type |
20+
| documentJson | The document object |
21+
| documentID | The document ID |
22+
| frames | The database Class Frame, or object of all class frames |
23+
| closeButtonClick | A function that acts as a callback when the panel exit `x` button is clicked |
24+
| updateDocument | A function that acts as a callback when the `submit` button is clicked |
25+
| SearchComponent | A react component used as search component |
2326

2427
## Example
28+
2529
```js
2630
import React, {useEffect} from "react";
2731
import {EditDocumentComponent,useTDBDocuments} from "@terminusdb/terminusdb-documents-ui-template"
@@ -77,9 +81,8 @@ export const DocumentEdit = ({type, documentID, tdbClient}) => {
7781
}
7882
```
7983

80-
View the EditDocumentComponent component integrated inside a dashboard here
84+
View the EditDocumentComponent component integrated inside a dashboard here
8185

8286
[EditDocumentComponent full example JS code](https://github.com/terminusdb/dashboard-examples-sandbox/blob/main/terminusdb-documents-ui-template-example/dashboard-demo/src/pages/DocumentEdit.js)
8387

8488
[Code Sandbox](https://codesandbox.io/s/github/terminusdb/dashboard-examples-sandbox/tree/main/terminusdb-documents-ui-template-example/dashboard-demo)
85-

0 commit comments

Comments
 (0)