saasufy-components 3.6.1 → 3.7.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
@@ -227,6 +227,7 @@ Can also perform basic CRUD operations such as deleting or creating records by l
227
227
  - `collection-page-size`: Sets how many items from the collection are displayed at once. This is useful for pagination, allowing users to navigate through large sets of data in chunks.
228
228
  - `collection-page-offset`: Indicates the current page offset in the collection's data. It’s like telling the browser which page of data you want to display initially.
229
229
  - `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}}`.
230
+ - `auto-reset-page-offset`: If this attribute is present, the `collection-page-offset` will be reset to zero whenever the view params change.
230
231
  - `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-browser` 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}}`.
231
232
  - `hide-error-logs`: A flag which, when present, suppresses error logs from being printed to the console.
232
233
  - `max-show-loader`: If this attribute is present, your slotted `loader` element will be shown as often as possible; this includes situations where the collection is merely refreshing itself. It is disabled by default.
@@ -104,6 +104,7 @@ class CollectionBrowser extends SocketConsumer {
104
104
  'collection-page-size',
105
105
  'collection-page-offset',
106
106
  'collection-get-count',
107
+ 'auto-reset-page-offset',
107
108
  'max-show-loader',
108
109
  'type-alias',
109
110
  'hide-error-logs'
@@ -112,15 +113,23 @@ class CollectionBrowser extends SocketConsumer {
112
113
 
113
114
  attributeChangedCallback(name, oldValue, newValue) {
114
115
  if (!this.isReady) return;
115
- if (this.collection && name === 'collection-page-offset') {
116
- let newOffset = Number(newValue);
117
- if (newOffset !== this.collection.meta.pageOffset) {
118
- this.isStale = true;
119
- this.collection.fetchPage(newOffset);
116
+ if (name === 'collection-page-offset') {
117
+ if (this.collection) {
118
+ let newOffset = Number(newValue);
119
+ if (newOffset !== this.collection.meta.pageOffset) {
120
+ this.isStale = true;
121
+ this.collection.fetchPage(newOffset);
122
+ }
123
+ this.updatePageNumberElements();
124
+ this.updatePageButtons();
120
125
  }
121
- this.updatePageNumberElements();
122
- this.updatePageButtons();
123
126
  } else {
127
+ let autoResetPageOffset = this.hasAttribute('auto-reset-page-offset');
128
+ if (autoResetPageOffset) {
129
+ if (this.collection) this.collection.destroy();
130
+ delete this.collection;
131
+ this.goToPage(0);
132
+ }
124
133
  this.render();
125
134
  }
126
135
  }
package/model-input.js CHANGED
@@ -169,7 +169,7 @@ class ModelInput extends SocketConsumer {
169
169
  this.inputElement = document.createElement(elementType);
170
170
  let optionList = null;
171
171
  if (type === 'select') {
172
- if (options) {
172
+ if (options != null) {
173
173
  optionList = options.split(',');
174
174
  let optionElements = optionList
175
175
  .map((option) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasufy-components",
3
- "version": "3.6.1",
3
+ "version": "3.7.1",
4
4
  "description": "Components for Saasufy.",
5
5
  "main": "index.js",
6
6
  "scripts": {