expensify-common 2.0.13 → 2.0.15
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/API.js +48 -24
- package/dist/APIDeferred.js +48 -27
- package/dist/BrowserDetect.js +26 -3
- package/dist/CONST.d.ts +4 -4
- package/dist/CONST.js +4 -4
- package/dist/ExpenseRule.js +3 -7
- package/dist/ExpensiMark.js +33 -39
- package/dist/Func.d.ts +2 -2
- package/dist/Func.js +33 -10
- package/dist/Log.js +27 -5
- package/dist/Logger.js +3 -2
- package/dist/Network.js +32 -10
- package/dist/Num.js +1 -2
- package/dist/PubSub.js +34 -11
- package/dist/ReportHistoryStore.js +11 -15
- package/dist/Templates.js +34 -11
- package/dist/components/StepProgressBar.js +2 -3
- package/dist/components/form/element/combobox.d.ts +1 -0
- package/dist/components/form/element/combobox.js +61 -35
- package/dist/components/form/element/dropdown.js +3 -3
- package/dist/components/form/element/switch.js +3 -5
- package/dist/mixins/PubSub.d.ts +2 -2
- package/dist/mixins/PubSub.js +30 -5
- package/dist/mixins/extraClasses.js +25 -2
- package/dist/str.js +3 -15
- package/dist/utils.d.ts +26 -1
- package/dist/utils.js +60 -1
- package/package.json +2 -3
package/dist/Func.js
CHANGED
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.mapByName = exports.die = exports.bulkInvoke = exports.invokeAsync = exports.invoke = void 0;
|
|
7
|
-
const
|
|
8
|
-
const underscore_1 = __importDefault(require("underscore"));
|
|
27
|
+
const Utils = __importStar(require("./utils"));
|
|
9
28
|
/**
|
|
10
29
|
* Invokes the given callback with the given arguments
|
|
11
30
|
*
|
|
@@ -16,7 +35,7 @@ const underscore_1 = __importDefault(require("underscore"));
|
|
|
16
35
|
* @returns {Mixed}
|
|
17
36
|
*/
|
|
18
37
|
function invoke(callback, args, scope) {
|
|
19
|
-
if (!
|
|
38
|
+
if (!Utils.isFunction(callback)) {
|
|
20
39
|
return null;
|
|
21
40
|
}
|
|
22
41
|
return callback.apply(scope, args || []);
|
|
@@ -30,16 +49,16 @@ exports.invoke = invoke;
|
|
|
30
49
|
* @param {Array} [args]
|
|
31
50
|
* @param {Object} [scope]
|
|
32
51
|
*
|
|
33
|
-
* @returns {
|
|
52
|
+
* @returns {Promise}
|
|
34
53
|
*/
|
|
35
54
|
function invokeAsync(callback, args, scope) {
|
|
36
|
-
if (!
|
|
37
|
-
return
|
|
55
|
+
if (!Utils.isFunction(callback)) {
|
|
56
|
+
return Promise.resolve();
|
|
38
57
|
}
|
|
39
58
|
let promiseFromCallback = callback.apply(scope, args || []);
|
|
40
59
|
// If there was not a promise returned from the prefetch callback, then create a dummy promise and resolve it
|
|
41
60
|
if (!promiseFromCallback) {
|
|
42
|
-
promiseFromCallback =
|
|
61
|
+
promiseFromCallback = Promise.resolve();
|
|
43
62
|
}
|
|
44
63
|
return promiseFromCallback;
|
|
45
64
|
}
|
|
@@ -69,6 +88,10 @@ exports.die = die;
|
|
|
69
88
|
* @returns {Array}
|
|
70
89
|
*/
|
|
71
90
|
function mapByName(list, methodName) {
|
|
72
|
-
|
|
91
|
+
let arr = list;
|
|
92
|
+
if (!Array.isArray(arr)) {
|
|
93
|
+
arr = Object.values(arr);
|
|
94
|
+
}
|
|
95
|
+
return arr.map((item) => item[methodName].call(item));
|
|
73
96
|
}
|
|
74
97
|
exports.mapByName = mapByName;
|
package/dist/Log.js
CHANGED
|
@@ -1,14 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
/* eslint-disable no-console */
|
|
7
|
-
const underscore_1 = __importDefault(require("underscore"));
|
|
8
30
|
const API_1 = __importDefault(require("./API"));
|
|
9
31
|
const Network_1 = __importDefault(require("./Network"));
|
|
10
32
|
const Logger_1 = __importDefault(require("./Logger"));
|
|
11
|
-
const
|
|
33
|
+
const Utils = __importStar(require("./utils"));
|
|
12
34
|
/**
|
|
13
35
|
* Network interface for logger.
|
|
14
36
|
*
|
|
@@ -27,15 +49,15 @@ function serverLoggingCallback(logger, params) {
|
|
|
27
49
|
* @param {String} message
|
|
28
50
|
*/
|
|
29
51
|
function clientLoggingCallback(message) {
|
|
30
|
-
if (
|
|
52
|
+
if (Utils.isWindowAvailable() && typeof window.g_printableReport !== 'undefined' && window.g_printableReport === true) {
|
|
31
53
|
return;
|
|
32
54
|
}
|
|
33
|
-
if (window.console &&
|
|
55
|
+
if (window.console && Utils.isFunction(console.log)) {
|
|
34
56
|
console.log(message);
|
|
35
57
|
}
|
|
36
58
|
}
|
|
37
59
|
exports.default = new Logger_1.default({
|
|
38
60
|
serverLoggingCallback,
|
|
39
61
|
clientLoggingCallback,
|
|
40
|
-
isDebug:
|
|
62
|
+
isDebug: Utils.isWindowAvailable() ? window.DEBUG : false,
|
|
41
63
|
});
|
package/dist/Logger.js
CHANGED
|
@@ -37,9 +37,10 @@ class Logger {
|
|
|
37
37
|
}
|
|
38
38
|
// eslint-disable-next-line rulesdir/prefer-early-return
|
|
39
39
|
promise.then((response) => {
|
|
40
|
-
if (response.requestID) {
|
|
41
|
-
|
|
40
|
+
if (!response.requestID) {
|
|
41
|
+
return;
|
|
42
42
|
}
|
|
43
|
+
this.info('Previous log requestID', false, { requestID: response.requestID }, true);
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
46
|
/**
|
package/dist/Network.js
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
const jquery_1 = __importDefault(require("jquery"));
|
|
7
|
-
const
|
|
8
|
-
const utils_1 = require("./utils");
|
|
30
|
+
const Utils = __importStar(require("./utils"));
|
|
9
31
|
/**
|
|
10
32
|
* Adds our API command to the URL so the API call is more easily identified in the
|
|
11
33
|
* network tab of the JS console
|
|
@@ -39,7 +61,7 @@ function Network(endpoint) {
|
|
|
39
61
|
throw new Error('Cannot instantiate Network without an url endpoint');
|
|
40
62
|
}
|
|
41
63
|
// Attach a listener to the event indicating that we're leaving a page
|
|
42
|
-
if (
|
|
64
|
+
if (Utils.isWindowAvailable()) {
|
|
43
65
|
window.onbeforeunload = () => {
|
|
44
66
|
isNavigatingAway = true;
|
|
45
67
|
};
|
|
@@ -80,7 +102,7 @@ function Network(endpoint) {
|
|
|
80
102
|
// Check to see if parameters contains a File or Blob object
|
|
81
103
|
// If it does, we should use formData instead of parameters and update
|
|
82
104
|
// the ajax settings accordingly
|
|
83
|
-
|
|
105
|
+
Object.entries(parameters).forEach(([key, value]) => {
|
|
84
106
|
if (!value) {
|
|
85
107
|
return;
|
|
86
108
|
}
|
|
@@ -120,14 +142,14 @@ function Network(endpoint) {
|
|
|
120
142
|
url = addCommandToUrl(parameters.command, url);
|
|
121
143
|
// Add our data as form data
|
|
122
144
|
const formData = new FormData();
|
|
123
|
-
|
|
124
|
-
if (
|
|
145
|
+
Object.entries(parameters).forEach(([key, value]) => {
|
|
146
|
+
if (value === undefined) {
|
|
125
147
|
return;
|
|
126
148
|
}
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
if (
|
|
130
|
-
|
|
149
|
+
if (Array.isArray(value)) {
|
|
150
|
+
value.forEach((valueItem, i) => {
|
|
151
|
+
if (Utils.isObject(valueItem)) {
|
|
152
|
+
Object.entries(valueItem).forEach(([valueItemObjectKey, valueItemObjectValue]) => {
|
|
131
153
|
formData.append(`${key}[${i}][${valueItemObjectKey}]`, valueItemObjectValue);
|
|
132
154
|
});
|
|
133
155
|
}
|
package/dist/Num.js
CHANGED
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const underscore_1 = __importDefault(require("underscore"));
|
|
7
6
|
const str_1 = __importDefault(require("./str"));
|
|
8
7
|
exports.default = {
|
|
9
8
|
/**
|
|
@@ -112,7 +111,7 @@ exports.default = {
|
|
|
112
111
|
* @returns {Boolean} true if the number is finite and not NaN.
|
|
113
112
|
*/
|
|
114
113
|
isFiniteNumber(number) {
|
|
115
|
-
return
|
|
114
|
+
return typeof number === 'number' && Number.isFinite(number) && !Number.isNaN(number);
|
|
116
115
|
},
|
|
117
116
|
/**
|
|
118
117
|
* Truncates the given number to the given precision.
|
package/dist/PubSub.js
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const underscore_1 = __importDefault(require("underscore"));
|
|
7
29
|
const has_1 = __importDefault(require("lodash/has"));
|
|
30
|
+
const lodash_1 = require("lodash");
|
|
8
31
|
const Log_1 = __importDefault(require("./Log"));
|
|
9
|
-
const
|
|
32
|
+
const Utils = __importStar(require("./utils"));
|
|
10
33
|
/**
|
|
11
34
|
* PubSub
|
|
12
35
|
*
|
|
@@ -43,13 +66,13 @@ const PubSubModule = {
|
|
|
43
66
|
if (eventMap[eventName] === undefined) {
|
|
44
67
|
return;
|
|
45
68
|
}
|
|
46
|
-
const eventIDs =
|
|
69
|
+
const eventIDs = eventMap[eventName].keys();
|
|
47
70
|
if (eventName === this.ERROR) {
|
|
48
71
|
// Doing the split slice 2 because the 1st element of the stacktrace will always be from here (PubSub.publish)
|
|
49
72
|
// When debugging, we just need to know who called PubSub.publish (so, all next elements in the stack)
|
|
50
73
|
Log_1.default.hmmm('Error published', 0, { tplt: param.tplt, stackTrace: new Error().stack.split(' at ').slice(2) });
|
|
51
74
|
}
|
|
52
|
-
|
|
75
|
+
eventIDs.forEach((eventID) => {
|
|
53
76
|
const subscriber = eventMap[eventName][eventID];
|
|
54
77
|
if (subscriber) {
|
|
55
78
|
subscriber.callback.call(subscriber.scope, param);
|
|
@@ -66,8 +89,8 @@ const PubSubModule = {
|
|
|
66
89
|
* @returns {String}
|
|
67
90
|
*/
|
|
68
91
|
once(eventName, callback, optionalScope) {
|
|
69
|
-
const scope =
|
|
70
|
-
const functionToCallOnce =
|
|
92
|
+
const scope = Utils.isObject(optionalScope) && optionalScope !== null ? optionalScope : window;
|
|
93
|
+
const functionToCallOnce = (0, lodash_1.once)((...args) => callback.apply(scope, args));
|
|
71
94
|
return this.subscribe(eventName, functionToCallOnce);
|
|
72
95
|
},
|
|
73
96
|
/**
|
|
@@ -86,8 +109,8 @@ const PubSubModule = {
|
|
|
86
109
|
if (!eventName) {
|
|
87
110
|
throw new Error('Attempted to subscribe to undefined event');
|
|
88
111
|
}
|
|
89
|
-
const callback =
|
|
90
|
-
const scope =
|
|
112
|
+
const callback = Utils.isFunction(optionalCallback) ? optionalCallback : () => { };
|
|
113
|
+
const scope = Utils.isObject(optionalScope) && optionalScope !== null ? optionalScope : window;
|
|
91
114
|
const eventID = generateID(eventName);
|
|
92
115
|
if (eventMap[eventName] === undefined) {
|
|
93
116
|
eventMap[eventName] = {};
|
|
@@ -104,8 +127,8 @@ const PubSubModule = {
|
|
|
104
127
|
* @param {String} bindID The id of the element to delete
|
|
105
128
|
*/
|
|
106
129
|
unsubscribe(bindID) {
|
|
107
|
-
const IDs =
|
|
108
|
-
|
|
130
|
+
const IDs = Array.isArray(bindID) ? bindID : [bindID];
|
|
131
|
+
IDs.forEach((id) => {
|
|
109
132
|
const eventName = extractEventName(id);
|
|
110
133
|
if ((0, has_1.default)(eventMap, `${eventName}.${id}`)) {
|
|
111
134
|
delete eventMap[eventName][id];
|
|
@@ -113,4 +136,4 @@ const PubSubModule = {
|
|
|
113
136
|
});
|
|
114
137
|
},
|
|
115
138
|
};
|
|
116
|
-
exports.default =
|
|
139
|
+
exports.default = Utils.isWindowAvailable() && window.PubSub ? window.PubSub : PubSubModule;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const underscore_1 = __importDefault(require("underscore"));
|
|
7
3
|
const simply_deferred_1 = require("simply-deferred");
|
|
8
4
|
class ReportHistoryStore {
|
|
9
5
|
// We need to instantiate the history cache with the platform specific implementations
|
|
@@ -31,7 +27,7 @@ class ReportHistoryStore {
|
|
|
31
27
|
*
|
|
32
28
|
* @returns {Object[]}
|
|
33
29
|
*/
|
|
34
|
-
this.filterHiddenActions = (historyItems) =>
|
|
30
|
+
this.filterHiddenActions = (historyItems) => historyItems.filter((historyItem) => historyItem.shouldShow);
|
|
35
31
|
/**
|
|
36
32
|
* Public Methods
|
|
37
33
|
*/
|
|
@@ -117,7 +113,7 @@ class ReportHistoryStore {
|
|
|
117
113
|
this.getFromCache(reportID)
|
|
118
114
|
.done((cachedHistory) => {
|
|
119
115
|
// Do we have the reportAction immediately before this one?
|
|
120
|
-
if (
|
|
116
|
+
if (cachedHistory.some(({ reportActionID }) => reportActionID === reportAction.reportActionID)) {
|
|
121
117
|
// If we have the previous one then we can assume we have an up to date history minus the most recent
|
|
122
118
|
// and must merge it into the cache
|
|
123
119
|
this.mergeHistoryByTimestamp(reportID, [reportAction]);
|
|
@@ -139,7 +135,7 @@ class ReportHistoryStore {
|
|
|
139
135
|
* @param {String[]} events
|
|
140
136
|
*/
|
|
141
137
|
bindCacheClearingEvents: (events) => {
|
|
142
|
-
|
|
138
|
+
events.each((event) => this.PubSub.subscribe(event, () => (this.cache = {})));
|
|
143
139
|
},
|
|
144
140
|
// We need this to be publically available for cases where we get the report history
|
|
145
141
|
// via PHP or html pages within the app e.g. printablereport.html
|
|
@@ -156,14 +152,14 @@ class ReportHistoryStore {
|
|
|
156
152
|
if (newHistory.length === 0) {
|
|
157
153
|
return;
|
|
158
154
|
}
|
|
159
|
-
const newCache =
|
|
160
|
-
if (!
|
|
155
|
+
const newCache = newHistory.reverse().reduce((prev, curr) => {
|
|
156
|
+
if (!prev.some((item) => item.sequenceNumber === curr.sequenceNumber)) {
|
|
161
157
|
prev.unshift(curr);
|
|
162
158
|
}
|
|
163
159
|
return prev;
|
|
164
160
|
}, this.cache[reportID] || []);
|
|
165
161
|
// Sort items in case they have become out of sync
|
|
166
|
-
this.cache[reportID] =
|
|
162
|
+
this.cache[reportID] = newCache.sort((a, b) => b.sequenceNumber - a.sequenceNumber);
|
|
167
163
|
}
|
|
168
164
|
/**
|
|
169
165
|
* Merges history items into the cache and creates it if it doesn't yet exist.
|
|
@@ -175,14 +171,14 @@ class ReportHistoryStore {
|
|
|
175
171
|
if (newHistory.length === 0) {
|
|
176
172
|
return;
|
|
177
173
|
}
|
|
178
|
-
const newCache =
|
|
179
|
-
if (!
|
|
174
|
+
const newCache = newHistory.reverse().reduce((prev, curr) => {
|
|
175
|
+
if (!prev.some((item) => item.reportActionTimestamp === curr.reportActionTimestamp)) {
|
|
180
176
|
prev.unshift(curr);
|
|
181
177
|
}
|
|
182
178
|
return prev;
|
|
183
179
|
}, this.cache[reportID] || []);
|
|
184
180
|
// Sort items in case they have become out of sync
|
|
185
|
-
this.cache[reportID] =
|
|
181
|
+
this.cache[reportID] = newCache.sort((a, b) => b.reportActionTimestamp - a.reportActionTimestamp);
|
|
186
182
|
}
|
|
187
183
|
/**
|
|
188
184
|
* Gets the history.
|
|
@@ -200,7 +196,7 @@ class ReportHistoryStore {
|
|
|
200
196
|
}
|
|
201
197
|
// We'll poll the API for the un-cached history
|
|
202
198
|
const cachedHistory = this.cache[reportID] || [];
|
|
203
|
-
const firstHistoryItem =
|
|
199
|
+
const firstHistoryItem = cachedHistory[0] || {};
|
|
204
200
|
// Grab the most recent sequenceNumber we have and poll the API for fresh data
|
|
205
201
|
this.API.Report_GetHistory({
|
|
206
202
|
reportID,
|
|
@@ -252,7 +248,7 @@ class ReportHistoryStore {
|
|
|
252
248
|
const promise = new simply_deferred_1.Deferred();
|
|
253
249
|
const cachedHistory = this.cache[reportID] || [];
|
|
254
250
|
// If comment is not in cache then fetch it
|
|
255
|
-
if (
|
|
251
|
+
if (cachedHistory.length === 0) {
|
|
256
252
|
return this.getFlatHistory(reportID);
|
|
257
253
|
}
|
|
258
254
|
return promise.resolve(cachedHistory);
|
package/dist/Templates.js
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/* eslint-disable max-classes-per-file */
|
|
7
|
-
const underscore_1 = __importDefault(require("underscore"));
|
|
8
29
|
const jquery_1 = __importDefault(require("jquery"));
|
|
30
|
+
const lodash_1 = require("lodash");
|
|
31
|
+
const Utils = __importStar(require("./utils"));
|
|
9
32
|
/**
|
|
10
33
|
* JS Templating system, powered by underscore template
|
|
11
34
|
*
|
|
@@ -39,7 +62,7 @@ exports.default = (function () {
|
|
|
39
62
|
*/
|
|
40
63
|
get(data = {}) {
|
|
41
64
|
if (!this.compiled) {
|
|
42
|
-
this.compiled =
|
|
65
|
+
this.compiled = (0, lodash_1.template)(this.templateValue);
|
|
43
66
|
this.templateValue = '';
|
|
44
67
|
}
|
|
45
68
|
return this.compiled(data);
|
|
@@ -71,7 +94,7 @@ exports.default = (function () {
|
|
|
71
94
|
// eslint-disable-next-line no-undef
|
|
72
95
|
dataToCompile.nestedTemplate = Templates.get;
|
|
73
96
|
if (!this.compiled) {
|
|
74
|
-
this.compiled =
|
|
97
|
+
this.compiled = (0, lodash_1.template)((0, jquery_1.default)(`#${this.id}`).html());
|
|
75
98
|
}
|
|
76
99
|
return this.compiled(dataToCompile);
|
|
77
100
|
}
|
|
@@ -84,7 +107,7 @@ exports.default = (function () {
|
|
|
84
107
|
*/
|
|
85
108
|
function getTemplate(templatePath) {
|
|
86
109
|
let template = templateStore;
|
|
87
|
-
|
|
110
|
+
templatePath.forEach((pathname) => {
|
|
88
111
|
template = template[pathname];
|
|
89
112
|
});
|
|
90
113
|
return template;
|
|
@@ -101,7 +124,7 @@ exports.default = (function () {
|
|
|
101
124
|
let currentArgument;
|
|
102
125
|
for (let argumentNumber = 0; argumentNumber < wantedNamespace.length; argumentNumber++) {
|
|
103
126
|
currentArgument = wantedNamespace[argumentNumber];
|
|
104
|
-
if (
|
|
127
|
+
if (namespace[currentArgument] === undefined) {
|
|
105
128
|
namespace[currentArgument] = {};
|
|
106
129
|
}
|
|
107
130
|
namespace = namespace[currentArgument];
|
|
@@ -118,7 +141,7 @@ exports.default = (function () {
|
|
|
118
141
|
*/
|
|
119
142
|
get(templatePath, data = {}) {
|
|
120
143
|
const template = getTemplate(templatePath);
|
|
121
|
-
if (
|
|
144
|
+
if (template === undefined) {
|
|
122
145
|
throw Error(`Template '${templatePath}' is not defined`);
|
|
123
146
|
}
|
|
124
147
|
// Check for the absense of get which means someone is likely using
|
|
@@ -134,7 +157,7 @@ exports.default = (function () {
|
|
|
134
157
|
* @return {Boolean}
|
|
135
158
|
*/
|
|
136
159
|
has(templatePath) {
|
|
137
|
-
return
|
|
160
|
+
return getTemplate(templatePath) !== undefined;
|
|
138
161
|
},
|
|
139
162
|
/**
|
|
140
163
|
* Inits the templating engine, and slurps all DOM templates in an internal data structure
|
|
@@ -159,12 +182,12 @@ exports.default = (function () {
|
|
|
159
182
|
*/
|
|
160
183
|
register(wantedNamespace, templateData) {
|
|
161
184
|
const namespace = getTemplateNamespace(wantedNamespace);
|
|
162
|
-
|
|
185
|
+
Object.keys(templateData).forEach((key) => {
|
|
163
186
|
const template = templateData[key];
|
|
164
|
-
if (
|
|
187
|
+
if (Utils.isObject(template)) {
|
|
165
188
|
// If the template is an object, add templates for all keys
|
|
166
189
|
namespace[key] = {};
|
|
167
|
-
|
|
190
|
+
Object.keys(template).forEach((templateKey) => {
|
|
168
191
|
namespace[key][templateKey] = new InlineTemplate(template[templateKey]);
|
|
169
192
|
});
|
|
170
193
|
}
|
|
@@ -27,7 +27,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const react_1 = __importDefault(require("react"));
|
|
30
|
-
const underscore_1 = __importDefault(require("underscore"));
|
|
31
30
|
const prop_types_1 = __importDefault(require("prop-types"));
|
|
32
31
|
const classnames_1 = __importDefault(require("classnames"));
|
|
33
32
|
const UIConstants = __importStar(require("../CONST"));
|
|
@@ -49,7 +48,7 @@ const propTypes = {
|
|
|
49
48
|
*/
|
|
50
49
|
function StepProgressBar({ steps, currentStep }) {
|
|
51
50
|
const isCurrentStep = (step) => step.id === currentStep;
|
|
52
|
-
const currentStepIndex = Math.max(0,
|
|
51
|
+
const currentStepIndex = Math.max(0, steps.findIndex(isCurrentStep));
|
|
53
52
|
const renderStep = (step, i) => {
|
|
54
53
|
let status = currentStepIndex === i ? UIConstants.UI.ACTIVE : '';
|
|
55
54
|
if (currentStepIndex > i) {
|
|
@@ -62,7 +61,7 @@ function StepProgressBar({ steps, currentStep }) {
|
|
|
62
61
|
react_1.default.createElement("span", { className: "js_step_title" }, step.title))));
|
|
63
62
|
};
|
|
64
63
|
return (react_1.default.createElement("div", { id: "js_steps_progress", className: "progress-wrapper" },
|
|
65
|
-
react_1.default.createElement("div", { className: "progress" },
|
|
64
|
+
react_1.default.createElement("div", { className: "progress" }, steps.map(renderStep))));
|
|
66
65
|
}
|
|
67
66
|
StepProgressBar.propTypes = propTypes;
|
|
68
67
|
exports.default = StepProgressBar;
|
|
@@ -165,6 +165,7 @@ declare namespace propTypes {
|
|
|
165
165
|
let defaultValue: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
166
166
|
let value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
167
167
|
let alreadySelectedOptions: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
168
|
+
id: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
168
169
|
value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
169
170
|
text: PropTypes.Requireable<string>;
|
|
170
171
|
}> | null | undefined)[]>;
|