fancygrid 1.1.0 → 2.0.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.
- data/CHANGELOG +9 -2
- data/Gemfile +6 -9
- data/Gemfile.lock +88 -103
- data/README.md +226 -0
- data/ROADMAP +0 -1
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/app/views/fancygrid/controls.html.haml +34 -0
- data/app/views/fancygrid/fancygrid.html.haml +18 -0
- data/app/views/fancygrid/search.html.haml +24 -0
- data/app/views/fancygrid/sort.html.haml +8 -0
- data/app/views/fancygrid/table.html.haml +25 -0
- data/config/locales/fancygrid.de.yml +17 -19
- data/config/locales/fancygrid.en.yml +14 -17
- data/fancygrid.gemspec +48 -88
- data/lib/assets/javascripts/fancygrid.js +425 -0
- data/lib/assets/javascripts/fancygrid.min.js +15 -0
- data/lib/assets/stylesheets/fancygrid.css +177 -0
- data/lib/fancygrid.rb +63 -44
- data/lib/fancygrid/column.rb +165 -0
- data/lib/fancygrid/controller/helper.rb +46 -0
- data/lib/fancygrid/grid.rb +171 -317
- data/lib/fancygrid/node.rb +85 -490
- data/lib/fancygrid/object_wrapper.rb +24 -0
- data/lib/fancygrid/orm/active_record.rb +39 -0
- data/lib/fancygrid/orm/sql_generator.rb +127 -0
- data/lib/fancygrid/view/helper.rb +44 -0
- data/lib/fancygrid/view_state.rb +161 -0
- data/spec/column_spec.rb +29 -0
- data/spec/dummy/app/controllers/application_controller.rb +48 -0
- data/spec/dummy/app/views/application/index.html.haml +11 -0
- data/spec/dummy/app/views/layouts/application.html.erb +1 -1
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/environments/development.rb +2 -2
- data/spec/dummy/config/environments/test.rb +2 -2
- data/spec/dummy/config/routes.rb +3 -2
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +26 -0
- data/spec/dummy/public/javascripts/jquery-1.4.2.js +6240 -0
- data/spec/dummy/public/javascripts/jquery-fancygrid.js +425 -0
- data/spec/dummy/public/javascripts/jquery-ui.js +41 -0
- data/spec/dummy/public/stylesheets/fancygrid.css +183 -0
- data/spec/node_spec.rb +79 -301
- data/spec/spec_helper.rb +0 -29
- data/spec/view_state_spec.rb +91 -0
- metadata +124 -137
- data/.bundle/config +0 -2
- data/README.rdoc +0 -299
- data/app/views/fancygrid/_cells.html.haml +0 -13
- data/app/views/fancygrid/base/controls.html.haml +0 -40
- data/app/views/fancygrid/base/list_frame.html.haml +0 -37
- data/app/views/fancygrid/base/search.html.haml +0 -33
- data/app/views/fancygrid/base/sort.html.haml +0 -20
- data/app/views/fancygrid/base/table_frame.html.haml +0 -45
- data/config/initializers/fancygrid.rb +0 -67
- data/lib/fancygrid/helper.rb +0 -129
- data/lib/fancygrid/query_generator.rb +0 -340
- data/lib/fancygrid/view.rb +0 -148
- data/lib/generators/install_generator.rb +0 -61
- data/lib/generators/views_generator.rb +0 -25
- data/lib/version.rb +0 -0
- data/public/images/fancygrid/add.png +0 -0
- data/public/images/fancygrid/clear.png +0 -0
- data/public/images/fancygrid/ddn.png +0 -0
- data/public/images/fancygrid/dn.png +0 -0
- data/public/images/fancygrid/dots.png +0 -0
- data/public/images/fancygrid/loading.gif +0 -0
- data/public/images/fancygrid/magnifier.png +0 -0
- data/public/images/fancygrid/next.png +0 -0
- data/public/images/fancygrid/order.png +0 -0
- data/public/images/fancygrid/prev.png +0 -0
- data/public/images/fancygrid/reload.png +0 -0
- data/public/images/fancygrid/remove.png +0 -0
- data/public/images/fancygrid/spacer.gif +0 -0
- data/public/images/fancygrid/submit.png +0 -0
- data/public/images/fancygrid/th_bg.png +0 -0
- data/public/images/fancygrid/up.png +0 -0
- data/public/images/fancygrid/uup.png +0 -0
- data/public/javascripts/fancygrid.js +0 -477
- data/public/javascripts/fancygrid.min.js +0 -17
- data/public/stylesheets/fancygrid.css +0 -289
- data/public/stylesheets/fancygrid.scss +0 -302
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/production.log +0 -0
- data/spec/dummy/log/server.log +0 -0
- data/spec/dummy/log/test.log +0 -1026
- data/spec/dummy/public/javascripts/application.js +0 -2
- data/spec/dummy/public/javascripts/controls.js +0 -965
- data/spec/dummy/public/javascripts/dragdrop.js +0 -974
- data/spec/dummy/public/javascripts/effects.js +0 -1123
- data/spec/dummy/public/javascripts/prototype.js +0 -6001
- data/spec/dummy/public/javascripts/rails.js +0 -175
- data/spec/grid_spec.rb +0 -15
- data/spec/integration/navigation_spec.rb +0 -9
- data/spec/query_generator_spec.rb +0 -358
data/ROADMAP
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
1.0.0 - Stable release
|
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ begin
|
|
15
15
|
gem.description = %Q{Enables easy table rendering in rails applications}
|
16
16
|
gem.email = "giniedp@online.de"
|
17
17
|
gem.homepage = "http://github.com/giniedp/fancygrid"
|
18
|
-
gem.authors = ["Alexander
|
18
|
+
gem.authors = ["Alexander Graefenstein"]
|
19
19
|
# gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
20
20
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
21
21
|
end
|
@@ -25,7 +25,7 @@ rescue LoadError
|
|
25
25
|
end
|
26
26
|
|
27
27
|
require 'rake'
|
28
|
-
require '
|
28
|
+
require 'rdoc/task'
|
29
29
|
|
30
30
|
require 'rspec/core'
|
31
31
|
require 'rspec/core/rake_task'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
@@ -0,0 +1,34 @@
|
|
1
|
+
%ul.fg-control-bar{ :class => tag_class }
|
2
|
+
|
3
|
+
%li.fg-button-prev{ :title => t(:"actions.prev", :default => "Previous page", :scope => Fancygrid.i18n_scope) }
|
4
|
+
%li
|
5
|
+
%span
|
6
|
+
= I18n.t(:"pagination.page", :default => "Page", :scope => Fancygrid.i18n_scope)
|
7
|
+
%span.fg-current-page
|
8
|
+
= fancygrid.view_state.pagination_page
|
9
|
+
%span
|
10
|
+
= I18n.t(:"pagination.of", :default => "of", :scope => Fancygrid.i18n_scope)
|
11
|
+
%span.fg-total-pages
|
12
|
+
= fancygrid.page_count
|
13
|
+
%li.fg-button-next{ :title => t(:"actions.next", :scope => Fancygrid.i18n_scope, :default => "Next page") }
|
14
|
+
|
15
|
+
%li.separator
|
16
|
+
|
17
|
+
%li
|
18
|
+
%span
|
19
|
+
= I18n.t(:"pagination.go_to", :default => "Go to page", :scope => Fancygrid.i18n_scope)
|
20
|
+
= text_field_tag(:page, fancygrid.view_state.pagination_page, :class => "fg-current-page")
|
21
|
+
|
22
|
+
%li
|
23
|
+
= select_tag(:per_page, options_for_select(fancygrid.per_page_values, fancygrid.per_page_value), :class => "fg-per-page")
|
24
|
+
|
25
|
+
%li.separator
|
26
|
+
|
27
|
+
%li.fg-button-search{ :title => t(:"actions.search", :default => "Search", :scope => Fancygrid.i18n_scope) }
|
28
|
+
%li.fg-button-refresh{ :title => t(:"actions.reload", :default => "Reload", :scope => Fancygrid.i18n_scope) }
|
29
|
+
%li.fg-button-clear{ :title => t(:"actions.reset", :default => "Reset", :scope => Fancygrid.i18n_scope) }
|
30
|
+
|
31
|
+
- if fancygrid.sort_window?
|
32
|
+
%li.fg-button-sort{ :title => t(:"actions.sort", :default => "Sort columns", :scope => Fancygrid.i18n_scope) }
|
33
|
+
|
34
|
+
= yield :"fancygrid_#{fancygrid.name}_buttons"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
.fg-wrapper
|
2
|
+
.fg-container{ :id => "fancygrid_#{fancygrid.name}" }
|
3
|
+
- if fancygrid.complex_search?
|
4
|
+
= render(:template => Fancygrid.search_template, :locals => { :fancygrid => fancygrid })
|
5
|
+
- if fancygrid.top_control?
|
6
|
+
= render(:template => Fancygrid.controls_template, :locals => { :fancygrid => fancygrid, :tag_class => :"controls top" })
|
7
|
+
|
8
|
+
= render(:template => Fancygrid.table_template, :locals => { :fancygrid => fancygrid, :format_block => format_block })
|
9
|
+
|
10
|
+
- if fancygrid.bottom_control?
|
11
|
+
= render(:template => Fancygrid.controls_template, :locals => { :fancygrid => fancygrid, :tag_class => :"controls bottom" })
|
12
|
+
- if fancygrid.sort_window?
|
13
|
+
= render(:template => Fancygrid.sort_template, :locals => { :fancygrid => fancygrid })
|
14
|
+
|
15
|
+
- if fancygrid.dynamic?
|
16
|
+
:javascript
|
17
|
+
$(function(){ $("#fancygrid_#{fancygrid.name}").fancygrid(#{fancygrid.js_options}); });
|
18
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
= field_set_tag( t(:"search.title", :default => "Search", :scope => Fancygrid.i18n_scope), :class => :"fg-search" ) do
|
2
|
+
%ul.fg-search-controls
|
3
|
+
%li.fg-button-refresh{ :title => t(:"search.add_criterion", :default => "Add criterion", :scope => Fancygrid.i18n_scope) }
|
4
|
+
%li.fg-button-refresh{ :title => t(:"actions.reload", :default => "Reload", :scope => Fancygrid.i18n_scope) }
|
5
|
+
%li.fg-button-clear{ :title => t(:"actions.reset", :default => "Reset", :scope => Fancygrid.i18n_scope) }
|
6
|
+
%li
|
7
|
+
= check_box_tag(:"fg-search-conditions", :all, fancygrid.view_state.conditions_match_all?)
|
8
|
+
= label_tag(:"fg-search-conditions", t(:"search.conditions", :default => 'All conditions must met:', :scope => Fancygrid.i18n_scope))
|
9
|
+
|
10
|
+
%ul.fg-search-criteria
|
11
|
+
- fancygrid.visible_columns.each do |column|
|
12
|
+
- fancygrid.view_state.column_conditions(column).each do |condition|
|
13
|
+
%li.fg-search-criterion
|
14
|
+
.fg-button-remove-criterion{ :title => t(:"search.remove_criterion", :default => "Remove criterion", :scope => Fancygrid.i18n_scope) }
|
15
|
+
= select_tag(:identifier, options_for_select(fancygrid.select_column_options, condition[:identifier]))
|
16
|
+
= select_tag(:operator, options_for_select(fancygrid.select_operator_options, condition[:operator] || fancygrid.search_operator))
|
17
|
+
= text_field_tag(:value, condition[:value])
|
18
|
+
|
19
|
+
.fg-search-template
|
20
|
+
%li.fg-search-criterion
|
21
|
+
.fg-button-remove-criterion{ :title => t(:"search.remove_criterion", :default => "Remove criterion", :scope => Fancygrid.i18n_scope) }
|
22
|
+
= select_tag(:identifier, options_for_select(fancygrid.select_column_options))
|
23
|
+
= select_tag(:operator, options_for_select(fancygrid.select_operator_options, fancygrid.search_operator))
|
24
|
+
= text_field_tag(:value)
|
@@ -0,0 +1,8 @@
|
|
1
|
+
.fg-sort-window{ :style => "display: none;" }
|
2
|
+
.fg-sort-content{ :style => "display: none;" }
|
3
|
+
%ul.fg-sortable
|
4
|
+
- fancygrid.leafs.each do |leaf|
|
5
|
+
%li.fg-sort-item
|
6
|
+
= check_box_tag leaf.identifier, "1", leaf.visible
|
7
|
+
= leaf.human_name
|
8
|
+
= submit_tag t(:"actions.save", :default => "Save", :scope => Fancygrid.i18n_scope)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
.fg-datawrapper{ :class => "fg-#{fancygrid.name}"}
|
2
|
+
%table.fg-datacontainer
|
3
|
+
%tr.fg-header
|
4
|
+
- fancygrid.visible_columns.each do |column|
|
5
|
+
%th{ :class => column.tag_class + (column.searchable ? " fg-orderable" : ""), :"fg-identifier" => column.identifier, :"fg-sort-order" => column.sort_order }
|
6
|
+
.fg-head-wrapper.fg-order-tag
|
7
|
+
= column.human_name
|
8
|
+
- if fancygrid.simple_search?
|
9
|
+
%tr.fg-search
|
10
|
+
- fancygrid.visible_columns.each do |column|
|
11
|
+
%td{ :class => column.tag_class }
|
12
|
+
- next unless column.searchable
|
13
|
+
.fg-search-criterion
|
14
|
+
= hidden_field_tag(:identifier, column.identifier)
|
15
|
+
= hidden_field_tag(:operator, fancygrid.search_operator)
|
16
|
+
- if column.search_options
|
17
|
+
= select_tag(:value, options_from_collection_for_select(column.search_options, :last, :first), :selected => column.search_value)
|
18
|
+
- else
|
19
|
+
= text_field_tag(:value, column.search_value)
|
20
|
+
|
21
|
+
- fancygrid.records.each do |record|
|
22
|
+
%tr.fg-row
|
23
|
+
- fancygrid.visible_columns.each do |column|
|
24
|
+
%td{ :class => column.tag_class }
|
25
|
+
= render_fancygrid_cell(record, column, &format_block)
|
@@ -1,25 +1,23 @@
|
|
1
1
|
de:
|
2
2
|
fancygrid:
|
3
|
-
pagination:
|
3
|
+
pagination:
|
4
|
+
page: Seite
|
5
|
+
of: von
|
4
6
|
per_page: 'Pro Seite:'
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
info: "Sie können die Spalten per Drag&Drop sortieren. Ziehen Sie die Spalten die Sie sehen möchten in die linke Liste, alle anderen in die rechte Liste. Klicken Sie zum Abschluss in den abgedunkelten Bereich."
|
15
|
-
header_visible: "Sichtbare Spalten"
|
16
|
-
header_hidden: "Versteckte Spalten"
|
7
|
+
go_to: Gehe zu Seite
|
8
|
+
actions:
|
9
|
+
search: 'Suchen'
|
10
|
+
reload: 'Suche neu laden'
|
11
|
+
reset: 'Suche löschen'
|
12
|
+
sort: 'Spalten sortieren'
|
13
|
+
save: 'Speichern'
|
14
|
+
prev: 'Vorherige Seite'
|
15
|
+
next: 'Nächste Seite'
|
17
16
|
search:
|
18
|
-
title:
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
conditions: 'Alle Bedingungen müssen erfüllt sein:'
|
17
|
+
title: Suche
|
18
|
+
conditions: 'Alle kriterien müssen erfüllt sein:'
|
19
|
+
add_criterion: Kriterium hinzufügen
|
20
|
+
remove_criterion: Kriterium löschen
|
23
21
|
|
24
22
|
operator:
|
25
23
|
equal: 'gleich'
|
@@ -38,4 +36,4 @@ de:
|
|
38
36
|
is_false: 'ist falsch'
|
39
37
|
is_not_false: 'ist nicht falsch'
|
40
38
|
in: 'ist in'
|
41
|
-
not_in: 'ist nicht in'
|
39
|
+
not_in: 'ist nicht in'
|
@@ -1,24 +1,23 @@
|
|
1
1
|
en:
|
2
2
|
fancygrid:
|
3
|
-
pagination:
|
3
|
+
pagination:
|
4
|
+
page: Page
|
5
|
+
of: of
|
4
6
|
per_page: 'Per page:'
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
prev_page: 'Pervious page'
|
9
|
-
next_page: 'Next page'
|
7
|
+
go_to: Go to page
|
8
|
+
actions:
|
9
|
+
search: 'Search'
|
10
10
|
reload: 'Reload'
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
reset: 'Reset'
|
12
|
+
sort: 'Sort columns'
|
13
|
+
save: 'Save'
|
14
|
+
prev: 'Pervious page'
|
15
|
+
next: 'Next page'
|
16
16
|
search:
|
17
|
-
title:
|
18
|
-
submit: 'Apply search'
|
19
|
-
clear: 'Clear search'
|
20
|
-
toggle: 'Show/Hide search'
|
17
|
+
title: Search
|
21
18
|
conditions: 'All conditions must be met:'
|
19
|
+
add_criterion: Add criterion
|
20
|
+
remove_criterion: Remove criterion
|
22
21
|
|
23
22
|
operator:
|
24
23
|
equal: 'equal'
|
@@ -38,5 +37,3 @@ en:
|
|
38
37
|
is_not_false: 'is not false'
|
39
38
|
in: 'is in'
|
40
39
|
not_in: 'is not in'
|
41
|
-
|
42
|
-
|
data/fancygrid.gemspec
CHANGED
@@ -4,75 +4,57 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "
|
7
|
+
s.name = "fancygrid"
|
8
|
+
s.version = "2.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Alexander
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
11
|
+
s.authors = ["Alexander Graefenstein"]
|
12
|
+
s.date = "2012-07-04"
|
13
|
+
s.description = "Enables easy table rendering in rails applications"
|
14
|
+
s.email = "giniedp@online.de"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
"README.
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
|
-
".bundle/config",
|
21
20
|
".rspec",
|
22
21
|
"CHANGELOG",
|
23
22
|
"Gemfile",
|
24
23
|
"Gemfile.lock",
|
25
24
|
"LICENSE",
|
26
|
-
"README.
|
25
|
+
"README.md",
|
27
26
|
"ROADMAP",
|
28
27
|
"Rakefile",
|
29
28
|
"VERSION",
|
30
|
-
"app/views/fancygrid/
|
31
|
-
"app/views/fancygrid/
|
32
|
-
"app/views/fancygrid/
|
33
|
-
"app/views/fancygrid/
|
34
|
-
"app/views/fancygrid/
|
35
|
-
"app/views/fancygrid/base/table_frame.html.haml",
|
36
|
-
"config/initializers/fancygrid.rb",
|
29
|
+
"app/views/fancygrid/controls.html.haml",
|
30
|
+
"app/views/fancygrid/fancygrid.html.haml",
|
31
|
+
"app/views/fancygrid/search.html.haml",
|
32
|
+
"app/views/fancygrid/sort.html.haml",
|
33
|
+
"app/views/fancygrid/table.html.haml",
|
37
34
|
"config/locales/fancygrid.de.yml",
|
38
35
|
"config/locales/fancygrid.en.yml",
|
39
36
|
"fancygrid.gemspec",
|
40
37
|
"init.rb",
|
38
|
+
"lib/assets/javascripts/fancygrid.js",
|
39
|
+
"lib/assets/javascripts/fancygrid.min.js",
|
40
|
+
"lib/assets/stylesheets/fancygrid.css",
|
41
41
|
"lib/fancygrid.rb",
|
42
|
+
"lib/fancygrid/column.rb",
|
43
|
+
"lib/fancygrid/controller/helper.rb",
|
42
44
|
"lib/fancygrid/grid.rb",
|
43
|
-
"lib/fancygrid/helper.rb",
|
44
45
|
"lib/fancygrid/node.rb",
|
45
|
-
"lib/fancygrid/
|
46
|
-
"lib/fancygrid/
|
47
|
-
"lib/
|
48
|
-
"lib/
|
49
|
-
"lib/
|
50
|
-
"
|
51
|
-
"public/images/fancygrid/clear.png",
|
52
|
-
"public/images/fancygrid/ddn.png",
|
53
|
-
"public/images/fancygrid/dn.png",
|
54
|
-
"public/images/fancygrid/dots.png",
|
55
|
-
"public/images/fancygrid/loading.gif",
|
56
|
-
"public/images/fancygrid/magnifier.png",
|
57
|
-
"public/images/fancygrid/next.png",
|
58
|
-
"public/images/fancygrid/order.png",
|
59
|
-
"public/images/fancygrid/prev.png",
|
60
|
-
"public/images/fancygrid/reload.png",
|
61
|
-
"public/images/fancygrid/remove.png",
|
62
|
-
"public/images/fancygrid/spacer.gif",
|
63
|
-
"public/images/fancygrid/submit.png",
|
64
|
-
"public/images/fancygrid/th_bg.png",
|
65
|
-
"public/images/fancygrid/up.png",
|
66
|
-
"public/images/fancygrid/uup.png",
|
67
|
-
"public/javascripts/fancygrid.js",
|
68
|
-
"public/javascripts/fancygrid.min.js",
|
69
|
-
"public/stylesheets/fancygrid.css",
|
70
|
-
"public/stylesheets/fancygrid.scss",
|
46
|
+
"lib/fancygrid/object_wrapper.rb",
|
47
|
+
"lib/fancygrid/orm/active_record.rb",
|
48
|
+
"lib/fancygrid/orm/sql_generator.rb",
|
49
|
+
"lib/fancygrid/view/helper.rb",
|
50
|
+
"lib/fancygrid/view_state.rb",
|
51
|
+
"spec/column_spec.rb",
|
71
52
|
"spec/dummy/Rakefile",
|
72
53
|
"spec/dummy/app/controllers/application_controller.rb",
|
73
54
|
"spec/dummy/app/helpers/application_helper.rb",
|
74
55
|
"spec/dummy/app/models/project.rb",
|
75
56
|
"spec/dummy/app/models/ticket.rb",
|
57
|
+
"spec/dummy/app/views/application/index.html.haml",
|
76
58
|
"spec/dummy/app/views/layouts/application.html.erb",
|
77
59
|
"spec/dummy/config.ru",
|
78
60
|
"spec/dummy/config/application.rb",
|
@@ -89,73 +71,51 @@ Gem::Specification.new do |s|
|
|
89
71
|
"spec/dummy/config/initializers/session_store.rb",
|
90
72
|
"spec/dummy/config/locales/en.yml",
|
91
73
|
"spec/dummy/config/routes.rb",
|
74
|
+
"spec/dummy/db/development.sqlite3",
|
92
75
|
"spec/dummy/db/migrate/20110112183948_create_projects.rb",
|
93
76
|
"spec/dummy/db/migrate/20110112183956_create_tickets.rb",
|
77
|
+
"spec/dummy/db/schema.rb",
|
94
78
|
"spec/dummy/db/test.sqlite3",
|
95
|
-
"spec/dummy/log/development.log",
|
96
|
-
"spec/dummy/log/production.log",
|
97
|
-
"spec/dummy/log/server.log",
|
98
|
-
"spec/dummy/log/test.log",
|
99
79
|
"spec/dummy/public/404.html",
|
100
80
|
"spec/dummy/public/422.html",
|
101
81
|
"spec/dummy/public/500.html",
|
102
82
|
"spec/dummy/public/favicon.ico",
|
103
|
-
"spec/dummy/public/javascripts/
|
104
|
-
"spec/dummy/public/javascripts/
|
105
|
-
"spec/dummy/public/javascripts/
|
106
|
-
"spec/dummy/public/javascripts/effects.js",
|
107
|
-
"spec/dummy/public/javascripts/prototype.js",
|
108
|
-
"spec/dummy/public/javascripts/rails.js",
|
83
|
+
"spec/dummy/public/javascripts/jquery-1.4.2.js",
|
84
|
+
"spec/dummy/public/javascripts/jquery-fancygrid.js",
|
85
|
+
"spec/dummy/public/javascripts/jquery-ui.js",
|
109
86
|
"spec/dummy/public/stylesheets/.gitkeep",
|
87
|
+
"spec/dummy/public/stylesheets/fancygrid.css",
|
110
88
|
"spec/dummy/script/rails",
|
111
|
-
"spec/grid_spec.rb",
|
112
|
-
"spec/integration/navigation_spec.rb",
|
113
89
|
"spec/node_spec.rb",
|
114
|
-
"spec/
|
115
|
-
"spec/
|
90
|
+
"spec/spec_helper.rb",
|
91
|
+
"spec/view_state_spec.rb"
|
116
92
|
]
|
117
|
-
s.homepage =
|
93
|
+
s.homepage = "http://github.com/giniedp/fancygrid"
|
118
94
|
s.require_paths = ["lib"]
|
119
|
-
s.rubygems_version =
|
120
|
-
s.summary =
|
121
|
-
s.test_files = [
|
122
|
-
"spec/dummy/app/controllers/application_controller.rb",
|
123
|
-
"spec/dummy/app/helpers/application_helper.rb",
|
124
|
-
"spec/dummy/app/models/project.rb",
|
125
|
-
"spec/dummy/app/models/ticket.rb",
|
126
|
-
"spec/dummy/config/application.rb",
|
127
|
-
"spec/dummy/config/boot.rb",
|
128
|
-
"spec/dummy/config/environment.rb",
|
129
|
-
"spec/dummy/config/environments/development.rb",
|
130
|
-
"spec/dummy/config/environments/production.rb",
|
131
|
-
"spec/dummy/config/environments/test.rb",
|
132
|
-
"spec/dummy/config/initializers/backtrace_silencers.rb",
|
133
|
-
"spec/dummy/config/initializers/inflections.rb",
|
134
|
-
"spec/dummy/config/initializers/mime_types.rb",
|
135
|
-
"spec/dummy/config/initializers/secret_token.rb",
|
136
|
-
"spec/dummy/config/initializers/session_store.rb",
|
137
|
-
"spec/dummy/config/routes.rb",
|
138
|
-
"spec/dummy/db/migrate/20110112183948_create_projects.rb",
|
139
|
-
"spec/dummy/db/migrate/20110112183956_create_tickets.rb",
|
140
|
-
"spec/grid_spec.rb",
|
141
|
-
"spec/integration/navigation_spec.rb",
|
142
|
-
"spec/node_spec.rb",
|
143
|
-
"spec/query_generator_spec.rb",
|
144
|
-
"spec/spec_helper.rb"
|
145
|
-
]
|
95
|
+
s.rubygems_version = "1.8.24"
|
96
|
+
s.summary = "Table rendering for rails applications"
|
146
97
|
|
147
98
|
if s.respond_to? :specification_version then
|
148
99
|
s.specification_version = 3
|
149
100
|
|
150
101
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
151
|
-
s.
|
102
|
+
s.add_runtime_dependency(%q<rails>, [">= 0"])
|
103
|
+
s.add_runtime_dependency(%q<haml>, [">= 0"])
|
104
|
+
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
105
|
+
s.add_development_dependency(%q<rspec-rails>, [">= 0"])
|
152
106
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
153
107
|
else
|
154
|
-
s.add_dependency(%q<rails>, [">=
|
108
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
109
|
+
s.add_dependency(%q<haml>, [">= 0"])
|
110
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
111
|
+
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
155
112
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
156
113
|
end
|
157
114
|
else
|
158
|
-
s.add_dependency(%q<rails>, [">=
|
115
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
116
|
+
s.add_dependency(%q<haml>, [">= 0"])
|
117
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
118
|
+
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
159
119
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
160
120
|
end
|
161
121
|
end
|
@@ -0,0 +1,425 @@
|
|
1
|
+
(function( $ ) {
|
2
|
+
|
3
|
+
// Query format that is sent to the backend
|
4
|
+
//{
|
5
|
+
// columns : [{
|
6
|
+
// identifier : <string>,
|
7
|
+
// visible : <bool>,
|
8
|
+
// position : <number>
|
9
|
+
// }],
|
10
|
+
// conditions : [{
|
11
|
+
// identifier : <string>,
|
12
|
+
// operator : <string>,
|
13
|
+
// value : <string>
|
14
|
+
// }],
|
15
|
+
// operator : ["all"|"any"],
|
16
|
+
// order : {
|
17
|
+
// identifier : <string>,
|
18
|
+
// direction : ["asc"|"desc"|""]
|
19
|
+
// },
|
20
|
+
// pagination : {
|
21
|
+
// page : <number>,
|
22
|
+
// per_page : <number>
|
23
|
+
// }
|
24
|
+
//}
|
25
|
+
|
26
|
+
var Fancygrid = this.Fancygrid = {};
|
27
|
+
|
28
|
+
var setValue = function(element, v){
|
29
|
+
$(element).each(function(index, item){
|
30
|
+
var $item = $(item);
|
31
|
+
if ($item.is("select") || $item.is("input")){
|
32
|
+
$item.val(v);
|
33
|
+
} else {
|
34
|
+
$item.text(v);
|
35
|
+
}
|
36
|
+
});
|
37
|
+
};
|
38
|
+
|
39
|
+
var getValue = function(element){
|
40
|
+
element = $(element).first();
|
41
|
+
if (element.is("select") || element.is("input")){
|
42
|
+
return element.val();
|
43
|
+
}
|
44
|
+
return element.text();
|
45
|
+
};
|
46
|
+
|
47
|
+
var FancygridWrapper = function(container, options){
|
48
|
+
|
49
|
+
// setup setings and default values
|
50
|
+
var settings = {
|
51
|
+
ajaxUrl : "/",
|
52
|
+
ajaxType : "GET",
|
53
|
+
name : "",
|
54
|
+
searchFadeTime : 25,
|
55
|
+
searchFadeOpac : 0.5,
|
56
|
+
page : 1,
|
57
|
+
perPage : 25
|
58
|
+
};
|
59
|
+
options = (options || {});
|
60
|
+
$.extend(settings, options);
|
61
|
+
|
62
|
+
// cache parameters
|
63
|
+
this.name = options.name;
|
64
|
+
this.container = container;
|
65
|
+
this.settings = settings;
|
66
|
+
this.queries = 0;
|
67
|
+
this.query = {
|
68
|
+
pagination : {
|
69
|
+
page : (settings.page),
|
70
|
+
per_page : settings.perPage
|
71
|
+
},
|
72
|
+
columns : [],
|
73
|
+
conditions : [],
|
74
|
+
operator : "all",
|
75
|
+
order : {}
|
76
|
+
};
|
77
|
+
|
78
|
+
// cache components
|
79
|
+
this.components = {
|
80
|
+
container : container,
|
81
|
+
search : container.find(".fg-search"),
|
82
|
+
searchTemplate : container.find(".fg-search-template"),
|
83
|
+
sortWindow : container.find(".fg-sort-window"),
|
84
|
+
sortContent : container.find(".fg-sort-content"),
|
85
|
+
controls : container.find(".fg-control-bar"),
|
86
|
+
dataWrapper : container.find(".fg-datawrapper"),
|
87
|
+
dataContainer : container.find(".fg-datacontainer"),
|
88
|
+
currentPage : container.find(".fg-current-page"),
|
89
|
+
totalPages : container.find(".fg-total-pages"),
|
90
|
+
perPage : container.find(".fg-per-page"),
|
91
|
+
buttons : {
|
92
|
+
prevPage : container.find(".fg-button-prev"),
|
93
|
+
nextPage : container.find(".fg-button-next"),
|
94
|
+
refresh : container.find(".fg-button-refresh"),
|
95
|
+
clearSearch : container.find(".fg-button-clear"),
|
96
|
+
toggleSearch : container.find(".fg-button-search"),
|
97
|
+
toggleSort : container.find(".fg-button-sort"),
|
98
|
+
addCriterion : container.find(".fg-button-add-criterion"),
|
99
|
+
removeCriterion : container.find(".fg-button-remove-criterion")
|
100
|
+
}
|
101
|
+
};
|
102
|
+
|
103
|
+
// hide components
|
104
|
+
this.components.searchTemplate.hide();
|
105
|
+
this.components.sortWindow.hide();
|
106
|
+
this.components.sortContent.hide();
|
107
|
+
if (!settings.searchVisible){
|
108
|
+
this.components.search.hide();
|
109
|
+
}
|
110
|
+
|
111
|
+
var instance = this;
|
112
|
+
|
113
|
+
// search attribute changed/focused
|
114
|
+
this.components.search.find("input[type='text'], select").bind("change.fancygrid", function(){
|
115
|
+
instance.buildConditions();
|
116
|
+
instance.refresh();
|
117
|
+
}).bind("focus.fancygrid", function(){
|
118
|
+
$(this).select();
|
119
|
+
});
|
120
|
+
|
121
|
+
// search attribute changed/focused
|
122
|
+
this.components.currentPage.bind("change.fancygrid", function(){
|
123
|
+
instance.setPage(getValue($(this)));
|
124
|
+
instance.refresh();
|
125
|
+
}).bind("focus.fancygrid", function(){
|
126
|
+
$(this).select();
|
127
|
+
});
|
128
|
+
|
129
|
+
// previous page click
|
130
|
+
this.components.buttons.prevPage.bind("click.fancygrid", function(e){
|
131
|
+
e.preventDefault();
|
132
|
+
instance.flipPages(-1);
|
133
|
+
instance.refresh();
|
134
|
+
});
|
135
|
+
|
136
|
+
// next page click
|
137
|
+
this.components.buttons.nextPage.bind("click.fancygrid", function(e){
|
138
|
+
e.preventDefault();
|
139
|
+
instance.flipPages(1);
|
140
|
+
instance.refresh();
|
141
|
+
});
|
142
|
+
|
143
|
+
// reload click
|
144
|
+
this.components.buttons.refresh.bind("click.fancygrid", function(e){
|
145
|
+
e.preventDefault();
|
146
|
+
instance.refresh();
|
147
|
+
});
|
148
|
+
|
149
|
+
// clear click
|
150
|
+
this.components.buttons.clearSearch.bind("click.fancygrid", function(e){
|
151
|
+
e.preventDefault();
|
152
|
+
instance.clearSearch();
|
153
|
+
instance.refresh();
|
154
|
+
});
|
155
|
+
|
156
|
+
// per page change
|
157
|
+
this.components.perPage.bind("change.fancygrid", function(e){
|
158
|
+
e.preventDefault();
|
159
|
+
instance.setPerPage(getValue($(this)));
|
160
|
+
instance.refresh();
|
161
|
+
});
|
162
|
+
|
163
|
+
// magnifier click
|
164
|
+
this.components.buttons.toggleSearch.bind("click.fancygrid", function(e){
|
165
|
+
e.preventDefault();
|
166
|
+
instance.toggleSearch();
|
167
|
+
});
|
168
|
+
|
169
|
+
// sort click
|
170
|
+
this.components.buttons.toggleSort.bind("click.fancygrid", function(e){
|
171
|
+
e.preventDefault();
|
172
|
+
instance.toggleSort();
|
173
|
+
});
|
174
|
+
this.components.sortWindow.click(function(){
|
175
|
+
instance.toggleSort();
|
176
|
+
});
|
177
|
+
|
178
|
+
// remove search criterion
|
179
|
+
this.components.buttons.removeCriterion.click(function(e){
|
180
|
+
e.preventDefault();
|
181
|
+
instance.buildConditions();
|
182
|
+
$(this).parents(".fg-search-criterion").detach();
|
183
|
+
});
|
184
|
+
|
185
|
+
// add search criterion
|
186
|
+
this.components.buttons.addCriterion.click(function(e){
|
187
|
+
e.preventDefault();
|
188
|
+
instance.addSearchCriterion();
|
189
|
+
});
|
190
|
+
|
191
|
+
//
|
192
|
+
container.find(".fg-orderable").click(function(e){
|
193
|
+
e.preventDefault();
|
194
|
+
instance.toggleOrder($(this));
|
195
|
+
});
|
196
|
+
};
|
197
|
+
|
198
|
+
FancygridWrapper.prototype.flipPages = function(value){
|
199
|
+
return this.setPage(this.query.pagination.page + value);
|
200
|
+
};
|
201
|
+
|
202
|
+
FancygridWrapper.prototype.setPage = function(value){
|
203
|
+
value = Math.max(1, value);
|
204
|
+
this.query.pagination.page = value;
|
205
|
+
setValue(this.components.currentPage, value);
|
206
|
+
return value;
|
207
|
+
};
|
208
|
+
|
209
|
+
FancygridWrapper.prototype.setPages = function(value){
|
210
|
+
value = Math.max(0, value);
|
211
|
+
setValue(this.components.totalPages, value);
|
212
|
+
return value;
|
213
|
+
};
|
214
|
+
|
215
|
+
FancygridWrapper.prototype.setPerPage = function(value){
|
216
|
+
value = Math.max(1, value);
|
217
|
+
this.query.pagination.per_page = value;
|
218
|
+
setValue(this.components.perPage, value);
|
219
|
+
};
|
220
|
+
|
221
|
+
FancygridWrapper.prototype.setOrder = function(identifier, direction){
|
222
|
+
this.query.order.identifier = identifier;
|
223
|
+
this.query.order.direction = direction;
|
224
|
+
this.container.find(".fg-orderable").attr("fg-sort-order", "");
|
225
|
+
this.container.find(".fg-orderable[fg-identifier='" + identifier + "']").attr("fg-sort-order", direction);
|
226
|
+
return this.query.order;
|
227
|
+
};
|
228
|
+
|
229
|
+
FancygridWrapper.prototype.toggleOrder = function(column){
|
230
|
+
var identifier = column.attr("fg-identifier");
|
231
|
+
var direction = column.attr("fg-sort-order");
|
232
|
+
|
233
|
+
if (direction == "asc"){
|
234
|
+
direction = "desc";
|
235
|
+
} else if (direction == "desc"){
|
236
|
+
direction = "";
|
237
|
+
} else {
|
238
|
+
direction = "asc";
|
239
|
+
}
|
240
|
+
|
241
|
+
this.setOrder(identifier, direction);
|
242
|
+
this.refresh();
|
243
|
+
};
|
244
|
+
|
245
|
+
FancygridWrapper.prototype.toggleSort = function(){
|
246
|
+
this.components.sortWindow.css({
|
247
|
+
position : "absolute",
|
248
|
+
top : 0,
|
249
|
+
left : 0,
|
250
|
+
width : "100%",
|
251
|
+
height : "100%",
|
252
|
+
opacity : 0.5
|
253
|
+
});
|
254
|
+
this.components.sortContent.css({
|
255
|
+
position : "absolute",
|
256
|
+
top : (window.innerHeight * 0.25) / 2,
|
257
|
+
left : (window.innerWidth - 200) / 2,
|
258
|
+
width : 200
|
259
|
+
});
|
260
|
+
var instance = this;
|
261
|
+
this.components.sortContent.find("input[type=submit]").click(function(){
|
262
|
+
instance.submitSort();
|
263
|
+
return false;
|
264
|
+
});
|
265
|
+
|
266
|
+
this.components.sortContent.find(".fg-sortable").sortable();
|
267
|
+
this.components.sortContent.find(".fg-sortable").disableSelection();
|
268
|
+
|
269
|
+
this.components.sortWindow.toggle();
|
270
|
+
this.components.sortContent.toggle();
|
271
|
+
};
|
272
|
+
|
273
|
+
FancygridWrapper.prototype.submitSort = function(){
|
274
|
+
this.buildColumns();
|
275
|
+
this.refresh(function(){
|
276
|
+
window.location.reload();
|
277
|
+
});
|
278
|
+
};
|
279
|
+
|
280
|
+
FancygridWrapper.prototype.clearSearch = function(){
|
281
|
+
// clear the complex search
|
282
|
+
this.container.find(".fg-search li.fg-search-criterion").detach();
|
283
|
+
// empty the simple search input fields
|
284
|
+
this.container.find(".fg-search-criterion *[name='value']").val("");
|
285
|
+
this.query.conditions = [];
|
286
|
+
return this.query.conditions;
|
287
|
+
};
|
288
|
+
|
289
|
+
FancygridWrapper.prototype.buildColumns = function(){
|
290
|
+
var inputs = this.components.sortContent.find(".fg-sort-item input");
|
291
|
+
var items = this.query.columns = [];
|
292
|
+
inputs.each(function(index, item){
|
293
|
+
item = $(item);
|
294
|
+
items.push({
|
295
|
+
identifier : item.attr("name"),
|
296
|
+
visible : item.is(":checked"),
|
297
|
+
position : index
|
298
|
+
});
|
299
|
+
});
|
300
|
+
return this.query.columns;
|
301
|
+
};
|
302
|
+
|
303
|
+
FancygridWrapper.prototype.buildConditions = function(){
|
304
|
+
this.query.operator = this.container.find("#fg-search-conditions:checked").val() || "all";
|
305
|
+
var conditions = this.query.conditions = [];
|
306
|
+
this.components.search.find(".fg-search-criterion").each(function(){
|
307
|
+
conditions.push({
|
308
|
+
identifier : getValue($(this).find("#identifier")),
|
309
|
+
operator : getValue($(this).find("#operator")),
|
310
|
+
value : getValue($(this).find("#value"))
|
311
|
+
});
|
312
|
+
});
|
313
|
+
return this.query;
|
314
|
+
};
|
315
|
+
|
316
|
+
FancygridWrapper.prototype.toggleSearch = function(){
|
317
|
+
this.components.search.toggle();
|
318
|
+
this.query.search_visible = this.components.search.is(":visible");
|
319
|
+
return this.query.search_visible;
|
320
|
+
};
|
321
|
+
|
322
|
+
FancygridWrapper.prototype.addSearchCriterion = function(){
|
323
|
+
if (!this.components.searchTemplate){
|
324
|
+
return false;
|
325
|
+
}
|
326
|
+
|
327
|
+
var instance = this;
|
328
|
+
var template = $(this.components.searchTemplate.html());
|
329
|
+
this.components.search.find(".fg-search-criteria").append(template);
|
330
|
+
|
331
|
+
// remove criterion binding
|
332
|
+
template.find(".fg-button-remove-criterion").click(function(){
|
333
|
+
template.remove();
|
334
|
+
instance.buildConditions();
|
335
|
+
});
|
336
|
+
|
337
|
+
|
338
|
+
// change value binding
|
339
|
+
template.find("input[type='text']").bind("change.fancygrid", function(){
|
340
|
+
instance.buildConditions();
|
341
|
+
}).bind("focus.fancygrid", function(){
|
342
|
+
$(this).select();
|
343
|
+
});
|
344
|
+
};
|
345
|
+
|
346
|
+
FancygridWrapper.prototype.refresh = function(callback){
|
347
|
+
var instance = this;
|
348
|
+
var queryData = {};
|
349
|
+
queryData.fancygrid = {};
|
350
|
+
queryData.fancygrid[instance.name] = instance.query;
|
351
|
+
|
352
|
+
instance.queries += 1;
|
353
|
+
instance.container.fadeTo(instance.settings.searchFadeTime, instance.settings.searchFadeOpac);
|
354
|
+
|
355
|
+
$.ajax({
|
356
|
+
type : instance.settings.ajaxType,
|
357
|
+
url : instance.settings.ajaxUrl,
|
358
|
+
data : queryData,
|
359
|
+
dataType : "html",
|
360
|
+
success : function(result){
|
361
|
+
instance.queries -= 1;
|
362
|
+
if(instance.queries === 0){
|
363
|
+
result = $(result).find("#fancygrid_" + instance.settings.name);
|
364
|
+
|
365
|
+
instance.container.find(".fg-row").detach();
|
366
|
+
instance.container.find(".fg-datacontainer").append(result.find(".fg-row"));
|
367
|
+
instance.setPage(getValue(result.find(".fg-current-page")));
|
368
|
+
instance.setPages(getValue(result.find(".fg-total-pages")));
|
369
|
+
instance.container.fadeTo(instance.settings.searchFadeTime, 1.0);
|
370
|
+
instance.container.trigger("ajaxSuccess");
|
371
|
+
}
|
372
|
+
},
|
373
|
+
error : function(){
|
374
|
+
instance.queries -= 1;
|
375
|
+
if(instance.queries === 0){
|
376
|
+
instance.container.find(".fg-row").detach();
|
377
|
+
instance.container.fadeTo(instance.settings.searchFadeTime, 1.0);
|
378
|
+
instance.container.trigger("ajaxError");
|
379
|
+
}
|
380
|
+
},
|
381
|
+
complete : callback
|
382
|
+
});
|
383
|
+
};
|
384
|
+
|
385
|
+
FancygridWrapper.prototype.download = function(type){
|
386
|
+
var instance = this;
|
387
|
+
var params = {};
|
388
|
+
params.fancygrid = {};
|
389
|
+
params.fancygrid[instance.name] = instance.query;
|
390
|
+
|
391
|
+
var url = instance.settings.ajaxUrl;
|
392
|
+
if (url.match(/\.html$/)){
|
393
|
+
url = url.substring(0, url.length - 5);
|
394
|
+
}
|
395
|
+
url = [url, type].join(".");
|
396
|
+
|
397
|
+
var data = $.param(params);
|
398
|
+
var method = instance.settings.ajaxType;
|
399
|
+
|
400
|
+
if( url && data ){
|
401
|
+
//data can be string of parameters or array/object
|
402
|
+
data = (typeof(data) === 'string') ? data : $.param(data);
|
403
|
+
|
404
|
+
//split params into form inputs
|
405
|
+
var inputs = '';
|
406
|
+
$.each(data.split('&'), function(){
|
407
|
+
var pair = this.split('=');
|
408
|
+
inputs += '<input type="hidden" name="'+ decodeURIComponent(pair[0]) +'" value="'+ decodeURIComponent(pair[1]) +'" />';
|
409
|
+
});
|
410
|
+
//send request
|
411
|
+
$('<form action="'+ url +'" method="'+ (method || 'post') + '">' + inputs + '</form>').appendTo('body').submit().remove();
|
412
|
+
}
|
413
|
+
};
|
414
|
+
|
415
|
+
|
416
|
+
//
|
417
|
+
// jQuery plugin
|
418
|
+
//
|
419
|
+
|
420
|
+
$.fn.fancygrid = function(options) {
|
421
|
+
Fancygrid[options.name] = new FancygridWrapper($(this), options);
|
422
|
+
$(this).data("fancygrid", Fancygrid[options.name]);
|
423
|
+
};
|
424
|
+
|
425
|
+
})(jQuery);
|