Custom Element API for <perspective-workspace>
#901
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
<perspective-workspace>
currently generates<perspective-viewer>
children in the light DOM when therestore()
method references one, or when the user clucks the Duplicate button. However, these<perspective-viewers>
are only incorporated into the underlying Phosphor DockPanel throughrestore()
, so new new<perspective-viewer>
elements added, or existing children removed, by the DOM API will not be reflected in the UI, and e.g.save()
will still try to serialize this missing element.This change allows
<perspective-workspace>
to be manipulated directly in the DOM, synchronizing the underlying PhosphorDockPanel
as children are removed, added and modified. For example, you can now declare an initial view entirely in static HTML:where:
table
attribute tells<perspective-workspace>
which table in itstables
map to use (should this exist on the DOM at all?)name
attribute is used as the title (should this betitle
?)Similarly, new
<perspective-viewer>
elements added viaappendChild
will be given default placements in the existing layout, and existing elements removed withremoveChild
will be closed. The parent workspace will remove any unused<perspective-viewer>
when e.g.restore()
is called with a layout which does not reference their slots, and will continue to generate new ones as needed.The actual layout itself must still be set with
restore()
, whose API has changed:layout
key is flattened away;master
anddetail
are top-level keys.widgets
within either are now a list of strings, instead of<perspective-viewer>
config objects. These strings references theslot
attribute used for each docked element, and must reference either an existing<perspective-viewer>
with this slow, or ...viewers
is a new top-level key, a map ofslot
string to<perspective-viewer>
config object. This is optional if the<perspective-viewer>
with the necessary slot already exists; if both exist,restore()
is called on the<perspective-viewer>
with thisslot
attribute set.In this example,
<perspective-viewer>
elements withslot
attributes"One"
and"Two"
must already exist as light DOM children, else this call torestore()
will report errors as they are not referenced in theviewers
key:addTable
,removeTable
andgetTable
have been replaced withtables
, a map property of every<perspective-workspace>
, which exposes the standardMap()
API and will auto-wire when modified. This would would have the side effect of callingload()
on<perspective-viewer name="Title!" table="superstore" row-pivots='["State"]'>
in the initial HTML example: