saasufy-components 3.19.0 → 3.20.0
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/collection-browser.js +3 -1
- package/package.json +1 -1
- package/utils.js +41 -24
package/collection-browser.js
CHANGED
|
@@ -260,7 +260,9 @@ class CollectionBrowser extends SocketConsumer {
|
|
|
260
260
|
);
|
|
261
261
|
let { fieldValues: viewParams } = convertStringToFieldParams(collectionViewParams);
|
|
262
262
|
let viewPrimaryFields = collectionViewPrimaryFields ?
|
|
263
|
-
collectionViewPrimaryFields.split(',').map(fieldName => fieldName.trim()) :
|
|
263
|
+
collectionViewPrimaryFields.split(',').map(fieldName => fieldName.trim()) :
|
|
264
|
+
collectionViewPrimaryFields == null ?
|
|
265
|
+
null : [];
|
|
264
266
|
|
|
265
267
|
if (this.collection) this.collection.destroy();
|
|
266
268
|
this.isStale = true;
|
package/package.json
CHANGED
package/utils.js
CHANGED
|
@@ -233,6 +233,7 @@ let templateFormatters = {
|
|
|
233
233
|
computeId
|
|
234
234
|
};
|
|
235
235
|
|
|
236
|
+
let templateRawTagsRegExp = /{{{.*?}}}/gs;
|
|
236
237
|
let templateTagsRegExp = /{{.*?}}/gs;
|
|
237
238
|
|
|
238
239
|
function execExpression(expression, options) {
|
|
@@ -246,33 +247,49 @@ function execExpression(expression, options) {
|
|
|
246
247
|
return (new Function(...args))(...keys.map(key => options[key]));
|
|
247
248
|
}
|
|
248
249
|
|
|
250
|
+
function getRenderOptions(data, socket) {
|
|
251
|
+
return {
|
|
252
|
+
...templateFormatters,
|
|
253
|
+
uuid,
|
|
254
|
+
socket: socket ? {
|
|
255
|
+
state: socket.state,
|
|
256
|
+
pendingReconnect: socket.pendingReconnect,
|
|
257
|
+
connectAttempts: socket.connectAttempts,
|
|
258
|
+
authState: socket.authState,
|
|
259
|
+
authToken: socket.authToken
|
|
260
|
+
} : undefined,
|
|
261
|
+
...data
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
249
265
|
export function renderTemplate(templateString, data, socket) {
|
|
250
|
-
return templateString
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
state: socket.state,
|
|
257
|
-
pendingReconnect: socket.pendingReconnect,
|
|
258
|
-
connectAttempts: socket.connectAttempts,
|
|
259
|
-
authState: socket.authState,
|
|
260
|
-
authToken: socket.authToken
|
|
261
|
-
} : undefined,
|
|
262
|
-
...data
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
try {
|
|
266
|
-
return toSafeHTML(
|
|
267
|
-
execExpression(
|
|
266
|
+
return templateString
|
|
267
|
+
.replace(templateRawTagsRegExp, (match) => {
|
|
268
|
+
let expString = match.slice(3, -3);
|
|
269
|
+
let options = getRenderOptions(data, socket);
|
|
270
|
+
try {
|
|
271
|
+
return execExpression(
|
|
268
272
|
toExpression(expString),
|
|
269
273
|
options
|
|
270
|
-
)
|
|
271
|
-
)
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
274
|
+
);
|
|
275
|
+
} catch (error) {
|
|
276
|
+
return match;
|
|
277
|
+
}
|
|
278
|
+
})
|
|
279
|
+
.replace(templateTagsRegExp, (match) => {
|
|
280
|
+
let expString = match.slice(2, -2);
|
|
281
|
+
let options = getRenderOptions(data, socket);
|
|
282
|
+
try {
|
|
283
|
+
return toSafeHTML(
|
|
284
|
+
execExpression(
|
|
285
|
+
toExpression(expString),
|
|
286
|
+
options
|
|
287
|
+
)
|
|
288
|
+
);
|
|
289
|
+
} catch (error) {
|
|
290
|
+
return match;
|
|
291
|
+
}
|
|
292
|
+
});
|
|
276
293
|
}
|
|
277
294
|
|
|
278
295
|
export function updateConsumerElements(consumers, value, template, sourceElementName) {
|