saasufy-components 1.7.0 → 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/collection-browser.js +15 -3
- 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
|
};
|
package/collection-browser.js
CHANGED
|
@@ -155,12 +155,19 @@ class CollectionBrowser extends SocketConsumer {
|
|
|
155
155
|
|
|
156
156
|
let itemTemplate = this.shadowRoot.querySelector('slot[name="item"]').assignedNodes()[0];
|
|
157
157
|
let noItemTemplate = this.shadowRoot.querySelector('slot[name="no-item"]').assignedNodes()[0];
|
|
158
|
+
let firstItemTemplate = this.shadowRoot.querySelector('slot[name="first-item"]').assignedNodes()[0];
|
|
159
|
+
let lastItemTemplate = this.shadowRoot.querySelector('slot[name="last-item"]').assignedNodes()[0];
|
|
158
160
|
|
|
161
|
+
let items = [];
|
|
162
|
+
|
|
163
|
+
if (firstItemTemplate) {
|
|
164
|
+
items.push(firstItemTemplate.innerHTML);
|
|
165
|
+
}
|
|
159
166
|
if (noItemTemplate && !this.collection.value.length) {
|
|
160
|
-
|
|
167
|
+
items.push(noItemTemplate.innerHTML);
|
|
161
168
|
} else if (itemTemplate) {
|
|
162
169
|
let type = this.getAttribute('type-alias') || this.collection.type;
|
|
163
|
-
|
|
170
|
+
|
|
164
171
|
for (let modelItem of this.collection.value) {
|
|
165
172
|
let itemString = renderTemplate(
|
|
166
173
|
itemTemplate.innerHTML,
|
|
@@ -168,8 +175,11 @@ class CollectionBrowser extends SocketConsumer {
|
|
|
168
175
|
);
|
|
169
176
|
items.push(itemString);
|
|
170
177
|
}
|
|
171
|
-
viewportNode.innerHTML = items.join('');
|
|
172
178
|
}
|
|
179
|
+
if (lastItemTemplate) {
|
|
180
|
+
items.push(lastItemTemplate.innerHTML);
|
|
181
|
+
}
|
|
182
|
+
viewportNode.innerHTML = items.join('');
|
|
173
183
|
}
|
|
174
184
|
|
|
175
185
|
render() {
|
|
@@ -204,6 +214,8 @@ class CollectionBrowser extends SocketConsumer {
|
|
|
204
214
|
this.shadowRoot.innerHTML = `
|
|
205
215
|
<slot name="item"></slot>
|
|
206
216
|
<slot name="no-item"></slot>
|
|
217
|
+
<slot name="first-item"></slot>
|
|
218
|
+
<slot name="last-item"></slot>
|
|
207
219
|
<slot name="viewport"></slot>
|
|
208
220
|
<slot name="previous-page"></slot>
|
|
209
221
|
<slot name="page-number"></slot>
|