|
5 | 5 | regular_images = raw_model.image_uploads.ordered.to_a |
6 | 6 | basil_images = (@basil_images || []).sort_by(&:position) |
7 | 7 |
|
8 | | - # Keep track of regular and AI images separately for display |
9 | | - images = regular_images |
10 | | - |
11 | 8 | # Calculate total images for display purposes |
12 | 9 | total_images = regular_images.count + basil_images.count |
13 | 10 |
|
|
22 | 19 | id: image.id, |
23 | 20 | type: 'image_upload', |
24 | 21 | data: image, |
25 | | - pinned: image.pinned? |
| 22 | + pinned: image.pinned?, |
| 23 | + created_at: image.created_at, |
| 24 | + position: image.position || 999999 |
26 | 25 | } |
27 | 26 | end |
28 | 27 |
|
|
31 | 30 | id: commission.id, |
32 | 31 | type: 'basil_commission', |
33 | 32 | data: commission, |
34 | | - pinned: commission.pinned? |
| 33 | + pinned: commission.pinned?, |
| 34 | + created_at: commission.saved_at, |
| 35 | + position: commission.position || 999999 |
35 | 36 | } |
36 | 37 | end |
37 | 38 |
|
38 | | - # If there's a pinned image, move it to the front |
39 | | - if pinned_image |
40 | | - combined_images.sort_by! { |img| img[:pinned] ? 0 : 1 } |
| 39 | + # Sort by position (using pinned status as priority) |
| 40 | + combined_images.sort_by! do |img| |
| 41 | + # The pinned flag is the primary sort key |
| 42 | + pinned_sort = img[:pinned] ? 0 : 1 |
| 43 | + # Position is the secondary sort key |
| 44 | + position_sort = img[:position] || 999999 |
| 45 | + # Created date is tertiary sort |
| 46 | + [pinned_sort, position_sort, img[:created_at] || Time.current] |
41 | 47 | end |
42 | 48 | %> |
43 | 49 |
|
44 | 50 | <div class="row"> |
45 | 51 | <div class="col s12"> |
46 | | - <% if images.any? || basil_images.any? %> |
| 52 | + <% if combined_images.any? %> |
47 | 53 | <!-- Gallery preview section --> |
48 | 54 | <div class="gallery-preview-section"> |
49 | 55 | <h5 class="gallery-section-title"> |
|
0 commit comments