formstrap 0.4.2 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/formstrap/controllers/media_controller.js +8 -1
- data/app/assets/javascripts/formstrap/controllers/select_controller.js +8 -1
- data/app/assets/javascripts/formstrap.js +14 -2
- data/app/models/formstrap/select_view.rb +2 -1
- data/lib/formstrap/version.rb +1 -1
- data/package.json +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9036a76a91e170b7fb332d006940db1273770254f9d26c090365c512ce0e0c16
|
4
|
+
data.tar.gz: 22433a20c6970ddcee18a5df637cc7a4506bc77d4516e73b3c39cc76af3026ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 733e8dc5350e55ae59df878de51daa8da355159eeccb7875ff5d9c0bfa19fafa7fc6019ed6e8779eca09a07a3657e451145f5e2c98d6f53e3bf91118ccda24d4
|
7
|
+
data.tar.gz: 3c39838520f7dc0d62bc010ca159e91c6df28e179c505c825362d50c941a9b972fb1845657352466e59517d3c903a27a9b86b60769392e4af7d77350c0e6d8ea
|
@@ -197,7 +197,8 @@ export default class extends Controller {
|
|
197
197
|
|
198
198
|
createItem (item) {
|
199
199
|
// Copy template
|
200
|
-
|
200
|
+
let templateHtml = this.templateTarget
|
201
|
+
templateHtml = this.randomizeIds(templateHtml)
|
201
202
|
this.thumbnailsTarget.insertAdjacentHTML('beforeend', templateHtml)
|
202
203
|
|
203
204
|
// Set new values
|
@@ -217,6 +218,12 @@ export default class extends Controller {
|
|
217
218
|
oldThumbnail.parentNode.replaceChild(newThumbnail, oldThumbnail)
|
218
219
|
}
|
219
220
|
|
221
|
+
randomizeIds (template) {
|
222
|
+
const regex = new RegExp(template.dataset.templateIdRegex, 'g')
|
223
|
+
const randomNumber = crypto.randomUUID().substring(0, 8)
|
224
|
+
return template.innerHTML.replace(regex, randomNumber)
|
225
|
+
}
|
226
|
+
|
220
227
|
removeAllDeselectedItems (items) {
|
221
228
|
this.removeDeselectedItems(items, this.itemTargets)
|
222
229
|
}
|
@@ -3,6 +3,10 @@ import TomSelect from 'tom-select'
|
|
3
3
|
import I18n from '../config/i18n'
|
4
4
|
|
5
5
|
export default class extends Controller {
|
6
|
+
static values = {
|
7
|
+
selected: Array
|
8
|
+
}
|
9
|
+
|
6
10
|
connect () {
|
7
11
|
if (this.element.hasAttribute('multiple') || this.element.dataset.tomSelect === 'true') {
|
8
12
|
this.initTomSelect()
|
@@ -45,7 +49,10 @@ export default class extends Controller {
|
|
45
49
|
|
46
50
|
initTomSelect () {
|
47
51
|
const defaultOptions = this.defaultOptions()
|
48
|
-
const options = {
|
52
|
+
const options = {
|
53
|
+
create: this.hasTags(),
|
54
|
+
items: this.selectedValue
|
55
|
+
}
|
49
56
|
|
50
57
|
/* eslint-disable no-new */
|
51
58
|
new TomSelect(this.element, { ...defaultOptions, ...options })
|
@@ -11221,7 +11221,8 @@ var media_controller_default = class extends Controller {
|
|
11221
11221
|
item.classList.remove("d-none");
|
11222
11222
|
}
|
11223
11223
|
createItem(item) {
|
11224
|
-
|
11224
|
+
let templateHtml = this.templateTarget;
|
11225
|
+
templateHtml = this.randomizeIds(templateHtml);
|
11225
11226
|
this.thumbnailsTarget.insertAdjacentHTML("beforeend", templateHtml);
|
11226
11227
|
const newItem = this.itemTargets.pop();
|
11227
11228
|
newItem.querySelector('input[name*="[blob_id]"]').value = item.blobId;
|
@@ -11234,6 +11235,11 @@ var media_controller_default = class extends Controller {
|
|
11234
11235
|
const newThumbnail = item.thumbnail.cloneNode(true);
|
11235
11236
|
oldThumbnail.parentNode.replaceChild(newThumbnail, oldThumbnail);
|
11236
11237
|
}
|
11238
|
+
randomizeIds(template) {
|
11239
|
+
const regex = new RegExp(template.dataset.templateIdRegex, "g");
|
11240
|
+
const randomNumber = crypto.randomUUID().substring(0, 8);
|
11241
|
+
return template.innerHTML.replace(regex, randomNumber);
|
11242
|
+
}
|
11237
11243
|
removeAllDeselectedItems(items) {
|
11238
11244
|
this.removeDeselectedItems(items, this.itemTargets);
|
11239
11245
|
}
|
@@ -13429,10 +13435,16 @@ var select_controller_default = class extends Controller {
|
|
13429
13435
|
}
|
13430
13436
|
initTomSelect() {
|
13431
13437
|
const defaultOptions = this.defaultOptions();
|
13432
|
-
const options = {
|
13438
|
+
const options = {
|
13439
|
+
create: this.hasTags(),
|
13440
|
+
items: this.selectedValue
|
13441
|
+
};
|
13433
13442
|
new import_tom_select.default(this.element, { ...defaultOptions, ...options });
|
13434
13443
|
}
|
13435
13444
|
};
|
13445
|
+
__publicField(select_controller_default, "values", {
|
13446
|
+
selected: Array
|
13447
|
+
});
|
13436
13448
|
|
13437
13449
|
// app/assets/javascripts/formstrap/controllers/textarea_controller.js
|
13438
13450
|
var textarea_controller_default = class extends Controller {
|
data/lib/formstrap/version.rb
CHANGED
data/package.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jef Vlamings
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: An extensive Bootstrap form library to power your Ruby On Rails application.
|
14
14
|
email:
|