trestle 0.8.11 → 0.8.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +11 -1
  3. data/README.md +8 -3
  4. data/app/assets/javascripts/trestle/components/_confirmation.js +22 -22
  5. data/app/assets/stylesheets/trestle/components/_dropdown.scss +28 -0
  6. data/app/assets/stylesheets/trestle/components/_fields.scss +5 -0
  7. data/app/assets/stylesheets/trestle/core/_defaults.scss +2 -0
  8. data/app/controllers/trestle/dashboard_controller.rb +1 -1
  9. data/app/helpers/trestle/i18n_helper.rb +6 -0
  10. data/app/helpers/trestle/panel_helper.rb +1 -1
  11. data/app/helpers/trestle/toolbars_helper.rb +2 -1
  12. data/app/views/layouts/trestle/admin.html.erb +5 -3
  13. data/app/views/trestle/application/_dialog.html.erb +2 -2
  14. data/app/views/trestle/application/_header.html.erb +2 -2
  15. data/app/views/trestle/shared/_sidebar.html.erb +1 -1
  16. data/config/locales/en.yml +1 -0
  17. data/config/locales/ko.rb +18 -0
  18. data/config/locales/ko.yml +96 -0
  19. data/gemfiles/rails-4.2.gemfile +1 -1
  20. data/gemfiles/rails-5.0.gemfile +1 -1
  21. data/gemfiles/rails-5.1.gemfile +1 -1
  22. data/gemfiles/rails-5.2.gemfile +1 -1
  23. data/gemfiles/rails-edge.gemfile +1 -1
  24. data/lib/generators/trestle/install/templates/trestle.rb.erb +4 -0
  25. data/lib/trestle.rb +5 -3
  26. data/lib/trestle/adapters/adapter.rb +2 -17
  27. data/lib/trestle/configuration.rb +3 -0
  28. data/lib/trestle/evaluation_context.rb +24 -0
  29. data/lib/trestle/form/fields/password_field.rb +4 -0
  30. data/lib/trestle/form/fields/select.rb +3 -1
  31. data/lib/trestle/form/renderer.rb +1 -0
  32. data/lib/trestle/navigation.rb +6 -6
  33. data/lib/trestle/navigation/block.rb +6 -6
  34. data/lib/trestle/resource.rb +6 -1
  35. data/lib/trestle/resource/builder.rb +6 -5
  36. data/lib/trestle/scopes.rb +23 -0
  37. data/lib/trestle/scopes/block.rb +38 -0
  38. data/lib/trestle/scopes/scope.rb +49 -0
  39. data/lib/trestle/toolbar.rb +11 -0
  40. data/lib/trestle/toolbar/builder.rb +8 -27
  41. data/lib/trestle/toolbar/item.rb +118 -0
  42. data/lib/trestle/toolbar/menu.rb +63 -0
  43. data/lib/trestle/version.rb +1 -1
  44. data/trestle.gemspec +4 -4
  45. metadata +34 -28
  46. data/lib/trestle/scope.rb +0 -47
@@ -0,0 +1,63 @@
1
+ module Trestle
2
+ class Toolbar
3
+ class Menu
4
+ delegate :content_tag, :safe_join, to: :@template
5
+
6
+ attr_reader :items
7
+
8
+ def initialize(template)
9
+ @template = template
10
+ @items = []
11
+ end
12
+
13
+ def build(&block)
14
+ builder = Builder.new(self, @template)
15
+
16
+ result = @template.capture { @template.instance_exec(builder, &block) }
17
+ items << result if result.present?
18
+ end
19
+
20
+ def render_toggle(options={})
21
+ content_tag(:button, type: "button", class: Array(options[:class]) + ["dropdown-toggle"], data: { toggle: "dropdown" }) do
22
+ safe_join([
23
+ content_tag(:span, "", class: "caret"),
24
+ content_tag(:span, I18n.t("trestle.ui.toggle_dropdown", default: "Toggle dropdown"), class: "sr-only")
25
+ ])
26
+ end
27
+ end
28
+
29
+ def render_items
30
+ content_tag(:ul, safe_join(items, "\n"), class: "dropdown-menu dropdown-menu-right", role: "menu")
31
+ end
32
+
33
+ class Builder
34
+ delegate :admin_link_to, :content_tag, to: :@template
35
+
36
+ def initialize(menu, template)
37
+ @menu, @template = menu, template
38
+ end
39
+
40
+ def link(*args)
41
+ item { admin_link_to(*args) }
42
+ end
43
+
44
+ def header(text)
45
+ item(class: "dropdown-header") { text }
46
+ end
47
+
48
+ def divider
49
+ item(class: "divider")
50
+ end
51
+
52
+ def item(options={}, &block)
53
+ opts = { role: "presentation" }.merge(options)
54
+ item = block_given? ? content_tag(:li, opts, &block) : content_tag(:li, "", opts)
55
+
56
+ @menu.items << item
57
+
58
+ nil
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -1,3 +1,3 @@
1
1
  module Trestle
2
- VERSION = "0.8.11"
2
+ VERSION = "0.8.12"
3
3
  end
@@ -39,12 +39,12 @@ Gem::Specification.new do |spec|
39
39
  spec.add_dependency "autoprefixer-rails", ">= 7.1.2"
40
40
  spec.add_dependency "kaminari", "~> 1.1.0"
41
41
 
