@inseefr/lunatic 2.4.7-go-to-page → 2.4.7-trevas0.1.18
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.
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _actions = require("../actions");
|
|
8
|
-
var _pageTag = require("../commons/page-tag");
|
|
9
8
|
var _commons = require("./commons");
|
|
10
9
|
var _reduceGoNextPage = _interopRequireDefault(require("./reduce-go-next-page"));
|
|
11
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -16,13 +15,14 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
16
15
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
17
16
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
18
17
|
function validateChange(state) {
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
var updatedState = _objectSpread({}, state);
|
|
19
|
+
if ((0, _commons.isOnEmptyPage)(updatedState)) {
|
|
20
|
+
return (0, _reduceGoNextPage["default"])(updatedState, {
|
|
21
21
|
type: _actions.ActionKind.GO_NEXT_PAGE,
|
|
22
22
|
payload: {}
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
return
|
|
25
|
+
return updatedState;
|
|
26
26
|
}
|
|
27
27
|
function resolveSubPage(state, action) {
|
|
28
28
|
var pager = state.pager,
|
|
@@ -54,42 +54,26 @@ function resolveSubPage(state, action) {
|
|
|
54
54
|
function reduceGoToPage(state, action) {
|
|
55
55
|
var isInLoop = state.isInLoop,
|
|
56
56
|
pager = state.pager;
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
if (_pager) {
|
|
63
|
-
action.payload.iteration = _pager.iteration;
|
|
64
|
-
action.payload.subPage = _pager.subPage;
|
|
65
|
-
action.payload.page = _pager.page;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// The page is still not a number, cancel the action
|
|
70
|
-
if (action.payload.page.match(/\D/)) {
|
|
71
|
-
console.error("Cannot reach page \"".concat(action.payload.page, "\", not a number"));
|
|
72
|
-
return state;
|
|
73
|
-
}
|
|
74
|
-
if (action.payload.iteration !== undefined) {
|
|
75
|
-
newState = resolveSubPage(state, action);
|
|
76
|
-
} else if (!isInLoop) {
|
|
77
|
-
newState = _objectSpread(_objectSpread({}, state), {}, {
|
|
78
|
-
pager: _objectSpread(_objectSpread({}, pager), {}, {
|
|
79
|
-
subPage: undefined,
|
|
80
|
-
nbSubPages: undefined,
|
|
81
|
-
iteration: undefined,
|
|
82
|
-
nbIterations: undefined,
|
|
83
|
-
page: action.payload.page
|
|
84
|
-
})
|
|
85
|
-
});
|
|
86
|
-
// TODO: fix when redirect to loop component
|
|
87
|
-
// How to calculate nbSubPages & nbIterations?
|
|
88
|
-
// How to calculate lazy variables we need?
|
|
89
|
-
// Handle setLoopBindings with the good iteration
|
|
57
|
+
var _action$payload2 = action.payload,
|
|
58
|
+
newPage = _action$payload2.page,
|
|
59
|
+
iteration = _action$payload2.iteration;
|
|
60
|
+
if (iteration !== undefined) {
|
|
61
|
+
return resolveSubPage(state, action);
|
|
90
62
|
}
|
|
91
|
-
|
|
92
|
-
|
|
63
|
+
if (!isInLoop) return _objectSpread(_objectSpread({}, state), {}, {
|
|
64
|
+
pager: _objectSpread(_objectSpread({}, pager), {}, {
|
|
65
|
+
subPage: undefined,
|
|
66
|
+
nbSubPages: undefined,
|
|
67
|
+
iteration: undefined,
|
|
68
|
+
nbIterations: undefined,
|
|
69
|
+
page: newPage
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
// TODO: fix when redirect to loop component
|
|
73
|
+
// How to calculate nbSubPages & nbIterations?
|
|
74
|
+
// How to calculate lazy variables we need?
|
|
75
|
+
// Handle setLoopBindings with the good iteration
|
|
76
|
+
return validateChange(state);
|
|
93
77
|
}
|
|
94
78
|
var _default = reduceGoToPage;
|
|
95
79
|
exports["default"] = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inseefr/lunatic",
|
|
3
|
-
"version": "2.4.7-
|
|
3
|
+
"version": "2.4.7-trevas0.1.18",
|
|
4
4
|
"workersVersion": "0.2.5-experimental",
|
|
5
5
|
"description": "Library of questionnaire components",
|
|
6
6
|
"repository": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"library"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@inseefr/trevas": "^0.1.
|
|
55
|
+
"@inseefr/trevas": "^0.1.18",
|
|
56
56
|
"@inseefr/vtl-2.0-antlr-tools": "^0.1.0-bundle",
|
|
57
57
|
"antlr4": "4.11.0",
|
|
58
58
|
"classnames": "^2.3.1",
|