express_admin 1.7.28 → 1.7.29

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b516340a35967fe889a0b444dbcaffba32b37391
4
- data.tar.gz: 48d9ed2620e2d914b96341a1270702133964dc83
3
+ metadata.gz: ef8cec8a16d8b19753bb84b13648532cf14f696f
4
+ data.tar.gz: 47d9fe386d1018d71caa8548da23340b16f92c18
5
5
  SHA512:
6
- metadata.gz: 29a40ae6919f23c5b068bfe2a147b1ae556b7f0daddc70397bf3d46c7a56db2e7aed2c048b5af549dd8f172ef9bf08ff66118a19d91f325a8d3adde102d2d844
7
- data.tar.gz: 2520ed01ae603ca06d3d83c5ad67844a4df190f2e588698de9ed213f8271cbf6657eada3892be8836987f6b93760baa13c13fb5c900c34b37231b510a52acb39
6
+ metadata.gz: fe38c39fc5686864203803f68ae1611a89c324bac1c96411d1cb1961fc06511463b176b54bd64396fda049ae43f8078fcda8f872d02ed247322b48ae4bdc1321
7
+ data.tar.gz: 4d38dd9c209e8f3149ad44d9cd4110fdc22c5615518b9c3bf0bac949181d368559cdc9331ee69923bd10397c46d66316aeadca0039a348a40fd0875b05e01413
@@ -0,0 +1,17 @@
1
+ .filter-tag
2
+ a
3
+ color: white
4
+ font-size: 1.2em
5
+ text-transform: none
6
+
7
+ .filter-criteria
8
+ float: right
9
+ display: block
10
+ margin-left: 1em
11
+ margin-right: 1em
12
+ margin-top: 1em
13
+
14
+ .content-title
15
+ display: inline
16
+ float: left
17
+ padding-left: 8px
@@ -25,6 +25,7 @@
25
25
  @import 'components/smart_table'
26
26
  @import 'components/label'
27
27
  @import 'components/image'
28
+ @import 'components/filter'
28
29
 
29
30
  @import 'shared/media_object'
30
31
  @import 'shared/breadcrumbs'
@@ -0,0 +1,31 @@
1
+ module ExpressAdmin
2
+ module Components
3
+ module Controls
4
+ class CollectionFilter < ExpressTemplates::Components::Configurable
5
+ include ExpressTemplates::Components::Capabilities::Resourceful
6
+
7
+ tag :span
8
+
9
+ before_build {
10
+ add_class 'filter-criteria'
11
+ }
12
+
13
+ contains -> {
14
+ if _filter_column
15
+ text_node "Filter: "
16
+ span(class: 'label filter-tag') {
17
+ icon_link(:'android-cancel', text: helpers.params[:filter][_filter_column],
18
+ href: log_entries_path(filter: {}),
19
+ right: true)
20
+ }
21
+ end
22
+ }
23
+
24
+ private
25
+ def _filter_column
26
+ helpers.params[:filter].try(:keys).try(:first)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -237,14 +237,33 @@ module ExpressAdmin
237
237
  else
238
238
  resource_class
239
239
  end
240
- scope = search?(scope)
241
- scope = instance_variable(scope)
242
- scope = params[:asc] || params[:desc] ? sort_table(scope) : scope
243
- self.instance_variable_set(collection_ivar, scope)
240
+ filtered_scope = filter(scope) # TODO: Removed the conditionally invoked .all
241
+ # scope = params[:asc] || params[:desc] ? sort_table(scope) : scope
242
+ self.instance_variable_set(collection_ivar, filtered_scope)
244
243
  end
245
244
 
246
- def instance_variable(scope)
247
- scope.kind_of?(Array) ? scope : scope.all
245
+ def filter(scope)
246
+ if _filter_field
247
+ scope.kind_of?(Array) ? _array_filter(scope) : _sql_filter(scope)
248
+ else
249
+ scope
250
+ end
251
+ end
252
+
253
+ def _filter_field
254
+ params[:filter] ? params[:filter].keys.first : nil
255
+ end
256
+
257
+ def _filter_value
258
+ params[:filter][_filter_field]
259
+ end
260
+
261
+ def _array_filter(list)
262
+ list.select {|item| item.send(_filter_field).eql?(_filter_value)}
263
+ end
264
+
265
+ def _sql_filter(scope)
266
+ scope.where(_filter_field.to_sym => _filter_value)
248
267
  end
249
268
 
250
269
  def sort_table(scope)
@@ -257,6 +276,7 @@ module ExpressAdmin
257
276
  end
258
277
  end
259
278
 
279
+ # TODO: Refactor.
260
280
  def search?(scope)
261
281
  params[:search_string].present? ? search(scope) : scope
262
282
  end
@@ -1,3 +1,3 @@
1
1
  module ExpressAdmin
2
- VERSION = "1.7.28"
2
+ VERSION = "1.7.29"
3
3
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: express_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.28
4
+ version: 1.7.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Talcott Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-09 00:00:00.000000000 Z
11
+ date: 2016-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: express_templates
@@ -399,6 +399,7 @@ files:
399
399
  - app/assets/stylesheets/express_admin/components/_command_button.sass
400
400
  - app/assets/stylesheets/express_admin/components/_definition.sass
401
401
  - app/assets/stylesheets/express_admin/components/_empty_state.sass
402
+ - app/assets/stylesheets/express_admin/components/_filter.sass
402
403
  - app/assets/stylesheets/express_admin/components/_h_box.sass
403
404
  - app/assets/stylesheets/express_admin/components/_image.sass
404
405
  - app/assets/stylesheets/express_admin/components/_label.sass
@@ -438,6 +439,7 @@ files:
438
439
  - app/assets/stylesheets/express_admin/shared/_widgets.sass
439
440
  - app/assets/stylesheets/ionicons/ionicons.scss
440
441
  - app/components/express_admin/code_editor.rb
442
+ - app/components/express_admin/collection_filter.rb
441
443
  - app/components/express_admin/command_button.rb
442
444
  - app/components/express_admin/command_button_list.rb
443
445
  - app/components/express_admin/country_select.rb
@@ -647,7 +649,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
647
649
  version: '0'
648
650
  requirements: []
649
651
  rubyforge_project:
650
- rubygems_version: 2.5.1
652
+ rubygems_version: 2.4.7
651
653
  signing_key:
652
654
  specification_version: 4
653
655
  summary: ExpressAdmin provides an admin menu framework based on Foundation.