spotlight_search 0.2.2 → 0.3.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 +4 -4
- data/Gemfile.lock +1 -3
- data/README.md +9 -6
- data/lib/generators/spotlight_search/filter_generator.rb +3 -0
- data/lib/generators/spotlight_search/install_generator.rb +3 -7
- data/lib/generators/spotlight_search/templates/application.css.scss +26 -0
- data/lib/generators/spotlight_search/templates/application.js +5 -1
- data/lib/generators/spotlight_search/templates/controller.rb.erb +8 -8
- data/lib/generators/spotlight_search/templates/environment.js +2 -1
- data/lib/generators/spotlight_search/templates/filters.html.erb +10 -12
- data/lib/generators/spotlight_search/templates/scaffolds.coffee +6 -1
- data/lib/generators/spotlight_search/templates/spotlight_search.rb +5 -1
- data/lib/spotlight_search/helpers.rb +36 -19
- data/lib/spotlight_search/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db095dee4fcbb232c1f7eddd83dfdfe279243415f3f6e54636740c2abbbe9ac3
|
|
4
|
+
data.tar.gz: c93d9955d07504a7aecca13cca15d1655fa847d0c13b1dc3643414ceeab39cb3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 67fc0b1c020ee49f59dbf539bf7854fcf65a8d8ce393b6315450c07812bec38020ace65fd29c36d76fb7408ddee3a6296c92ebf94dddc13026bc000660e26651
|
|
7
|
+
data.tar.gz: f4b76130d03a78c7fefdf61feffa8a61712097bd9807b479e3d9f41246fa69ed45bed3071a4df6b59ca94f5a3ea03dc0f1ecbdf74fdc701c6b845b92354b3123
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -42,14 +42,17 @@ The install generator does the following
|
|
|
42
42
|
* Adds a line in route for mounting.
|
|
43
43
|
|
|
44
44
|
Generator that installs filter and table files to application
|
|
45
|
+
$ rails g spotlight_search filter orders --filters scope_name:filter_type
|
|
46
|
+
$ rails g spotlight_search filter orders --filters search:input order_status:multi_select status:select
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
scope_name is the model scope name, scope can written after running this generator, it won't throw any error that it has to be present.
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
Following filter type are supported
|
|
51
|
+
* input
|
|
52
|
+
* single-select
|
|
53
|
+
* multi-select
|
|
54
|
+
* datetime
|
|
55
|
+
* daterange
|
|
53
56
|
|
|
54
57
|
|
|
55
58
|
## Usage
|
|
@@ -8,6 +8,9 @@ module SpotlightSearch
|
|
|
8
8
|
|
|
9
9
|
def copy_filter_contents_to_app
|
|
10
10
|
if @options.filters?
|
|
11
|
+
inject_into_file "app/models/#{model.singularize}.rb", after: "ApplicationRecord" do
|
|
12
|
+
"\n include SpotlightSearch\n"
|
|
13
|
+
end
|
|
11
14
|
template 'filters.html.erb', "app/views/admin/#{model}/_filters.html.slim"
|
|
12
15
|
template 'controller.rb.erb', "app/controllers/admin/#{model}_controller.rb"
|
|
13
16
|
end
|
|
@@ -11,19 +11,15 @@ module SpotlightSearch
|
|
|
11
11
|
copy_file 'environment.js', 'config/webpack/environment.js'
|
|
12
12
|
copy_file 'coffee.js', 'config/webpack/loaders/coffee.js'
|
|
13
13
|
copy_file 'spotlight_search.rb', 'config/initializers/spotlight_search.rb'
|
|
14
|
+
copy_file 'application.css.scss', 'app/assets/stylesheets/application.css.scss'
|
|
14
15
|
route "mount SpotlightSearch::Engine => '/spotlight_search'"
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
def add_essentials
|
|
18
|
-
system("yarn add jquery")
|
|
19
|
-
system("yarn add coffeescript")
|
|
20
|
-
system("yarn add select2")
|
|
21
|
-
inject_into_file 'app/assets/stylesheets/application.css.scss', before: " */" do
|
|
22
|
-
" *= require select2\n"
|
|
23
|
-
end
|
|
19
|
+
system("yarn add jquery coffeescript coffee-loader select2 popper.js daterangepicker bootstrap-datepicker")
|
|
24
20
|
template "application.js", "app/javascript/packs/application.js"
|
|
25
21
|
template 'scaffolds.coffee', "app/javascript/application/coffee_scripts/scaffolds.coffee"
|
|
26
|
-
gem 'kaminari'
|
|
22
|
+
gem 'kaminari'
|
|
27
23
|
end
|
|
28
24
|
|
|
29
25
|
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
|
|
6
|
+
* vendor/assets/stylesheets directory can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
|
11
|
+
* It is generally better to create a new file per style scope.
|
|
12
|
+
*
|
|
13
|
+
*= require_self
|
|
14
|
+
*= require font-awesome
|
|
15
|
+
*= require 'select2'
|
|
16
|
+
*= require bootstrap/dist/css/bootstrap
|
|
17
|
+
*= require bootstrap-datepicker/dist/css/bootstrap-datepicker3
|
|
18
|
+
*= require daterangepicker
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
$fa-font-path: '@fortawesome/fontawesome-free/webfonts';
|
|
22
|
+
@import '@fortawesome/fontawesome-free/scss/fontawesome';
|
|
23
|
+
@import '@fortawesome/fontawesome-free/scss/solid';
|
|
24
|
+
@import '@fortawesome/fontawesome-free/scss/regular';
|
|
25
|
+
@import '@fortawesome/fontawesome-free/scss/brands';
|
|
26
|
+
@import '@fortawesome/fontawesome-free/scss/v4-shims';
|
|
@@ -7,9 +7,13 @@
|
|
|
7
7
|
require("@rails/ujs").start()
|
|
8
8
|
require("turbolinks").start()
|
|
9
9
|
require("@rails/activestorage").start()
|
|
10
|
-
require(
|
|
10
|
+
require("spotlight_search")
|
|
11
|
+
require("daterangepicker")
|
|
11
12
|
|
|
12
13
|
import jQuery from 'jquery';
|
|
13
14
|
window.$ = jQuery
|
|
14
15
|
window.jQuery = jQuery
|
|
15
16
|
import 'select2';
|
|
17
|
+
import 'bootstrap/dist/js/bootstrap'
|
|
18
|
+
import 'bootstrap-datepicker/dist/js/bootstrap-datepicker.js';
|
|
19
|
+
import '../application/coffee_scripts/scaffolds.coffee';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class Admin::<%= model.titleize %>Controller < ApplicationController
|
|
1
|
+
class Admin::<%= model.titleize.gsub(' ', '') %>Controller < ApplicationController
|
|
2
2
|
before_action :set_<%= model.singularize %>, only: [:show, :edit, :update, :destroy]
|
|
3
3
|
|
|
4
4
|
# GET /<%= model %>
|
|
@@ -22,7 +22,7 @@ class Admin::<%= model.titleize %>Controller < ApplicationController
|
|
|
22
22
|
|
|
23
23
|
# GET /<%= model %>/new
|
|
24
24
|
def new
|
|
25
|
-
@<%= model.singularize %> =
|
|
25
|
+
@<%= model.singularize %> = <%= model.singularize.titleize.gsub(' ', '') %>.new
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
# GET /<%= model %>/1/edit
|
|
@@ -32,11 +32,11 @@ class Admin::<%= model.titleize %>Controller < ApplicationController
|
|
|
32
32
|
# POST /<%= model %>
|
|
33
33
|
# POST /<%= model %>.json
|
|
34
34
|
def create
|
|
35
|
-
@<%= model.singularize %> =
|
|
35
|
+
@<%= model.singularize %> = <%= model.singularize.titleize.gsub(' ', '') %>.new(<%= model.singularize %>_params)
|
|
36
36
|
|
|
37
37
|
respond_to do |format|
|
|
38
38
|
if @<%= model.singularize %>.save
|
|
39
|
-
format.html { redirect_to @<%= model.singularize
|
|
39
|
+
format.html { redirect_to admin_<%= model.singularize %>_path(@<%= model.singularize %>), notice: '<%= model.singularize.titleize.gsub(' ', '') %> was successfully created.' }
|
|
40
40
|
format.json { render :show, status: :created, location: @<%= model.singularize %> }
|
|
41
41
|
else
|
|
42
42
|
format.html { render :new }
|
|
@@ -50,7 +50,7 @@ class Admin::<%= model.titleize %>Controller < ApplicationController
|
|
|
50
50
|
def update
|
|
51
51
|
respond_to do |format|
|
|
52
52
|
if @<%= model.singularize %>.update(<%= model.singularize %>_params)
|
|
53
|
-
format.html { redirect_to @<%= model.singularize
|
|
53
|
+
format.html { redirect_to admin_<%= model.singularize %>_path(@<%= model.singularize %>), notice: '<%= model.singularize.titleize.gsub(' ', '') %> was successfully updated.' }
|
|
54
54
|
format.json { render :show, status: :ok, location: @<%= model.singularize %> }
|
|
55
55
|
else
|
|
56
56
|
format.html { render :edit }
|
|
@@ -64,7 +64,7 @@ class Admin::<%= model.titleize %>Controller < ApplicationController
|
|
|
64
64
|
def destroy
|
|
65
65
|
@<%= model.singularize %>.destroy
|
|
66
66
|
respond_to do |format|
|
|
67
|
-
format.html { redirect_to <%= model
|
|
67
|
+
format.html { redirect_to admin_<%= model %>_path, notice: '<%= model.singularize.titleize.gsub(' ', '') %> was successfully destroyed.' }
|
|
68
68
|
format.json { head :no_content }
|
|
69
69
|
end
|
|
70
70
|
end
|
|
@@ -73,7 +73,7 @@ class Admin::<%= model.titleize %>Controller < ApplicationController
|
|
|
73
73
|
|
|
74
74
|
# Use callbacks to share common setup or constraints between actions.
|
|
75
75
|
def set_<%= model.singularize %>
|
|
76
|
-
@<%= model.singularize %> =
|
|
76
|
+
@<%= model.singularize %> = <%= model.singularize.titleize.gsub(' ', '') %>.find(params[:id])
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
# Only allow a list of trusted parameters through.
|
|
@@ -83,7 +83,7 @@ class Admin::<%= model.titleize %>Controller < ApplicationController
|
|
|
83
83
|
|
|
84
84
|
def filter_params
|
|
85
85
|
params.require(:filters).permit(<%= @options.filters.map{ |f| ':' + f.split(':')[0] }.join(', ') %>) if params[:filters]
|
|
86
|
-
|
|
86
|
+
end
|
|
87
87
|
|
|
88
88
|
def sort_params
|
|
89
89
|
params.require(:sort).permit(:sort_column, :sort_direction) if params[:sort]
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
<%-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<%- end -%>
|
|
12
|
-
= clear_filters(admin_<%= model %>_path, nil, nil, "Clear all")
|
|
1
|
+
.filter-section
|
|
2
|
+
.filter-section__lhs
|
|
3
|
+
= filter_wrapper({filter_url: '/admin/<%= model %>', replacement_class: "<%= model %>-table"})
|
|
4
|
+
<%- @options.filters.each do |filter| -%>
|
|
5
|
+
<%- filter_arr = filter.split(':') -%>
|
|
6
|
+
= cm_filter_tag("<%= filter_arr[1] %>", "<%= filter_arr[0] %>", "", 'field-area', "<%= filter_arr[0].titleize %>")
|
|
7
|
+
<%- end -%>
|
|
8
|
+
= clear_filters(admin_<%= model %>_path, nil, nil, "Clear all")
|
|
9
|
+
.filter-section__rhs
|
|
10
|
+
= link_to 'Add', <%= "new_admin_" + model.singularize + "_path" %>, class: 'filter-btn'
|
|
@@ -12,9 +12,9 @@ module SpotlightSearch
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def exportable(email, klass, html_class: [])
|
|
15
|
-
tag.
|
|
16
|
-
concat tag.
|
|
17
|
-
concat
|
|
15
|
+
tag.a "Export as excel", class: html_class.append("filter-btn modal-btn mr-2"), data: {toggle: "modal", target: "#exportmodal"} do
|
|
16
|
+
concat tag.i class: 'fa fa-download'
|
|
17
|
+
concat tag.span " Excel"
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -57,7 +57,8 @@ module SpotlightSearch
|
|
|
57
57
|
when :v2
|
|
58
58
|
concat checkbox_row_v2(klass)
|
|
59
59
|
end
|
|
60
|
-
concat
|
|
60
|
+
concat tag.hr
|
|
61
|
+
concat submit_tag 'Export as excel', class: 'btn btn-primary btn-bordered export-to-file-btn'
|
|
61
62
|
end
|
|
62
63
|
end
|
|
63
64
|
end
|
|
@@ -89,16 +90,32 @@ module SpotlightSearch
|
|
|
89
90
|
end
|
|
90
91
|
end
|
|
91
92
|
|
|
92
|
-
def
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
93
|
+
def cm_filter_tag(input_type, scope_name, value, classes = nil, placeholder = nil)
|
|
94
|
+
case input_type
|
|
95
|
+
when 'input'
|
|
96
|
+
tag.div class: 'filter-field' do
|
|
97
|
+
concat text_field_tag scope_name, '', class: "#{classes}", data: {behaviour: "filter", scope: scope_name, type: "input-filter"}, placeholder: "#{placeholder}"
|
|
98
|
+
concat tag.span class: 'fa fa-search search-icon'
|
|
99
|
+
end
|
|
100
|
+
when 'single-select'
|
|
101
|
+
tag.div class: 'filter-field' do
|
|
102
|
+
select_tag scope_name, options_for_select(value), class: "#{classes} select2-single", data: {behaviour: "filter", scope: scope_name, type: "select-filter"}, include_blank: "#{placeholder}"
|
|
103
|
+
end
|
|
104
|
+
when 'multi-select'
|
|
105
|
+
tag.div class: 'filter-field' do
|
|
106
|
+
select_tag scope_name, options_for_select(value), class: "#{classes} select2-single", data: {behaviour: "filter", scope: scope_name, type: "select-filter"}, include_blank: "#{placeholder}", multiple: true
|
|
107
|
+
end
|
|
108
|
+
when 'datetime'
|
|
109
|
+
tag.div class: 'filter-field' do
|
|
110
|
+
concat text_field_tag scope_name, '', class: "#{classes}", data: {behaviour: "filter", scope: scope_name, type: "input-filter", provide: "datepicker"}, placeholder: "#{placeholder}"
|
|
111
|
+
concat tag.span class: 'fa fa-search search-icon'
|
|
112
|
+
end
|
|
113
|
+
when 'daterange'
|
|
114
|
+
tag.div class: 'filter-field' do
|
|
115
|
+
concat text_field_tag scope_name, '', class: "#{classes} filter-rangepicker", data: {behaviour: "filter", scope: scope_name, type: "input-filter"}, placeholder: "#{placeholder}"
|
|
116
|
+
concat tag.span class: 'fa fa-search search-icon'
|
|
117
|
+
end
|
|
118
|
+
end
|
|
102
119
|
end
|
|
103
120
|
|
|
104
121
|
def clear_filters(clear_path, classes=nil, data_behaviours=nil, clear_text=nil)
|
|
@@ -116,30 +133,30 @@ module SpotlightSearch
|
|
|
116
133
|
def create_checkbox_v2(column_path)
|
|
117
134
|
tag.div class: "col-md-4" do
|
|
118
135
|
concat check_box_tag "columns[]", column_path, id: column_path.to_s.gsub('/', '-')
|
|
119
|
-
concat column_path.to_s.gsub('/', '_').humanize
|
|
136
|
+
concat " " + column_path.to_s.gsub('/', '_').humanize
|
|
120
137
|
end
|
|
121
138
|
end
|
|
122
139
|
|
|
123
140
|
def cm_paginate(facets)
|
|
124
|
-
tag.div class: '
|
|
141
|
+
tag.div class: 'cm-pagination' do
|
|
125
142
|
tag.div class: 'nav navbar navbar-inner' do
|
|
126
143
|
tag.ul class: 'pagination' do
|
|
127
144
|
if facets.previous_page != false
|
|
128
145
|
previous_page = tag.li do
|
|
129
|
-
tag.button class: '
|
|
146
|
+
tag.button class: 'cm-pagination__item', data: { behaviour: 'previous-page'} do
|
|
130
147
|
tag.span "Previous"
|
|
131
148
|
end
|
|
132
149
|
end
|
|
133
150
|
end
|
|
134
151
|
current_page = content_tag :li do
|
|
135
|
-
tag.
|
|
152
|
+
tag.button class: 'cm-pagination__item', data: {sort_column: facets.sort[:sort_column], sort_direction: facets.sort[:sort_direction], page: facets.current_page, behaviour: 'current-page' } do
|
|
136
153
|
"Showing #{facets.current_page} of #{facets.total_pages} pages"
|
|
137
154
|
end
|
|
138
155
|
end
|
|
139
156
|
|
|
140
157
|
if facets.next_page != false
|
|
141
158
|
next_page = tag.li do
|
|
142
|
-
tag.button class: '
|
|
159
|
+
tag.button class: 'cm-pagination__item', data: { behaviour: 'next-page'} do
|
|
143
160
|
tag.span "Next"
|
|
144
161
|
end
|
|
145
162
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spotlight_search
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Anbazhagan Palani
|
|
@@ -108,6 +108,7 @@ files:
|
|
|
108
108
|
- config/routes.rb
|
|
109
109
|
- lib/generators/spotlight_search/filter_generator.rb
|
|
110
110
|
- lib/generators/spotlight_search/install_generator.rb
|
|
111
|
+
- lib/generators/spotlight_search/templates/application.css.scss
|
|
111
112
|
- lib/generators/spotlight_search/templates/application.js
|
|
112
113
|
- lib/generators/spotlight_search/templates/coffee.js
|
|
113
114
|
- lib/generators/spotlight_search/templates/controller.rb.erb
|