/ui/utils/jsonDataview

The jsonDataview module exports as default an object with a create method for JSON dataviews.

Requires

Methods

(async, inner) create(dataview)

The create [json] dataview method sets default props for the creation of a jsoneditor dataview element.

The setData method is assign to set the json content of the jsoneditor element.

The setData method will be called if data is provided with the dataview object.

Parameters:
NameTypeDescription
dataviewdataview

Dataview object.

Properties
NameTypeDescription
dataview.dataobject

A JSON data object to be assigned as data to the Json dataview.

dataview.propsobject

Custom properties for the jsoneditor element.

(inner) jsonfile(dataview) → {HTMLElement}

The button method creates a button element.

The button will call the textFile utility method to create a json file download.

Parameters:
NameTypeDescription
dataviewdataview

Dataview object.

Returns:

Returns the button element.

Type: 
HTMLElement

(inner) setData(data)

The [json] dataview setData method calls the set method of the dataview.jsoneditor control to set the data as json content.

Parameters:
NameTypeDescription
dataObject

JSON data.

(inner) sqlinsert(dataview) → {HTMLElement}

The sqlinsert toolbar function makes the JSONEditor writable. The text content will be passed as POST body to the query defined in the sqlinsert configuration.

"toolbar": {
  "sqlinsert": {
    "layer_template": "scratch",
    "template": "sql_table_insert",
    "table": "sql_insert"
  }
}

The default sql_table_insert query module can be used to securely load a JSON body into a SQL table.

Parameters:
NameTypeDescription
dataviewdataview

Dataview object.

Returns:

Returns the button element.

Type: 
HTMLElement