saasufy-components 9.3.1 → 9.4.1

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/README.md CHANGED
@@ -413,6 +413,7 @@ In addition to the slots shown above, the `collection-viewer` also supports the
413
413
  - `collection-page-offset`: Indicates the current page offset in the collection's data. It’s like telling the viewer which page of data you want to display initially.
414
414
  - `collection-get-count`: If this attribute is present, the component will get the record count of the target view. The count can be rendered into the template by prefixing the model name with a dollar sign and accessing the `count` property like this: `{{$MyModelName.count}}`.
415
415
  - `collection-disable-realtime`: If this attribute is present, the underlying collection will not listen for changes nor update in realtime. Fields of records that are in view may still update in realtime.
416
+ - `realtime-fields`: An optional comma-separated list of field names that should update in realtime. If not specified, all fields update in realtime. This can be used to limit realtime updates to only the fields that need it, improving performance.
416
417
  - `auto-reset-page-offset`: If this attribute is present, the `collection-page-offset` will be reset to zero whenever the view params change.
417
418
  - `type-alias`: Allows you to provide an alternative name for your `Model` to use when injecting values inside the template. This is useful for situations where you may have multiple `collection-viewer` elements and/or `model-viewer` elements of the same type nested inside each other and want to avoid `Model` name clashes in the nested template definitions. For example, if the `type-alias` in the snippet above was set to `SubChat`, then `{{Chat.message}}` would become `{{SubChat.message}}`.
418
419
  - `hide-error-logs`: A flag which, when present, suppresses error logs from being printed to the console.
@@ -626,6 +627,7 @@ In the example above, the name of the first element can be accessed with `{{Cate
626
627
  - `collection-page-offset`: Indicates the current page offset in the collection's data. It’s like telling the viewer which page of data you want to display initially.
627
628
  - `collection-get-count`: If this attribute is present, the component will get the record count of the target view. The count can be rendered into the template by prefixing the model name with a dollar sign and accessing the `count` property like this: `{{$MyModelName.count}}`.
628
629
  - `type-alias`: Allows you to provide an alternative name for your `Model` to use when injecting values inside the template. This is useful for situations where you may have multiple `collection-viewer` elements and/or `model-viewer` elements of the same type nested inside each other and want to avoid `Model` name clashes in the nested template definitions. For example, if the `type-alias` in the snippet above was set to `SubChat`, then `{{Chat.message}}` would become `{{SubChat.message}}`.
630
+ - `realtime-fields`: An optional comma-separated list of field names that should update in realtime. If not specified, all fields update in realtime. This can be used to limit realtime updates to only the fields that need it, improving performance.
629
631
  - `hide-error-logs`: A flag which, when present, suppresses error logs from being printed to the console.
630
632
  - `greedy-refresh`: If this attribute exists, the component will refresh itself whenever an attribute is set, even if that attribute's value did not change.
631
633
 
@@ -748,6 +750,7 @@ Used for rendering a single model resource using a template. This is the single-
748
750
  - `model-fields` (required): A comma-separated list of fields to bind to. Note that unlike with `model-input` and `model-text`, the attribute name is plural and can bind to multiple fields.
749
751
  - `type-alias`: Allows you to provide an alternative name for your `Model` to use when injecting values inside the template. This is useful for situations where you may have multiple `model-viewer` elements and/or `model-viewer` elements of the same type nested inside each other and want to avoid `Model` name clashes in the nested template definitions. For example, if the `type-alias` in the snippet above was set to `MyProduct`, then `{{Product.name}}` would become `{{MyProduct.name}}`.
750
752
  - `fields-slice-to`: Optional attribute which can be used to trim strings down to a maximum number of characters when reading. The format is `fieldName1=number1,fieldName2=number2`. This is useful when dealing with potentially very long field values. Note that it may affect caching if the same field is being referenced in multiple parts of the application at the same time within the same `socket-provider`.
753
+ - `realtime-fields`: An optional comma-separated list of field names that should update in realtime. If not specified, all fields update in realtime. This can be used to limit realtime updates to only the fields that need it, improving performance.
751
754
  - `hide-error-logs`: A flag which, when present, suppresses error logs from being printed to the console.
752
755
  - `greedy-refresh`: If this attribute exists, the component will refresh itself whenever an attribute is set, even if that attribute's value did not change.
753
756
 
@@ -75,6 +75,7 @@ class CollectionReducer extends SocketConsumer {
75
75
  'collection-page-size',
76
76
  'collection-page-offset',
77
77
  'collection-get-count',
78
+ 'realtime-fields',
78
79
  'max-show-loader',
79
80
  'type-alias'
80
81
  ];
@@ -217,6 +218,8 @@ class CollectionReducer extends SocketConsumer {
217
218
  let collectionPageOffset = this.getAttribute('collection-page-offset');
218
219
  let collectionGetCount = this.hasAttribute('collection-get-count');
219
220
 
221
+ let realtimeFields = this.hasAttribute('realtime-fields') ?
222
+ this.getAttribute('realtime-fields').split(',').map(field => field.trim()).filter(field => field) : null;
220
223
  let collectionReloadDelay = Number(
221
224
  this.getAttribute('collection-reload-delay') || DEFAULT_RELOAD_DELAY
222
225
  );
@@ -234,7 +237,8 @@ class CollectionReducer extends SocketConsumer {
234
237
  pageSize: Number(collectionPageSize || 10),
235
238
  pageOffset: Number(collectionPageOffset || 0),
236
239
  changeReloadDelay: collectionReloadDelay,
237
- getCount: collectionGetCount
240
+ getCount: collectionGetCount,
241
+ realtimeFields
238
242
  });
239
243
 
240
244
  this.shadowRoot.innerHTML = `
