saasufy-components 9.0.0 → 9.0.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 +1 -0
- package/collection-adder-form.js +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -494,6 +494,7 @@ This component is similar to the `collection-adder` component except that it req
|
|
|
494
494
|
- `success-message`: A message to show the user if the resource has been successfully added to the collection after submitting the form.
|
|
495
495
|
- `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.
|
|
496
496
|
- `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.
|
|
497
|
+
- `disable-submit-on-enter-key`: If this attribute exists, then the form will not submit when the enter key is pressed.
|
|
497
498
|
- `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.
|
|
498
499
|
- `consumers`: This allows you to connect this `collection-adder-form` to other elements on your page. It should be used in conjunction with the `provider-template` attribute. The `consumers` attribute takes a list of selectors with optional attributes to target in the format `element-selector:attribute-name`. For example `.my-input:value` will find all elements with a `my-input` class and update their `value` attributes with the output of the `collection-adder-form` component on submit. You can specify multiple selectors separated by commas such as `.my-input,my-div`; in this case, because attribute names are not specified, values will be injected into the `value` attribute (for input elements) or into the `innerHTML` property (for other kinds of elements). The default attribute/property depends on the element type.
|
|
499
500
|
- `success-consumers`: Same as the `consumers` attribute but the target elements are only updated if insertion was a success.
|
package/collection-adder-form.js
CHANGED
|
@@ -33,6 +33,7 @@ class CollectionAdderForm extends SocketConsumer {
|
|
|
33
33
|
'collection-type',
|
|
34
34
|
'model-values',
|
|
35
35
|
'success-message',
|
|
36
|
+
'disable-submit-on-enter-key',
|
|
36
37
|
'trim-spaces'
|
|
37
38
|
];
|
|
38
39
|
}
|
|
@@ -244,6 +245,14 @@ class CollectionAdderForm extends SocketConsumer {
|
|
|
244
245
|
await this.submit();
|
|
245
246
|
}
|
|
246
247
|
});
|
|
248
|
+
|
|
249
|
+
if (!this.hasAttribute('disable-submit-on-enter-key')) {
|
|
250
|
+
inputSlot.addEventListener('keydown', async (event) => {
|
|
251
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
252
|
+
await this.submit();
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
247
256
|
}
|
|
248
257
|
}
|
|
249
258
|
|