effective_bootstrap 1.21.19 → 1.22.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb3798d8e9ef7bfd8032c9ca14b4e882acd8ab4c98f044148c5339378eeddc75
4
- data.tar.gz: 234097c1eec1005076aa924ba965a8bb5a73d1f6c4d1c618f3ed911d60dfddc0
3
+ metadata.gz: 67309075b096a201f87cb46e5eb5a232320b9eb30f3d627f842d5a1a9d574a6b
4
+ data.tar.gz: 690e7121600303eb322ac8ae6f2f3dcf5cc1a5914e205b6dd5a2a97466075326
5
5
  SHA512:
6
- metadata.gz: 32d9a426708c93c5b0d276cc3d5f45abe54b7a850b898aca9818d07607686b896743387efda84c4f73a1d068b970ae11ef2dc20fcb2749f2eccd659ff7b88f30
7
- data.tar.gz: 46132969d40d8bc183a2b9d36544d959426f2ab5ef156d5c980f88f8352c56ab0b0d514dc70eb7b19496654fb5b8525c12e48b20a4541a669633e92e6da2855c
6
+ metadata.gz: b86b1ee80275ce1bae0d8c1ab00856ab5d379fe1be90e7bdcdf7d9ec82f3d8ef7de6819cb660a27f3bbb25ed552be29ea0601d5df702e39f5ccff4140ff310f7
7
+ data.tar.gz: 65727df86bf8f294d377fda450f6404a18a0ab654fcccc0cd1369ef278e9fe3d6e17374e6c14cf41148bd6a42512d1412ec4a5d21f7b3406f39e00889bc8db1f
@@ -1,6 +1,6 @@
1
1
  // Set the document hash to the tab href
2
2
  $(document).on('show.bs.tab', function (e) {
3
- history.replaceState(null, null, '#' + e.target.getAttribute('id'));
3
+ history.replaceState(history.state, null, '#' + e.target.getAttribute('id'));
4
4
  });
5
5
 
6
6
  // Display the tab based on form errors, the document hash, or ?tab= params
@@ -67,3 +67,19 @@ $(document).on 'drop', '.effective-file-drop-zone', (event) ->
67
67
  $input[0].files = dt.files
68
68
 
69
69
  $input.trigger('change')
70
+
71
+ # Per-file Remove / Undo toggle on existing attachments
72
+ $(document).on 'click', '.effective-file-remove', (event) ->
73
+ event.preventDefault()
74
+ $button = $(event.currentTarget)
75
+ $attachment = $button.closest('.effective-file-attachment')
76
+ $input = $attachment.find('.effective-file-remove-input')
77
+
78
+ if $input.prop('disabled')
79
+ $input.prop('disabled', false)
80
+ $attachment.addClass('effective-file-attachment--pending-removal')
81
+ $button.text('Undo').removeClass('btn-outline-danger').addClass('btn-outline-secondary')
82
+ else
83
+ $input.prop('disabled', true)
84
+ $attachment.removeClass('effective-file-attachment--pending-removal')
85
+ $button.text('Remove').removeClass('btn-outline-secondary').addClass('btn-outline-danger')
@@ -69,3 +69,10 @@ input.form-control-file {
69
69
  cursor: pointer;
70
70
  }
71
71
 
72
+ .effective-file-attachment--pending-removal {
73
+ opacity: 0.5;
74
+
75
+ .card-link, a { text-decoration: line-through; }
76
+ img { filter: grayscale(100%); }
77
+ }
78
+
@@ -73,17 +73,19 @@ module Effective
73
73
  end
74
74
 
75
75
  def build_table_attachments(attachments)
76
- content_tag(:table, class: 'table table-hover effective_file_attachments') do
76
+ content_tag(:table, class: 'table table-hover effective_file_attachments mt-2') do
77
77
  content_tag(:thead) do
78
78
  content_tag(:tr) do
79
- content_tag(:th, 'Image') +
79
+ content_tag(:th, '') +
80
80
  content_tag(:th, 'Title') +
81
81
  content_tag(:th, 'Size') +
82
82
  content_tag(:th, '')
83
83
  end
84
84
  end +
85
85
  content_tag(:tbody) do
86
- attachments.map { |attachment| content_tag(:tr, build_table_attachment(attachment)) }.join.html_safe
86
+ attachments.map do |attachment|
87
+ content_tag(:tr, build_table_attachment(attachment), class: 'effective-file-attachment', data: { signed_id: attachment.signed_id })
88
+ end.join.html_safe
87
89
  end
