look_for 1.0.1
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/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +142 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/look_for/index.js +1 -0
- data/app/assets/javascripts/look_for/look_for.js +50 -0
- data/app/assets/stylesheets/look_for/index.css +13 -0
- data/app/assets/stylesheets/look_for/look_for-tableless.css +48 -0
- data/app/controllers/look_for_controller.rb +228 -0
- data/app/views/look_for/_header.html.erb +61 -0
- data/app/views/look_for/_look_for.html.erb +51 -0
- data/app/views/look_for/_pagination.html.erb +3 -0
- data/app/views/look_for/_results.html.erb +48 -0
- data/app/views/look_for/_toolbar.html.erb +5 -0
- data/app/views/look_for/assign_and_close.js.erb +16 -0
- data/app/views/look_for/assign_first.js.erb +12 -0
- data/app/views/look_for/clear.js.erb +6 -0
- data/app/views/look_for/look_for.js.erb +119 -0
- data/config/routes.rb +4 -0
- data/lib/look_for/engine.rb +7 -0
- data/lib/look_for/helpers/look_for_helper.rb +19 -0
- data/lib/look_for/version.rb +3 -0
- data/lib/look_for.rb +7 -0
- data/look_for.gemspec +21 -0
- metadata +92 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: c43d40ad20f8c03594704126e9280dd9df5d9fe8b70d4009e2b3c9daf2a8c7ca
|
|
4
|
+
data.tar.gz: 6a502b18527084da6e4f2f13eed2383b39ec02f8259b18bfa64aef655d4ad1ba
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: dafbb1c6e24495e07591e23b37cc5ca1aa8b5ab0bd524a87e5338add3e6a1030e22219130ddc26499b072da04a62332a903100e47dec31460c5c62156287c814
|
|
7
|
+
data.tar.gz: 1eb464289af6de9b643e8c7466472242119bc6c61bed5cc87e3faad311b2b253fc97170c66aa2696284a77fce55e4a4a7f2eaf0ad508df2df898094c6ba482f2
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2012 Gianni Rossi
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# LookFor
|
|
2
|
+
|
|
3
|
+
Simple ajax search form.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'look_for'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install look_for
|
|
18
|
+
|
|
19
|
+
## Assets
|
|
20
|
+
|
|
21
|
+
In application.js add
|
|
22
|
+
|
|
23
|
+
//= require look_for
|
|
24
|
+
|
|
25
|
+
In application.css add
|
|
26
|
+
|
|
27
|
+
*= require look_for
|
|
28
|
+
|
|
29
|
+
You can use the Themeroller (http://jqueryui.com/themeroller/) to define and download an appropriate css file and the pictures needed.
|
|
30
|
+
Add the downloaded Themeroller css file to the css assets and add the Themeroller images to the image assets.
|
|
31
|
+
|
|
32
|
+
#### Adding a touch of style to LookFor element
|
|
33
|
+
|
|
34
|
+
Example, in your application css add:
|
|
35
|
+
|
|
36
|
+
#look_for-toolbar {
|
|
37
|
+
margin-bottom: 0.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#look_for-header .cell {
|
|
41
|
+
font-family: Lucida Grande, Lucida Sans, Arial, sans-serif;
|
|
42
|
+
font-size: 1.1em;
|
|
43
|
+
font-weight: bold;
|
|
44
|
+
text-align: center;
|
|
45
|
+
color: #ffffff;
|
|
46
|
+
background-color: #5c9ccc;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
#look_for-filter .cell {
|
|
50
|
+
padding: 0.1em;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#look_for-results a {
|
|
54
|
+
font-family: Lucida Grande, Lucida Sans, Arial, sans-serif;
|
|
55
|
+
font-size: 1em;
|
|
56
|
+
color: inherit;
|
|
57
|
+
background-color: inherit;
|
|
58
|
+
display: block;
|
|
59
|
+
text-decoration: none;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#look_for-results .row:hover {
|
|
63
|
+
color: #fff;
|
|
64
|
+
background-color: #ff8000;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
#look_for-results .even {
|
|
68
|
+
color: #5c9ccc;
|
|
69
|
+
background-color: #dff;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#look_for-results .odd {
|
|
73
|
+
color: #5c9ccc;
|
|
74
|
+
background-color: #ffd;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
#look_for-pagination .page_info {
|
|
78
|
+
margin-top: 0.5em;
|
|
79
|
+
color: #5c9ccc;
|
|
80
|
+
text-align: left;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#look_for-pagination .page_info b {
|
|
84
|
+
color: #6aa6ed;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
## Usage
|
|
88
|
+
|
|
89
|
+
Looking For Helper
|
|
90
|
+
|
|
91
|
+
Creates a link tag to open LookFor search form with the given options.
|
|
92
|
+
|
|
93
|
+
##### Signatures
|
|
94
|
+
|
|
95
|
+
look_for(object_name, method_names, link_body, options = {}, html_options = {})
|
|
96
|
+
|
|
97
|
+
* object_name - A model name, for example 'Item' or a collection in a one-to-many association (for example 'user.items' if user has many items).
|
|
98
|
+
* method_names - An array of method names for build the results columns (for example [:id, :code, :description] if id, code, description are attributues of object_name)
|
|
99
|
+
* link_body - The link body
|
|
100
|
+
|
|
101
|
+
###### options
|
|
102
|
+
|
|
103
|
+
* :fill - Fill html input with value from database ( db_field => input_tag_id ) when a row is selected.
|
|
104
|
+
* :width - Width of dialog, optional, default 500px.
|
|
105
|
+
* :height - Height of dialog, optional, default 300px.
|
|
106
|
+
|
|
107
|
+
###### html_options
|
|
108
|
+
|
|
109
|
+
Like html_options in link_to helper but :remote will be always true.
|
|
110
|
+
|
|
111
|
+
##### Examples
|
|
112
|
+
|
|
113
|
+
In your application generate a scaffold for the Item resource :
|
|
114
|
+
|
|
115
|
+
rails generate scaffold Item code:string description:string
|
|
116
|
+
rake db:migrate
|
|
117
|
+
|
|
118
|
+
In a view put this code:
|
|
119
|
+
|
|
120
|
+
<%= text_field_tag :item_id , '', :name => "look_for_filter[id]" , :class => :look_for, :look_for_id => 'look_for_items' %>
|
|
121
|
+
<%= look_for 'Item',
|
|
122
|
+
[:id,:code,:description],
|
|
123
|
+
'Search',
|
|
124
|
+
{ :fill => {:id => :item_id,
|
|
125
|
+
:code => :item_code,
|
|
126
|
+
:description => :item_description},
|
|
127
|
+
:width => 550,
|
|
128
|
+
:height => 360},
|
|
129
|
+
:id => 'look_for_items' %>
|
|
130
|
+
<%= text_field_tag :item_code , "", :name => "look_for_filter[code]" , :class => :look_for, :look_for_id => 'look_for_items' %>
|
|
131
|
+
<%= text_field_tag :item_description, "", :name => "look_for_filter[description]", :class => :look_for, :look_for_id => 'look_for_items' %>
|
|
132
|
+
|
|
133
|
+
Start web server and try it!
|
|
134
|
+
|
|
135
|
+
## TODO:
|
|
136
|
+
|
|
137
|
+
* Add column sorting
|
|
138
|
+
* More options for each column, for example width, min_width, max_width.
|
|
139
|
+
* Drill-down rows
|
|
140
|
+
* Inline editing
|
|
141
|
+
* ....
|
|
142
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//= require_tree .
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var last_id, last_value, t;
|
|
2
|
+
|
|
3
|
+
$(document).on('change', 'input.look_for', function() {
|
|
4
|
+
var href_new, href_old, look_for_id, name, val;
|
|
5
|
+
name = $(this).attr('name');
|
|
6
|
+
val = $(this).val();
|
|
7
|
+
if ($(this).attr('look_for_id') !== void 0) {
|
|
8
|
+
look_for_id = '#' + $(this).attr('look_for_id');
|
|
9
|
+
href_old = $(look_for_id).attr('href');
|
|
10
|
+
|
|
11
|
+
if (val !== '') {
|
|
12
|
+
href_new = href_old + '&' + name + '=' + encodeURI(val) + '&validate=true';
|
|
13
|
+
} else {
|
|
14
|
+
href_new = href_old + '&' + name + '=' + encodeURI(val) + '&clear=true';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
$(look_for_id).attr('href', href_new);
|
|
18
|
+
$(look_for_id)[0].click();
|
|
19
|
+
return $(look_for_id).attr('href', href_old);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
t = null;
|
|
24
|
+
last_id = null;
|
|
25
|
+
last_value = null;
|
|
26
|
+
|
|
27
|
+
$(document).on('keyup', 'input.look_for_filter', function(e) {
|
|
28
|
+
if (last_id === $(this).id && last_value === $(this).val()) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
last_id = $(this).id;
|
|
32
|
+
last_value = $(this).val();
|
|
33
|
+
if (e.keyCode === 13) {
|
|
34
|
+
$('#' + $(this).closest("form").attr('id').replace('_form', '_find')).click();
|
|
35
|
+
} else {
|
|
36
|
+
if (t !== null) {
|
|
37
|
+
clearTimeout(t);
|
|
38
|
+
}
|
|
39
|
+
return t = setTimeout("$('#" + $(this).closest('form').attr('id').replace('_form', '_page') + "').val('1');" + "$('#" + $(this).closest('form').attr('id').replace('_form', '_find') + "').click();", 500);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
$(document).on('click', '.look_for_sort_buttons', function(e) {
|
|
44
|
+
var href_new, href_old, order_by;
|
|
45
|
+
order_by = $(this).data('sortstring');
|
|
46
|
+
$('#' + $(this).closest("form").attr('id').replace('_form', '_page')).val('1');
|
|
47
|
+
href_old = $(this).closest('form').attr('action');
|
|
48
|
+
href_new = href_old + '&order=' + encodeURI(order_by);
|
|
49
|
+
$(this).closest("form").attr('action', href_new);
|
|
50
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
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, vendor/assets/stylesheets,
|
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, 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 top of the
|
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
|
10
|
+
*
|
|
11
|
+
*= require_self
|
|
12
|
+
*= require_tree .
|
|
13
|
+
*/
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
.look_for_window {
|
|
2
|
+
text-align: center;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.look_for_table {
|
|
6
|
+
display: inline-block;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.look_for_header {
|
|
10
|
+
display: table-row;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.look_for_header .look_for_cell {
|
|
14
|
+
display: table-cell;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.look_for_filters {
|
|
18
|
+
display: table-row;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.look_for_filters .look_for_cell {
|
|
22
|
+
display: table-cell;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
input.look_for_filter {
|
|
26
|
+
background: #eeeeee;
|
|
27
|
+
border: 2px solid #bbbbbb;
|
|
28
|
+
width: 100%;
|
|
29
|
+
box-sizing: border-box;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.look_for_body {
|
|
33
|
+
background: #eeeeee;
|
|
34
|
+
display: table-row-group;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.look_for_row {
|
|
38
|
+
display: table-row;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.look_for_row .look_for_cell {
|
|
42
|
+
display: table-cell;
|
|
43
|
+
text-align: left;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.ui-dialog {
|
|
47
|
+
background: #fafafa;
|
|
48
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
class LookForController < ApplicationController
|
|
2
|
+
def search
|
|
3
|
+
|
|
4
|
+
# logger.fatal '------------------------------------------------------'
|
|
5
|
+
# logger.fatal 'params = '+params.inspect
|
|
6
|
+
# logger.fatal '------------------------------------------------------'
|
|
7
|
+
|
|
8
|
+
get_table_aliasing params[:include], params[:object_name]
|
|
9
|
+
|
|
10
|
+
if eval("current_user.service.respond_to? '#{params[:object_name].downcase.pluralize}'") && (!params[:all_services] || params[:all_services] != 'true') && (!params[:all_companies] || params[:all_companies] != 'true')
|
|
11
|
+
object_eval = eval("current_user.service.#{params[:object_name].downcase.pluralize}")
|
|
12
|
+
elsif params[:all_companies] && params[:all_companies] == 'true'
|
|
13
|
+
object_eval = eval("#{params[:object_name].classify}.all")
|
|
14
|
+
else
|
|
15
|
+
object_eval = eval("current_user.company.#{params[:object_name].downcase.pluralize}")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
if params[:include]
|
|
19
|
+
params[:include].each do |incl|
|
|
20
|
+
#logger.fatal '------------------------------------------------------'
|
|
21
|
+
#logger.fatal 'incl = ' + incl.to_s
|
|
22
|
+
#logger.fatal 'incl re-writed = ' + rewrite_hash(incl).inspect
|
|
23
|
+
#logger.fatal '------------------------------------------------------'
|
|
24
|
+
rewr_incl = rewrite_hash(incl)
|
|
25
|
+
object_eval = object_eval.includes(rewr_incl).references(rewr_incl)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
params[:base_id] ||= "look_for_#{params[:object_name].downcase.pluralize}"
|
|
30
|
+
|
|
31
|
+
if params[:look_for_filter]
|
|
32
|
+
params[:look_for_filter].each do |key, value|
|
|
33
|
+
|
|
34
|
+
#logger.fatal '------------------------------------------------------'
|
|
35
|
+
#logger.fatal 'esamino i filtri'
|
|
36
|
+
#logger.fatal 'key = '+key.inspect
|
|
37
|
+
#logger.fatal 'value = '+value.inspect
|
|
38
|
+
#logger.fatal '------------------------------------------------------'
|
|
39
|
+
|
|
40
|
+
if value!=""
|
|
41
|
+
#logger.fatal 'key spezzata e ricomposta = ' + key.split('.')[0...-1].join('.')
|
|
42
|
+
if @table_aliasing[key.split('.')[0...-1].join('.')]
|
|
43
|
+
#logger.fatal 'caso 1'
|
|
44
|
+
table_alias = @table_aliasing[key.split('.')[0...-1].join('.')]
|
|
45
|
+
field = key.split('.').pop
|
|
46
|
+
else
|
|
47
|
+
#logger.fatal 'caso 2'
|
|
48
|
+
table_alias_and_field = key
|
|
49
|
+
table_alias_and_field = "#{params[:object_name].underscore}.#{key}" if key.split('.').length == 1
|
|
50
|
+
ar = table_alias_and_field.split('.')
|
|
51
|
+
table_alias = ar[ar.length-2]
|
|
52
|
+
field = ar[ar.length-1]
|
|
53
|
+
table_alias = table_alias.pluralize
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
translated_column = multilanguage(params[:object_name],field)
|
|
57
|
+
|
|
58
|
+
table_alias_and_field = "#{table_alias}.#{translated_column}"
|
|
59
|
+
|
|
60
|
+
#logger.fatal 'table_alias_and_field = ' + table_alias_and_field.inspect
|
|
61
|
+
|
|
62
|
+
if params[:no_case] && params[:no_case].include?(key)
|
|
63
|
+
|
|
64
|
+
#logger.fatal '------------------------------------------------------'
|
|
65
|
+
#logger.fatal 'no_case include la key'
|
|
66
|
+
#logger.fatal 'no_case = '+params[:no_case].inspect
|
|
67
|
+
#logger.fatal 'key = '+key.inspect
|
|
68
|
+
#logger.fatal 'value = '+value.inspect
|
|
69
|
+
#logger.fatal '------------------------------------------------------'
|
|
70
|
+
|
|
71
|
+
#logger.fatal 'aggiungo referenza a ' + table_alias
|
|
72
|
+
object_eval = object_eval.where("upper(#{table_alias_and_field}) like ? ",value.upcase+"%").references(table_alias)
|
|
73
|
+
elsif params[:use_upper] && params[:use_upper].include?(key)
|
|
74
|
+
|
|
75
|
+
#logger.fatal '------------------------------------------------------'
|
|
76
|
+
#logger.fatal 'use_upper include la key'
|
|
77
|
+
#logger.fatal 'use_upper = '+params[:use_upper].inspect
|
|
78
|
+
#logger.fatal 'key = '+key.inspect
|
|
79
|
+
#logger.fatal 'value = '+value.inspect
|
|
80
|
+
#logger.fatal '------------------------------------------------------'
|
|
81
|
+
|
|
82
|
+
#logger.fatal 'aggiungo referenza a ' + table_alias
|
|
83
|
+
object_eval = object_eval.where("#{table_alias_and_field} like ? ",value.upcase+"%").references(table_alias)
|
|
84
|
+
else
|
|
85
|
+
|
|
86
|
+
#logger.fatal '------------------------------------------------------'
|
|
87
|
+
#logger.fatal 'filtro pulito'
|
|
88
|
+
#logger.fatal 'key = '+key.inspect
|
|
89
|
+
#logger.fatal 'value = '+value.inspect
|
|
90
|
+
#logger.fatal '------------------------------------------------------'
|
|
91
|
+
|
|
92
|
+
#logger.fatal 'aggiungo referenza a ' + table_alias
|
|
93
|
+
object_eval = object_eval.where("#{table_alias_and_field} like ? ",value+"%").references(table_alias)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
if params[:conditions] && params[:conditions].class == Array
|
|
100
|
+
params[:conditions].collect! do |a|
|
|
101
|
+
if a=='true'
|
|
102
|
+
true
|
|
103
|
+
elsif a=='false'
|
|
104
|
+
false
|
|
105
|
+
else
|
|
106
|
+
a
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
object_eval = object_eval.where(params[:conditions]) if params[:conditions]
|
|
112
|
+
object_eval = object_eval.where(params[:with]) if params[:with]
|
|
113
|
+
|
|
114
|
+
@records = object_eval.paginate(:per_page => 20,:page => params["#{params[:base_id]}_page".to_sym]).order(params[:order])
|
|
115
|
+
|
|
116
|
+
template = 'look_for'
|
|
117
|
+
template = 'assign_first' if @records.length == 1 && params[:validate] == 'true'
|
|
118
|
+
template = 'clear' if params[:clear] == 'true'
|
|
119
|
+
|
|
120
|
+
respond_to do |format|
|
|
121
|
+
format.js { render template}
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
private
|
|
126
|
+
|
|
127
|
+
def rewrite_hash(h)
|
|
128
|
+
return h.to_sym if h.is_a?(::String)
|
|
129
|
+
|
|
130
|
+
if (h.to_unsafe_h() rescue h).is_a?(::Hash)
|
|
131
|
+
r = Hash.new
|
|
132
|
+
(h.to_unsafe_h() rescue h).each{|k,v| r[k.to_sym] = rewrite_hash(v)}
|
|
133
|
+
return r
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def read_hash h, parent_model = nil, parent = nil
|
|
138
|
+
|
|
139
|
+
# logger.fatal '------------------------------------------------------'
|
|
140
|
+
# logger.fatal 'entro in read hash con h = ' + h.inspect + ' e parent_model = ' + parent_model.inspect
|
|
141
|
+
# logger.fatal '------------------------------------------------------'
|
|
142
|
+
|
|
143
|
+
parent_model = parent_model.capitalize if parent_model
|
|
144
|
+
|
|
145
|
+
h.each do |key,value|
|
|
146
|
+
|
|
147
|
+
# logger.fatal 'entro nel ciclo con key = ' + key.inspect + ' e value = ' + value.inspect
|
|
148
|
+
|
|
149
|
+
# logger.fatal '- 1 -'
|
|
150
|
+
read_symbol key, parent_model if key.is_a?(Symbol) || key.is_a?(String)
|
|
151
|
+
# logger.fatal '- 2 -'
|
|
152
|
+
read_symbol value, eval(parent_model||@model_name).reflect_on_association(key.to_sym).class_name, key if value.is_a?(Symbol) || value.is_a?(String)
|
|
153
|
+
# logger.fatal '- 3 -'
|
|
154
|
+
read_array value, "#{"#{parent_model}." if parent_model}#{eval(parent_model||@model_name).reflect_on_association(key.to_sym).class_name}", key if value.is_a? Array
|
|
155
|
+
# logger.fatal '- 4 -'
|
|
156
|
+
vv = value.to_unsafe_h() rescue value
|
|
157
|
+
read_hash vv, eval(parent_model||@model_name).reflect_on_association(key.to_sym).class_name , key if vv.is_a? Hash
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def read_array a, parent_model = nil, parent = nil
|
|
162
|
+
|
|
163
|
+
# logger.fatal '------------------------------------------------------'
|
|
164
|
+
# logger.fatal 'entro in read array con a = ' + a.inspect + ' e parent_model = ' + parent_model.inspect + ' e parent = ' + parent.inspect
|
|
165
|
+
# logger.fatal '------------------------------------------------------'
|
|
166
|
+
|
|
167
|
+
a.each do |i|
|
|
168
|
+
puts "#{"#{parent_model}." if parent_model}#{i}" if i.is_a?(Symbol) || i.is_a?(String)
|
|
169
|
+
ii = i.to_unsafe_h() rescue i
|
|
170
|
+
read_hash ii,parent_model if ii.is_a? Hash
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def read_symbol s, parent_model=nil, parent = nil
|
|
175
|
+
|
|
176
|
+
# logger.fatal '------------------------------------------------------'
|
|
177
|
+
# logger.fatal 'entro in read symbol con s = ' + s.inspect + ' e parent_model = ' + parent_model.inspect
|
|
178
|
+
# logger.fatal 'table_referencing = ' + @table_referencing.inspect
|
|
179
|
+
# logger.fatal '@table_aliasiang = ' + @table_aliasing.inspect
|
|
180
|
+
# logger.fatal '------------------------------------------------------'
|
|
181
|
+
|
|
182
|
+
key = "#{"#{parent}." if parent}#{s.to_s}"
|
|
183
|
+
table_alias = eval(parent_model||@model_name).reflect_on_association(s.to_sym).table_name
|
|
184
|
+
# logger.fatal 'table_alias = ' + table_alias.inspect
|
|
185
|
+
@table_referencing[table_alias] = 0 if !@table_referencing[table_alias] && table_alias == @model_name.tableize
|
|
186
|
+
|
|
187
|
+
if @table_referencing[table_alias]
|
|
188
|
+
@table_referencing[table_alias] = @table_referencing[table_alias] + 1
|
|
189
|
+
if @table_referencing[table_alias] > 2
|
|
190
|
+
table_alias = s.to_s.pluralize + "_"+ eval(parent_model||@model_name).table_name + "_" + (@table_referencing[table_alias]-1).to_s
|
|
191
|
+
else
|
|
192
|
+
table_alias = s.to_s.pluralize + "_"+ eval(parent_model||@model_name).table_name
|
|
193
|
+
end
|
|
194
|
+
else
|
|
195
|
+
@table_referencing[table_alias] = 0
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
@table_aliasing[key] = table_alias
|
|
199
|
+
|
|
200
|
+
# logger.fatal '------------------------------------------------------'
|
|
201
|
+
# logger.fatal 'esco da read symbol con table_aliasing = ' + @table_aliasing.inspect + ' e table_referencing = ' + @table_referencing.inspect
|
|
202
|
+
# logger.fatal '------------------------------------------------------'
|
|
203
|
+
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def get_table_aliasing include, model_name
|
|
207
|
+
|
|
208
|
+
# logger.fatal '------------------------------------------------------'
|
|
209
|
+
# logger.fatal 'entro in get_table_aliasing con include = ' + include.inspect + ' e model_name = ' + model_name.inspect
|
|
210
|
+
# logger.fatal '------------------------------------------------------'
|
|
211
|
+
|
|
212
|
+
@model_name = model_name
|
|
213
|
+
@table_referencing = {}
|
|
214
|
+
@table_aliasing = {}
|
|
215
|
+
include||=[]
|
|
216
|
+
include.each do |i|
|
|
217
|
+
ii = i.to_unsafe_h() rescue i
|
|
218
|
+
read_hash ii if ii.is_a? Hash
|
|
219
|
+
read_symbol(i) if i.is_a?(Symbol) || i.is_a?(String)
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# logger.fatal '------------------------------------------------------'
|
|
223
|
+
# logger.fatal 'esco da get_table_aliasing con @table_aliasing = ' + @table_aliasing.inspect
|
|
224
|
+
# logger.fatal '------------------------------------------------------'
|
|
225
|
+
|
|
226
|
+
@table_aliasing
|
|
227
|
+
end
|
|
228
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<% if !params[:labels] %>
|
|
2
|
+
<% params[:method_names].each do |method_name| %>
|
|
3
|
+
<div class="look_for_cell"><%= label(params[:object_name].downcase, method_name) %></div>
|
|
4
|
+
<% end %>
|
|
5
|
+
<% else %>
|
|
6
|
+
<% methods = params[:method_names].reverse %>
|
|
7
|
+
<% params[:labels].each do |label| %>
|
|
8
|
+
|
|
9
|
+
<%
|
|
10
|
+
method = methods.pop.downcase
|
|
11
|
+
show_sort_buttons = true
|
|
12
|
+
|
|
13
|
+
classe = method.split(".").take(method.split(".").size-1).join(".")
|
|
14
|
+
|
|
15
|
+
if @table_aliasing[classe]
|
|
16
|
+
table_alias = @table_aliasing[classe]
|
|
17
|
+
field = method.split(".").pop
|
|
18
|
+
else
|
|
19
|
+
table_alias_and_field = method
|
|
20
|
+
table_alias_and_field = "#{params[:object_name].underscore}.#{method}" if method.split('.').length == 1
|
|
21
|
+
ar = table_alias_and_field.split('.')
|
|
22
|
+
table_alias = ar[ar.length-2]
|
|
23
|
+
field = ar[ar.length-1]
|
|
24
|
+
table_alias = table_alias.pluralize
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
translated_column = multilanguage(params[:object_name],field)
|
|
28
|
+
|
|
29
|
+
order_by = table_alias == 'todostatuses' && translated_column == 'log' ? "dbms_lob.substr(#{table_alias}.#{translated_column},100,1)" : "#{table_alias}.#{translated_column}"
|
|
30
|
+
|
|
31
|
+
old_order = ''
|
|
32
|
+
|
|
33
|
+
if params[:order]
|
|
34
|
+
|
|
35
|
+
old_order = params[:order].to_s
|
|
36
|
+
dot_syntax = old_order.include?(".")
|
|
37
|
+
|
|
38
|
+
if !dot_syntax
|
|
39
|
+
old_order = params[:object_name].tableize + '.' + params[:order]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
old_order = old_order + " asc" if (!old_order.downcase.include?(" asc") && !old_order.downcase.include?(" desc"))
|
|
43
|
+
end
|
|
44
|
+
%>
|
|
45
|
+
|
|
46
|
+
<div class="look_for_cell">
|
|
47
|
+
<div class="look_for_header_cell_content">
|
|
48
|
+
<% if !show_sort_buttons %>
|
|
49
|
+
<%= label %>
|
|
50
|
+
<% else %>
|
|
51
|
+
<div style="overflow: hidden;white-space: nowrap;">
|
|
52
|
+
<%= label %>
|
|
53
|
+
<%= content_tag :button, 'Asc' , {:id => "#{params[:base_id]}_#{label.hash}_asc" , 'data-sortstring' => order_by + ' asc' , :class => [:look_for_sort_buttons , order_by + ' asc' == old_order ? :selected : :unselected]} %>
|
|
54
|
+
<%= content_tag :button, 'Desc' , {:id => "#{params[:base_id]}_#{label.hash}_desc" , 'data-sortstring' => order_by + ' desc' , :class => [:look_for_sort_buttons , order_by + ' desc' == old_order ? :selected : :unselected]} %>
|
|
55
|
+
</div>
|
|
56
|
+
<% end %>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<% end %>
|
|
61
|
+
<% end %>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<div class="look_for_window">
|
|
2
|
+
|
|
3
|
+
<%
|
|
4
|
+
include_proc = []
|
|
5
|
+
params[:include].each {|a| include_proc << (a.to_unsafe_h() rescue a)} if params[:include]
|
|
6
|
+
%>
|
|
7
|
+
|
|
8
|
+
<%= form_tag({controller: :look_for,
|
|
9
|
+
action: :search,
|
|
10
|
+
object_name: params[:object_name],
|
|
11
|
+
method_names: params[:method_names],
|
|
12
|
+
conditions: params[:conditions],
|
|
13
|
+
no_case: params[:no_case],
|
|
14
|
+
use_upper: params[:use_upper],
|
|
15
|
+
include: include_proc,
|
|
16
|
+
update: params[:update],
|
|
17
|
+
on_row_click: params[:on_row_click],
|
|
18
|
+
effect: params[:effect],
|
|
19
|
+
base_id: params[:base_id],
|
|
20
|
+
order: params[:order],
|
|
21
|
+
labels: params[:labels],
|
|
22
|
+
onsetvalue: params[:onsetvalue],
|
|
23
|
+
with: params[:with],
|
|
24
|
+
all_services: params[:all_services],
|
|
25
|
+
all_companies: params[:all_companies],
|
|
26
|
+
title: params[:title],
|
|
27
|
+
fill: (params[:fill].to_unsafe_h() rescue params[:fill])
|
|
28
|
+
},
|
|
29
|
+
{method: :post, remote: true, id: "#{params[:base_id]}_form" } ) do %>
|
|
30
|
+
|
|
31
|
+
<div id="<%= params[:base_id] %>-toolbar" class="look_for_toolbar ui-corner-all"></div>
|
|
32
|
+
|
|
33
|
+
<div id="<%= params[:base_id] %>-table" class="look_for_table">
|
|
34
|
+
|
|
35
|
+
<div id="<%= params[:base_id] %>-header" class="look_for_header"></div>
|
|
36
|
+
|
|
37
|
+
<div id="<%= params[:base_id] %>-filters" class="look_for_filters">
|
|
38
|
+
<% params[:look_for_filter] ||= {} %>
|
|
39
|
+
<% params[:method_names].each do |method_name| %>
|
|
40
|
+
<div class="look_for_cell">
|
|
41
|
+
<%= text_field_tag "look_for_filter[#{method_name}]" , params[:look_for_filter][method_name]||'', :class => 'look_for_filter' %>
|
|
42
|
+
</div>
|
|
43
|
+
<% end %>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<div id="<%= params[:base_id] %>-results" class="look_for_body"></div>
|
|
47
|
+
<div id="<%= params[:base_id] %>-pagination" class="look_for_pagination"></div>
|
|
48
|
+
|
|
49
|
+
</div>
|
|
50
|
+
<% end %>
|
|
51
|
+
</div>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<% @records.each do |record| %>
|
|
2
|
+
<% assignments = {} %>
|
|
3
|
+
<% if !params[:fill].nil? %>
|
|
4
|
+
<% params[:fill].each do |key, value| %>
|
|
5
|
+
<% translated_key = multilanguage(params[:object_name],key) %>
|
|
6
|
+
<% assignments[value] = eval("record.#{translated_key}") rescue nil %>
|
|
7
|
+
<% end %>
|
|
8
|
+
<% end %>
|
|
9
|
+
|
|
10
|
+
<div class="look_for_row <%= cycle("even", "odd") %>">
|
|
11
|
+
<% if params[:method_names] %>
|
|
12
|
+
<% params[:method_names].each do |method_name| %>
|
|
13
|
+
<div class="look_for_cell">
|
|
14
|
+
|
|
15
|
+
<% field_class = eval("record.#{method_name}.class") rescue nil %>
|
|
16
|
+
<% translated_column = multilanguage(params[:object_name],method_name) %>
|
|
17
|
+
|
|
18
|
+
<% unless assignments.empty? %>
|
|
19
|
+
<%= link_to( (field_class == TrueClass) | (field_class== FalseClass) ?
|
|
20
|
+
check_box_tag(method_name , eval("record."+method_name) , eval("record."+method_name) , :disabled=>true) :
|
|
21
|
+
eval("record."+translated_column)||'',
|
|
22
|
+
{
|
|
23
|
+
:controller => :look_for,
|
|
24
|
+
:action => :assign_and_close,
|
|
25
|
+
:assignments => assignments,
|
|
26
|
+
:onsetvalue => params[:onsetvalue],
|
|
27
|
+
:name => params[:name],
|
|
28
|
+
:base_id => params[:base_id]
|
|
29
|
+
},
|
|
30
|
+
:remote=> true) rescue '' %>
|
|
31
|
+
<% else %>
|
|
32
|
+
<% if params[:on_row_click] %>
|
|
33
|
+
<%= link_to( (field_class == TrueClass) | (field_class== FalseClass) ?
|
|
34
|
+
check_box_tag(method_name , eval("record."+method_name) , eval("record."+method_name) , :disabled=>true) :
|
|
35
|
+
eval("record."+translated_column)||'',
|
|
36
|
+
eval(params[:on_row_click]),
|
|
37
|
+
:remote=> true) rescue '' %>
|
|
38
|
+
<% else %>
|
|
39
|
+
<%= ((field_class == TrueClass) | (field_class== FalseClass) ?
|
|
40
|
+
check_box_tag(method_name , eval("record."+method_name) , eval("record."+method_name) , :disabled=>true) :
|
|
41
|
+
eval("record."+translated_column)||'') rescue '' %>
|
|
42
|
+
<% end %>
|
|
43
|
+
<% end %>
|
|
44
|
+
</div>
|
|
45
|
+
<% end %>
|
|
46
|
+
<% end %>
|
|
47
|
+
</div>
|
|
48
|
+
<% end %>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<%= content_tag :button, 'Previous', :id => "#{params[:base_id]}_prev", :disabled => !(@records.current_page > 1 && @records.current_page - 1) %>
|
|
2
|
+
<%= content_tag :button, 'Search' , :id => "#{params[:base_id]}_find" %>
|
|
3
|
+
<%= content_tag :button, 'Next' , :id => "#{params[:base_id]}_next", :disabled => !(@records.current_page < @records.total_pages && @records.current_page + 1) %>
|
|
4
|
+
|
|
5
|
+
<%= hidden_field_tag "#{params[:base_id]}_page", @records.current_page %>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<% params[:name] ||= "#{params[:base_id]}_window" %>
|
|
2
|
+
var window_id = "<%= params[:name] %>";
|
|
3
|
+
|
|
4
|
+
<% params[:assignments].to_unsafe_h().each do |key, value| %>
|
|
5
|
+
$("#<%= key %>").val("<%= value.html_safe() %>");
|
|
6
|
+
<% end %>
|
|
7
|
+
|
|
8
|
+
<% if params[:assignments].to_unsafe_h().size > 0 %>
|
|
9
|
+
$("#recordischanged").val('true');
|
|
10
|
+
<% end %>
|
|
11
|
+
|
|
12
|
+
<% if params[:onsetvalue] && params[:onsetvalue] != '' %>
|
|
13
|
+
<%= params[:onsetvalue].html_safe %>
|
|
14
|
+
<% end %>
|
|
15
|
+
|
|
16
|
+
$("#"+window_id).dialog('close');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<% if !params[:fill].nil? %>
|
|
2
|
+
<% params[:fill].each do |key, value| %>
|
|
3
|
+
<% v = eval("@records.first.#{key}") %>
|
|
4
|
+
$("#<%= value %>").val("<%= v.to_s.html_safe() %>");
|
|
5
|
+
<% end %>
|
|
6
|
+
<% end %>
|
|
7
|
+
|
|
8
|
+
<% if params[:onsetvalue] && params[:onsetvalue] != '' %>
|
|
9
|
+
<%= params[:onsetvalue].html_safe %>
|
|
10
|
+
<% end %>
|
|
11
|
+
|
|
12
|
+
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<% params[:name] ||= "#{params[:base_id]}_window" %>
|
|
2
|
+
var window_id = "<%= params[:name] %>";
|
|
3
|
+
|
|
4
|
+
<% if params[:validate] == 'true' %>
|
|
5
|
+
<% if !params[:fill].nil? %>
|
|
6
|
+
<% params[:fill].each do |key, value| %>
|
|
7
|
+
$("#<%= value %>").val("");
|
|
8
|
+
<% end %>
|
|
9
|
+
<% end %>
|
|
10
|
+
<% end %>
|
|
11
|
+
|
|
12
|
+
<% unless params[:update] %>
|
|
13
|
+
if ($("#"+window_id).length == 0)
|
|
14
|
+
{
|
|
15
|
+
<%
|
|
16
|
+
# calcolo dimensione finestra
|
|
17
|
+
|
|
18
|
+
@sum = {}
|
|
19
|
+
@meanvalue = {}
|
|
20
|
+
@not_null = {}
|
|
21
|
+
|
|
22
|
+
params[:method_names].each do |method_name|
|
|
23
|
+
@sum[method_name] = 0
|
|
24
|
+
@not_null[method_name] = 0
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
@records.each do |record|
|
|
28
|
+
|
|
29
|
+
params[:method_names].each do |method_name|
|
|
30
|
+
field_class = eval("record.#{method_name}.class") rescue nil
|
|
31
|
+
translated_column = multilanguage(params[:object_name],method_name)
|
|
32
|
+
|
|
33
|
+
if (field_class == TrueClass) || (field_class == FalseClass)
|
|
34
|
+
@sum[method_name] = 1
|
|
35
|
+
@not_null[method_name] += 1
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
if !((field_class == TrueClass) || (field_class == FalseClass))
|
|
39
|
+
@sum[method_name] += (eval("record."+translated_column+".size") rescue 0)
|
|
40
|
+
@not_null[method_name] += 1
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
params[:method_names].each do |method_name|
|
|
47
|
+
@meanvalue[method_name] = @sum[method_name].to_f / @not_null[method_name] if @sum[method_name] > 0 && @not_null[method_name] > 0
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
@total = @meanvalue.each_value.sum
|
|
51
|
+
|
|
52
|
+
# logger.fatal '----------------------------------------------------'
|
|
53
|
+
# logger.fatal '@records.size = ' + @records.size.inspect
|
|
54
|
+
# logger.fatal '@not_null = ' + @not_null.inspect
|
|
55
|
+
# logger.fatal '@meanvalue = ' + @meanvalue.inspect
|
|
56
|
+
# logger.fatal '@total =' + @total.inspect
|
|
57
|
+
# logger.fatal '----------------------------------------------------'
|
|
58
|
+
%>
|
|
59
|
+
|
|
60
|
+
var p_width = <%= [[@total.round * 11 , (params[:method_names].size * 145)+100].max , 800].min %>;
|
|
61
|
+
var p_height = <%= @records.size * 12 + 200 %>;
|
|
62
|
+
|
|
63
|
+
$("<div id='"+window_id+"'></div>").dialog({autoOpen: true,title: '<%= params[:title] ? params[:title].capitalize : t(params[:object_name].to_s.downcase).capitalize %>',height: p_height,width: p_width,modal: true, show: "fade", hide: "fade", close: function(ev, ui) {$(this).remove();}});
|
|
64
|
+
$("#"+window_id).html("<%= escape_javascript(render('look_for')) %>");
|
|
65
|
+
<% if params[:effect] %>
|
|
66
|
+
$("#"+window_id).effect('<%= params[:effect] %>');
|
|
67
|
+
<% end %>
|
|
68
|
+
}
|
|
69
|
+
$("#"+window_id).dialog('open');
|
|
70
|
+
<% else %>
|
|
71
|
+
if ($("#<%= params[:update] %> div.look_for").length == 0)
|
|
72
|
+
{
|
|
73
|
+
$("#<%= params[:update] %>").html("<%= escape_javascript(render('look_for')) %>");
|
|
74
|
+
|
|
75
|
+
<% if params[:effect] %>
|
|
76
|
+
$("#<%= params[:update] %>").effect('<%= params[:effect] %>');
|
|
77
|
+
<% end %>
|
|
78
|
+
}
|
|
79
|
+
<% end %>
|
|
80
|
+
|
|
81
|
+
$("#<%= params[:base_id] %>-toolbar").html("<%= escape_javascript(render('toolbar')) %>");
|
|
82
|
+
$("#<%= params[:base_id] %>-header").html("<%= escape_javascript(render('header')) %>");
|
|
83
|
+
$("#<%= params[:base_id] %>-results").html("<%= escape_javascript(render('results')) %>");
|
|
84
|
+
$("#<%= params[:base_id] %>-pagination").html("<%= escape_javascript(render('pagination')) %>");
|
|
85
|
+
|
|
86
|
+
$("#<%= params[:base_id] %>_prev").button({text: false, icons: { primary: "ui-icon-seek-prev"}}).css('padding-top','4px').css('padding-bottom','4px');
|
|
87
|
+
$("#<%= params[:base_id] %>_next").button({text: false, icons: { primary: "ui-icon-seek-next"}}).css('padding-top','4px').css('padding-bottom','4px');
|
|
88
|
+
$("#<%= params[:base_id] %>_find").button({text: false, icons: { primary: "ui-icon-search"}}).css('padding-top','4px').css('padding-bottom','4px');
|
|
89
|
+
|
|
90
|
+
<% if params[:labels] %>
|
|
91
|
+
<% params[:labels].each do |lab| %>
|
|
92
|
+
$("#<%= params[:base_id] %>_<%= lab.hash %>_asc").hasClass('selected') ? $("#<%= params[:base_id] %>_<%= lab.hash %>_asc").button({text: false, icons: { primary: "ui-icon-carat-1-n"}}).css('font-size','5px').css('padding-left','10px').css('padding-right','10px').css('padding-top','3px').css('padding-bottom','3px') : $("#<%= params[:base_id] %>_<%= lab.hash %>_asc").button({text: false, icons: { primary: "ui-icon-triangle-1-n"}}).css('font-size','5px').css('padding-left','10px').css('padding-right','10px').css('padding-top','3px').css('padding-bottom','3px');
|
|
93
|
+
$("#<%= params[:base_id] %>_<%= lab.hash %>_desc").hasClass('selected') ? $("#<%= params[:base_id] %>_<%= lab.hash %>_desc").button({text: false, icons: { primary: "ui-icon-carat-1-s"}}).css('font-size','5px').css('padding-left','10px').css('padding-right','10px').css('padding-top','3px').css('padding-bottom','3px') : $("#<%= params[:base_id] %>_<%= lab.hash %>_desc").button({text: false, icons: { primary: "ui-icon-triangle-1-s"}}).css('font-size','5px').css('padding-left','10px').css('padding-right','10px').css('padding-top','3px').css('padding-bottom','3px');
|
|
94
|
+
<% end %>
|
|
95
|
+
<% end %>
|
|
96
|
+
|
|
97
|
+
$('#<%= params[:base_id] %>_prev').click
|
|
98
|
+
(
|
|
99
|
+
function(e)
|
|
100
|
+
{
|
|
101
|
+
$('#<%= params[:base_id] %>_form input[name=<%= params[:base_id]%>_page]').val(parseInt($('#<%= params[:base_id] %>_form input[name=<%= params[:base_id]%>_page]').val())-1);
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
$('#<%= params[:base_id] %>_find').click
|
|
106
|
+
(
|
|
107
|
+
function(e)
|
|
108
|
+
{
|
|
109
|
+
$('#<%= params[:base_id] %>_form input[name=<%= params[:base_id]%>_page]').val(1);
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
$('#<%= params[:base_id] %>_next').click
|
|
114
|
+
(
|
|
115
|
+
function(e)
|
|
116
|
+
{
|
|
117
|
+
$('#<%= params[:base_id] %>_form input[name=<%= params[:base_id]%>_page]').val(parseInt($('#<%= params[:base_id] %>_form input[name=<%= params[:base_id]%>_page]').val())+1);
|
|
118
|
+
}
|
|
119
|
+
);
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# look_for/helpers/look_for_helper.rb
|
|
2
|
+
|
|
3
|
+
module LookForHelper
|
|
4
|
+
def look_for(*args)
|
|
5
|
+
opt = args[3] || {}
|
|
6
|
+
opt[:controller] = :look_for
|
|
7
|
+
opt[:action] = :search
|
|
8
|
+
opt[:width] ||= 0
|
|
9
|
+
opt[:height] ||= 0
|
|
10
|
+
opt[:object_name] = args.first
|
|
11
|
+
opt[:method_names] = args[1]
|
|
12
|
+
|
|
13
|
+
html_opt = args[4] || {}
|
|
14
|
+
html_opt[:remote] = true
|
|
15
|
+
html_opt[:id] ||= "look_for_#{args.first.downcase.pluralize}"
|
|
16
|
+
|
|
17
|
+
link_to args[2], opt, html_opt.merge(method: :post)
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/look_for.rb
ADDED
data/look_for.gemspec
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
require File.expand_path('../lib/look_for/version', __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |gem|
|
|
5
|
+
gem.name = "look_for"
|
|
6
|
+
gem.version = LookFor::VERSION
|
|
7
|
+
gem.authors = ["Fabio Montarsolo"]
|
|
8
|
+
gem.email = ["fabio.montarsolo@gmail.com"]
|
|
9
|
+
gem.summary = %q{Look for}
|
|
10
|
+
gem.description = %q{Simple ajax search form}
|
|
11
|
+
gem.homepage = "https://github.com/TheSynthMaster/look_for"
|
|
12
|
+
gem.license = "MIT"
|
|
13
|
+
|
|
14
|
+
gem.required_ruby_version = ">= 3.0"
|
|
15
|
+
|
|
16
|
+
gem.files = Dir.glob("**/*").select { |f| File.file?(f) }
|
|
17
|
+
gem.require_paths = ["lib"]
|
|
18
|
+
|
|
19
|
+
gem.add_dependency "rails", "~> 7.0"
|
|
20
|
+
gem.add_dependency "will_paginate", "~> 3.0"
|
|
21
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: look_for
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Fabio Montarsolo
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: rails
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '7.0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '7.0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: will_paginate
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '3.0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '3.0'
|
|
40
|
+
description: Simple ajax search form
|
|
41
|
+
email:
|
|
42
|
+
- fabio.montarsolo@gmail.com
|
|
43
|
+
executables: []
|
|
44
|
+
extensions: []
|
|
45
|
+
extra_rdoc_files: []
|
|
46
|
+
files:
|
|
47
|
+
- Gemfile
|
|
48
|
+
- LICENSE
|
|
49
|
+
- README.md
|
|
50
|
+
- Rakefile
|
|
51
|
+
- app/assets/javascripts/look_for/index.js
|
|
52
|
+
- app/assets/javascripts/look_for/look_for.js
|
|
53
|
+
- app/assets/stylesheets/look_for/index.css
|
|
54
|
+
- app/assets/stylesheets/look_for/look_for-tableless.css
|
|
55
|
+
- app/controllers/look_for_controller.rb
|
|
56
|
+
- app/views/look_for/_header.html.erb
|
|
57
|
+
- app/views/look_for/_look_for.html.erb
|
|
58
|
+
- app/views/look_for/_pagination.html.erb
|
|
59
|
+
- app/views/look_for/_results.html.erb
|
|
60
|
+
- app/views/look_for/_toolbar.html.erb
|
|
61
|
+
- app/views/look_for/assign_and_close.js.erb
|
|
62
|
+
- app/views/look_for/assign_first.js.erb
|
|
63
|
+
- app/views/look_for/clear.js.erb
|
|
64
|
+
- app/views/look_for/look_for.js.erb
|
|
65
|
+
- config/routes.rb
|
|
66
|
+
- lib/look_for.rb
|
|
67
|
+
- lib/look_for/engine.rb
|
|
68
|
+
- lib/look_for/helpers/look_for_helper.rb
|
|
69
|
+
- lib/look_for/version.rb
|
|
70
|
+
- look_for.gemspec
|
|
71
|
+
homepage: https://github.com/TheSynthMaster/look_for
|
|
72
|
+
licenses:
|
|
73
|
+
- MIT
|
|
74
|
+
metadata: {}
|
|
75
|
+
rdoc_options: []
|
|
76
|
+
require_paths:
|
|
77
|
+
- lib
|
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '3.0'
|
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - ">="
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '0'
|
|
88
|
+
requirements: []
|
|
89
|
+
rubygems_version: 3.7.2
|
|
90
|
+
specification_version: 4
|
|
91
|
+
summary: Look for
|
|
92
|
+
test_files: []
|