Class: AccessPolicyView

AccessPolicyView()

Edits access policies through the legacy Backbone rule views. This view accepts two types of access policy inputs. Legacy `DataONEObject` callers pass a `collections/AccessPolicy` through `options.collection`. The view derives context from `collection.dataONEObject` and uses the existing save path. The newer DataPackage callers pass a typed System Metadata policy, explicit display context, and an apply callback. The editing controls still operate on `collections/AccessPolicy`. In the typed policy mode, the view copies the typed rules into that legacy collection and returns the edited collection through `onApply`. This keeps `PortalEditorView` on its current `DataONEObject` path during the migration. Once portal access policy editing uses typed System Metadata, remove the legacy collection mode and its save and broadcast branches.

Screenshot

Constructor

new AccessPolicyView()

Source:

Extends

  • Backbone.View

Members

broadcast :boolean

Whether this view edits package level sharing. Package level views show the apply to all control; legacy DataONEObject views also broadcast their policy through the legacy package collection.
Type:
  • boolean
Since:
  • 2.15.0
Source:

cachedModels :Array.<AccessRule>

Used to track the collection of models set on the view in order to handle undoing all changes made when we either hit Cancel or click otherwise hide the modal (such as clicking outside of it).
Type:
Since:
  • 2.15.0
Source:

cachedRightsHolder :string|null|undefined

Cached rightsHolder so cancelling or hiding restores edits made in the view.
Type:
  • string | null | undefined
Source:

className :string

The HTML classes to use for this view's element
Type:
  • string
Source:

collection :AccessPolicy

The AccessPolicy collection that is displayed in this View
Type:
Source:

events :object

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

isApplying :boolean

Whether this view is currently applying changes.
Type:
  • boolean
Source:

onApply :function|null

Async apply callback supplied with an explicit policy.
Type:
  • function | null
Source:

policyContext :object

Explicit rendering and apply context for this policy editor. This replaces the old assumption that the collection carries a target similar to a DataONEObject on `collection.dataONEObject`.
Type:
  • object
Source:

publicToggleSection :string

A selector for the element in this view that contains the public/private toggle section
Type:
  • string
Since:
  • 2.15.0
Source:

resourceType :string

The type of object/resource that this AccessPolicy is for. This is used for display purposes only.
Type:
  • string
Source:
Example
"dataset", "portal", "data file"

template :Underscore.Template

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

type :string

The type of View this is
Type:
  • string
Source:

Methods

addAccessRule(accessRule)

Adds the given AccessRule model to the AccessPolicy collection associated with this view
Parameters:
Name Type Description
accessRule AccessRule The AccessRule to add
Source:

addEmptyRow()

Render a row with input elements for adding a new AccessRule
Source:

apply() → {Promise.<void>}

Apply the edited policy through the explicit callback or legacy target.
Since:
  • 2.39.0
Source:
Returns:
Resolves when the apply operation completes
Type
Promise.<void>

applyDataONEObjectPolicy(dataONEObject) → {Promise.<void>}

Apply this policy through the legacy DataONEObject system metadata path.
Parameters:
Name Type Description
dataONEObject Backbone.Model Object whose policy is being edited
Since:
  • 2.39.0
Source:
Returns:
Resolves when the save completes
Type
Promise.<void>

checkForOwners(accessRuleModel)

Checks that there is at least one owner of this resource, and displays a warning message if not.
Parameters:
Name Type Description
accessRuleModel AccessRule Rule whose permissions changed
Source:

getPublicToggleHelpText() → {string}

Constructs and returns a message that explains if this resource is public or private. This message is displayed in the tooltip for the public/private toggle or in place of the toggle when the toggle is disabled. Override this function to create a custom message.
Since:
  • 2.15.0
Source:
Returns:
Public or private status message
Type
string

getResourceType() → {string}

Get the resource label used in modal copy.
Since:
  • 2.39.0
Source:
Returns:
Display resource type
Type
string

getRightsHolder() → {string|null|undefined}

Get the rightsHolder for the policy target.
Since:
  • 2.39.0
Source:
Returns:
Current rightsHolder subject
Type
string | null | undefined

handleHide(event) → {boolean}

Reset edits when the modal closes, unless an apply operation is active.
Parameters:
Name Type Description
event Event Bootstrap modal hide event
Since:
  • 2.39.0
Source:
Returns:
Whether the hide can continue
Type
boolean

handleRemove(event)

Checks that there is at least one owner of this resource, and displays a warning message if not.
Parameters:
Name Type Description
event Event Click event
Source:

initialize(options)

Creates a view in legacy collection or explicit policy mode.
Parameters:
Name Type Description
options object View options
Properties
Name Type Attributes Description
collection AccessPolicy <optional>
Legacy Backbone policy collection owned by a `DataONEObject`
policy Array.<object> <optional>
Typed System Metadata policy copied into an editable legacy collection
policyContext object <optional>
Explicit display/editor context
onApply function <optional>
Applies edits from explicit policy mode
Source:

normalizeAccessPolicy(policy) → {AccessPolicy}

Adapt a typed System Metadata policy to the Backbone collection consumed by the existing `AccessRuleView` editing UI.
Parameters:
Name Type Description
policy Array.<object> System Metadata access policy
Since:
  • 2.39.0
Source:
Returns:
Legacy access policy collection
Type
AccessPolicy

render()

Source:

renderHelpText()

Renders help text for the form in this view
Source:

renderPublicToggle()

Renders a public/private toggle that toggles the public readability of the given resource.
Source:

replaceRightsHolder()

Promote another owner access rule into the rightsHolder slot.
Since:
  • 2.39.0
Source:

reset()

Resets the state of the models stored in the view's collection to the latest cached copy. Triggered either when the Cancel button is hit or the modal containing this view is hidden.
Since:
  • 2.15.0
Source:

setApplying(isApplying)

Enable or disable the permission modal while changes are applied.
Parameters:
Name Type Description
isApplying boolean Whether apply work is in progress
Since:
  • 2.39.0
Source:

setRightsHolder(subject)

Update the current rightsHolder and the legacy model when present.
Parameters:
Name Type Description
subject string | null | undefined New rightsHolder subject
Since:
  • 2.39.0
Source:

showApplyError(message)

Show an apply failure message and restore the modal controls.
Parameters:
Name Type Description
message string Error message to display
Since:
  • 2.39.0
Source:

showOwnerWarning()

Displays a warning message in this view that the object needs at least one owner.
Source:

showRightsholder()

Adds an AccessRuleView that represents the rightsHolder of the object. The rightsHolder needs to be handled specially because it's not a regular access rule in the system metadata.
Source:

showUnauthorized()

Adds messaging to this view to tell the user they are unauthorized to change the AccessPolicy of this object(s)
Source:

syncPublicToggle(inputopt)

Sync the public/private toggle state into the access policy collection.
Parameters:
Name Type Attributes Description
input HTMLElement | jQuery <optional>
Public toggle input
Since:
  • 2.39.0
Source:

togglePrivacy(event)

Toggles the public-read AccessRule for this resource
Parameters:
Name Type Description
event Event Toggle change event
Source: