will_filter 3.1.11 → 5.1.0
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 +7 -0
- data/.gitignore +1 -0
- data/Gemfile +8 -3
- data/Gemfile.lock +182 -127
- data/README.rdoc +1 -10
- data/app/assets/images/will_filter/loading.gif +0 -0
- data/app/assets/javascripts/will_filter/filter.js +526 -517
- data/app/assets/stylesheets/will_filter/filter.css.scss +405 -108
- data/app/controllers/will_filter/calendar_controller.rb +10 -1
- data/app/controllers/will_filter/exporter_controller.rb +12 -3
- data/app/controllers/will_filter/filter_controller.rb +19 -10
- data/app/models/will_filter/filter.rb +254 -203
- data/app/views/will_filter/calendar/index.html.erb +55 -43
- data/app/views/will_filter/common/_actions_bar.html.erb +3 -3
- data/app/views/will_filter/common/_results_table.html.erb +55 -39
- data/app/views/will_filter/common/_scripts.html.erb +2 -12
- data/app/views/will_filter/exporter/index.html.erb +26 -22
- data/app/views/will_filter/filter/_condition.html.erb +25 -9
- data/app/views/will_filter/filter/_conditions.html.erb +12 -9
- data/app/views/will_filter/filter/_conditions_footer.html.erb +25 -10
- data/app/views/will_filter/filter/_conditions_header.html.erb +38 -24
- data/app/views/will_filter/filter/_container.html.erb +10 -9
- data/app/views/will_filter/filter/containers/_date.html.erb +8 -10
- data/app/views/will_filter/filter/containers/_date_range.html.erb +21 -13
- data/app/views/will_filter/filter/containers/_date_time.html.erb +8 -10
- data/app/views/will_filter/filter/containers/_date_time_range.html.erb +21 -13
- data/app/views/will_filter/filter/containers/_list.html.erb +16 -6
- data/config/routes.rb +26 -16
- data/deploy +63 -0
- data/lib/generators/will_filter/templates/config.yml +18 -5
- data/lib/generators/will_filter/templates/create_will_filter_filters.rb +12 -1
- data/lib/generators/will_filter/will_filter_generator.rb +10 -1
- data/lib/tasks/will_filter_tasks.rake +10 -2
- data/lib/will_filter.rb +10 -1
- data/lib/will_filter/calendar.rb +10 -1
- data/lib/will_filter/config.rb +31 -4
- data/lib/will_filter/containers/boolean.rb +10 -1
- data/lib/will_filter/containers/date.rb +10 -1
- data/lib/will_filter/containers/date_range.rb +10 -1
- data/lib/will_filter/containers/date_time.rb +10 -1
- data/lib/will_filter/containers/date_time_range.rb +10 -1
- data/lib/will_filter/containers/double.rb +10 -1
- data/lib/will_filter/containers/double_delimited.rb +10 -1
- data/lib/will_filter/containers/double_range.rb +10 -1
- data/lib/will_filter/containers/filter_list.rb +21 -7
- data/lib/will_filter/containers/list.rb +10 -1
- data/lib/will_filter/containers/nil.rb +10 -1
- data/lib/will_filter/containers/numeric.rb +10 -1
- data/lib/will_filter/containers/numeric_delimited.rb +10 -1
- data/lib/will_filter/containers/numeric_range.rb +10 -1
- data/lib/will_filter/containers/single_date.rb +12 -1
- data/lib/will_filter/containers/text.rb +10 -1
- data/lib/will_filter/containers/text_delimited.rb +11 -2
- data/lib/will_filter/engine.rb +10 -1
- data/lib/will_filter/extensions/action_controller_extension.rb +34 -10
- data/lib/will_filter/extensions/action_view_extension.rb +12 -3
- data/lib/will_filter/extensions/active_record_extension.rb +11 -1
- data/lib/will_filter/extensions/active_record_relation_extension.rb +51 -0
- data/lib/will_filter/extensions/array_extension.rb +10 -1
- data/lib/will_filter/filter_condition.rb +11 -7
- data/lib/will_filter/filter_container.rb +10 -1
- data/lib/will_filter/filter_exception.rb +10 -1
- data/lib/will_filter/railtie.rb +14 -4
- data/lib/will_filter/version.rb +11 -2
- data/spec/config/config_spec.rb +5 -5
- data/spec/models/will_filter/filter_spec.rb +130 -131
- data/test/dummy/app/assets/javascripts/application.js +3 -0
- data/test/dummy/app/assets/javascripts/bootstrap.js +1951 -0
- data/test/dummy/app/assets/javascripts/jquery-2.1.3.min.js +4 -0
- data/test/dummy/app/assets/javascripts/select2.min.js +3 -0
- data/test/dummy/app/assets/stylesheets/{application.css → application.css.sass} +5 -2
- data/test/dummy/app/assets/stylesheets/bootstrap.min.css +7 -0
- data/test/dummy/app/assets/stylesheets/select2.min.css +1 -0
- data/test/dummy/app/controllers/advanced_controller.rb +4 -4
- data/test/dummy/app/controllers/orders_controller.rb +2 -2
- data/test/dummy/app/controllers/simple_controller.rb +3 -3
- data/test/dummy/app/models/event.rb +1 -1
- data/test/dummy/app/models/user.rb +1 -1
- data/test/dummy/app/views/common/_events.html.erb +7 -13
- data/test/dummy/app/views/common/_menu.html.erb +25 -27
- data/test/dummy/app/views/layouts/application.html.erb +3 -5
- data/test/dummy/config/environments/development.rb +2 -0
- data/test/dummy/config/environments/production.rb +2 -0
- data/test/dummy/config/environments/test.rb +2 -0
- data/test/dummy/config/initializers/assets.rb +12 -0
- data/test/dummy/config/routes.rb +10 -10
- data/test/dummy/db/schema.rb +46 -50
- data/will_filter.gemspec +3 -3
- metadata +39 -44
- data/.rvmrc +0 -1
- data/app/assets/javascripts/will_filter/filter_prototype_effects.js +0 -38
- data/app/assets/stylesheets/will_filter/actions.css.scss +0 -27
- data/app/assets/stylesheets/will_filter/buttons.css.scss +0 -24
- data/app/assets/stylesheets/will_filter/calendar.css.scss +0 -102
- data/app/assets/stylesheets/will_filter/exporter.css.scss +0 -89
- data/app/assets/stylesheets/will_filter/results.css.scss +0 -63
- data/app/views/layouts/will_filter/application.html.erb +0 -14
- data/test/dummy/app/assets/javascripts/orders.js +0 -2
- data/test/dummy/app/assets/stylesheets/orders.css +0 -4
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -66,10 +75,13 @@ defaults: &defaults
|
|
|
66
75
|
script_path: "will_filter/filter_prototype_effects.js"
|
|
67
76
|
|
|
68
77
|
save_options:
|
|
69
|
-
enabled:
|
|
70
|
-
user_filters_enabled:
|
|
71
|
-
user_class_name:
|
|
72
|
-
current_user_method:
|
|
78
|
+
enabled: true
|
|
79
|
+
user_filters_enabled: false # if set to true, the filters will be private
|
|
80
|
+
user_class_name: User
|
|
81
|
+
current_user_method: current_user
|
|
82
|
+
project_filters_enabled: false # if set to true, the filters will be project based
|
|
83
|
+
project_class_name: Project
|
|
84
|
+
current_project_method: current_project
|
|
73
85
|
|
|
74
86
|
export_options:
|
|
75
87
|
enabled: true
|
|
@@ -119,6 +131,7 @@ defaults: &defaults
|
|
|
119
131
|
is_not: 200
|
|
120
132
|
is_on: 300
|
|
121
133
|
is_in: 400
|
|
134
|
+
is_not_in: 450
|
|
122
135
|
is_provided: 500
|
|
123
136
|
is_not_provided: 600
|
|
124
137
|
is_after: 700
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -28,11 +37,13 @@ class CreateWillFilterFilters < ActiveRecord::Migration
|
|
|
28
37
|
t.string :name
|
|
29
38
|
t.text :data
|
|
30
39
|
t.integer :user_id
|
|
40
|
+
t.integer :project_id
|
|
31
41
|
t.string :model_class_name
|
|
32
42
|
|
|
33
43
|
t.timestamps
|
|
34
44
|
end
|
|
35
45
|
|
|
36
46
|
add_index :will_filter_filters, [:user_id]
|
|
47
|
+
add_index :will_filter_filters, [:project_id]
|
|
37
48
|
end
|
|
38
49
|
end
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -23,5 +32,4 @@
|
|
|
23
32
|
|
|
24
33
|
namespace :will_filter do
|
|
25
34
|
|
|
26
|
-
|
|
27
35
|
end
|
data/lib/will_filter.rb
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
data/lib/will_filter/calendar.rb
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
data/lib/will_filter/config.rb
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -23,16 +32,22 @@
|
|
|
23
32
|
|
|
24
33
|
module WillFilter
|
|
25
34
|
class Config
|
|
26
|
-
def self.init(site_current_user)
|
|
35
|
+
def self.init(site_current_user, site_current_project = nil)
|
|
27
36
|
Thread.current[:current_user] = site_current_user
|
|
37
|
+
Thread.current[:current_project] = site_current_project
|
|
28
38
|
end
|
|
29
39
|
|
|
30
40
|
def self.current_user
|
|
31
41
|
Thread.current[:current_user]
|
|
32
42
|
end
|
|
33
|
-
|
|
43
|
+
|
|
44
|
+
def self.current_project
|
|
45
|
+
Thread.current[:current_project]
|
|
46
|
+
end
|
|
47
|
+
|
|
34
48
|
def self.reset!
|
|
35
49
|
Thread.current[:current_user] = nil
|
|
50
|
+
Thread.current[:current_project] = nil
|
|
36
51
|
end
|
|
37
52
|
|
|
38
53
|
def self.load_yml(file_path)
|
|
@@ -99,7 +114,19 @@ module WillFilter
|
|
|
99
114
|
def self.current_user_method
|
|
100
115
|
save_options[:current_user_method]
|
|
101
116
|
end
|
|
102
|
-
|
|
117
|
+
|
|
118
|
+
def self.project_filters_enabled?
|
|
119
|
+
save_options[:project_filters_enabled]
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def self.project_class_name
|
|
123
|
+
save_options[:project_class_name]
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def self.current_project_method
|
|
127
|
+
save_options[:current_project_method]
|
|
128
|
+
end
|
|
129
|
+
|
|
103
130
|
def self.exporting_enabled?
|
|
104
131
|
export_options[:enabled]
|
|
105
132
|
end
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -27,30 +36,35 @@ module WillFilter
|
|
|
27
36
|
def self.operators
|
|
28
37
|
[:is_filtered_by]
|
|
29
38
|
end
|
|
30
|
-
|
|
39
|
+
|
|
31
40
|
def validate
|
|
32
41
|
return "Value must be provided" if value.blank?
|
|
33
42
|
end
|
|
34
|
-
|
|
43
|
+
|
|
35
44
|
def template_name
|
|
36
45
|
'list'
|
|
37
46
|
end
|
|
38
47
|
|
|
39
48
|
def linked_filter
|
|
40
49
|
@linked_filter ||= begin
|
|
41
|
-
|
|
50
|
+
model_class = filter.model_class_for_column_key(condition.key)
|
|
51
|
+
|
|
52
|
+
if model_class
|
|
53
|
+
model_class_name = model_class.name
|
|
54
|
+
elsif condition.key == :id
|
|
42
55
|
model_class_name = filter.model_class_name
|
|
43
56
|
else
|
|
44
57
|
model_class_name = condition.key.to_s[0..-4].camelcase
|
|
45
58
|
end
|
|
59
|
+
|
|
46
60
|
WillFilter::Filter.new(model_class_name)
|
|
47
61
|
end
|
|
48
62
|
end
|
|
49
|
-
|
|
63
|
+
|
|
50
64
|
def options
|
|
51
65
|
linked_filter.saved_filters(false)
|
|
52
66
|
end
|
|
53
|
-
|
|
67
|
+
|
|
54
68
|
def sql_condition
|
|
55
69
|
return nil unless operator == :is_filtered_by
|
|
56
70
|
sub_filter = WillFilter::Filter.find_by_id(value) || linked_filter.user_filters.first
|
|
@@ -62,7 +76,7 @@ module WillFilter
|
|
|
62
76
|
sub_conds[0] = " #{condition.full_key} IN (SELECT #{sub_filter.table_name}.id FROM #{sub_filter.table_name}) "
|
|
63
77
|
else
|
|
64
78
|
sub_conds[0] = " #{condition.full_key} IN (SELECT #{sub_filter.table_name}.id FROM #{sub_filter.table_name} WHERE #{sub_conds[0]}) "
|
|
65
|
-
end
|
|
79
|
+
end
|
|
66
80
|
|
|
67
81
|
sub_conds
|
|
68
82
|
end
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright (c)
|
|
2
|
+
# Copyright (c) 2017 Michael Berkovich, theiceberk@gmail.com
|
|
3
|
+
#
|
|
4
|
+
# __ __ ____ _ _ _____ ____ _ ______ ___ ____
|
|
5
|
+
# | |__| || || | | | | || || | | | / _]| \
|
|
6
|
+
# | | | | | | | | | | | __| | | | | | | / [_ | D )
|
|
7
|
+
# | | | | | | | |___ | |___ | |_ | | | |___|_| |_|| _]| /
|
|
8
|
+
# | ` ' | | | | || | | _] | | | | | | | [_ | \
|
|
9
|
+
# \ / | | | || | | | | | | | | | | || . \
|
|
10
|
+
# \_/\_/ |____||_____||_____| |__| |____||_____| |__| |_____||__|\_|
|
|
11
|
+
#
|
|
3
12
|
#
|
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
|
5
14
|
# a copy of this software and associated documentation files (the
|