cx 25.5.0 → 25.5.2
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/dist/manifest.js +461 -461
- package/dist/ui.js +7 -16
- package/dist/widgets.js +16 -1
- package/package.json +1 -1
- package/src/data/AugmentedViewBase.js +77 -77
- package/src/data/ExposedRecordView.js +75 -75
- package/src/data/ExposedValueView.js +73 -73
- package/src/ui/Container.js +154 -154
- package/src/ui/DataProxy.js +31 -45
- package/src/ui/DetachedScope.js +98 -98
- package/src/ui/Instance.d.ts +72 -72
- package/src/ui/Instance.js +623 -623
- package/src/ui/IsolatedScope.js +30 -30
- package/src/ui/Repeater.js +8 -1
- package/src/ui/Rescope.js +35 -35
- package/src/ui/Restate.js +167 -167
- package/src/ui/Widget.js +184 -184
- package/src/ui/adapter/ArrayAdapter.js +152 -152
- package/src/ui/adapter/TreeAdapter.js +101 -101
- package/src/ui/layout/exploreChildren.d.ts +12 -12
- package/src/ui/layout/exploreChildren.js +27 -27
- package/src/widgets/List.js +9 -2
- package/src/widgets/form/Checkbox.js +203 -200
- package/src/widgets/grid/Grid.js +7 -0
- package/src/widgets/nav/Route.js +102 -102
|
@@ -1,200 +1,203 @@
|
|
|
1
|
-
import { Widget, VDOM, getContent } from "../../ui/Widget";
|
|
2
|
-
import { Field, getFieldTooltip } from "./Field";
|
|
3
|
-
import { tooltipMouseMove, tooltipMouseLeave } from "../overlay/tooltip-ops";
|
|
4
|
-
import { stopPropagation } from "../../util/eventCallbacks";
|
|
5
|
-
import { KeyCode } from "../../util/KeyCode";
|
|
6
|
-
import CheckIcon from "../icons/check";
|
|
7
|
-
import SquareIcon from "../icons/square";
|
|
8
|
-
|
|
9
|
-
export class Checkbox extends Field {
|
|
10
|
-
init() {
|
|
11
|
-
if (this.checked) this.value = this.checked;
|
|
12
|
-
|
|
13
|
-
super.init();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declareData() {
|
|
17
|
-
super.declareData(
|
|
18
|
-
{
|
|
19
|
-
value: !this.indeterminate ? false : undefined,
|
|
20
|
-
text: undefined,
|
|
21
|
-
readOnly: undefined,
|
|
22
|
-
disabled: undefined,
|
|
23
|
-
enabled: undefined,
|
|
24
|
-
required: undefined,
|
|
25
|
-
viewText: undefined,
|
|
26
|
-
},
|
|
27
|
-
...arguments
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
renderWrap(context, instance, key, content) {
|
|
32
|
-
let { data } = instance;
|
|
33
|
-
return (
|
|
34
|
-
<label
|
|
35
|
-
key={key}
|
|
36
|
-
className={data.classNames}
|
|
37
|
-
onMouseDown={
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
Checkbox.prototype.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
let
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
1
|
+
import { Widget, VDOM, getContent } from "../../ui/Widget";
|
|
2
|
+
import { Field, getFieldTooltip } from "./Field";
|
|
3
|
+
import { tooltipMouseMove, tooltipMouseLeave } from "../overlay/tooltip-ops";
|
|
4
|
+
import { stopPropagation } from "../../util/eventCallbacks";
|
|
5
|
+
import { KeyCode } from "../../util/KeyCode";
|
|
6
|
+
import CheckIcon from "../icons/check";
|
|
7
|
+
import SquareIcon from "../icons/square";
|
|
8
|
+
|
|
9
|
+
export class Checkbox extends Field {
|
|
10
|
+
init() {
|
|
11
|
+
if (this.checked) this.value = this.checked;
|
|
12
|
+
|
|
13
|
+
super.init();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declareData() {
|
|
17
|
+
super.declareData(
|
|
18
|
+
{
|
|
19
|
+
value: !this.indeterminate ? false : undefined,
|
|
20
|
+
text: undefined,
|
|
21
|
+
readOnly: undefined,
|
|
22
|
+
disabled: undefined,
|
|
23
|
+
enabled: undefined,
|
|
24
|
+
required: undefined,
|
|
25
|
+
viewText: undefined,
|
|
26
|
+
},
|
|
27
|
+
...arguments,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
renderWrap(context, instance, key, content) {
|
|
32
|
+
let { data } = instance;
|
|
33
|
+
return (
|
|
34
|
+
<label
|
|
35
|
+
key={key}
|
|
36
|
+
className={data.classNames}
|
|
37
|
+
onMouseDown={(e) => {
|
|
38
|
+
e.stopPropagation();
|
|
39
|
+
if (this.unfocusable) e.preventDefault();
|
|
40
|
+
}}
|
|
41
|
+
onMouseMove={(e) => tooltipMouseMove(e, ...getFieldTooltip(instance))}
|
|
42
|
+
onMouseLeave={(e) => tooltipMouseLeave(e, ...getFieldTooltip(instance))}
|
|
43
|
+
onClick={(e) => {
|
|
44
|
+
this.handleClick(e, instance);
|
|
45
|
+
}}
|
|
46
|
+
style={data.style}
|
|
47
|
+
>
|
|
48
|
+
{content}
|
|
49
|
+
{this.labelPlacement && getContent(this.renderLabel(context, instance, "label"))}
|
|
50
|
+
</label>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
validateRequired(context, instance) {
|
|
55
|
+
let { data } = instance;
|
|
56
|
+
if (!data.value) return this.requiredText;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
renderNativeCheck(context, instance) {
|
|
60
|
+
let { CSS, baseClass } = this;
|
|
61
|
+
let { data } = instance;
|
|
62
|
+
return (
|
|
63
|
+
<input
|
|
64
|
+
key="input"
|
|
65
|
+
className={CSS.element(baseClass, "checkbox")}
|
|
66
|
+
id={data.id}
|
|
67
|
+
type="checkbox"
|
|
68
|
+
checked={data.value || false}
|
|
69
|
+
disabled={data.disabled}
|
|
70
|
+
{...data.inputAttrs}
|
|
71
|
+
onClick={stopPropagation}
|
|
72
|
+
onChange={(e) => {
|
|
73
|
+
this.handleChange(e, instance);
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
renderCheck(context, instance) {
|
|
80
|
+
return <CheckboxCmp key="check" instance={instance} data={instance.data} />;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
renderInput(context, instance, key) {
|
|
84
|
+
let { data } = instance;
|
|
85
|
+
let text = data.text || this.renderChildren(context, instance);
|
|
86
|
+
let { CSS, baseClass } = this;
|
|
87
|
+
return this.renderWrap(context, instance, key, [
|
|
88
|
+
this.native ? this.renderNativeCheck(context, instance) : this.renderCheck(context, instance),
|
|
89
|
+
text ? (
|
|
90
|
+
<div key="text" className={CSS.element(baseClass, "text")}>
|
|
91
|
+
{text}
|
|
92
|
+
</div>
|
|
93
|
+
) : (
|
|
94
|
+
<span key="baseline" className={CSS.element(baseClass, "baseline")}>
|
|
95
|
+
|
|
96
|
+
</span>
|
|
97
|
+
),
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
renderValue(context, { data }) {
|
|
102
|
+
if (!data.viewText) return super.renderValue(...arguments);
|
|
103
|
+
return <span className={this.CSS.element(this.baseClass, "view-text")}>{data.viewText}</span>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
formatValue(context, instance) {
|
|
107
|
+
let { data } = instance;
|
|
108
|
+
return data.value && (data.text || this.renderChildren(context, instance));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
handleClick(e, instance) {
|
|
112
|
+
if (this.native) e.stopPropagation();
|
|
113
|
+
else {
|
|
114
|
+
var el = document.getElementById(instance.data.id);
|
|
115
|
+
if (el) el.focus();
|
|
116
|
+
if (!instance.data.viewMode) {
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
e.stopPropagation();
|
|
119
|
+
this.handleChange(e, instance, !instance.data.value);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
handleChange(e, instance, checked) {
|
|
125
|
+
let { data } = instance;
|
|
126
|
+
|
|
127
|
+
if (data.readOnly || data.disabled || data.viewMode) return;
|
|
128
|
+
|
|
129
|
+
instance.set("value", checked != null ? checked : e.target.checked);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
Checkbox.prototype.baseClass = "checkbox";
|
|
134
|
+
Checkbox.prototype.native = false;
|
|
135
|
+
Checkbox.prototype.indeterminate = false;
|
|
136
|
+
Checkbox.prototype.unfocusable = false;
|
|
137
|
+
|
|
138
|
+
Widget.alias("checkbox", Checkbox);
|
|
139
|
+
|
|
140
|
+
class CheckboxCmp extends VDOM.Component {
|
|
141
|
+
constructor(props) {
|
|
142
|
+
super(props);
|
|
143
|
+
this.state = {
|
|
144
|
+
value: props.data.value,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
UNSAFE_componentWillReceiveProps(props) {
|
|
149
|
+
this.setState({
|
|
150
|
+
value: props.data.value,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
render() {
|
|
155
|
+
let { instance, data } = this.props;
|
|
156
|
+
let { widget } = instance;
|
|
157
|
+
let { baseClass, CSS } = widget;
|
|
158
|
+
|
|
159
|
+
let check = false;
|
|
160
|
+
|
|
161
|
+
if (this.state.value == null && widget.indeterminate) check = "indeterminate";
|
|
162
|
+
else if (this.state.value) check = "check";
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<span
|
|
166
|
+
key="check"
|
|
167
|
+
tabIndex={widget.unfocusable || data.disabled ? null : data.tabIndex || 0}
|
|
168
|
+
className={CSS.element(baseClass, "input", {
|
|
169
|
+
checked: check,
|
|
170
|
+
})}
|
|
171
|
+
style={CSS.parseStyle(data.inputStyle)}
|
|
172
|
+
id={data.id}
|
|
173
|
+
onClick={this.onClick.bind(this)}
|
|
174
|
+
onKeyDown={this.onKeyDown.bind(this)}
|
|
175
|
+
>
|
|
176
|
+
{check == "check" && <CheckIcon className={CSS.element(baseClass, "input-check")} />}
|
|
177
|
+
{check == "indeterminate" && <SquareIcon className={CSS.element(baseClass, "input-check")} />}
|
|
178
|
+
</span>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
onClick(e) {
|
|
183
|
+
let { instance, data } = this.props;
|
|
184
|
+
let { widget } = instance;
|
|
185
|
+
if (!data.disabled && !data.readOnly) {
|
|
186
|
+
e.stopPropagation();
|
|
187
|
+
e.preventDefault();
|
|
188
|
+
this.setState({ value: !this.state.value });
|
|
189
|
+
widget.handleChange(e, instance, !this.state.value);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
onKeyDown(e) {
|
|
194
|
+
let { instance } = this.props;
|
|
195
|
+
if (instance.widget.handleKeyDown(e, instance) === false) return;
|
|
196
|
+
|
|
197
|
+
switch (e.keyCode) {
|
|
198
|
+
case KeyCode.space:
|
|
199
|
+
this.onClick(e);
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
package/src/widgets/grid/Grid.js
CHANGED
|
@@ -112,6 +112,13 @@ export class Grid extends Container {
|
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
applyParentStore(instance) {
|
|
116
|
+
super.applyParentStore(instance);
|
|
117
|
+
|
|
118
|
+
// force prepareData to execute again and propagate the store change to the records
|
|
119
|
+
if (instance.cached) delete instance.cached.rawData;
|
|
120
|
+
}
|
|
121
|
+
|
|
115
122
|
createRowTemplate(context, columnParams, instance, groupingData) {
|
|
116
123
|
var row = this.row || {};
|
|
117
124
|
let columns = this.columns;
|
package/src/widgets/nav/Route.js
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
import { Widget } from "../../ui/Widget";
|
|
2
|
-
import { PureContainer } from "../../ui/PureContainer";
|
|
3
|
-
import RouteMatcher from "route-parser";
|
|
4
|
-
import { ReadOnlyDataView } from "../../data/ReadOnlyDataView";
|
|
5
|
-
import { routeAppend } from "../../util/routeAppend";
|
|
6
|
-
|
|
7
|
-
export class Route extends PureContainer {
|
|
8
|
-
init() {
|
|
9
|
-
if (this.path) this.route = this.path;
|
|
10
|
-
|
|
11
|
-
super.init();
|
|
12
|
-
|
|
13
|
-
if (this.route && this.route[0] !== "+")
|
|
14
|
-
this.matcher = new RouteMatcher(this.route + (this.prefix ? "(*remainder)" : ""));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
initInstance(context, instance) {
|
|
18
|
-
instance.store = new ReadOnlyDataView({
|
|
19
|
-
store: instance.parentStore,
|
|
20
|
-
});
|
|
21
|
-
super.initInstance(context, instance);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
applyParentStore(instance) {
|
|
25
|
-
instance.store.setStore(instance.parentStore);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
declareData() {
|
|
29
|
-
super.declareData(...arguments, {
|
|
30
|
-
url: undefined,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
checkVisible(context, instance, data) {
|
|
35
|
-
if (!data.visible) return false;
|
|
36
|
-
|
|
37
|
-
if (data.url !== instance.cached.url) {
|
|
38
|
-
instance.cached.url = data.url;
|
|
39
|
-
let matcher = this.matcher;
|
|
40
|
-
let route = this.route;
|
|
41
|
-
if (this.route[0] === "+") {
|
|
42
|
-
route = routeAppend(context.lastRoute.route, this.route.substring(1));
|
|
43
|
-
if (!instance.cached.matcher || instance.cached.route !== route)
|
|
44
|
-
instance.cached.matcher = new RouteMatcher(route + (this.prefix ? "(*remainder)" : ""));
|
|
45
|
-
matcher = instance.cached.matcher;
|
|
46
|
-
}
|
|
47
|
-
instance.cached.result = matcher.match(data.url);
|
|
48
|
-
instance.cached.matcher = matcher;
|
|
49
|
-
instance.cached.route = data.route = route;
|
|
50
|
-
}
|
|
51
|
-
if (!instance.cached.result) return false;
|
|
52
|
-
|
|
53
|
-
return super.checkVisible(context, instance, data);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
prepareData(context, { data, store, cached }) {
|
|
57
|
-
super.prepareData(...arguments);
|
|
58
|
-
|
|
59
|
-
store.setData({
|
|
60
|
-
[this.recordName]: cached.result,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
//TODO: Replace comparison with deepEquals
|
|
64
|
-
if (this.params && this.params.bind) {
|
|
65
|
-
var params = store.get(this.params.bind);
|
|
66
|
-
if (JSON.stringify(params) != JSON.stringify(cached.result)) {
|
|
67
|
-
store.set(this.params.bind, cached.result);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (this.map) {
|
|
72
|
-
for (var key in result) {
|
|
73
|
-
var binding = this.map[key];
|
|
74
|
-
if (binding) store.set(binding, result[key]);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
explore(context, instance) {
|
|
80
|
-
context.push("lastRoute", {
|
|
81
|
-
route: instance.cached.route,
|
|
82
|
-
result: instance.cached.result,
|
|
83
|
-
reverse: function (data) {
|
|
84
|
-
return instance.cached.matcher.reverse({
|
|
85
|
-
...instance.cached.result,
|
|
86
|
-
remainder: "",
|
|
87
|
-
...data,
|
|
88
|
-
});
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
super.explore(context, instance);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
exploreCleanup(context, instance) {
|
|
95
|
-
context.pop("lastRoute");
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
Route.prototype.recordName = "$route";
|
|
100
|
-
Route.prototype.prefix = false;
|
|
101
|
-
|
|
102
|
-
Widget.alias("route", Route);
|
|
1
|
+
import { Widget } from "../../ui/Widget";
|
|
2
|
+
import { PureContainer } from "../../ui/PureContainer";
|
|
3
|
+
import RouteMatcher from "route-parser";
|
|
4
|
+
import { ReadOnlyDataView } from "../../data/ReadOnlyDataView";
|
|
5
|
+
import { routeAppend } from "../../util/routeAppend";
|
|
6
|
+
|
|
7
|
+
export class Route extends PureContainer {
|
|
8
|
+
init() {
|
|
9
|
+
if (this.path) this.route = this.path;
|
|
10
|
+
|
|
11
|
+
super.init();
|
|
12
|
+
|
|
13
|
+
if (this.route && this.route[0] !== "+")
|
|
14
|
+
this.matcher = new RouteMatcher(this.route + (this.prefix ? "(*remainder)" : ""));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
initInstance(context, instance) {
|
|
18
|
+
instance.store = new ReadOnlyDataView({
|
|
19
|
+
store: instance.parentStore,
|
|
20
|
+
});
|
|
21
|
+
super.initInstance(context, instance);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
applyParentStore(instance) {
|
|
25
|
+
instance.store.setStore(instance.parentStore);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declareData() {
|
|
29
|
+
super.declareData(...arguments, {
|
|
30
|
+
url: undefined,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
checkVisible(context, instance, data) {
|
|
35
|
+
if (!data.visible) return false;
|
|
36
|
+
|
|
37
|
+
if (data.url !== instance.cached.url) {
|
|
38
|
+
instance.cached.url = data.url;
|
|
39
|
+
let matcher = this.matcher;
|
|
40
|
+
let route = this.route;
|
|
41
|
+
if (this.route[0] === "+") {
|
|
42
|
+
route = routeAppend(context.lastRoute.route, this.route.substring(1));
|
|
43
|
+
if (!instance.cached.matcher || instance.cached.route !== route)
|
|
44
|
+
instance.cached.matcher = new RouteMatcher(route + (this.prefix ? "(*remainder)" : ""));
|
|
45
|
+
matcher = instance.cached.matcher;
|
|
46
|
+
}
|
|
47
|
+
instance.cached.result = matcher.match(data.url);
|
|
48
|
+
instance.cached.matcher = matcher;
|
|
49
|
+
instance.cached.route = data.route = route;
|
|
50
|
+
}
|
|
51
|
+
if (!instance.cached.result) return false;
|
|
52
|
+
|
|
53
|
+
return super.checkVisible(context, instance, data);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
prepareData(context, { data, store, cached }) {
|
|
57
|
+
super.prepareData(...arguments);
|
|
58
|
+
|
|
59
|
+
store.setData({
|
|
60
|
+
[this.recordName]: cached.result,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
//TODO: Replace comparison with deepEquals
|
|
64
|
+
if (this.params && this.params.bind) {
|
|
65
|
+
var params = store.get(this.params.bind);
|
|
66
|
+
if (JSON.stringify(params) != JSON.stringify(cached.result)) {
|
|
67
|
+
store.set(this.params.bind, cached.result);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (this.map) {
|
|
72
|
+
for (var key in result) {
|
|
73
|
+
var binding = this.map[key];
|
|
74
|
+
if (binding) store.set(binding, result[key]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
explore(context, instance) {
|
|
80
|
+
context.push("lastRoute", {
|
|
81
|
+
route: instance.cached.route,
|
|
82
|
+
result: instance.cached.result,
|
|
83
|
+
reverse: function (data) {
|
|
84
|
+
return instance.cached.matcher.reverse({
|
|
85
|
+
...instance.cached.result,
|
|
86
|
+
remainder: "",
|
|
87
|
+
...data,
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
super.explore(context, instance);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
exploreCleanup(context, instance) {
|
|
95
|
+
context.pop("lastRoute");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
Route.prototype.recordName = "$route";
|
|
100
|
+
Route.prototype.prefix = false;
|
|
101
|
+
|
|
102
|
+
Widget.alias("route", Route);
|