saasufy-components 7.3.0 → 7.3.2
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 +5 -13
- package/collection-adder.js +1 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -413,6 +413,7 @@ This component is similar to the `collection-adder` component except that it req
|
|
|
413
413
|
**Attributes of slotted input, select, textarea... elements**
|
|
414
414
|
|
|
415
415
|
- `name` (required): This must correspond to a field name on the model specified via the `collection-type` attribute of the `collection-adder-form`.
|
|
416
|
+
- `output-type`: An optional type to cast the value of the input element into when the form is submitted.
|
|
416
417
|
|
|
417
418
|
### collection-deleter
|
|
418
419
|
|
package/collection-adder-form.js
CHANGED
|
@@ -77,7 +77,10 @@ class CollectionAdderForm extends SocketConsumer {
|
|
|
77
77
|
} else {
|
|
78
78
|
inputType = input.type;
|
|
79
79
|
}
|
|
80
|
-
let Type = getTypeCastFunction(
|
|
80
|
+
let Type = getTypeCastFunction(
|
|
81
|
+
inputType === 'hidden' ?
|
|
82
|
+
input.getAttribute('output-type') : inputType
|
|
83
|
+
);
|
|
81
84
|
let value;
|
|
82
85
|
if (inputType === 'file' && input.files && input.files.length) {
|
|
83
86
|
let reader = new FileReader();
|
|
@@ -198,21 +201,10 @@ class CollectionAdderForm extends SocketConsumer {
|
|
|
198
201
|
let collectionType = this.getAttribute('collection-type');
|
|
199
202
|
|
|
200
203
|
let {
|
|
201
|
-
fieldTypes: modelFieldTypes,
|
|
202
204
|
fieldValues: modelFieldValues
|
|
203
205
|
} = convertStringToFieldParams(this.getAttribute('model-values'));
|
|
204
206
|
|
|
205
|
-
this.modelFieldValues =
|
|
206
|
-
Object.entries(modelFieldValues).map(([key, value]) => {
|
|
207
|
-
if (modelFieldTypes[key] === 'boolean') {
|
|
208
|
-
return [ key, value !== 'false' && value !== '' ];
|
|
209
|
-
}
|
|
210
|
-
if (modelFieldTypes[key] === 'number') {
|
|
211
|
-
return [ key, Number(value) ];
|
|
212
|
-
}
|
|
213
|
-
return [ key, value ];
|
|
214
|
-
})
|
|
215
|
-
);
|
|
207
|
+
this.modelFieldValues = modelFieldValues;
|
|
216
208
|
|
|
217
209
|
if (this.collection) this.collection.destroy();
|
|
218
210
|
|
package/collection-adder.js
CHANGED
|
@@ -184,7 +184,6 @@ class CollectionAdder extends SocketConsumer {
|
|
|
184
184
|
|
|
185
185
|
let {
|
|
186
186
|
fieldNames: modelFieldNames,
|
|
187
|
-
fieldTypes: modelFieldTypes,
|
|
188
187
|
fieldValues: modelFieldValues
|
|
189
188
|
} = convertStringToFieldParams(this.getAttribute('model-values'));
|
|
190
189
|
|
|
@@ -205,17 +204,7 @@ class CollectionAdder extends SocketConsumer {
|
|
|
205
204
|
autocorrect ? ` autocorrect="${autocorrect}"` : ''
|
|
206
205
|
}`;
|
|
207
206
|
|
|
208
|
-
this.modelFieldValues =
|
|
209
|
-
Object.entries(modelFieldValues).map(([key, value]) => {
|
|
210
|
-
if (modelFieldTypes[key] === 'boolean') {
|
|
211
|
-
return [ key, value !== 'false' && value !== '' ];
|
|
212
|
-
}
|
|
213
|
-
if (modelFieldTypes[key] === 'number') {
|
|
214
|
-
return [ key, Number(value) ];
|
|
215
|
-
}
|
|
216
|
-
return [ key, value ];
|
|
217
|
-
})
|
|
218
|
-
);
|
|
207
|
+
this.modelFieldValues = modelFieldValues;
|
|
219
208
|
|
|
220
209
|
if (this.collection) this.collection.destroy();
|
|
221
210
|
|