Class: DataObjectView

DataObjectView()

A view that downloads and displays a DataONE object. Currently there is support for displaying CSV files as a table.

Screenshot

Constructor

new DataObjectView()

Since:
  • 2.32.0
Source:

Extends

  • Backbone.View

Members

alertTemplate :UnderscoreTemplate

The template for the alert message
Type:
  • UnderscoreTemplate
Source:

className

Source:

formatMap :object

The data formats that are supported by this view, mapped to the functions that render them, i.e. { renderFunction: [format1, format2] }. Formats should include all relevant DataONE object formats as well as the possible Content-Type values from the headers of the response.
Type:
  • object
Source:

loadingTemplate :UnderscoreTemplate

The template for the loading spinner
Type:
  • UnderscoreTemplate
Source:

sizeLimit :number|null

The file size limit for viewing files, in bytes. If the file is larger than this limit, the object will not be displayed. Default is 20 megabytes.
Type:
  • number | null
Source:

tagName

Source:

type

Source:

Methods

downloadObject() → {Promise}

Downloads the DataONE object
Source:
Returns:
Promise that resolves with the Response from DataONE
Type
Promise

fetchMetadata(callback)

Fetches the metadata for the object
Parameters:
Name Type Description
callback function The function to call when the metadata is fetched
Source:

handleResponse(response)

Handle the response from the DataONE object API. Renders the data and shows the download button if the response is successful.
Parameters:
Name Type Description
response Response The response from the DataONE object API
Source:

hasRequiredMetadata() → {boolean}

Checks if the model has the required metadata fields
Source:
Returns:
True if the model has the required metadata fields and they are not empty
Type
boolean

hideLoading()

Remove the loading spinner
Source:

initialize(options)

Initializes the DataObjectView
Parameters:
Name Type Description
options object Options for the view
Properties
Name Type Attributes Description
model SolrResult A SolrResult model
id string The ID of the DataONE object to view. Used to create a SolrResult model if one is not provided.
buttonContainer Element <optional>
The container for the download button (defaults to the view's element)
Source:

isValidSizeAndFormat() → {boolean|object}

Checks if the size and format of the object are valid
Source:
Returns:
True if the size and format are valid, or an object with error messages if they are not
Type
boolean | object

render()

Source:

renderDownloadButton()

Renders a download button
Source:

renderObject(response)

With the already fetched DataONE object, check the format and render the object accordingly.
Parameters:
Name Type Description
response Response The response from the DataONE object API
Source:

renderTable(response)

Shows the CSV file as a table
Parameters:
Name Type Description
response Response The response from the DataONE object API
Source:

showError(message)

Display an error message to the user
Parameters:
Name Type Description
message string The error message to display
Source:

showLoading(messageopt)

Indicate that the data is loading
Parameters:
Name Type Attributes Description
message string <optional>
The message to display while loading
Source: