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.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/Gemfile +8 -3
  4. data/Gemfile.lock +182 -127
  5. data/README.rdoc +1 -10
  6. data/app/assets/images/will_filter/loading.gif +0 -0
  7. data/app/assets/javascripts/will_filter/filter.js +526 -517
  8. data/app/assets/stylesheets/will_filter/filter.css.scss +405 -108
  9. data/app/controllers/will_filter/calendar_controller.rb +10 -1
  10. data/app/controllers/will_filter/exporter_controller.rb +12 -3
  11. data/app/controllers/will_filter/filter_controller.rb +19 -10
  12. data/app/models/will_filter/filter.rb +254 -203
  13. data/app/views/will_filter/calendar/index.html.erb +55 -43
  14. data/app/views/will_filter/common/_actions_bar.html.erb +3 -3
  15. data/app/views/will_filter/common/_results_table.html.erb +55 -39
  16. data/app/views/will_filter/common/_scripts.html.erb +2 -12
  17. data/app/views/will_filter/exporter/index.html.erb +26 -22
  18. data/app/views/will_filter/filter/_condition.html.erb +25 -9
  19. data/app/views/will_filter/filter/_conditions.html.erb +12 -9
  20. data/app/views/will_filter/filter/_conditions_footer.html.erb +25 -10
  21. data/app/views/will_filter/filter/_conditions_header.html.erb +38 -24
  22. data/app/views/will_filter/filter/_container.html.erb +10 -9
  23. data/app/views/will_filter/filter/containers/_date.html.erb +8 -10
  24. data/app/views/will_filter/filter/containers/_date_range.html.erb +21 -13
  25. data/app/views/will_filter/filter/containers/_date_time.html.erb +8 -10
  26. data/app/views/will_filter/filter/containers/_date_time_range.html.erb +21 -13
  27. data/app/views/will_filter/filter/containers/_list.html.erb +16 -6
  28. data/config/routes.rb +26 -16
  29. data/deploy +63 -0
  30. data/lib/generators/will_filter/templates/config.yml +18 -5
  31. data/lib/generators/will_filter/templates/create_will_filter_filters.rb +12 -1
  32. data/lib/generators/will_filter/will_filter_generator.rb +10 -1
  33. data/lib/tasks/will_filter_tasks.rake +10 -2
  34. data/lib/will_filter.rb +10 -1
  35. data/lib/will_filter/calendar.rb +10 -1
  36. data/lib/will_filter/config.rb +31 -4
  37. data/lib/will_filter/containers/boolean.rb +10 -1
  38. data/lib/will_filter/containers/date.rb +10 -1
  39. data/lib/will_filter/containers/date_range.rb +10 -1
  40. data/lib/will_filter/containers/date_time.rb +10 -1
  41. data/lib/will_filter/containers/date_time_range.rb +10 -1
  42. data/lib/will_filter/containers/double.rb +10 -1
  43. data/lib/will_filter/containers/double_delimited.rb +10 -1
  44. data/lib/will_filter/containers/double_range.rb +10 -1
  45. data/lib/will_filter/containers/filter_list.rb +21 -7
  46. data/lib/will_filter/containers/list.rb +10 -1
  47. data/lib/will_filter/containers/nil.rb +10 -1
  48. data/lib/will_filter/containers/numeric.rb +10 -1
  49. data/lib/will_filter/containers/numeric_delimited.rb +10 -1
  50. data/lib/will_filter/containers/numeric_range.rb +10 -1
  51. data/lib/will_filter/containers/single_date.rb +12 -1
  52. data/lib/will_filter/containers/text.rb +10 -1
  53. data/lib/will_filter/containers/text_delimited.rb +11 -2
  54. data/lib/will_filter/engine.rb +10 -1
  55. data/lib/will_filter/extensions/action_controller_extension.rb +34 -10
  56. data/lib/will_filter/extensions/action_view_extension.rb +12 -3
  57. data/lib/will_filter/extensions/active_record_extension.rb +11 -1
  58. data/lib/will_filter/extensions/active_record_relation_extension.rb +51 -0
  59. data/lib/will_filter/extensions/array_extension.rb +10 -1
  60. data/lib/will_filter/filter_condition.rb +11 -7
  61. data/lib/will_filter/filter_container.rb +10 -1
  62. data/lib/will_filter/filter_exception.rb +10 -1
  63. data/lib/will_filter/railtie.rb +14 -4
  64. data/lib/will_filter/version.rb +11 -2
  65. data/spec/config/config_spec.rb +5 -5
  66. data/spec/models/will_filter/filter_spec.rb +130 -131
  67. data/test/dummy/app/assets/javascripts/application.js +3 -0
  68. data/test/dummy/app/assets/javascripts/bootstrap.js +1951 -0
  69. data/test/dummy/app/assets/javascripts/jquery-2.1.3.min.js +4 -0
  70. data/test/dummy/app/assets/javascripts/select2.min.js +3 -0
  71. data/test/dummy/app/assets/stylesheets/{application.css → application.css.sass} +5 -2
  72. data/test/dummy/app/assets/stylesheets/bootstrap.min.css +7 -0
  73. data/test/dummy/app/assets/stylesheets/select2.min.css +1 -0
  74. data/test/dummy/app/controllers/advanced_controller.rb +4 -4
  75. data/test/dummy/app/controllers/orders_controller.rb +2 -2
  76. data/test/dummy/app/controllers/simple_controller.rb +3 -3
  77. data/test/dummy/app/models/event.rb +1 -1
  78. data/test/dummy/app/models/user.rb +1 -1
  79. data/test/dummy/app/views/common/_events.html.erb +7 -13
  80. data/test/dummy/app/views/common/_menu.html.erb +25 -27
  81. data/test/dummy/app/views/layouts/application.html.erb +3 -5
  82. data/test/dummy/config/environments/development.rb +2 -0
  83. data/test/dummy/config/environments/production.rb +2 -0
  84. data/test/dummy/config/environments/test.rb +2 -0
  85. data/test/dummy/config/initializers/assets.rb +12 -0
  86. data/test/dummy/config/routes.rb +10 -10
  87. data/test/dummy/db/schema.rb +46 -50
  88. data/will_filter.gemspec +3 -3
  89. metadata +39 -44
  90. data/.rvmrc +0 -1
  91. data/app/assets/javascripts/will_filter/filter_prototype_effects.js +0 -38
  92. data/app/assets/stylesheets/will_filter/actions.css.scss +0 -27
  93. data/app/assets/stylesheets/will_filter/buttons.css.scss +0 -24
  94. data/app/assets/stylesheets/will_filter/calendar.css.scss +0 -102
  95. data/app/assets/stylesheets/will_filter/exporter.css.scss +0 -89
  96. data/app/assets/stylesheets/will_filter/results.css.scss +0 -63
  97. data/app/views/layouts/will_filter/application.html.erb +0 -14
  98. data/test/dummy/app/assets/javascripts/orders.js +0 -2
  99. data/test/dummy/app/assets/stylesheets/orders.css +0 -4
@@ -1,5 +1,14 @@
1
1
  #--
2
- # Copyright (c) 2010-2013 Michael Berkovich
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: true
70
- user_filters_enabled: false # if set to true, the filters will be private
71
- user_class_name: User
72
- current_user_method: current_user
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) 2010-2013 Michael Berkovich
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) 2010-2013 Michael Berkovich
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) 2010-2012 Michael Berkovich
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) 2010-2012 Michael Berkovich
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) 2010-2013 Michael Berkovich
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) 2010-2013 Michael Berkovich
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) 2010-2013 Michael Berkovich
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) 2010-2013 Michael Berkovich
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) 2010-2013 Michael Berkovich
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) 2010-2013 Michael Berkovich
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) 2010-2013 Michael Berkovich
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) 2010-2013 Michael Berkovich
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) 2010-2013 Michael Berkovich
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) 2010-2013 Michael Berkovich
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) 2010-2013 Michael Berkovich
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
- if condition.key == :id
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) 2010-2013 Michael Berkovich
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) 2010-2013 Michael Berkovich
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) 2010-2013 Michael Berkovich
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