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
package/dist/ui.js
CHANGED
|
@@ -1017,7 +1017,7 @@ var ArrayAdapter = /*#__PURE__*/ (function (_DataAdapter) {
|
|
|
1017
1017
|
|
|
1018
1018
|
// cache by the key or by data reference
|
|
1019
1019
|
if (key != null) instance.cacheByKey[key] = recordStore;
|
|
1020
|
-
else instance.recordStoreCache.set(data, recordStore);
|
|
1020
|
+
else if (isObject(data)) instance.recordStoreCache.set(data, recordStore);
|
|
1021
1021
|
return {
|
|
1022
1022
|
store: recordStore,
|
|
1023
1023
|
index: index,
|
|
@@ -1147,6 +1147,12 @@ var Repeater = /*#__PURE__*/ (function (_Container) {
|
|
|
1147
1147
|
_proto.initInstance = function initInstance(context, instance) {
|
|
1148
1148
|
this.dataAdapter.initInstance(context, instance);
|
|
1149
1149
|
};
|
|
1150
|
+
_proto.applyParentStore = function applyParentStore(instance) {
|
|
1151
|
+
_Container.prototype.applyParentStore.call(this, instance);
|
|
1152
|
+
|
|
1153
|
+
// force prepareData to execute again and propagate the store change to the records
|
|
1154
|
+
if (instance.cached) delete instance.cached.rawData;
|
|
1155
|
+
};
|
|
1150
1156
|
_proto.prepareData = function prepareData(context, instance) {
|
|
1151
1157
|
var _this = this;
|
|
1152
1158
|
var data = instance.data;
|
|
@@ -2975,21 +2981,6 @@ var DataProxy = /*#__PURE__*/ (function (_PureContainer) {
|
|
|
2975
2981
|
_proto.init = function init() {
|
|
2976
2982
|
if (!this.data) this.data = {};
|
|
2977
2983
|
if (this.alias) this.data[this.alias] = this.value;
|
|
2978
|
-
|
|
2979
|
-
// nesting is required to avoid resetting the store on every render and recalculating the data
|
|
2980
|
-
this.container = PureContainer.create({
|
|
2981
|
-
type: PureContainer,
|
|
2982
|
-
items: this.children || this.items,
|
|
2983
|
-
layout: this.layout,
|
|
2984
|
-
controller: this.controller,
|
|
2985
|
-
outerLayout: this.outerLayout,
|
|
2986
|
-
ws: this.ws,
|
|
2987
|
-
});
|
|
2988
|
-
this.children = [this.container];
|
|
2989
|
-
delete this.items;
|
|
2990
|
-
delete this.controller;
|
|
2991
|
-
delete this.outerLayout;
|
|
2992
|
-
this.layout = UseParentLayout;
|
|
2993
2984
|
_PureContainer.prototype.init.call(this);
|
|
2994
2985
|
};
|
|
2995
2986
|
_proto.initInstance = function initInstance(context, instance) {
|
package/dist/widgets.js
CHANGED
|
@@ -1272,6 +1272,12 @@ var List = /*#__PURE__*/ (function (_Widget) {
|
|
|
1272
1272
|
});
|
|
1273
1273
|
_Widget.prototype.prepareData.call(this, context, instance);
|
|
1274
1274
|
};
|
|
1275
|
+
_proto.applyParentStore = function applyParentStore(instance) {
|
|
1276
|
+
_Widget.prototype.applyParentStore.call(this, instance);
|
|
1277
|
+
|
|
1278
|
+
// force prepareData to execute again and propagate the store change to the records
|
|
1279
|
+
if (instance.cached) delete instance.cached.rawData;
|
|
1280
|
+
};
|
|
1275
1281
|
_proto.explore = function explore(context, instance, data) {
|
|
1276
1282
|
var _this2 = this;
|
|
1277
1283
|
var instances = [];
|
|
@@ -7334,7 +7340,10 @@ var Checkbox = /*#__PURE__*/ (function (_Field) {
|
|
|
7334
7340
|
"label",
|
|
7335
7341
|
{
|
|
7336
7342
|
className: data.classNames,
|
|
7337
|
-
onMouseDown:
|
|
7343
|
+
onMouseDown: function onMouseDown(e) {
|
|
7344
|
+
e.stopPropagation();
|
|
7345
|
+
if (_this.unfocusable) e.preventDefault();
|
|
7346
|
+
},
|
|
7338
7347
|
onMouseMove: function onMouseMove(e) {
|
|
7339
7348
|
return tooltipMouseMove$1.apply(void 0, [e].concat(getFieldTooltip(instance)));
|
|
7340
7349
|
},
|
|
@@ -15644,6 +15653,12 @@ var Grid = /*#__PURE__*/ (function (_Container) {
|
|
|
15644
15653
|
page: 1,
|
|
15645
15654
|
};
|
|
15646
15655
|
};
|
|
15656
|
+
_proto.applyParentStore = function applyParentStore(instance) {
|
|
15657
|
+
_Container.prototype.applyParentStore.call(this, instance);
|
|
15658
|
+
|
|
15659
|
+
// force prepareData to execute again and propagate the store change to the records
|
|
15660
|
+
if (instance.cached) delete instance.cached.rawData;
|
|
15661
|
+
};
|
|
15647
15662
|
_proto.createRowTemplate = function createRowTemplate(context, columnParams, instance, groupingData) {
|
|
15648
15663
|
var _this = this;
|
|
15649
15664
|
var row = this.row || {};
|
package/package.json
CHANGED
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import { View } from "./View";
|
|
2
|
-
import { Binding } from "./Binding";
|
|
3
|
-
|
|
4
|
-
export class AugmentedViewBase extends View {
|
|
5
|
-
getData() {
|
|
6
|
-
if (this.sealed && this.meta.version === this.cache.version && this.meta === this.store.meta)
|
|
7
|
-
return this.cache.result;
|
|
8
|
-
let parentStoreData = this.store.getData();
|
|
9
|
-
let result = this.getBaseData(parentStoreData);
|
|
10
|
-
this.embedAugmentData(result, parentStoreData);
|
|
11
|
-
this.cache.result = result;
|
|
12
|
-
this.cache.parentStoreData = parentStoreData;
|
|
13
|
-
this.cache.version = this.meta.version;
|
|
14
|
-
this.meta = this.store.meta;
|
|
15
|
-
return this.cache.result;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
getBaseData(parentStoreData) {
|
|
19
|
-
if (this.sealed || this.immutable || this.store.sealed) return { ...parentStoreData };
|
|
20
|
-
return parentStoreData;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
embedAugmentData(result, parentStoreData) {
|
|
24
|
-
throw new Error("abstract");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
isExtraKey(key) {
|
|
28
|
-
throw new Error("abstract");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Stores which need to support nested aliases should override this method
|
|
32
|
-
getExtraKeyBinding(key) {
|
|
33
|
-
let binding = Binding.get(key);
|
|
34
|
-
return this.isExtraKey(binding.parts[0]) ? Binding.get(binding.parts[0]) : null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
setExtraKeyValue(key, value) {
|
|
38
|
-
throw new Error("abstract");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
deleteExtraKeyValue(key) {
|
|
42
|
-
throw new Error("abstract");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
setItem(path, value) {
|
|
46
|
-
let extraKeyBinding = this.getExtraKeyBinding(path);
|
|
47
|
-
if (extraKeyBinding) {
|
|
48
|
-
let binding = Binding.get(path);
|
|
49
|
-
let newValue = value;
|
|
50
|
-
if (binding.parts.length > extraKeyBinding.parts.length) {
|
|
51
|
-
let data = {};
|
|
52
|
-
this.embedAugmentData(data, this.store.getData());
|
|
53
|
-
let binding = Binding.get(path);
|
|
54
|
-
data = binding.set(data, value);
|
|
55
|
-
newValue = extraKeyBinding.value(data);
|
|
56
|
-
}
|
|
57
|
-
return this.setExtraKeyValue(extraKeyBinding.path, newValue);
|
|
58
|
-
}
|
|
59
|
-
return super.setItem(path, value);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
deleteItem(path) {
|
|
63
|
-
let extraKeyBinding = this.getExtraKeyBinding(path);
|
|
64
|
-
if (extraKeyBinding) {
|
|
65
|
-
if (path == extraKeyBinding.path) return this.deleteExtraKeyValue(extraKeyBinding.path);
|
|
66
|
-
let data = {};
|
|
67
|
-
this.embedAugmentData(data, this.store.getData());
|
|
68
|
-
let binding = Binding.get(path);
|
|
69
|
-
data = binding.delete(data);
|
|
70
|
-
let newValue = extraKeyBinding.value(data);
|
|
71
|
-
return this.setExtraKeyValue(extraKeyBinding.path, newValue);
|
|
72
|
-
}
|
|
73
|
-
return super.deleteItem(path);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
AugmentedViewBase.prototype.immutable = false;
|
|
1
|
+
import { View } from "./View";
|
|
2
|
+
import { Binding } from "./Binding";
|
|
3
|
+
|
|
4
|
+
export class AugmentedViewBase extends View {
|
|
5
|
+
getData() {
|
|
6
|
+
if (this.sealed && this.meta.version === this.cache.version && this.meta === this.store.meta)
|
|
7
|
+
return this.cache.result;
|
|
8
|
+
let parentStoreData = this.store.getData();
|
|
9
|
+
let result = this.getBaseData(parentStoreData);
|
|
10
|
+
this.embedAugmentData(result, parentStoreData);
|
|
11
|
+
this.cache.result = result;
|
|
12
|
+
this.cache.parentStoreData = parentStoreData;
|
|
13
|
+
this.cache.version = this.meta.version;
|
|
14
|
+
this.meta = this.store.meta;
|
|
15
|
+
return this.cache.result;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getBaseData(parentStoreData) {
|
|
19
|
+
if (this.sealed || this.immutable || this.store.sealed) return { ...parentStoreData };
|
|
20
|
+
return parentStoreData;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
embedAugmentData(result, parentStoreData) {
|
|
24
|
+
throw new Error("abstract");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
isExtraKey(key) {
|
|
28
|
+
throw new Error("abstract");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Stores which need to support nested aliases should override this method
|
|
32
|
+
getExtraKeyBinding(key) {
|
|
33
|
+
let binding = Binding.get(key);
|
|
34
|
+
return this.isExtraKey(binding.parts[0]) ? Binding.get(binding.parts[0]) : null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
setExtraKeyValue(key, value) {
|
|
38
|
+
throw new Error("abstract");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
deleteExtraKeyValue(key) {
|
|
42
|
+
throw new Error("abstract");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setItem(path, value) {
|
|
46
|
+
let extraKeyBinding = this.getExtraKeyBinding(path);
|
|
47
|
+
if (extraKeyBinding) {
|
|
48
|
+
let binding = Binding.get(path);
|
|
49
|
+
let newValue = value;
|
|
50
|
+
if (binding.parts.length > extraKeyBinding.parts.length) {
|
|
51
|
+
let data = {};
|
|
52
|
+
this.embedAugmentData(data, this.store.getData());
|
|
53
|
+
let binding = Binding.get(path);
|
|
54
|
+
data = binding.set(data, value);
|
|
55
|
+
newValue = extraKeyBinding.value(data);
|
|
56
|
+
}
|
|
57
|
+
return this.setExtraKeyValue(extraKeyBinding.path, newValue);
|
|
58
|
+
}
|
|
59
|
+
return super.setItem(path, value);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
deleteItem(path) {
|
|
63
|
+
let extraKeyBinding = this.getExtraKeyBinding(path);
|
|
64
|
+
if (extraKeyBinding) {
|
|
65
|
+
if (path == extraKeyBinding.path) return this.deleteExtraKeyValue(extraKeyBinding.path);
|
|
66
|
+
let data = {};
|
|
67
|
+
this.embedAugmentData(data, this.store.getData());
|
|
68
|
+
let binding = Binding.get(path);
|
|
69
|
+
data = binding.delete(data);
|
|
70
|
+
let newValue = extraKeyBinding.value(data);
|
|
71
|
+
return this.setExtraKeyValue(extraKeyBinding.path, newValue);
|
|
72
|
+
}
|
|
73
|
+
return super.deleteItem(path);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
AugmentedViewBase.prototype.immutable = false;
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { View } from "./View";
|
|
2
|
-
import { Binding } from "./Binding";
|
|
3
|
-
|
|
4
|
-
export class ExposedRecordView extends View {
|
|
5
|
-
getData() {
|
|
6
|
-
if (
|
|
7
|
-
this.sealed &&
|
|
8
|
-
this.meta.version === this.cache.version &&
|
|
9
|
-
this.cache.itemIndex === this.itemIndex &&
|
|
10
|
-
this.meta === this.store.meta
|
|
11
|
-
)
|
|
12
|
-
return this.cache.result;
|
|
13
|
-
|
|
14
|
-
this.cache.result = this.embed(this.store.getData());
|
|
15
|
-
this.cache.version = this.meta.version;
|
|
16
|
-
this.cache.itemIndex = this.itemIndex;
|
|
17
|
-
this.meta = this.store.meta;
|
|
18
|
-
return this.cache.result;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
embed(data) {
|
|
22
|
-
const collection = this.collectionBinding.value(data);
|
|
23
|
-
const record = collection[this.itemIndex];
|
|
24
|
-
const copy = this.sealed || this.immutable || this.store.sealed ? { ...data } : data;
|
|
25
|
-
copy[this.recordName] = record;
|
|
26
|
-
if (this.indexName) copy[this.indexName] = this.itemIndex;
|
|
27
|
-
return copy;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
setIndex(index) {
|
|
31
|
-
this.itemIndex = index;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
setItem(path, value) {
|
|
35
|
-
if (path == this.recordName || path.indexOf(this.recordName + ".") == 0) {
|
|
36
|
-
const storeData = this.store.getData();
|
|
37
|
-
const collection = this.collectionBinding.value(storeData);
|
|
38
|
-
const data = this.embed(storeData);
|
|
39
|
-
const d = Binding.get(path).set(data, value);
|
|
40
|
-
if (d === data) return false;
|
|
41
|
-
const record = d[this.recordName];
|
|
42
|
-
const newCollection = [
|
|
43
|
-
...collection.slice(0, this.itemIndex),
|
|
44
|
-
record,
|
|
45
|
-
...collection.slice(this.itemIndex + 1),
|
|
46
|
-
];
|
|
47
|
-
return this.store.setItem(this.collectionBinding.path, newCollection);
|
|
48
|
-
}
|
|
49
|
-
return this.store.setItem(path, value);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
deleteItem(path) {
|
|
53
|
-
let storeData, collection, newCollection;
|
|
54
|
-
|
|
55
|
-
if (path == this.recordName) {
|
|
56
|
-
storeData = this.store.getData();
|
|
57
|
-
collection = this.collectionBinding.value(storeData);
|
|
58
|
-
newCollection = [...collection.slice(0, this.itemIndex), ...collection.slice(this.itemIndex + 1)];
|
|
59
|
-
return this.store.setItem(this.collectionBinding.path, newCollection);
|
|
60
|
-
} else if (path.indexOf(this.recordName + ".") == 0) {
|
|
61
|
-
storeData = this.store.getData();
|
|
62
|
-
collection = this.collectionBinding.value(storeData);
|
|
63
|
-
const data = this.embed(storeData);
|
|
64
|
-
const d = Binding.get(path).delete(data);
|
|
65
|
-
if (d === data) return false;
|
|
66
|
-
const record = d[this.recordName];
|
|
67
|
-
newCollection = [...collection.slice(0, this.itemIndex), record, ...collection.slice(this.itemIndex + 1)];
|
|
68
|
-
return this.store.setItem(this.collectionBinding.path, newCollection);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return this.store.deleteItem(path);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
ExposedRecordView.prototype.immutable = false;
|
|
1
|
+
import { View } from "./View";
|
|
2
|
+
import { Binding } from "./Binding";
|
|
3
|
+
|
|
4
|
+
export class ExposedRecordView extends View {
|
|
5
|
+
getData() {
|
|
6
|
+
if (
|
|
7
|
+
this.sealed &&
|
|
8
|
+
this.meta.version === this.cache.version &&
|
|
9
|
+
this.cache.itemIndex === this.itemIndex &&
|
|
10
|
+
this.meta === this.store.meta
|
|
11
|
+
)
|
|
12
|
+
return this.cache.result;
|
|
13
|
+
|
|
14
|
+
this.cache.result = this.embed(this.store.getData());
|
|
15
|
+
this.cache.version = this.meta.version;
|
|
16
|
+
this.cache.itemIndex = this.itemIndex;
|
|
17
|
+
this.meta = this.store.meta;
|
|
18
|
+
return this.cache.result;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
embed(data) {
|
|
22
|
+
const collection = this.collectionBinding.value(data);
|
|
23
|
+
const record = collection[this.itemIndex];
|
|
24
|
+
const copy = this.sealed || this.immutable || this.store.sealed ? { ...data } : data;
|
|
25
|
+
copy[this.recordName] = record;
|
|
26
|
+
if (this.indexName) copy[this.indexName] = this.itemIndex;
|
|
27
|
+
return copy;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
setIndex(index) {
|
|
31
|
+
this.itemIndex = index;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setItem(path, value) {
|
|
35
|
+
if (path == this.recordName || path.indexOf(this.recordName + ".") == 0) {
|
|
36
|
+
const storeData = this.store.getData();
|
|
37
|
+
const collection = this.collectionBinding.value(storeData);
|
|
38
|
+
const data = this.embed(storeData);
|
|
39
|
+
const d = Binding.get(path).set(data, value);
|
|
40
|
+
if (d === data) return false;
|
|
41
|
+
const record = d[this.recordName];
|
|
42
|
+
const newCollection = [
|
|
43
|
+
...collection.slice(0, this.itemIndex),
|
|
44
|
+
record,
|
|
45
|
+
...collection.slice(this.itemIndex + 1),
|
|
46
|
+
];
|
|
47
|
+
return this.store.setItem(this.collectionBinding.path, newCollection);
|
|
48
|
+
}
|
|
49
|
+
return this.store.setItem(path, value);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
deleteItem(path) {
|
|
53
|
+
let storeData, collection, newCollection;
|
|
54
|
+
|
|
55
|
+
if (path == this.recordName) {
|
|
56
|
+
storeData = this.store.getData();
|
|
57
|
+
collection = this.collectionBinding.value(storeData);
|
|
58
|
+
newCollection = [...collection.slice(0, this.itemIndex), ...collection.slice(this.itemIndex + 1)];
|
|
59
|
+
return this.store.setItem(this.collectionBinding.path, newCollection);
|
|
60
|
+
} else if (path.indexOf(this.recordName + ".") == 0) {
|
|
61
|
+
storeData = this.store.getData();
|
|
62
|
+
collection = this.collectionBinding.value(storeData);
|
|
63
|
+
const data = this.embed(storeData);
|
|
64
|
+
const d = Binding.get(path).delete(data);
|
|
65
|
+
if (d === data) return false;
|
|
66
|
+
const record = d[this.recordName];
|
|
67
|
+
newCollection = [...collection.slice(0, this.itemIndex), record, ...collection.slice(this.itemIndex + 1)];
|
|
68
|
+
return this.store.setItem(this.collectionBinding.path, newCollection);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return this.store.deleteItem(path);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
ExposedRecordView.prototype.immutable = false;
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import { View } from "./View";
|
|
2
|
-
import { Binding } from "./Binding";
|
|
3
|
-
|
|
4
|
-
export class ExposedValueView extends View {
|
|
5
|
-
getData() {
|
|
6
|
-
if (
|
|
7
|
-
this.sealed &&
|
|
8
|
-
this.meta.version === this.cache.version &&
|
|
9
|
-
this.cache.key === this.key &&
|
|
10
|
-
this.meta == this.store.meta
|
|
11
|
-
)
|
|
12
|
-
return this.cache.result;
|
|
13
|
-
|
|
14
|
-
let data = this.store.getData();
|
|
15
|
-
let container = this.containerBinding.value(data) || {};
|
|
16
|
-
let record = container[this.key];
|
|
17
|
-
|
|
18
|
-
this.cache.version = this.meta.version;
|
|
19
|
-
this.cache.key = this.key;
|
|
20
|
-
this.cache.result = this.sealed || this.immutable || this.store.sealed ? { ...data } : data;
|
|
21
|
-
this.cache.result[this.recordName] = record;
|
|
22
|
-
this.meta = this.store.meta;
|
|
23
|
-
return this.cache.result;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
setKey(key) {
|
|
27
|
-
this.key = key;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
getKey() {
|
|
31
|
-
return this.key;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
setItem(path, value) {
|
|
35
|
-
if (path == this.recordName || path.indexOf(this.recordName + ".") == 0) {
|
|
36
|
-
var data = this.getData();
|
|
37
|
-
var d = Binding.get(path).set(data, value);
|
|
38
|
-
if (d === data) return false;
|
|
39
|
-
var container = this.containerBinding.value(d);
|
|
40
|
-
var record = d[this.recordName];
|
|
41
|
-
var newContainer = Object.assign({}, container);
|
|
42
|
-
newContainer[this.key] = record;
|
|
43
|
-
return this.store.setItem(this.containerBinding.path, newContainer);
|
|
44
|
-
}
|
|
45
|
-
return this.store.setItem(path, value);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
deleteItem(path) {
|
|
49
|
-
var data, container, newContainer;
|
|
50
|
-
|
|
51
|
-
if (path == this.recordName) {
|
|
52
|
-
data = this.getData();
|
|
53
|
-
container = this.containerBinding.value(data);
|
|
54
|
-
if (!container || !container.hasOwnProperty(path)) return false;
|
|
55
|
-
newContainer = Object.assign({}, container);
|
|
56
|
-
delete newContainer[this.key];
|
|
57
|
-
this.store.set(this.containerBinding.path, newContainer);
|
|
58
|
-
} else if (path.indexOf(this.recordName + ".") == 0) {
|
|
59
|
-
data = this.getData();
|
|
60
|
-
var d = Binding.get(path).delete(data);
|
|
61
|
-
if (d === data) return false;
|
|
62
|
-
container = this.containerBinding.value(d);
|
|
63
|
-
var record = d[this.recordName];
|
|
64
|
-
newContainer = Object.assign({}, container);
|
|
65
|
-
newContainer[this.key] = record;
|
|
66
|
-
return this.store.setItem(this.containerBinding.path, newContainer);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return this.store.deleteItem(path);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
ExposedValueView.prototype.immutable = false;
|
|
1
|
+
import { View } from "./View";
|
|
2
|
+
import { Binding } from "./Binding";
|
|
3
|
+
|
|
4
|
+
export class ExposedValueView extends View {
|
|
5
|
+
getData() {
|
|
6
|
+
if (
|
|
7
|
+
this.sealed &&
|
|
8
|
+
this.meta.version === this.cache.version &&
|
|
9
|
+
this.cache.key === this.key &&
|
|
10
|
+
this.meta == this.store.meta
|
|
11
|
+
)
|
|
12
|
+
return this.cache.result;
|
|
13
|
+
|
|
14
|
+
let data = this.store.getData();
|
|
15
|
+
let container = this.containerBinding.value(data) || {};
|
|
16
|
+
let record = container[this.key];
|
|
17
|
+
|
|
18
|
+
this.cache.version = this.meta.version;
|
|
19
|
+
this.cache.key = this.key;
|
|
20
|
+
this.cache.result = this.sealed || this.immutable || this.store.sealed ? { ...data } : data;
|
|
21
|
+
this.cache.result[this.recordName] = record;
|
|
22
|
+
this.meta = this.store.meta;
|
|
23
|
+
return this.cache.result;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
setKey(key) {
|
|
27
|
+
this.key = key;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getKey() {
|
|
31
|
+
return this.key;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setItem(path, value) {
|
|
35
|
+
if (path == this.recordName || path.indexOf(this.recordName + ".") == 0) {
|
|
36
|
+
var data = this.getData();
|
|
37
|
+
var d = Binding.get(path).set(data, value);
|
|
38
|
+
if (d === data) return false;
|
|
39
|
+
var container = this.containerBinding.value(d);
|
|
40
|
+
var record = d[this.recordName];
|
|
41
|
+
var newContainer = Object.assign({}, container);
|
|
42
|
+
newContainer[this.key] = record;
|
|
43
|
+
return this.store.setItem(this.containerBinding.path, newContainer);
|
|
44
|
+
}
|
|
45
|
+
return this.store.setItem(path, value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
deleteItem(path) {
|
|
49
|
+
var data, container, newContainer;
|
|
50
|
+
|
|
51
|
+
if (path == this.recordName) {
|
|
52
|
+
data = this.getData();
|
|
53
|
+
container = this.containerBinding.value(data);
|
|
54
|
+
if (!container || !container.hasOwnProperty(path)) return false;
|
|
55
|
+
newContainer = Object.assign({}, container);
|
|
56
|
+
delete newContainer[this.key];
|
|
57
|
+
this.store.set(this.containerBinding.path, newContainer);
|
|
58
|
+
} else if (path.indexOf(this.recordName + ".") == 0) {
|
|
59
|
+
data = this.getData();
|
|
60
|
+
var d = Binding.get(path).delete(data);
|
|
61
|
+
if (d === data) return false;
|
|
62
|
+
container = this.containerBinding.value(d);
|
|
63
|
+
var record = d[this.recordName];
|
|
64
|
+
newContainer = Object.assign({}, container);
|
|
65
|
+
newContainer[this.key] = record;
|
|
66
|
+
return this.store.setItem(this.containerBinding.path, newContainer);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return this.store.deleteItem(path);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
ExposedValueView.prototype.immutable = false;
|