@@ -163,6 +163,7 @@ class CollectionViewer extends SocketConsumer {
163
163
  'collection-page-offset',
164
164
  'collection-get-count',
165
165
  'collection-disable-realtime',
166
+ 'realtime-fields',
166
167
  'auto-reset-page-offset',
167
168
  'max-show-loader',
168
169
  'type-alias'
@@ -379,6 +380,8 @@ class CollectionViewer extends SocketConsumer {
379
380
  let collectionPageOffset = this.getAttribute('collection-page-offset');
380
381
  let collectionGetCount = this.hasAttribute('collection-get-count');
381
382
  let collectionDisableRealtime = this.hasAttribute('collection-disable-realtime');
383
+ let realtimeFields = this.hasAttribute('realtime-fields') ?
384
+ this.getAttribute('realtime-fields').split(',').map(field => field.trim()).filter(field => field) : null;
382
385
  let collectionReloadDelay = Number(
383
386
  this.getAttribute('collection-reload-delay') || DEFAULT_RELOAD_DELAY
384
387
  );
@@ -402,7 +405,8 @@ class CollectionViewer extends SocketConsumer {
402
405
  pageOffset: Number(collectionPageOffset || 0),
403
406
  changeReloadDelay: collectionReloadDelay,
404
407
  getCount: collectionGetCount,
405
- realtimeCollection: !collectionDisableRealtime
408
+ realtimeCollection: !collectionDisableRealtime,
409
+ realtimeFields
406
410
  });
407
411
 
408
412
  this.shadowRoot.innerHTML = `
package/model-viewer.js CHANGED
@@ -35,7 +35,8 @@ class ModelViewer extends SocketConsumer {
35
35
  'model-id',
36
36
  'model-fields',
37
37
  'fields-slice-to',
38
- 'type-alias'
38
+ 'type-alias',
39
+ 'realtime-fields'
39
40
  ];
40
41
  }
41
42
 
@@ -160,12 +161,16 @@ class ModelViewer extends SocketConsumer {
160
161
  }
161
162
  this.socket = socket;
162
163
 
164
+ let realtimeFields = this.hasAttribute('realtime-fields') ?
165
+ this.getAttribute('realtime-fields').split(',').map(field => field.trim()).filter(field => field) : null;
166
+
163
167
  this.model = new AGModel({
164
168
  socket: this.socket,
165
169
  type: modelType,
166
170
  id: modelId,
167
171
  fields: modelFields.split(',').map(field => field.trim()).filter(field => field),
168
- fieldTransformations
172
+ fieldTransformations,
173
+ realtimeFields
169
174
  });
170
175
 
171
176
  this.shadowRoot.innerHTML = `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasufy-components",
3
- "version": "9.3.1",
3
+ "version": "9.4.1",
4
4
  "description": "Components for Saasufy.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,8 +17,8 @@
17
17
  "author": "Jonathan Gros-Dubois",
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
- "ag-collection": "^5.4.1",
21
- "ag-model": "^3.2.1",
20
+ "ag-collection": "^6.0.0",
21
+ "ag-model": "^4.0.0",
22
22
  "capitalisk-auth-client": "^2.0.0",
23
23
  "socketcluster-client": "^20.0.1",
24
24
  "uuid": "^8.3.2"