42
- spec.add_development_dependency "bundler", "~> 1.12"
43
- spec.add_development_dependency "rake", "~> 10.0"
44
- spec.add_development_dependency "rspec-rails", "~> 3.5"
42
+ spec.add_development_dependency "rspec-rails", "~> 3.5"
45
43
  spec.add_development_dependency "rspec-html-matchers", "~> 0.7.1"
46
44
  spec.add_development_dependency "database_cleaner", "~> 1.6.2"
47
45
 
48
- spec.add_development_dependency "sqlite3"
46
+ spec.add_development_dependency "bundler"
47
+ spec.add_development_dependency "rake"
48
+ spec.add_development_dependency "sqlite3", "~> 1.3.6"
49
49
  spec.add_development_dependency "turbolinks"
50
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trestle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.11
4
+ version: 0.8.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Pohlenz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-19 00:00:00.000000000 Z
11
+ date: 2019-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -81,89 +81,89 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.1.0
83
83
  - !ruby/object:Gem::Dependency
84
- name: bundler
84
+ name: rspec-rails
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.12'
89
+ version: '3.5'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.12'
96
+ version: '3.5'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rake
98
+ name: rspec-html-matchers
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '10.0'
103
+ version: 0.7.1
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '10.0'
110
+ version: 0.7.1
111
111
  - !ruby/object:Gem::Dependency
112
- name: rspec-rails
112
+ name: database_cleaner
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '3.5'
117
+ version: 1.6.2
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '3.5'
124
+ version: 1.6.2
125
125
  - !ruby/object:Gem::Dependency
126
- name: rspec-html-matchers
126
+ name: bundler
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: 0.7.1
131
+ version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: 0.7.1
138
+ version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: database_cleaner
140
+ name: rake
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - "~>"
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: 1.6.2
145
+ version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - "~>"
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: 1.6.2
152
+ version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: sqlite3
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ">="
157
+ - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '0'
159
+ version: 1.3.6
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ">="
164
+ - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '0'
166
+ version: 1.3.6
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: turbolinks
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -319,6 +319,8 @@ files:
319
319
  - config/locales/es.yml
320
320
  - config/locales/fr.rb
321
321
  - config/locales/fr.yml
322
+ - config/locales/ko.rb
323
+ - config/locales/ko.yml
322
324
  - config/locales/lv.rb
323
325
  - config/locales/lv.yml
324
326
  - config/locales/nl.rb
@@ -361,6 +363,7 @@ files:
361
363
  - lib/trestle/configuration.rb
362
364
  - lib/trestle/display.rb
363
365
  - lib/trestle/engine.rb
366
+ - lib/trestle/evaluation_context.rb
364
367
  - lib/trestle/form.rb
365
368
  - lib/trestle/form/automatic.rb
366
369
  - lib/trestle/form/builder.rb
@@ -412,7 +415,9 @@ files:
412
415
  - lib/trestle/resource/builder.rb
413
416
  - lib/trestle/resource/collection.rb
414
417
  - lib/trestle/resource/controller.rb
415
- - lib/trestle/scope.rb
418
+ - lib/trestle/scopes.rb
419
+ - lib/trestle/scopes/block.rb
420
+ - lib/trestle/scopes/scope.rb
416
421
  - lib/trestle/tab.rb
417
422
  - lib/trestle/table.rb
418
423
  - lib/trestle/table/actions_column.rb
@@ -424,6 +429,8 @@ files:
424
429
  - lib/trestle/toolbar.rb
425
430
  - lib/trestle/toolbar/builder.rb
426
431
  - lib/trestle/toolbar/context.rb
432
+ - lib/trestle/toolbar/item.rb
433
+ - lib/trestle/toolbar/menu.rb
427
434
  - lib/trestle/version.rb
428
435
  - trestle.gemspec
429
436
  - vendor/assets/bower_components/trestle/bootstrap-confirmation2/bootstrap-confirmation.js
@@ -636,8 +643,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
636
643
  - !ruby/object:Gem::Version
637
644
  version: '0'
638
645
  requirements: []
639
- rubyforge_project:
640
- rubygems_version: 2.7.6
646
+ rubygems_version: 3.0.2
641
647
  signing_key:
642
648
  specification_version: 4
643
649
  summary: A modern, responsive admin framework for Ruby on Rails
@@ -1,47 +0,0 @@
1
- module Trestle
2
- class Scope
3
- attr_reader :name, :options, :block
4
-
5
- def initialize(admin, name, options={}, &block)
6
- @admin, @name, @options, @block = admin, name, options, block
7
- end
8
-
9
- def to_param
10
- name
11
- end
12
-
13
- def label
14
- @options[:label] || I18n.t("admin.scopes.#{name}", default: name.to_s.humanize.titleize)
15
- end
16
-
17
- def default?
18
- @options[:default] == true
19
- end
20
-
21
- def apply(collection)
22
- if @block
23
- if @block.arity == 1
24
- @admin.instance_exec(collection, &@block)
25
- else
26
- @admin.instance_exec(&@block)
27
- end
28
- else
29
- collection.public_send(name)
30
- end
31
- end
32
-
33
- def count(collection)
34
- @admin.count(@admin.merge_scopes(collection, apply(collection)))
35
- end
36
-
37
- def active?(params)
38
- active_scopes = Array(params[:scope])
39
-
40
- if active_scopes.any?
41
- active_scopes.include?(to_param.to_s)
42
- else
43
- default?
44
- end
45
- end
46
- end
47
- end