saasufy-components 1.7.1 → 1.7.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/collection-adder.js +34 -21
- package/package.json +1 -1
package/collection-adder.js
CHANGED
|
@@ -8,6 +8,7 @@ class CollectionAdder extends SocketConsumer {
|
|
|
8
8
|
|
|
9
9
|
this.typeCastFunctions = {
|
|
10
10
|
text: String,
|
|
11
|
+
textarea: String,
|
|
11
12
|
checkbox: Boolean,
|
|
12
13
|
number: Number
|
|
13
14
|
};
|
|
@@ -112,8 +113,8 @@ class CollectionAdder extends SocketConsumer {
|
|
|
112
113
|
inputTypeParams = inputTypeParts[3] ? inputTypeParts[3].split(',') : [];
|
|
113
114
|
}
|
|
114
115
|
if (inputType === 'checkbox') {
|
|
115
|
-
items.push(
|
|
116
|
-
|
|
116
|
+
items.push(
|
|
117
|
+
`<label>
|
|
117
118
|
${
|
|
118
119
|
field
|
|
119
120
|
}
|
|
@@ -122,23 +123,29 @@ class CollectionAdder extends SocketConsumer {
|
|
|
122
123
|
}" name="${
|
|
123
124
|
field
|
|
124
125
|
}" />
|
|
125
|
-
</label
|
|
126
|
-
|
|
126
|
+
</label>`
|
|
127
|
+
);
|
|
127
128
|
} else if (inputType === 'text-select') {
|
|
128
129
|
items.push(
|
|
129
|
-
|
|
130
|
-
<
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
<
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
130
|
+
`<div class="collection-adder-select-text-row">
|
|
131
|
+
<input class="collection-adder-input" type="text" name="${
|
|
132
|
+
field
|
|
133
|
+
}" placeholder="${
|
|
134
|
+
field
|
|
135
|
+
}" />
|
|
136
|
+
<select class="collection-adder-select">
|
|
137
|
+
<option value="" selected disabled hidden>Options</option>
|
|
138
|
+
${inputTypeParams.map(param => `<option value="${param}">${param}</option>`)}
|
|
139
|
+
</select>
|
|
140
|
+
</div>`
|
|
141
|
+
);
|
|
142
|
+
} else if (inputType === 'textarea') {
|
|
143
|
+
items.push(
|
|
144
|
+
`<textarea class="collection-adder-input" name="${
|
|
145
|
+
field
|
|
146
|
+
}" placeholder="${
|
|
147
|
+
field
|
|
148
|
+
}"></textarea>`
|
|
142
149
|
);
|
|
143
150
|
} else {
|
|
144
151
|
items.push(
|
|
@@ -186,11 +193,17 @@ class CollectionAdder extends SocketConsumer {
|
|
|
186
193
|
...modelFieldValues,
|
|
187
194
|
...Object.fromEntries(
|
|
188
195
|
[...event.target.querySelectorAll('.collection-adder-input')]
|
|
196
|
+
.filter(input => input.value !== '')
|
|
189
197
|
.map((input) => {
|
|
190
|
-
let
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
198
|
+
let fieldType = fieldTypes[input.name];
|
|
199
|
+
let Type = this.getTypeCastFunction(fieldType);
|
|
200
|
+
let value;
|
|
201
|
+
if (fieldType === 'checkbox') {
|
|
202
|
+
value = input.checked;
|
|
203
|
+
} else {
|
|
204
|
+
value = input.value;
|
|
205
|
+
}
|
|
206
|
+
return [ input.name, Type(value) ];
|
|
194
207
|
})
|
|
195
208
|
)
|
|
196
209
|
};
|