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 +4 -4
- data/app/assets/javascripts/effective_article_editor/initialize.js.coffee +29 -3
- data/app/assets/stylesheets/effective_bootstrap/forms.scss +1 -0
- data/app/assets/stylesheets/effective_has_many/input.scss +10 -1
- data/app/helpers/effective_bootstrap_helper.rb +17 -0
- data/app/models/effective/form_inputs/has_many.rb +7 -7
- data/app/models/effective/form_logics/hide_if.rb +2 -1
- data/app/models/effective/form_logics/show_if.rb +2 -1
- data/app/models/effective/form_logics/show_if_any.rb +2 -1
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72c48edcadc713215002d5ae870cee436b886c3a1918de8564e33d91e7104404
|
4
|
+
data.tar.gz: 016bd24058640f34bf36a4b8ccb5435a1c4bf478f3abb4a1bae0398d6238c40f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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',
|
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(
|
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(
|
56
|
+
.addClass(classes)
|
31
57
|
.removeAttr('data-file')
|
32
58
|
.removeAttr('data-name')
|
33
59
|
|
@@ -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
|
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: '
|
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.
|
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.
|
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.
|
38
|
+
selected = object.try(args.first)
|
38
39
|
selected == value || selected.to_s == value.to_s
|
39
40
|
end
|
40
41
|
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.
|
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-
|
11
|
+
date: 2022-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|