Class: EditorView

EditorView()

A basic shell of a view, primarily meant to be extended for views that allow editing capabilities.

Constructor

new EditorView()

Source:

Extends

  • Backbone.View

Members

accessPolicyControlContainer :string

The selector for the HTML element that will contain a button/link/control for opening the AccessPolicyView modal window. If this element doesn't exist on the page, then the AccessPolicyView will be inserted into the `accessPolicyViewContainer` directly, rather than a modal window.
Type:
  • string
Source:

accessPolicyModalID :string

The text to use in the editor submit button
Type:
  • string
Source:

accessPolicyViewContainer :string

The selector for the HTML element that will contain the AccessPolicyView. If this element doesn't exist on the page, then the AccessPolicyView will not be inserted into the page. If a `accessPolicyControlContainer` element is on the page, then this element will contain the modal window element.
Type:
  • string
Source:

editorSubmitMessageTemplate

References to templates for this view. HTML files are converted to Underscore.js templates
Source:

el :string|DOMElement

The element this view is contained in. A jQuery selector or the element itself.
Type:
  • string | DOMElement
Source:

events :Object

The events this view will listen to and the associated function to call
Type:
  • Object
Source:

submitButtonText :string

The text to use in the editor submit button
Type:
  • string
Source:

Methods

canClose() → {boolean}

Checks if there are unsaved changes in this Editor that should prevent closing of this view. This function is also executed by the AppView, which controls the top-level navigation.
Source:
Returns:
Returns true if this view should be closed. False if it should remain opened and active.
Type
boolean

cancel()

Cancel all edits in the editor by simply re-rendering the view
Source:

checkValidity()

Check the validity of this view's model
Source:

disableControls(messageopt)

Disable the Save button and display a message to explain why
Parameters:
Name Type Attributes Description
message string <optional>
A short text message to display in the Save button
Since:
  • 2.17.1
Source:

enableControls()

Enable the Save button. Resets any changes made in EditorView#disableControls
Since:
  • 2.17.1
Source:

getConfirmCloseMessage() → {string}

This function is called whenever the user is about to leave this view.
Source:
Returns:
The message that asks the user if they are sure they want to close this view
Type
string

getErrorListItem(error) → {string}

Creates an HTML string to display this error message on the page. Errors can be strings, arrays of strings, arrays of literal objects with string values, or a literal object with strings as the values.
Parameters:
Name Type Description
error string | Array.<string> | object A single error message in string format or a collection of error strings as an array or object
Since:
  • 2.18.0
Source:
Returns:
The error message HTML
Type
string

getRequiredFields() → {object}

Gets a list of required fields for this editor, or an empty object if there are none.
Since:
  • 2.19.0
Source:
Returns:
Type
object

handleSaveCancel()

Trigger a save error with a message that the save was cancelled
Source:

hasUnsavedChanges() → {boolean}

Returns true if there are unsaved changes in this Editor This function should be extended by each subclass of EditorView to check for unsaved changes for that model type
Source:
Returns:
Type
boolean

hideControls()

Hide the editor footer controls (Save bar)
Source:

hideLoading(container)

Remove the styles set in showLoading()
Parameters:
Name Type Description
container string | DOMElement The element the loading message is conttained in. Either a jQuery selector or the element itself.
Source:

hideSaving()

Remove the styles set in showSaving()
Source:

isAccessPolicyEditEnabled() → {boolean}

Checks if the Access Policy editor is enabled in this instance of MetacatUI for the type of object being edited.
Since:
  • 2.15.0
Source:
Returns:
Type
boolean

onClose()

Perform clean-up functions when this view is about to be removed from the page or navigated away from.
Source:

removeValidation()

Removes all the validation error styling and messaging from this view
Source:

render()

Renders this view
Source:

renderAccessPolicy(model)

Renders the AccessPolicyView
Parameters:
Name Type Description
model Backbone.Model Optional. The Model to render the AccessPolicy of. If not passed, method uses the Editor's model
Source:

renderAccessPolicyControl()

Adds a Share button for editing the access policy
Source:

renderEditorControls()

Adds top-level control elements to this editor.
Source:

renderRequiredIcons(requiredFields)

Shows the required icons for the sections and fields that must be completed in this editor.
Parameters:
Name Type Description
requiredFields object A literal object that specified which fields should be required. The keys on the object map to model attributes, and the value is true if required, false if optional.
Source:

save()

Saves the model
Source:

saveError(errorMsg)

When the object fails to save, tell the user
Parameters:
Name Type Description
errorMsg string The error message resulting from a failed attempt to save
Source:

saveSuccess(savedObject)

When the object is saved successfully, tell the user
Parameters:
Name Type Description
savedObject object the object that was successfully saved
Source:

setListeners()

Set listeners on the view's model. This function centralizes all the listeners so that when/if the view's model is replaced, the listeners can be reset.
Source:

showAccessPolicyModal(e, model)

Shows the AccessPolicyView for the object being edited.
Parameters:
Name Type Description
e Event The click event
model Backbone.Model | null The model to show the view for. If null, defaults to the model set for the view.
Source:

showControls()

Show the editor footer controls (Save bar)
Source:

showLoading(container, message)

Style the view to show that it is loading
Parameters:
Name Type Description
container string | DOMElement The element to put the loading styling in. Either a jQuery selector or the element itself.
message string | DOMElement The message to display next to the loading icon. Either a jQuery selector or the element itself.
Source:

showNotFound()

Called when there is no object found with this ID
Source:

showSaving()

Change the styling of this view to show that the object is in the process of saving
Source:

showSignIn()

Show Sign In buttons
Source:

showValidation()

Show validation errors, if there are any
Source: