Constructor
new AccessPolicyView()
- Source:
Extends
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:
- Since:
- 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:
- 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:
- Source:
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:
- Source:
isApplying :boolean
Whether this view is currently applying changes.
Type:
- Source:
onApply :function|null
Async apply callback supplied with an explicit policy.
Type:
- 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:
- Source:
publicToggleSection :string
A selector for the element in this view that contains the
public/private toggle section
Type:
- Since:
- Source:
resourceType :string
The type of object/resource that this AccessPolicy is for. This is used
for display purposes only.
Type:
- Source:
Example
"dataset", "portal", "data file"
template :Underscore.Template
References to templates for this view. HTML files are converted to
Underscore.js templates
Type:
- Source:
type :string
The type of View this is
Type:
- 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:
- 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:
- 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:
- Source:
Returns:
Public or private status message
-
Type
-
string
getResourceType() → {string}
Get the resource label used in modal copy.
- Since:
- Source:
Returns:
Display resource type
-
Type
-
string
getRightsHolder() → {string|null|undefined}
Get the rightsHolder for the policy target.
- Since:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- Source:
showApplyError(message)
Show an apply failure message and restore the modal controls.
Parameters:
| Name |
Type |
Description |
message |
string
|
Error message to display |
- Since:
- 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:
- Source:
togglePrivacy(event)
Toggles the public-read AccessRule for this resource
Parameters:
| Name |
Type |
Description |
event |
Event
|
Toggle change event |
- Source: