saasufy-components 5.0.1 → 5.1.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/README.md +12 -0
- package/collection-adder-form.js +1 -1
- package/input-provider.js +15 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -286,6 +286,10 @@ Can also perform basic CRUD operations such as deleting or creating records by l
|
|
|
286
286
|
</div>
|
|
287
287
|
</template>
|
|
288
288
|
|
|
289
|
+
<template slot="no-item">
|
|
290
|
+
<div>There are no messages.</div>
|
|
291
|
+
</template>
|
|
292
|
+
|
|
289
293
|
<template slot="loader">
|
|
290
294
|
<div class="loading-spinner-container">
|
|
291
295
|
<div class="spinning">↻</div>
|
|
@@ -296,6 +300,13 @@ Can also perform basic CRUD operations such as deleting or creating records by l
|
|
|
296
300
|
</collection-viewer>
|
|
297
301
|
```
|
|
298
302
|
|
|
303
|
+
In addition to the slots shown above, the `collection-viewer` also supports the following optional slots:
|
|
304
|
+
- `previous-page`: This is typically an `input` element of type `button` for pagination.
|
|
305
|
+
- `next-page`: This is typically an `input` element of type `button` for pagination.
|
|
306
|
+
- `page-number`: This is typically a `div` element to display the current page number. Alternatively, it can be an `input-provider` element to allow the user to manually type in the page number.
|
|
307
|
+
- `first-item`: This should be a `template` element. It can be used to inject an element just above the first record. This can be useful to render the `collection-viewer` as a table with a heading above table rows.
|
|
308
|
+
- `last-item`: This should be a `template` element. It can be used to inject an element just after the last record.
|
|
309
|
+
|
|
299
310
|
**Attributes**
|
|
300
311
|
|
|
301
312
|
- `collection-type` (required): Specifies the type of collection to display. This should match a `Model` available in your Saasufy service.
|
|
@@ -380,6 +391,7 @@ This component is similar to the `collection-adder` component except that it req
|
|
|
380
391
|
- `model-values`: An optional list of key-value pairs in the format `field1=value1,field2=value2` to add to the newly created resource alongside the values collected from the user via the form. For non-string values, the type should be provided in the format `fieldName:type=value`; supported types are `string`, `number` and `boolean`. Unlike `collection-fields` which are rendered as input elements in the form, `model-values` are not shown to the user.
|
|
381
392
|
- `success-message`: A message to show the user if the resource has been successfully added to the collection after submitting the form.
|
|
382
393
|
- `trim-spaces`: If this attribute exists on the element, then leading and trailing spaces will be trimmed from each input element's value before submitting the form.
|
|
394
|
+
- `auto-reset-hidden-inputs`: If this attribute exists, then `hidden` input elements which are inside the `collection-adder-form` will be cleared along with other input fields. By default, `hidden` input elements are not cleared when the form is reset.
|
|
383
395
|
|
|
384
396
|
**Attributes of slotted input, select, textarea... elements**
|
|
385
397
|
|
package/collection-adder-form.js
CHANGED
|
@@ -155,7 +155,7 @@ class CollectionAdderForm extends SocketConsumer {
|
|
|
155
155
|
if (element.nodeName === 'INPUT') {
|
|
156
156
|
if (element.type === 'checkbox' || element.type === 'radio') {
|
|
157
157
|
element.checked = false;
|
|
158
|
-
} else {
|
|
158
|
+
} else if (element.type !== 'hidden' || this.hasAttribute('auto-reset-hidden-inputs')) {
|
|
159
159
|
element.value = '';
|
|
160
160
|
}
|
|
161
161
|
} else if (element.nodeName === 'TEXTAREA') {
|
package/input-provider.js
CHANGED
|
@@ -87,7 +87,8 @@ class InputProvider extends HTMLElement {
|
|
|
87
87
|
}
|
|
88
88
|
oldValue = this.inputElement.value;
|
|
89
89
|
this.inputElement.value = newValue;
|
|
90
|
-
if (oldValue !== newValue) {
|
|
90
|
+
if (oldValue !== newValue || this.forceTriggerChange) {
|
|
91
|
+
delete this.forceTriggerChange;
|
|
91
92
|
this.triggerChange();
|
|
92
93
|
}
|
|
93
94
|
}
|
|
@@ -115,6 +116,14 @@ class InputProvider extends HTMLElement {
|
|
|
115
116
|
let height = this.getAttribute('height');
|
|
116
117
|
let value = this.getAttribute('value') || '';
|
|
117
118
|
let inputProps = this.getAttribute('input-props');
|
|
119
|
+
let name = this.getAttribute('name');
|
|
120
|
+
|
|
121
|
+
if (name) {
|
|
122
|
+
inputProps = {
|
|
123
|
+
name,
|
|
124
|
+
...inputProps
|
|
125
|
+
};
|
|
126
|
+
}
|
|
118
127
|
|
|
119
128
|
let elementType;
|
|
120
129
|
if (type === 'select') {
|
|
@@ -169,6 +178,11 @@ class InputProvider extends HTMLElement {
|
|
|
169
178
|
}
|
|
170
179
|
}
|
|
171
180
|
|
|
181
|
+
if (type === 'select') {
|
|
182
|
+
this.forceTriggerChange = true;
|
|
183
|
+
value = this.inputElement.value;
|
|
184
|
+
}
|
|
185
|
+
|
|
172
186
|
this.updateInputClassList(value);
|
|
173
187
|
this.appendChild(this.inputElement);
|
|
174
188
|
|