@brightspace-ui/labs 2.36.0 → 2.36.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -755,17 +755,20 @@ class TreeFilter extends LocalizeLabsElement(MobxLitElement) {
|
|
|
755
755
|
_renderChildren(id, parentName, indentLevel = 0) {
|
|
756
756
|
parentName = parentName || this.localize('components:ouFilter:treeFilter:nodeName:root');
|
|
757
757
|
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
758
|
+
const emptyState = html`<d2l-empty-state-simple
|
|
759
|
+
slot="tree"
|
|
760
|
+
description="${this.localize('components:ouFilter:treeSelector:noFiltersAvailable')}"
|
|
761
|
+
></d2l-empty-state-simple>`;
|
|
762
|
+
|
|
763
|
+
if (id === undefined) {
|
|
764
|
+
return emptyState;
|
|
764
765
|
}
|
|
765
766
|
|
|
766
767
|
if (!this.tree.isPopulated(id)) {
|
|
767
768
|
// request children; in the meantime we can render whatever we have
|
|
768
769
|
this._requestChildren(id);
|
|
770
|
+
} else if (this.tree.getChildIdsForDisplay(id).length === 0) {
|
|
771
|
+
return emptyState;
|
|
769
772
|
}
|
|
770
773
|
|
|
771
774
|
return [
|
|
@@ -184,6 +184,15 @@ import { navigate } from '@brightspace-ui/labs/utilities/lit-router';
|
|
|
184
184
|
navigate('/my-app/new-place');
|
|
185
185
|
```
|
|
186
186
|
|
|
187
|
+
navigate can also be used to pass data between views. This is useful for sharing state objects between views without needing to make additional server calls. If the data you are sharing with a view is part of the state of the next view consider using a search param instead.
|
|
188
|
+
|
|
189
|
+
```js
|
|
190
|
+
import { navigate } from '@brightspace-ui/labs/utilities/lit-router';
|
|
191
|
+
|
|
192
|
+
navigate(`/users?userId=${userId}`, { data: { /* sharing the user object here so I don't need to fetch it again */ } });
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
|
|
187
196
|
To redirect to a page and replace the previous browser history item the new one, use `redirect(path)`:
|
|
188
197
|
|
|
189
198
|
```js
|
|
@@ -224,4 +233,4 @@ describe('Page Routing', () => {
|
|
|
224
233
|
|
|
225
234
|
This issue is resolved by default but the fix can be bypassed (for backwards compatibility) by setting the `disableRouteOrderFix` option to `true`.
|
|
226
235
|
|
|
227
|
-
Bypassing the fix causes a warning to appear in the dev console. To resolve the warning, remove the `disaableRouteOrderFix` option and thoroughly test your routing. If your routes contain wildcards (`*`, typically for 404s), you may need to register them last.
|
|
236
|
+
Bypassing the fix causes a warning to appear in the dev console. To resolve the warning, remove the `disaableRouteOrderFix` option and thoroughly test your routing. If your routes contain wildcards (`*`, typically for 404s), you may need to register them last.
|
|
@@ -3,6 +3,7 @@ import page from 'page';
|
|
|
3
3
|
let activePage = page;
|
|
4
4
|
let _lastOptions = {};
|
|
5
5
|
let _lastContext = {};
|
|
6
|
+
let passedData = undefined;
|
|
6
7
|
|
|
7
8
|
export const _createReducedContext = pageContext => ({
|
|
8
9
|
params: pageContext.params,
|
|
@@ -13,6 +14,7 @@ export const _createReducedContext = pageContext => ({
|
|
|
13
14
|
route: pageContext.routePath,
|
|
14
15
|
title: pageContext.title,
|
|
15
16
|
options: {},
|
|
17
|
+
passedData
|
|
16
18
|
});
|
|
17
19
|
|
|
18
20
|
const _storeCtx = () => {
|
|
@@ -27,7 +29,9 @@ const _handleRouteView = (context, next, r) => {
|
|
|
27
29
|
const reducedContext = _createReducedContext(context);
|
|
28
30
|
context.view = (host, options) => {
|
|
29
31
|
reducedContext.options = options || {};
|
|
30
|
-
|
|
32
|
+
const resultingView = r.view.call(host, reducedContext);
|
|
33
|
+
passedData = undefined;
|
|
34
|
+
return resultingView;
|
|
31
35
|
};
|
|
32
36
|
context.handled = true;
|
|
33
37
|
|
|
@@ -118,7 +122,9 @@ const addMiddleware = callback => {
|
|
|
118
122
|
|
|
119
123
|
// Triggers navigation to the specified route path.
|
|
120
124
|
// Creates a new entry in the browser's history stack.
|
|
121
|
-
|
|
125
|
+
// data in the options object is available to the next view in ctx.passedData
|
|
126
|
+
export const navigate = (path, options) => {
|
|
127
|
+
passedData = options?.data;
|
|
122
128
|
activePage.show(path);
|
|
123
129
|
};
|
|
124
130
|
|