effective_bootstrap 0.11.0 → 0.11.3

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: c1483d8802c16a38a151708060665d5fbf2a47b33f41d09eafdf2cc289ab398e
4
- data.tar.gz: c215f00abcb30632e41c2ad85c2e7c235649dc61d8faf39795137fc5aa9b2c38
3
+ metadata.gz: 72c48edcadc713215002d5ae870cee436b886c3a1918de8564e33d91e7104404
4
+ data.tar.gz: 016bd24058640f34bf36a4b8ccb5435a1c4bf478f3abb4a1bae0398d6238c40f
5
5
  SHA512:
6
- metadata.gz: dfe6422310d0bfcb92ffe81cbdadd49cb5327030903b9ddca48c8f51eb0bff479b1fd561f84fb0aa1b2ae60fb85e5ddcf24371ad7f7a914d2eeb5d690d0ddd9d
7
- data.tar.gz: c17eeb42ce4a4dd2d3869cf0c0822987fa689ba10135a859308e850d92fbbb35a4c6b10f26682cf39636eb8b023dde32200997e403de150363c90e22d4f91ef0
6
+ metadata.gz: a57d9fee9a0864bb0b5f51fc29afea8a27b03c6c0e15ae5ba252a1d87b78b25401ae881ba77deee5698b598fa723e806158d41389ce7e1a19eeb2be427c472d6
7
+ data.tar.gz: 7e47e151514ce87587a9bb2098f7a57aec95832cae0718371eafb7bba7c95de217af5ab1f1a9789468d6208c318a60d827b2dc8024e89ef38487c6a3bcd879ed
@@ -1,19 +1,45 @@
1
1
  # https://imperavi.com/article/
2
2
 
3
+ sendMarkPublicRequest = (editor, blob, authenticity_token) ->
4
+ editor.ajax.post(
5
+ url: "/storage/#{blob.signed_id}/mark_public",
6
+ data: {
7
+ id: blob.signed_id,
8
+ authenticity_token: authenticity_token
9
+ }
10
+ )
11
+
3
12
  uploadActiveStorage = (editor, data) ->
4
13
  rails_url = '/rails/active_storage/blobs/redirect/'
5
14
 
15
+ # The editor is actually the popup form
16
+ $form = editor.$element.closest('form')
17
+
18
+ if $form.length == 0
19
+ $form = editor.$element.closest('.arx-popup')
20
+
21
+ permission_public = $form.find("input[name=public_permission]").val() || false
22
+
23
+ # This is an effective_form with the article editor in it
24
+ $parentForm = editor.app.$element.closest('form')
25
+ authenticity_token = $parentForm.find("input[name=authenticity_token]").val() || 'missing authenticity token'
26
+
27
+ # Attachment classes
28
+ classes = (if permission_public then 'effective-article-editor-attachment effective-article-editor-attachment-permission-public' else 'effective-article-editor-attachment')
29
+
6
30
  for file in data.files
7
31
  upload = new ActiveStorage.DirectUpload(file, '/rails/active_storage/direct_uploads')
8
32
 
9
33
  upload.create (error, blob) =>
34
+ sendMarkPublicRequest(editor, blob, authenticity_token) if permission_public
35
+
10
36
  url = rails_url + blob.signed_id + '/' + blob.filename
11
37
  editor.complete({ file: { url: url, name: blob.filename, content_type: blob.content_type }}, data.e)
12
38
 
13
39
  # We append this nested attachment html
14
40
  attachment = $('<action-text-attachment>')
15
41
  .attr('sgid', blob.attachable_sgid)
16
- .attr('class', 'effective-article-editor-attachment')
42
+ .attr('class', classes)
17
43
 
18
44
  attachment = $('<div>').append(attachment).html()
19
45
 
@@ -22,12 +48,12 @@ uploadActiveStorage = (editor, data) ->
22
48
  doc
23
49
  .find("img[src^='#{rails_url}']:not(.effective-article-editor-attachment)")
24
50
  .after(attachment)
25
- .addClass('effective-article-editor-attachment')
51
+ .addClass(classes)
26
52
 
27
53
  doc
28
54
  .find("a[data-file][data-name='#{file.name}']:not(.action-text-attachment)")
29
55
  .after(attachment)
30
- .addClass('effective-article-editor-attachment')
56
+ .addClass(classes)
31
57
  .removeAttr('data-file')
32
58
  .removeAttr('data-name')
33
59
 
@@ -74,5 +74,6 @@ div.form-group > label + .btn-group { display: block; }
74
74
  // Has Many
75
75
  .form-has-many .has-many-remove {
76
76
  margin-top: 0;
77
+ margin-bottom: 1rem;
77
78
  .eb-icon { height: 1.5rem; width: 1.5rem; }
78
79
  }
@@ -4,7 +4,6 @@
4
4
  .has-many-remove-disabled { opacity: 0; cursor: default !important; }
5
5
 
6
6
  .has-many-actions { margin-bottom: 0.75rem; }
7
- .has-many-remove { margin-top: 1rem; }
8
7
  .has-many-move { margin-top: 1.5rem; }
9
8
  }
10
9
 
@@ -19,3 +18,13 @@
19
18
  .has-many-remove { margin-top: 0; }
20
19
  .has-many-move { margin-top: 0.5rem; }
21
20
  }
21
+
22
+ .form-has-many .has-many-remove {
23
+ margin-top: 0;
24
+ .eb-icon { height: $font-size-sm; width: $font-size-sm; margin-bottom: 2px; }
25
+ }
26
+
27
+ .form-has-many .has-many-add {
28
+ margin-top: 0;
29
+ .eb-icon { height: $font-size-sm; width: $font-size-sm; margin-bottom: 2px; }
30
+ }
@@ -43,6 +43,23 @@ module EffectiveBootstrapHelper
43
43
  end