88
90
  end
89
91
  end
@@ -96,7 +98,7 @@ module Effective
96
98
 
97
99
  image_tag = content_tag(:img, '', class: '', src: url, alt: attachment.filename.to_s) if attachment.image?
98
100
  link_tag = link_to(attachment.filename, url)
99
- size_tag = (attachment.content_type + '<br>' + @template.number_to_human_size(attachment.byte_size)).html_safe
101
+ size_tag = @template.number_to_human_size(attachment.byte_size)
100
102
 
101
103
  content_tag(:td, image_tag) +
102
104
  content_tag(:td, link_tag) +
@@ -105,6 +107,8 @@ module Effective
105
107
  content_tag(:td) do
106
108
  if attachments_style == :ck_assets
107
109
  link_to('Attach', url, class: 'btn btn-primary', 'data-insert-ck-asset': true, alt: attachment.filename.to_s)
110
+ else
111
+ build_attachment_remove(attachment)
108
112
  end
109
113
  end
110
114
  end
@@ -119,9 +123,9 @@ module Effective
119
123
 
120
124
  return unless url
121
125
 
122
- content_tag(:div, class: 'col-lg-4') do
126
+ content_tag(:div, class: 'col-lg-4 effective-file-attachment', data: { signed_id: attachment.signed_id }) do
123
127
  content_tag(:div, class: 'card mb-3') do
124
- if attachment.image?
128
+ body = if attachment.image?
125
129
  content_tag(:div, class: 'card-body text-center') do
126
130
  content_tag(:div, image_tag(url, alt: attachment.filename.to_s, class: 'img-fluid mb-2')) +
127
131
  content_tag(:div, link_to(attachment.filename, url, class: 'card-link'))
@@ -129,29 +133,18 @@ module Effective
129
133
  else
130
134
  content_tag(:div, class: 'card-body') do
131
135
  content_tag(:p, class: 'card-text') do
132
- link_to(attachment.filename, url, class: 'card-link stretched-link') +
133
- ('<br />' +
134
- @template.number_to_human_size(attachment.byte_size
135
- )).html_safe
136
+ link_to(attachment.filename, url, class: 'card-link') + '<br>'.html_safe + @template.number_to_human_size(attachment.byte_size)
136
137
  end
137
138
  end
139
+ end
138
140
 
139
- end.html_safe
141
+ body + build_attachment_remove(attachment, footer: true)
140
142
  end
141
143
  end
142
144
  end
143
145
 
144
146
  def build_uploads_and_purge(super_file_field)
145
- wrapped_input = content_tag(:div, super_file_field, class: 'effective-file-drop-zone')
146
-
147
- if purge? && attachments_present?
148
- content_tag(:div) do
149
- content_tag(:div, (build_uploads + wrapped_input), class: 'mb-3') +
150
- content_tag(:div, build_purge)
151
- end
152
- else
153
- build_uploads + wrapped_input
154
- end
147
+ build_uploads + content_tag(:div, super_file_field, class: 'effective-file-drop-zone')
155
148
  end
156
149
 
157
150
  def build_uploads
@@ -165,11 +158,17 @@ module Effective
165
158
  end
166
159
  end
167
160
 
168
- def build_purge
169
- return ''.html_safe unless purge? && !disabled?
161
+ def build_attachment_remove(attachment, footer: false)
162
+ return ''.html_safe if disabled? || !purge?
163
+
164
+ hidden = @template.hidden_field_tag("#{@builder.object_name}[_purge][]", attachment.signed_id, disabled: true, class: 'effective-file-remove-input', id: nil)
165
+ button = @template.content_tag(:button, 'Remove', type: 'button', class: 'btn btn-sm btn-outline-danger effective-file-remove')
170
166
 
171
- label = (multiple? ? 'Delete existing files on save' : 'Delete existing file on save')
172
- @builder.check_box('_purge', multiple: true, label: label, id: "#{tag_id}_purge", checked_value: name)
167
+ if footer
168
+ content_tag(:div, hidden + button, class: 'card-footer bg-transparent text-right')
169
+ else
170
+ hidden + button
171
+ end
173
172
  end
174
173
 
175
174
  def purge?
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '1.21.19'.freeze
2
+ VERSION = '1.22.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_bootstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.21.19
4
+ version: 1.22.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-10 00:00:00.000000000 Z
11
+ date: 2026-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails