saasufy-components 5.3.0 → 5.4.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 +4 -0
- package/collection-adder-form.js +8 -0
- package/collection-adder.js +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -364,6 +364,8 @@ This component is a simplified version of the `collection-adder-form` component
|
|
|
364
364
|
- `autocorrect`: Can be set to `off` to disable auto-correction of input on mobile devices.
|
|
365
365
|
- `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.
|
|
366
366
|
- `consumers`: This allows you to connect this `collection-adder` 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` 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.
|
|
367
|
+
- `success-consumers`: Same as the `consumers` attribute but the target elements are only updated if insertion was a success.
|
|
368
|
+
- `error-consumers`: Same as the `consumers` attribute but the target elements are only updated if insertion was a failure.
|
|
367
369
|
- `provider-template`: A template string within which the `{{value}}` can be injected before passing to consumers. In the case of the `collection-adder` component, the value is an object with either a `resource` property (on successful insert) or `error` (on failure). On success, the `resource` object will be the object which was added to the collection. On failure, the `error` object will be a JavaScript `Error` object with a `message` property.
|
|
368
370
|
|
|
369
371
|
### collection-adder-form
|
|
@@ -402,6 +404,8 @@ This component is similar to the `collection-adder` component except that it req
|
|
|
402
404
|
- `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.
|
|
403
405
|
- `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.
|
|
404
406
|
- `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.
|
|
407
|
+
- `success-consumers`: Same as the `consumers` attribute but the target elements are only updated if insertion was a success.
|
|
408
|
+
- `error-consumers`: Same as the `consumers` attribute but the target elements are only updated if insertion was a failure.
|
|
405
409
|
- `provider-template`: A template string within which the `{{value}}` can be injected before passing to consumers. In the case of the `collection-adder-form` component, the value is an object with either a `resource` property (on successful insert) or `error` (on failure). On success, the `resource` object will be the object which was added to the collection. On failure, the `error` object will be a JavaScript `Error` object with a `message` property.
|
|
406
410
|
|
|
407
411
|
**Attributes of slotted input, select, textarea... elements**
|
package/collection-adder-form.js
CHANGED
|
@@ -152,6 +152,14 @@ class CollectionAdderForm extends SocketConsumer {
|
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
154
|
let consumers = this.getAttribute('consumers');
|
|
155
|
+
let outcomeConsumers = this.getAttribute(outputValue.error ? 'error-consumers' : 'success-consumers');
|
|
156
|
+
if (consumers) {
|
|
157
|
+
if (outcomeConsumers) {
|
|
158
|
+
consumers = `${consumers},${outcomeConsumers}`;
|
|
159
|
+
}
|
|
160
|
+
} else if (outcomeConsumers) {
|
|
161
|
+
consumers = outcomeConsumers;
|
|
162
|
+
}
|
|
155
163
|
let providerTemplate = this.getAttribute('provider-template');
|
|
156
164
|
updateConsumerElements(consumers, outputValue, providerTemplate, this.getAttribute('name'));
|
|
157
165
|
}
|
package/collection-adder.js
CHANGED
|
@@ -149,6 +149,14 @@ class CollectionAdder extends SocketConsumer {
|
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
let consumers = this.getAttribute('consumers');
|
|
152
|
+
let outcomeConsumers = this.getAttribute(outputValue.error ? 'error-consumers' : 'success-consumers');
|
|
153
|
+
if (consumers) {
|
|
154
|
+
if (outcomeConsumers) {
|
|
155
|
+
consumers = `${consumers},${outcomeConsumers}`;
|
|
156
|
+
}
|
|
157
|
+
} else if (outcomeConsumers) {
|
|
158
|
+
consumers = outcomeConsumers;
|
|
159
|
+
}
|
|
152
160
|
let providerTemplate = this.getAttribute('provider-template');
|
|
153
161
|
updateConsumerElements(consumers, outputValue, providerTemplate, this.getAttribute('name'));
|
|
154
162
|
}
|