record_collection 0.10.0 → 0.10.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/CHANGELOG.md +5 -0
- data/app/assets/javascripts/record_collection/optionals.js.coffee +3 -1
- data/app/assets/stylesheets/record_collection/optionals.sass +26 -0
- data/lib/record_collection/rails/form_builder.rb +7 -1
- data/lib/record_collection/version.rb +1 -1
- data/spec/dummy/app/models/project/collection.rb +1 -0
- data/spec/dummy/app/views/projects/collection_edit.html.slim +2 -1
- data/spec/dummy/db/migrate/20151226083300_add_hint_visible_to_projects.rb +5 -0
- data/spec/dummy/db/schema.rb +4 -3
- data/spec/features/optional_boolean_hint_spec.rb +11 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d074f869d99ecf6e034ce94c81bbf041cab5416
|
4
|
+
data.tar.gz: 34655d94e3c4d2fe95771cca7f7bcb2c6a70d863
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea293bbdd54ed4184d60495c139b1cb83707d7a9e13227b384787825c485285cccd8a98f6774505dca4baa1a8b9ffdcf8d014616cb3b805850cb76bece422360
|
7
|
+
data.tar.gz: 803da8176458262709b914ef5f57fc167f260071ba0bd4ea35f67de4639d898fd47e97c95a45adac6731eae53f5051da19080c8b93aee42970d11e3dc712e71c
|
data/CHANGELOG.md
CHANGED
@@ -11,12 +11,13 @@ class Optionals
|
|
11
11
|
@prependActivator(container)
|
12
12
|
|
13
13
|
# Replace the <input type="checkbox"> for a <input type="hidden" # value="0|1"> fields
|
14
|
-
# managed by the javascript
|
14
|
+
# managed by the javascript. The strategy is to completely rebuild the html structure
|
15
15
|
optionalBoolean: (container)->
|
16
16
|
check_box = container.find('input')
|
17
17
|
initially_checked = check_box.is(':checked')
|
18
18
|
field_name = check_box.attr('name')
|
19
19
|
one = container.data('one')
|
20
|
+
hint_field = container.find('.optional-attribute-hint')
|
20
21
|
|
21
22
|
label_text = container.find('label').text()
|
22
23
|
|
@@ -62,6 +63,7 @@ class Optionals
|
|
62
63
|
container.append label
|
63
64
|
container.append value_toggle
|
64
65
|
container.append value_field
|
66
|
+
container.append hint_field if hint_field.length
|
65
67
|
activator_toggle.hide() if one
|
66
68
|
|
67
69
|
prependActivator: (container)->
|
@@ -54,3 +54,29 @@ $unchecked-color: #999
|
|
54
54
|
&:not(.disabled)
|
55
55
|
.optional-boolean-toggle
|
56
56
|
cursor: pointer
|
57
|
+
.optional-attribute-hint
|
58
|
+
@extend .fa, .fa-2x, .fa-info-circle
|
59
|
+
margin-left: 10px
|
60
|
+
color: #888
|
61
|
+
cursor: pointer
|
62
|
+
position: relative
|
63
|
+
&::after
|
64
|
+
content: attr(data-hint)
|
65
|
+
font-size: 10px
|
66
|
+
position: absolute
|
67
|
+
z-index: 999
|
68
|
+
white-space: nowrap
|
69
|
+
bottom: 9999px
|
70
|
+
left: 80%
|
71
|
+
background-color: #000
|
72
|
+
color: #e0e0e0
|
73
|
+
padding: 0px 7px
|
74
|
+
line-height: 24px
|
75
|
+
height: 24px
|
76
|
+
opacity: 0
|
77
|
+
transition: opacity 0.4s ease-out
|
78
|
+
&:hover
|
79
|
+
color: #3636BD
|
80
|
+
&::after
|
81
|
+
opacity: 1
|
82
|
+
bottom: 0
|
@@ -46,7 +46,13 @@ ActionView::Helpers::FormBuilder.class_eval do
|
|
46
46
|
|
47
47
|
def optional_form_element(element, attr, options = {})
|
48
48
|
classes = get_optional_classes(attr, options.reverse_merge(base_class: 'optional-text-area'))
|
49
|
-
|
49
|
+
label_tag = label(attr, options[:label])
|
50
|
+
element_tag = send(element, attr, options)
|
51
|
+
content = label_tag + element_tag
|
52
|
+
# Hint tag is empty to make it easy to implement using js. Adding it as text is a better option than hiding the text.
|
53
|
+
# Graceful Degradation is not an option anyway
|
54
|
+
content += @template.content_tag(:span, nil, class: 'optional-attribute-hint', data: {hint: options[:hint]}) if options[:hint].present?
|
55
|
+
add_collection_ids @template.content_tag(:div, content, class: classes, data: get_data_attributes(attr, options))
|
50
56
|
end
|
51
57
|
|
52
58
|
private
|
@@ -2,8 +2,9 @@ h1 Edit multiple projects
|
|
2
2
|
= simple_form_for @collection, url: [:collection_update, @collection] do |f|
|
3
3
|
= render 'form_errors', target: @collection
|
4
4
|
.form-inputs= f.optional_boolean :finished, disabled: true
|
5
|
+
.form-inputs= f.optional_boolean :hint_visible, hint: "Check this one if the hint is visible. Hint testing"
|
5
6
|
.form-inputs= f.optional_input :start_date
|
6
|
-
.form-inputs= f.optional_input :description
|
7
|
+
.form-inputs= f.optional_input :description, hint: "Hint normal display for other attributes, use .optional-attribute-hint with data-hint='abc' in your simple_form config to use the record_collection styling"
|
7
8
|
.form-actions= f.submit
|
8
9
|
.page-actions
|
9
10
|
= link_to 'Back', employees_path
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20151226083300) do
|
15
15
|
|
16
16
|
create_table "employees", force: :cascade do |t|
|
17
17
|
t.string "name"
|
@@ -27,10 +27,11 @@ ActiveRecord::Schema.define(version: 20151225113902) do
|
|
27
27
|
t.string "name"
|
28
28
|
t.boolean "finished"
|
29
29
|
t.string "state"
|
30
|
-
t.datetime "created_at",
|
31
|
-
t.datetime "updated_at",
|
30
|
+
t.datetime "created_at", null: false
|
31
|
+
t.datetime "updated_at", null: false
|
32
32
|
t.text "description"
|
33
33
|
t.date "start_date"
|
34
|
+
t.boolean "hint_visible", default: false, null: false
|
34
35
|
end
|
35
36
|
|
36
37
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.feature "Hint with optional boolean", type: :feature do
|
4
|
+
scenario "Seeing the hint", js: true do
|
5
|
+
project = Project.create name: 'P1', finished: true
|
6
|
+
visit collection_edit_projects_path(ids: [project.id])
|
7
|
+
|
8
|
+
page.should have_selector '.optional-attribute-container.hint_visible .optional-attribute-hint'
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: record_collection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin ter Kuile
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -504,6 +504,7 @@ files:
|
|
504
504
|
- spec/dummy/db/migrate/20150721122805_add_description_to_projects.rb
|
505
505
|
- spec/dummy/db/migrate/20151215123553_add_project_id_to_employees.rb
|
506
506
|
- spec/dummy/db/migrate/20151225113902_add_start_date_to_projects.rb
|
507
|
+
- spec/dummy/db/migrate/20151226083300_add_hint_visible_to_projects.rb
|
507
508
|
- spec/dummy/db/schema.rb
|
508
509
|
- spec/dummy/lib/assets/.keep
|
509
510
|
- spec/dummy/log/.keep
|
@@ -513,6 +514,7 @@ files:
|
|
513
514
|
- spec/dummy/public/favicon.ico
|
514
515
|
- spec/features/disabled_boolean_spec.rb
|
515
516
|
- spec/features/multi_select_spec.rb
|
517
|
+
- spec/features/optional_boolean_hint_spec.rb
|
516
518
|
- spec/features/optional_boolean_with_normal_resource_spec.rb
|
517
519
|
- spec/features/optional_date_field_all_nil_spec.rb
|
518
520
|
- spec/features/optional_text_field_with_normal_resource_spec.rb
|
@@ -627,6 +629,7 @@ test_files:
|
|
627
629
|
- spec/dummy/db/migrate/20150721122805_add_description_to_projects.rb
|
628
630
|
- spec/dummy/db/migrate/20151215123553_add_project_id_to_employees.rb
|
629
631
|
- spec/dummy/db/migrate/20151225113902_add_start_date_to_projects.rb
|
632
|
+
- spec/dummy/db/migrate/20151226083300_add_hint_visible_to_projects.rb
|
630
633
|
- spec/dummy/db/schema.rb
|
631
634
|
- spec/dummy/lib/assets/.keep
|
632
635
|
- spec/dummy/log/.keep
|
@@ -636,6 +639,7 @@ test_files:
|
|
636
639
|
- spec/dummy/public/favicon.ico
|
637
640
|
- spec/features/disabled_boolean_spec.rb
|
638
641
|
- spec/features/multi_select_spec.rb
|
642
|
+
- spec/features/optional_boolean_hint_spec.rb
|
639
643
|
- spec/features/optional_boolean_with_normal_resource_spec.rb
|
640
644
|
- spec/features/optional_date_field_all_nil_spec.rb
|
641
645
|
- spec/features/optional_text_field_with_normal_resource_spec.rb
|