44
44
  end
45
45
 
46
+ # https://getbootstrap.com/docs/4.0/components/badge/
47
+ # = badge('Warning', :secondary)
48
+ # Can pass class or a context
49
+ def badge(value = nil, opts = {})
50
+ value = Array(value) - [nil, '']
51
+ return if value.blank?
52
+
53
+ badge_opts = opts
54
+ badge_opts = {context: opts} unless badge_opts.kind_of?(Hash)
55
+
56
+ context = badge_opts[:context].to_s.sub('badge-', '').presence || 'secondary'
57
+ badge_opts[:class] ||= "badge badge-#{context}"
58
+
59
+ value.map { |value| content_tag(:span, value, badge_opts) }.join(' ').html_safe
60
+ end
61
+ alias_method :badges, :badge
62
+
46
63
  # https://getbootstrap.com/docs/4.0/components/card/
47
64
  # = card('title do')
48
65
  # %p Stuff
@@ -126,7 +126,7 @@ module Effective
126
126
  def has_many_links_for(block)
127
127
  return BLANK unless add? || reorder?
128
128
 
129
- content_tag(:div, class: 'has-many-links text-center mt-2') do
129
+ content_tag(:div, class: 'has-many-links mt-2') do
130
130
  [*(link_to_add(block) if add?), *(link_to_reorder(block) if reorder?)].join(' ').html_safe
131
131
  end
132
132
  end
@@ -171,7 +171,7 @@ module Effective
171
171
  content_tag(:div, content, class: 'col mr-auto') do
172
172
  content_tag(:div, class: 'card') do
173
173
  content_tag(:div, class: 'card-body') do
174
- content_tag(:div, remove, class: 'float-right') + content
174
+ content_tag(:div, remove, class: 'd-flex justify-content-end') + content
175
175
  end
176
176
  end
177
177
  end
@@ -205,7 +205,7 @@ module Effective
205
205
  content_tag(
206
206
  :button,
207
207
  icon('plus-circle') + 'Add Another',
208
- class: 'has-many-add btn btn-secondary',
208
+ class: 'has-many-add btn btn-sm btn-secondary',
209
209
  title: 'Add Another',
210
210
  data: {
211
211
  'effective-form-has-many-add': true,
@@ -227,7 +227,7 @@ module Effective
227
227
  content_tag(
228
228
  (tag || :button),
229
229
  (label || (icon('plus-circle') + 'Insert Another')),
230
- class: 'has-many-insert ' + (html_class || 'btn btn-secondary'),
230
+ class: 'has-many-insert ' + (html_class || 'btn btn-sm btn-secondary'),
231
231
  title: (title || 'Insert Another'),
232
232
  data: {
233
233
  'effective-form-has-many-insert': true,
@@ -257,8 +257,8 @@ module Effective
257
257
 
258
258
  content_tag(
259
259
  (tag || :button),
260
- (label || icon('trash-2')),
261
- class: 'has-many-remove ' + (html_class || 'btn btn-danger'),
260
+ (label || (icon('trash-2') + 'Remove')),
261
+ class: 'has-many-remove ' + (html_class || 'btn btn-sm btn-danger'),
262
262
  title: (title || 'Remove'),
263
263
  data: {
264
264
  'confirm': "Remove #{resource}?",
@@ -271,7 +271,7 @@ module Effective
271
271
  content_tag(
272
272
  :button,
273
273
  icon('trash-2'),
274
- class: 'has-many-remove-disabled btn btn-danger',
274
+ class: 'has-many-remove-disabled btn btn-sm btn-danger',
275
275
  title: 'Remove',
276
276
  data: {
277
277
  'effective-form-has-many-remove-disabled': true,
@@ -29,11 +29,12 @@ module Effective
29
29
  end
30
30
 
31
31
  def validate!(args)
32
+ return if args.third.kind_of?(Hash) && args.third[:validate] == false
32
33
  raise "expected object to respond to #{args.first}" unless object.respond_to?(args.first)
33
34
  end
34
35
 
35
36
  def hide?
36
- (object.send(args.first) == args.second) || (object.send(args.first).to_s == args.second.to_s)
37
+ (object.try(args.first) == args.second) || (object.try(args.first).to_s == args.second.to_s)
37
38
  end
38
39
 
39
40
  end
@@ -29,11 +29,12 @@ module Effective
29
29
  end
30
30
 
31
31
  def validate!(args)
32
+ return if args.third.kind_of?(Hash) && args.third[:validate] == false
32
33
  raise "expected object to respond to #{args.first}" unless object.respond_to?(args.first)
33
34
  end
34
35
 
35
36
  def show?
36
- (object.send(args.first) == args.second) || (object.send(args.first).to_s == args.second.to_s)
37
+ (object.try(args.first) == args.second) || (object.try(args.first).to_s == args.second.to_s)
37
38
  end
38
39
 
39
40
  end
@@ -29,12 +29,13 @@ module Effective
29
29
  end
30
30
 
31
31
  def validate!(args)
32
+ return if args.third.kind_of?(Hash) && args.third[:validate] == false
32
33
  raise "expected object to respond to #{args.first}" unless object.respond_to?(args.first)
33
34
  end
34
35
 
35
36
  def show?
36
37
  Array(args.second).any? do |value|
37
- selected = object.send(args.first)
38
+ selected = object.try(args.first)
38
39
  selected == value || selected.to_s == value.to_s
39
40
  end
40
41
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '0.11.0'.freeze
2
+ VERSION = '0.11.3'.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: 0.11.0
4
+ version: 0.11.3
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: 2022-08-24 00:00:00.000000000 Z
11
+ date: 2022-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails