peentar-smart_listing 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +279 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/javascripts/smart_listing.coffee.erb +438 -0
  6. data/app/helpers/smart_listing/application_helper.rb +5 -0
  7. data/app/helpers/smart_listing/helper.rb +366 -0
  8. data/app/views/kaminari/smart_listing/_first_page.html.erb +13 -0
  9. data/app/views/kaminari/smart_listing/_gap.html.erb +8 -0
  10. data/app/views/kaminari/smart_listing/_last_page.html.erb +13 -0
  11. data/app/views/kaminari/smart_listing/_next_page.html.erb +13 -0
  12. data/app/views/kaminari/smart_listing/_page.html.erb +12 -0
  13. data/app/views/kaminari/smart_listing/_paginator.html.erb +25 -0
  14. data/app/views/kaminari/smart_listing/_prev_page.html.erb +13 -0
  15. data/app/views/smart_listing/_action_custom.html.erb +10 -0
  16. data/app/views/smart_listing/_action_delete.html.erb +12 -0
  17. data/app/views/smart_listing/_action_edit.html.erb +11 -0
  18. data/app/views/smart_listing/_action_show.html.erb +11 -0
  19. data/app/views/smart_listing/_item_new.html.erb +30 -0
  20. data/app/views/smart_listing/_pagination_per_page_link.html.erb +12 -0
  21. data/app/views/smart_listing/_pagination_per_page_links.html.erb +19 -0
  22. data/app/views/smart_listing/_sortable.html.erb +21 -0
  23. data/app/views/smart_listing/_update_list.js.erb +2 -0
  24. data/app/views/smart_listing/create.js.erb +2 -0
  25. data/app/views/smart_listing/destroy.js.erb +1 -0
  26. data/app/views/smart_listing/edit.js.erb +1 -0
  27. data/app/views/smart_listing/index.js.erb +1 -0
  28. data/app/views/smart_listing/item/_create.js.erb +3 -0
  29. data/app/views/smart_listing/item/_create_continue.js.erb +6 -0
  30. data/app/views/smart_listing/item/_destroy.js.erb +2 -0
  31. data/app/views/smart_listing/item/_edit.js.erb +2 -0
  32. data/app/views/smart_listing/item/_new.js.erb +2 -0
  33. data/app/views/smart_listing/item/_remove.js.erb +2 -0
  34. data/app/views/smart_listing/item/_update.js.erb +2 -0
  35. data/app/views/smart_listing/new.js.erb +1 -0
  36. data/app/views/smart_listing/update.js.erb +2 -0
  37. data/config/locales/en.yml +15 -0
  38. data/config/routes.rb +2 -0
  39. data/lib/generators/smart_listing/install_generator.rb +20 -0
  40. data/lib/generators/smart_listing/templates/initializer.rb +88 -0
  41. data/lib/generators/smart_listing/views_generator.rb +23 -0
  42. data/lib/smart_listing.rb +216 -0
  43. data/lib/smart_listing/config.rb +159 -0
  44. data/lib/smart_listing/engine.rb +5 -0
  45. data/lib/smart_listing/version.rb +3 -0
  46. data/lib/tasks/smart_list_tasks.rake +4 -0
  47. metadata +245 -0
@@ -0,0 +1,159 @@
1
+ module SmartListing
2
+ mattr_reader :configs
3
+
4
+ def self.configure profile = nil
5
+ profile ||= :default
6
+ @@configs ||= {}
7
+ yield @@configs[profile] ||= SmartListing::Configuration.new
8
+ end
9
+
10
+ def self.config profile = nil
11
+ profile ||= :default
12
+ @@configs ||= {}
13
+ @@configs[profile] ||= SmartListing::Configuration.new
14
+ end
15
+
16
+ class Configuration
17
+ DEFAULT_PAGE_SIZES = [10, 20, 50, 100].freeze
18
+
19
+ DEFAULTS = {
20
+ :global_options => {
21
+ :param_names => { # param names
22
+ :page => :page,
23
+ :per_page => :per_page,
24
+ :sort => :sort,
25
+ },
26
+ :array => false, # controls whether smart list should be using arrays or AR collections
27
+ :max_count => nil, # limit number of rows
28
+ :unlimited_per_page => false, # allow infinite page size
29
+ :paginate => true, # allow pagination
30
+ :memorize_per_page => false,
31
+ :page_sizes => DEFAULT_PAGE_SIZES.dup, # set available page sizes array
32
+ :kaminari_options => {:theme => "smart_listing"}, # Kaminari's paginate helper options
33
+ :sort_dirs => [nil, "asc", "desc"], # Default sorting directions cycle of sortables
34
+ },
35
+ :constants => {
36
+ :classes => {
37
+ :main => "smart-listing",
38
+ :editable => "editable",
39
+ :content => "content",
40
+ :loading => "loading",
41
+ :status => "smart-listing-status",
42
+ :item_actions => "actions",
43
+ :new_item_placeholder => "new-item-placeholder",
44
+ :new_item_action => "new-item-action",
45
+ :new_item_button => "btn",
46
+ :hidden => "hidden",
47
+ :autoselect => "autoselect",
48
+ :callback => "callback",
49
+ :pagination_wrapper => "text-center",
50
+ :pagination_container => "pagination",
51
+ :pagination_per_page => "pagination-per-page text-center",
52
+ :inline_editing => "info",
53
+ :no_records => "no-records",
54
+ :limit => "smart-listing-limit",
55
+ :limit_alert => "smart-listing-limit-alert",
56
+ :controls => "smart-listing-controls",
57
+ :controls_reset => "reset",
58
+ :filtering => "filter",
59
+ :filtering_search => "glyphicon-search",
60
+ :filtering_cancel => "glyphicon-remove",
61
+ :filtering_disabled => "disabled",
62
+ :sortable => "sortable",
63
+ :icon_new => "glyphicon glyphicon-plus",
64
+ :icon_edit => "glyphicon glyphicon-pencil",
65
+ :icon_trash => "glyphicon glyphicon-trash",
66
+ :icon_inactive => "glyphicon glyphicon-remove-circle text-muted",
67
+ :icon_show => "glyphicon glyphicon-share-alt",
68
+ :icon_sort_none => "glyphicon glyphicon-resize-vertical",
69
+ :icon_sort_up => "glyphicon glyphicon-chevron-up",
70
+ :icon_sort_down => "glyphicon glyphicon-chevron-down",
71
+ :muted => "text-muted",
72
+ },
73
+ :data_attributes => {
74
+ :main => "smart-listing",
75
+ :controls_initialized => "smart-listing-controls-initialized",
76
+ :confirmation => "confirmation",
77
+ :id => "id",
78
+ :href => "href",
79
+ :callback_href => "callback-href",
80
+ :max_count => "max-count",
81
+ :item_count => "item-count",
82
+ :inline_edit_backup => "smart-listing-edit-backup",
83
+ :params => "params",
84
+ :observed => "observed",
85
+ :autoshow => "autoshow",
86
+ :popover => "slpopover",
87
+ },
88
+ :selectors => {
89
+ :item_action_destroy => "a.destroy",
90
+ :edit_cancel => "button.cancel",
91
+ :row => "tr",
92
+ :head => "thead",
93
+ :filtering_button => "button",
94
+ :filtering_icon => "button span",
95
+ :filtering_input => ".filter input",
96
+ :pagination_count => ".pagination-per-page .count",
97
+ },
98
+ :element_templates => {
99
+ :row => "<tr />",
100
+ }
101
+ }
102
+ }.freeze
103
+
104
+ attr_reader :options
105
+
106
+ def initialize
107
+ @options = {}
108
+ end
109
+
110
+ def method_missing(sym, *args, &block)
111
+ @options[sym] = *args
112
+ end
113
+
114
+ def constants key, value = nil
115
+ if value && !value.empty?
116
+ @options[:constants] ||= {}
117
+ @options[:constants][key] ||= {}
118
+ @options[:constants][key].merge!(value)
119
+ end
120
+ @options[:constants].try(:[], key) || DEFAULTS[:constants][key]
121
+ end
122
+
123
+ def classes key
124
+ @options[:constants].try(:[], :classes).try(:[], key) || DEFAULTS[:constants][:classes][key]
125
+ end
126
+
127
+ def data_attributes key
128
+ @options[:constants].try(:[], :data_attributes).try(:[], key) || DEFAULTS[:constants][:data_attributes][key]
129
+ end
130
+
131
+ def selectors key
132
+ @options[:constants].try(:[], :selectors).try(:[], key) || DEFAULTS[:constants][:selectors][key]
133
+ end
134
+
135
+ def element_templates key
136
+ @options[:constants].try(:[], :element_templates).try(:[], key) || DEFAULTS[:constants][:element_templates][key]
137
+ end
138
+
139
+ def global_options value = nil
140
+ if value && !value.empty?
141
+ @options[:global_options] ||= {}
142
+ @options[:global_options].merge!(value)
143
+ end
144
+ !@options[:global_options] ? DEFAULTS[:global_options] : DEFAULTS[:global_options].deep_merge(@options[:global_options])
145
+ end
146
+
147
+ def to_json
148
+ @options.to_json
149
+ end
150
+
151
+ def dump
152
+ DEFAULTS.deep_merge(@options)
153
+ end
154
+
155
+ def dump_json
156
+ dump.to_json
157
+ end
158
+ end
159
+ end
@@ -0,0 +1,5 @@
1
+ module SmartListing
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace SmartListing
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module SmartListing
2
+ VERSION = "1.1.3"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :smart_list do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,245 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: peentar-smart_listing
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Peentar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: coffee-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: kaminari
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jquery-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bootstrap-sass
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: capybara
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: poltergeist
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: database_cleaner
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description: Ruby on Rails data listing gem with built-in sorting, filtering and in-place
168
+ editing.
169
+ email:
170
+ - mufid@peentar.com
171
+ executables: []
172
+ extensions: []
173
+ extra_rdoc_files: []
174
+ files:
175
+ - LICENSE
176
+ - README.md
177
+ - Rakefile
178
+ - app/assets/javascripts/smart_listing.coffee.erb
179
+ - app/helpers/smart_listing/application_helper.rb
180
+ - app/helpers/smart_listing/helper.rb
181
+ - app/views/kaminari/smart_listing/_first_page.html.erb
182
+ - app/views/kaminari/smart_listing/_gap.html.erb
183
+ - app/views/kaminari/smart_listing/_last_page.html.erb
184
+ - app/views/kaminari/smart_listing/_next_page.html.erb
185
+ - app/views/kaminari/smart_listing/_page.html.erb
186
+ - app/views/kaminari/smart_listing/_paginator.html.erb
187
+ - app/views/kaminari/smart_listing/_prev_page.html.erb
188
+ - app/views/smart_listing/_action_custom.html.erb
189
+ - app/views/smart_listing/_action_delete.html.erb
190
+ - app/views/smart_listing/_action_edit.html.erb
191
+ - app/views/smart_listing/_action_show.html.erb
192
+ - app/views/smart_listing/_item_new.html.erb
193
+ - app/views/smart_listing/_pagination_per_page_link.html.erb
194
+ - app/views/smart_listing/_pagination_per_page_links.html.erb
195
+ - app/views/smart_listing/_sortable.html.erb
196
+ - app/views/smart_listing/_update_list.js.erb
197
+ - app/views/smart_listing/create.js.erb
198
+ - app/views/smart_listing/destroy.js.erb
199
+ - app/views/smart_listing/edit.js.erb
200
+ - app/views/smart_listing/index.js.erb
201
+ - app/views/smart_listing/item/_create.js.erb
202
+ - app/views/smart_listing/item/_create_continue.js.erb
203
+ - app/views/smart_listing/item/_destroy.js.erb
204
+ - app/views/smart_listing/item/_edit.js.erb
205
+ - app/views/smart_listing/item/_new.js.erb
206
+ - app/views/smart_listing/item/_remove.js.erb
207
+ - app/views/smart_listing/item/_update.js.erb
208
+ - app/views/smart_listing/new.js.erb
209
+ - app/views/smart_listing/update.js.erb
210
+ - config/locales/en.yml
211
+ - config/routes.rb
212
+ - lib/generators/smart_listing/install_generator.rb
213
+ - lib/generators/smart_listing/templates/initializer.rb
214
+ - lib/generators/smart_listing/views_generator.rb
215
+ - lib/smart_listing.rb
216
+ - lib/smart_listing/config.rb
217
+ - lib/smart_listing/engine.rb
218
+ - lib/smart_listing/version.rb
219
+ - lib/tasks/smart_list_tasks.rake
220
+ homepage: https://github.com/peentar/smart_listing
221
+ licenses:
222
+ - MIT
223
+ metadata: {}
224
+ post_install_message:
225
+ rdoc_options: []
226
+ require_paths:
227
+ - lib
228
+ required_ruby_version: !ruby/object:Gem::Requirement
229
+ requirements:
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ version: '0'
233
+ required_rubygems_version: !ruby/object:Gem::Requirement
234
+ requirements:
235
+ - - ">="
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
238
+ requirements: []
239
+ rubyforge_project:
240
+ rubygems_version: 2.4.8
241
+ signing_key:
242
+ specification_version: 4
243
+ summary: SmartListing helps creating sortable lists of ActiveRecord collections with
244
+ pagination, filtering and inline editing.
245
+ test_files: []