bullet_train 1.30.0 → 1.30.1
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/docs/super-scaffolding/sortable.md +37 -2
- data/lib/bullet_train/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: d9f6244b94a762526cb882b252268da769b8a57128a9c14146e8f59f02b4458b
|
4
|
+
data.tar.gz: 77aaadf410ce7bdc6fe99f84e3683e537b0c7699e57186f0f0729d23e42b1978
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b28b0737f177702aea10af4e93180458d5ae7b7b731d5f7925042287ee376872b99b0a9816457d52c0eecd7e8e99d4fae962466104c004db30c92c49517f9eab
|
7
|
+
data.tar.gz: 609d5613617adb5819c61c2fe076126f1cff5a53074e254de6a622dcde0133c6ea1248ec3c0284acfa9e515fadcf4f05478058336066b8eab461e8487c4680da
|
@@ -180,10 +180,10 @@ Using the example of a sortable `Page` model from above you'll want to update tw
|
|
180
180
|
|
181
181
|
### `app/views/account/pages/_page.html.erb`
|
182
182
|
|
183
|
-
In `app/views/account/pages/_page.html.erb` you should add a `<td>` as the first cell
|
183
|
+
In `app/views/account/pages/_page.html.erb` you should add a `class="group"` attribute to the `<tr>`, and add a `<td>` containing a drag handle as the first cell inside the `<tr>`. Be sure to include `data-sortable-target="handle"` on the cell so that the controller recognizes it as a handle.
|
184
184
|
|
185
185
|
```html
|
186
|
-
<tr data-id="<%= page.id %>">
|
186
|
+
<tr data-id="<%= page.id %>" class="group"> <!-- Add the class attribute on this line! -->
|
187
187
|
<td class="cursor-grab active:cursor-grabbing" data-sortable-target="handle"><i class="ti ti-menu opacity-25 group-hover:opacity-100"></i></td> <!-- Add this line! -->
|
188
188
|
<!-- Your existing cells here -->
|
189
189
|
</tr>
|
@@ -202,4 +202,39 @@ In `app/views/account/pages/_index.html.erb` you should add an empty `<td>` as t
|
|
202
202
|
</thead>
|
203
203
|
```
|
204
204
|
|
205
|
+
## Drag styling
|
205
206
|
|
207
|
+
The visual styling of dragged items and drop targets is handled by the addition and removal of specific class names by the controller.
|
208
|
+
|
209
|
+
To override the default styles you could write some custom CSS like this:
|
210
|
+
|
211
|
+
```css
|
212
|
+
.sortable-active-dropzone {
|
213
|
+
/* Styles for the entire table when a drag is in progress. */
|
214
|
+
}
|
215
|
+
|
216
|
+
.sortable-active-item {
|
217
|
+
/* Styles for the item that is being dragged. */
|
218
|
+
}
|
219
|
+
|
220
|
+
.sortable-drop-target {
|
221
|
+
/* Styles for the empty space representing the new location for the item being dragged. */
|
222
|
+
}
|
223
|
+
```
|
224
|
+
|
225
|
+
Any styles you add to those classes will be combined with the defaults.
|
226
|
+
|
227
|
+
If you'd like to start fresh with a clean set of classes you can tell the controller to use different class names by adding some data attributes to the primary `sortable` target (the `<tbody>` tag by default).
|
228
|
+
|
229
|
+
For instance:
|
230
|
+
|
231
|
+
```erb
|
232
|
+
<tbody data-controller="sortable" data-sortable-reorder-path-value="<%= url_for [:reorder, :account, context, collection] %>"
|
233
|
+
|
234
|
+
<%# Use Stimulus class attributes to make the controller apply different class names: %>
|
235
|
+
data-sortable-active-dropzone-class="your-custom-active-dropzone-class-name"
|
236
|
+
data-sortable-active-item-class="your-custom-active-item-class-name"
|
237
|
+
data-sortable-drop-target-class="your-custom-drop-target-class-name"
|
238
|
+
|
239
|
+
>
|
240
|
+
```
|
data/lib/bullet_train/version.rb
CHANGED