oak-domain 1.1.10 → 1.1.12
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/lib/store/CascadeStore.js +1 -1
- package/lib/store/modi.js +25 -4
- package/lib/triggers/modi.js +22 -12
- package/package.json +1 -1
|
@@ -60,7 +60,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
60
60
|
};
|
|
61
61
|
CascadeStore.prototype.reduceDescendants = function (entity, rows) {
|
|
62
62
|
var _this = this;
|
|
63
|
-
return rows.map(function (row) {
|
|
63
|
+
return rows.filter(function (ele) { return !!ele; }).map(function (row) {
|
|
64
64
|
var _a;
|
|
65
65
|
var row2 = {};
|
|
66
66
|
for (var attr in row) {
|
package/lib/store/modi.js
CHANGED
|
@@ -21,19 +21,40 @@ function createOperationsFromModies(modies) {
|
|
|
21
21
|
exports.createOperationsFromModies = createOperationsFromModies;
|
|
22
22
|
function applyModis(filter, context, option) {
|
|
23
23
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
24
|
-
var _a, _b, _c;
|
|
24
|
+
var modis, _a, _b, _c;
|
|
25
25
|
var _d;
|
|
26
26
|
return tslib_1.__generator(this, function (_e) {
|
|
27
27
|
switch (_e.label) {
|
|
28
|
-
case 0:
|
|
28
|
+
case 0: return [4 /*yield*/, context.rowStore.select('modi', {
|
|
29
|
+
data: {
|
|
30
|
+
id: 1,
|
|
31
|
+
},
|
|
32
|
+
filter: filter,
|
|
33
|
+
sorter: [
|
|
34
|
+
{
|
|
35
|
+
$attr: {
|
|
36
|
+
$$createAt$$: 1,
|
|
37
|
+
},
|
|
38
|
+
$direction: 'asc',
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}, context, Object.assign({}, option, {
|
|
42
|
+
blockTrigger: false,
|
|
43
|
+
}))];
|
|
44
|
+
case 1:
|
|
45
|
+
modis = (_e.sent()).result;
|
|
29
46
|
_b = (_a = context.rowStore).operate;
|
|
30
47
|
_c = ['modi'];
|
|
31
48
|
_d = {};
|
|
32
49
|
return [4 /*yield*/, generateNewId()];
|
|
33
|
-
case
|
|
50
|
+
case 2: return [2 /*return*/, _b.apply(_a, _c.concat([(_d.id = _e.sent(),
|
|
34
51
|
_d.action = 'apply',
|
|
35
52
|
_d.data = {},
|
|
36
|
-
_d.filter =
|
|
53
|
+
_d.filter = {
|
|
54
|
+
id: {
|
|
55
|
+
$in: modis.map(function (ele) { return ele.id; }),
|
|
56
|
+
}
|
|
57
|
+
},
|
|
37
58
|
_d.sorter = [
|
|
38
59
|
{
|
|
39
60
|
$attr: {
|
package/lib/triggers/modi.js
CHANGED
|
@@ -10,7 +10,7 @@ var triggers = [
|
|
|
10
10
|
fn: function (_a, context, option) {
|
|
11
11
|
var operation = _a.operation;
|
|
12
12
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
13
|
-
var filter, modies, modies_1, modies_1_1, modi, targetEntity, id, action, data, filter_1, e_1_1;
|
|
13
|
+
var filter, modies, modies_1, modies_1_1, modi, targetEntity, id, action, data, filter_1, targets, e_1_1;
|
|
14
14
|
var e_1, _b;
|
|
15
15
|
return tslib_1.__generator(this, function (_c) {
|
|
16
16
|
switch (_c.label) {
|
|
@@ -30,39 +30,49 @@ var triggers = [
|
|
|
30
30
|
modies = (_c.sent()).result;
|
|
31
31
|
_c.label = 2;
|
|
32
32
|
case 2:
|
|
33
|
-
_c.trys.push([2,
|
|
33
|
+
_c.trys.push([2, 8, 9, 10]);
|
|
34
34
|
modies_1 = tslib_1.__values(modies), modies_1_1 = modies_1.next();
|
|
35
35
|
_c.label = 3;
|
|
36
36
|
case 3:
|
|
37
|
-
if (!!modies_1_1.done) return [3 /*break*/,
|
|
37
|
+
if (!!modies_1_1.done) return [3 /*break*/, 7];
|
|
38
38
|
modi = modies_1_1.value;
|
|
39
39
|
targetEntity = modi.targetEntity, id = modi.id, action = modi.action, data = modi.data, filter_1 = modi.filter;
|
|
40
|
+
return [4 /*yield*/, context.rowStore.select(targetEntity, {
|
|
41
|
+
data: {
|
|
42
|
+
id: 1,
|
|
43
|
+
},
|
|
44
|
+
filter: filter_1,
|
|
45
|
+
}, context, Object.assign({}, option, {
|
|
46
|
+
blockTrigger: true,
|
|
47
|
+
}))];
|
|
48
|
+
case 4:
|
|
49
|
+
targets = _c.sent();
|
|
40
50
|
return [4 /*yield*/, context.rowStore.operate(targetEntity, {
|
|
41
51
|
id: id,
|
|
42
52
|
action: action,
|
|
43
53
|
data: data,
|
|
44
|
-
filter:
|
|
54
|
+
filter: targets.result.map(function (ele) { return ele.id; }),
|
|
45
55
|
}, context, Object.assign({}, option, {
|
|
46
56
|
blockTrigger: true,
|
|
47
57
|
}))];
|
|
48
|
-
case 4:
|
|
49
|
-
_c.sent();
|
|
50
|
-
_c.label = 5;
|
|
51
58
|
case 5:
|
|
59
|
+
_c.sent();
|
|
60
|
+
_c.label = 6;
|
|
61
|
+
case 6:
|
|
52
62
|
modies_1_1 = modies_1.next();
|
|
53
63
|
return [3 /*break*/, 3];
|
|
54
|
-
case
|
|
55
|
-
case
|
|
64
|
+
case 7: return [3 /*break*/, 10];
|
|
65
|
+
case 8:
|
|
56
66
|
e_1_1 = _c.sent();
|
|
57
67
|
e_1 = { error: e_1_1 };
|
|
58
|
-
return [3 /*break*/,
|
|
59
|
-
case
|
|
68
|
+
return [3 /*break*/, 10];
|
|
69
|
+
case 9:
|
|
60
70
|
try {
|
|
61
71
|
if (modies_1_1 && !modies_1_1.done && (_b = modies_1.return)) _b.call(modies_1);
|
|
62
72
|
}
|
|
63
73
|
finally { if (e_1) throw e_1.error; }
|
|
64
74
|
return [7 /*endfinally*/];
|
|
65
|
-
case
|
|
75
|
+
case 10: return [2 /*return*/, modies.length];
|
|
66
76
|
}
|
|
67
77
|
});
|
|
68
78
|
});
|