formstrap 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee49a6e7a9f068d3403b4ebfd46c19cf07b6c293e8893f1e561e8ae20ed0af77
4
- data.tar.gz: f85517d919e6c9360ac31c7f1aa7b8f2ff3705ea31a2a6a76f0b72ae82f58c30
3
+ metadata.gz: 50b7aa8b45373a4b43cd424293b56eeb64590fc55c065a9b651e5158109535fe
4
+ data.tar.gz: 7d1a6a62da8d0f14ff326b3613378b3f7c0f55362944923d2fab8a2d9e8668bc
5
5
  SHA512:
6
- metadata.gz: ab80f8fd25603f0c9ce6f5ea6c92dc025b62f7b932f0b0e7bd7867bd4432845f902a6f5f7ba6492a6455ae9f3eb93fe411497a9dc2cf346538e3a610a05fd253
7
- data.tar.gz: a5db302d1730c5f0cb801ddf248d24a0c5111ec0f8ae6d7aaa24d5a36c0e50913f1939a71df275c47429016162b59e47024a4be0e186e23b661c3393321cb9e4
6
+ metadata.gz: e9b5821af79d4065266e3a9e61e74fadc07588f04079ee00d273ddc722f8b2a6ecd31db3012019de739006bbcc90cb219f95fc2f9cb9ca215a8a0677d4bc66d5
7
+ data.tar.gz: e90836b7abe84b63a3cf7df7bb17df0e48ba9cdad8b7eb52b58e8304d19cbba459c12451f950df889035548432260b20a3306dd7b65533fc979266c9dc695acf
@@ -197,7 +197,8 @@ export default class extends Controller {
197
197
 
198
198
  createItem (item) {
199
199
  // Copy template
200
- const templateHtml = this.templateTarget.innerHTML
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
  }
@@ -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
- const templateHtml = this.templateTarget.innerHTML;
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
  }
@@ -1,3 +1,3 @@
1
1
  module Formstrap
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontierdotbe/formstrap",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Bootstrap-powered Form Helpers",
5
5
  "module": "app/assets/javascripts/formstrap.js",
6
6
  "main": "app/assets/javascripts/formstrap.js",
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.2
4
+ version: 0.4.3
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-06-27 00:00:00.000000000 Z
11
+ date: 2024-07-08 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: