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.
@@ -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()) : null;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasufy-components",
3
- "version": "3.19.0",
3
+ "version": "3.20.0",
4
4
  "description": "Components for Saasufy.",
5
5
  "main": "index.js",
6
6
  "scripts": {
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.replace(templateTagsRegExp, (match) => {
251
- let expString = match.slice(2, -2);
252
- let options = {
253
- ...templateFormatters,
254
- uuid,
255
- socket: socket ? {
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
- } catch (error) {
273
- return match;
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) {