binxtils 0.3.0 → 0.3.2
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/README.md +3 -5
- data/lib/binxtils/controller_namespace.rb +16 -0
- data/lib/binxtils/nav_helper.rb +19 -0
- data/lib/binxtils/sortable_helper.rb +5 -1
- data/lib/binxtils/version.rb +1 -1
- data/lib/binxtils.rb +2 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 12c38db3719c95218c1a383e855d0e93ce8ad95c502a7de561ac0d009001f527
|
|
4
|
+
data.tar.gz: f3882973303d67f8f7acba2c7bea3472fb05b851643bbf319abd977e89ca9bc0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 94cd2d95f60467acd0c83146669332cad4eeb213e99fe5151c7baed440825605082b3415850dd06943403bce8eba0b04890d4c047b5b678be25503b7a6047198
|
|
7
|
+
data.tar.gz: d92707eecbb21127b312ff3eec0c82ccb02c86238d23e84f3996272c9fcfc2233244abe275b118b610de8e8954b850ac4926d689efe678a0d68ec8ccd80ceb53
|
data/README.md
CHANGED
|
@@ -41,12 +41,10 @@ end
|
|
|
41
41
|
|
|
42
42
|
module ApplicationHelper
|
|
43
43
|
include Binxtils::SortableHelper
|
|
44
|
-
|
|
45
|
-
# Optionally extend the permitted search params
|
|
46
|
-
def default_search_keys
|
|
47
|
-
super + [:organization_id, query_items: []]
|
|
48
|
-
end
|
|
49
44
|
end
|
|
45
|
+
|
|
46
|
+
# Optionally extend the permitted search params (e.g. in an initializer)
|
|
47
|
+
Binxtils::SortableHelper.extra_search_keys = [:organization_id, query_items: []]
|
|
50
48
|
```
|
|
51
49
|
|
|
52
50
|
`SortableTable` requires a `sortable_columns` method in your controller:
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Binxtils
|
|
4
|
+
module ControllerNamespace
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
|
|
7
|
+
included do
|
|
8
|
+
helper_method :controller_namespace
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def controller_namespace
|
|
12
|
+
return @controller_namespace if defined?(@controller_namespace)
|
|
13
|
+
@controller_namespace = (self.class.module_parent == Object) ? nil : self.class.module_parent.name.underscore
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Binxtils
|
|
4
|
+
module NavHelper
|
|
5
|
+
def current_page_active?(link_path, match_controller = false)
|
|
6
|
+
return current_page?(link_path) unless match_controller
|
|
7
|
+
|
|
8
|
+
Rails.application.routes.recognize_path(link_path)[:controller] == current_request_controller
|
|
9
|
+
rescue ActionController::RoutingError
|
|
10
|
+
false
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def current_request_controller
|
|
16
|
+
@current_request_controller ||= Rails.application.routes.recognize_path(request.url)[:controller]
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
module Binxtils
|
|
4
4
|
module SortableHelper
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
|
|
5
7
|
BASE_SEARCH_KEYS = [
|
|
6
8
|
:direction, :sort, # sorting params
|
|
7
9
|
:period, :start_time, :end_time, :render_chart, # Time period params
|
|
8
10
|
:user_id, :query, :per_page # General search params
|
|
9
11
|
].freeze
|
|
10
12
|
|
|
13
|
+
mattr_accessor :extra_search_keys, default: []
|
|
14
|
+
|
|
11
15
|
# Set defaults, required for testing
|
|
12
16
|
def sort_column = "id"
|
|
13
17
|
def sort_direction = "desc"
|
|
14
18
|
|
|
15
19
|
def default_search_keys
|
|
16
|
-
BASE_SEARCH_KEYS
|
|
20
|
+
BASE_SEARCH_KEYS + Binxtils::SortableHelper.extra_search_keys
|
|
17
21
|
end
|
|
18
22
|
|
|
19
23
|
def sortable(column, title = nil, html_options = {}, &block)
|
data/lib/binxtils/version.rb
CHANGED
data/lib/binxtils.rb
CHANGED
|
@@ -13,4 +13,6 @@ require_relative "binxtils/time_parser"
|
|
|
13
13
|
require_relative "binxtils/set_period"
|
|
14
14
|
require_relative "binxtils/sortable_table"
|
|
15
15
|
require_relative "binxtils/sortable_helper"
|
|
16
|
+
require_relative "binxtils/controller_namespace"
|
|
17
|
+
require_relative "binxtils/nav_helper"
|
|
16
18
|
require_relative "binxtils/railtie" if defined?(Rails::Railtie)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: binxtils
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bike Index
|
|
@@ -88,7 +88,9 @@ files:
|
|
|
88
88
|
- LICENSE
|
|
89
89
|
- README.md
|
|
90
90
|
- lib/binxtils.rb
|
|
91
|
+
- lib/binxtils/controller_namespace.rb
|
|
91
92
|
- lib/binxtils/input_normalizer.rb
|
|
93
|
+
- lib/binxtils/nav_helper.rb
|
|
92
94
|
- lib/binxtils/railtie.rb
|
|
93
95
|
- lib/binxtils/set_period.rb
|
|
94
96
|
- lib/binxtils/sortable_helper.rb
|