tramway 3.1.2.7 → 3.1.2.8
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.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/app/assets/javascripts/tramway/tramway.js +19 -4
- data/app/components/tramway/flash_component.html.haml +6 -0
- data/lib/tramway/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4734bad656c9c6530213422f8e87e54ce595404ef127010b781e45af3f94967a
|
|
4
|
+
data.tar.gz: d9b3ee1e03ccfe40912955fd490ccc88a6b127965696b9956ecf5d5ced27e727
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 54ade07629589d86733af1c559579cae2d1dab1d35f21616bd3e01ddcd3e964f027ce8fa71a44dede44061382b5637887151c680236b22ca2eb5abba5af82346
|
|
7
|
+
data.tar.gz: 9c37d9d2b6e868e34c533034e3f40e4953c21120986c0d68aaadf351f21732e7ef31955a354048a2bae669e624711691e743778507cd6107de57fd66211dc04c
|
data/README.md
CHANGED
|
@@ -1380,6 +1380,9 @@ Autocomplete select example:
|
|
|
1380
1380
|
`autocomplete: true` renders an autocomplete-enabled select. It cannot be used together with `multiselect: true` in the
|
|
1381
1381
|
same select field.
|
|
1382
1382
|
|
|
1383
|
+
When you use `multiselect: true`, make sure any preselected values still exist in the collection you render. Unknown
|
|
1384
|
+
values are ignored by the widget so the select can still boot safely.
|
|
1385
|
+
|
|
1383
1386
|
**Examples**
|
|
1384
1387
|
|
|
1385
1388
|
1. Sign In Form for `devise` authentication
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
/* global console */
|
|
2
3
|
|
|
3
4
|
class TramwaySelect extends Controller {
|
|
4
5
|
static targets = ["dropdown", "showSelectedArea", "hiddenInput", "caretDown", "caretUp"]
|
|
@@ -32,11 +33,21 @@ class TramwaySelect extends Controller {
|
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
const initialValues = this.element.dataset.value === undefined ? [] : JSON.parse(this.element.dataset.value);
|
|
36
|
+
const selectedValues = new Set(initialValues.map(value => value.toString()));
|
|
37
|
+
const missingValues = initialValues
|
|
38
|
+
.map(value => value.toString())
|
|
39
|
+
.filter(value => !this.items.some(item => item.value.toString() === value));
|
|
40
|
+
|
|
41
|
+
if (missingValues.length > 0) {
|
|
42
|
+
console.warn(
|
|
43
|
+
`Tramway select ignored ${missingValues.length} stale selected value${missingValues.length === 1 ? '' : 's'} ` +
|
|
44
|
+
`that are not present in the collection: ${missingValues.join(', ')}.`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})
|
|
48
|
+
this.items.forEach(item => {
|
|
49
|
+
item.selected = selectedValues.has(item.value.toString());
|
|
50
|
+
});
|
|
40
51
|
|
|
41
52
|
this.selectedItems = this.items.filter(item => item.selected);
|
|
42
53
|
|
|
@@ -137,6 +148,10 @@ class TramwaySelect extends Controller {
|
|
|
137
148
|
const itemIndex = this.items.findIndex(x => x.value === currentTarget.dataset.value);
|
|
138
149
|
const itemSelectedIndex = this.selectedItems.findIndex(x => x.value === currentTarget.dataset.value);
|
|
139
150
|
|
|
151
|
+
if (itemIndex === -1) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
140
155
|
if (!this.multiple()) {
|
|
141
156
|
this.selectedItems = [];
|
|
142
157
|
this.items.forEach(item => item.selected = false);
|
|
@@ -2,14 +2,20 @@
|
|
|
2
2
|
@keyframes fadeout {
|
|
3
3
|
0% {
|
|
4
4
|
opacity: 1;
|
|
5
|
+
visibility: visible;
|
|
6
|
+
pointer-events: auto;
|
|
5
7
|
}
|
|
6
8
|
|
|
7
9
|
80% {
|
|
8
10
|
opacity: 1;
|
|
11
|
+
visibility: visible;
|
|
12
|
+
pointer-events: auto;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
100% {
|
|
12
16
|
opacity: 0;
|
|
17
|
+
visibility: hidden;
|
|
18
|
+
pointer-events: none;
|
|
13
19
|
}
|
|
14
20
|
}
|
|
15
21
|
|
data/lib/tramway/version.rb
CHANGED