GithubHelp home page GithubHelp logo

leikind / wice_grid Goto Github PK

View Code? Open in Web Editor NEW
533.0 533.0 212.0 1.36 MB

A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters

Home Page: http://wicegrid.herokuapp.com/

License: MIT License

Ruby 99.51% HTML 0.49%

wice_grid's People

Contributors

ablancag avatar afdev82 avatar allolex avatar asgeo1 avatar ashanbrown avatar bhushangahire avatar brian-vogogo avatar cfiorini avatar colinramsay avatar ctreptow avatar danielweigl avatar dima4p avatar dsandber avatar eikes avatar fernandoalmeida avatar golddiga avatar gonzih avatar harrykiselev avatar harrypl avatar havran avatar kabturek avatar kreintjes avatar kris-luminar avatar leikind avatar mattsoutherden avatar nathanvda avatar noahc avatar ryanfox1985 avatar vit-panchuk avatar xavier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wice_grid's Issues

Showing all records doesn't behave properly when the filter is updated

How to reproduce:

  1. Filter on some criterion (let N be the total number of records in the result set)
  2. Toggle "show all records"
  3. Change the filter so you get a total number of records which is greater than N

At that point, the grid shows only N records and displays both "show all" and "back to paginated view" links.

I guess that a more appropriate behavior would be either to :

  • reset the display mode to paginated view when the filter is updated; or
  • stick with "show all" but then actually show all records from the new results set.

NameError (uninitialized constant Wice::Defaults::JS_FRAMEWORK)

The title explains the problem :-)
Everything seems to be properly installed with one only problem.
That 's the message Message : JS_FRAMEWORK constant is not initialized.
Which causes logically crash of the Application.

Environmet:
Rails 3.0.3
ruby 1.9.2p174
running RVM
installed Gems:
gem 'rails'
gem 'mysql2'
gem 'heroku'
gem 'will_paginate'
gem 'dropbox'
gem 'nifty-generators'
gem 'simple_form'
gem 'jquery-rails'
gem 'wice_grid', '3.0.0.pre1'

Maybe it has got some influence- I get always by starting the Server also the Warning:
/Users/sopira/.rvm/gems/ruby-1.9.2-head@rails3/gems/json_pure-1.4.6/lib/json/common.rb:65: warning: already initialized constant State
/Users/sopira/.rvm/gems/ruby-1.9.2-head@rails3/gems/json_pure-1.4.6/lib/json/common.rb:66: warning: already initialized constant SAFE_STATE_PROTOTYPE
/Users/sopira/.rvm/gems/ruby-1.9.2-head@rails3/gems/json_pure-1.4.6/lib/json/common.rb:67: warning: already initialized constant FAST_STATE_PROTOTYPE
/Users/sopira/.rvm/gems/ruby-1.9.2-head@rails3/gems/json_pure-1.4.6/lib/json/common.rb:74: warning: already initialized constant PRETTY_STATE_PROTOTYPE/Users/sopira/.rvm/gems/ruby-1.9.2-head@rails3/gems/json_pure-1.4.6/lib/json/ext.rb:14: warning: already initialized constant JSON_LOADED

...but this warning is not causing the crash of the applicayion. Only sucks.

thanks for any great idea.

nstant JSON_LOADED

.CSV export file in /tmp is sometimes erased before being sent, causing error

First off, great plugin!

I noticed this error and did some digging. I have Rails 2.3.10 and Ruby 1.8 on Mac OS X Snow Leopard under Mongrel 1.1.5. Apparently due to sporadic garbage collection while doing .CSV export, the temporary file in /tmp is sometimes erased before being sent, causing error in send_file.

According to the documentation of Ruby Tempfile close method, "close(unlink_now=false)
Closes the file. If the optional flag is true, unlinks the file after closing.
If you don‘t explicitly unlink the temporary file, the removal will be delayed until the object is finalized." (http://ruby-doc.org/core/classes/Tempfile.html).

It is obvious from code inspection (in wice_grid_view_helpers.rd:grid_csv) that the object (spreadsheet) is finalized upon return, and the file has not been sent yet, thus, the file can be unlinked / deleted before send_file (or not, depending on Ruby's garbage collector mood).

Wice::define_routes(map, controller) in Routes.rb not working

The define_routes method expects a IActionController::Routing::RouteSet::Mapper object, and controller. name. In rails 3, the ActionController::Routing::RouteSet::Mapper has been deprecated. I'm gettng the exception:

undefined method `create_serialized_query_url' for Class

Seems the routes are not picked by the Rails 3 environment. What change is required to make it work?

Thanks

ERB_MODE Duplicate tables

When i use :erb_mode => true, this generate 2 tables.

I use: RAILS 3.0.9 + inherited_resources + Jquery

CODE:

<%# Wice_Grid %>
<%= include_wice_grid_assets %>

<% grid(@tabela, :show_filters => :always, :erb_mode => true) do |g| %>

<% g.column :column_name => 'Título', :attribute_name => 'titulo' do |tabela| %>
  <%= tabela.titulo %>
<% end  %>

<% g.column :column_name => 'Agência', :attribute_name => 'agencia' do |tabela| %>
  <%= tabela.agencia %>
<% end  %>

<% g.column :column_name => 'Conta', :attribute_name => 'conta' do |tabela| %>
  <%= tabela.conta %>
<% end  %>

<% g.column do |tabela| %>      
    <%= link_to image_tag('/stylesheets/admin/assets/icons/actions_small/display.png'), tabela, :class => 'tooltip table_icon', :title => 'Visualizar' %>
    <%= link_to image_tag('/stylesheets/admin/assets/icons/actions_small/edit.png'), edit_resource_path(tabela), :class => 'tooltip table_icon', :title => 'Editar' %>
    <%= link_to image_tag('/stylesheets/admin/assets/icons/actions_small/delete.png'), tabela, :confirm => 'Deseja excluir este item ?', :method => :delete, :class => 'tooltip table_icon', :title => 'Excluir' %>
<% end %>

<% end -%>

Filter Default

Hi!
I would like to bring a filter default. E.g.: Show at the index only the records of current month. What better way ?
I tried a few things in the controller but I had no success.

Thanks a lot

Incorrect unicode characters

During 'script/generate wice_grid_assets' I got the following (ruby 1.9.1):

vendor/plugins/wice_grid/lib/wice_grid.rb:161: invalid multibyte char (US-ASCII)
.....

And the same for the line 167. The reason is a two-byte chracter 'С' instead of 'C' in the word 'Column'. So, I mean... you know )) \u0421 instead of 43 (ASCII).

Date Time

Hi!

Hello, I'm trying to use :helper_style => :calendar to style my DATETIME filter and it continues with the helper from rails. In filters DATE jQuery works perfectly.

Currently my index.html.erb is thus:
g.column :column_name => 'Date', :attribute_name => 'date_inicial', :helper_style => :calendar do |ordem_servico|
[(link_to ordem_servico.data_inicial.to_s_br, edit_ordem_servico_path(ordem_servico)),{:class=>"center"}]
end

Can you give some tips how to configure your Jquery helper to my DATETIME Filter ?

Thank u a lot

grid#column without a block does not work when model_class is present

Example:

class Person < ActiveRecord::Base
  belongs_to :company 
end

...
@people_grid = initialize_grid(Person, :include => :company, ...)
...
grid(@people_grid) do |g|
g.column(:attribute_name => "name") # will output Person#name
g.column(:attribute_name => "name", :model_class => "Company") # will output Person#name whereas company.name would be expected
end

I have the feeling that this might be a tricky one to solve. It's a totally non-blocking issue but it had to be put on the record. :)

Add a last row to grid

Hi!

How can i to add a last row to grid?

I need to show cumulative values to specifc columns, id this possible with wice grid?

Thanks.

Can't skip with default_scope

for example:
class Post < ActiveRecord::Base
default_scope :conditions => ['state = ?',1]
end

before use wice_grid I found data with this:
Post.send(:with_exclusive_scope) { Post.all }

when I use wice_grid, I must find with this:
initialize_grid(Post)

I have try to this:
Post.send(:with_exclusive_scope) { initialize_grid(Post) }
but it's can not skip Post's default_scope

so, I modify you source code like this:
http://pasite.org/code/279
I add "skip_default_scope" into "options" and default was true, because sometime I used wice_grid in Admin Panel, I want to list all of the records.

Integer column copywriter feature

Hello Yuri,

I found most users just want to search the exact value instead a range search of an Integer.

So I hacked into the ViewColumnInteger class in view_column.rb, and make a simple javascript addon to line 196

opts1 = {:size => 3, :id => @dom_id, :onkeyup=>"$(#{@dom_id2}).value=$(this).value"}

This will enlighten user experience a bit without losing usefulness of range search abilty.

Excel export?

I would like to not only have .csv export, but proper MS-Excel export as well, maybe by using the Ruby Spreadsheet gem in connection with Wice Grid? Thank you for the great Wice Grid, it really rocks, btw!

No upgrade strategy exists

Running
script/plugin install git://github.com/leikind/wice_grid.git
script/generate wice_grid_assets
in a setup having already wice_grid configured leads to unpredictable results.

A upgrade strategy from previous versions of wice_grid could be helpful. In the meantime, copying wice_grid_assets by hand helps.

polymorphic associations

Great grid! I really like it.

I have one problem. I can't figure out how to get a polymorphic relationship working, as I have to specify the class name explicitly for any joins.

Could you help? Thanks,

Export to CSV doesn't start download but renders tempfile path

Hi,

another problem I have run into: In my new application (Rails 2.3.8), I have enabled export_to_csv. When clicking the export button, there is no file download starting, but the only thing that happens is a new page with only the path to the tmpfile (the csv) rendering in the view, something like:

/var/folders/3N/3NYKFtItHaCuQL6h0KVbkk+++TI/-Tmp-/channels_7068020100831-1170-x3xr6a-0

for my grid named "channels".

I have browsed the code a bit but I cannot see the actual call to send the csv to the browser. If possible, I would like to use apache's x-sendfile for sending the data, but of course getting it to work at all is the priority.

Thank you for looking into this.

jQuery + :negation_in_filter always submits =1, regardless of checkbox.checked

I traced to code in generators/wice_grid_jquery.js:read_values_and_form_query_string function, where line
res.push(templates[i] + encodeURIComponent(val));
is called for a checkbox, regardless of its "checked" state. According to HTML spec, checkboxes always have value set, and the submit only posts value when the checkbox is checked. Therefore, the code should not run if the control is a checkbox and it is is not checked.

using current_page_records and all_pages_records from controller (e.g. for XML format)

I am trying to make XML export for index action. Trying this pattern:

  def index
    @objects_grid = initialize_grid(Users)
    unless export_grid_if_requested
      respond_to do |format|
        format.html
        format.xml  { render :xml => @objects_grid.current_page_records }
      end
    end
  end

It does not work (as explained nicely in README/Accessing Records Via The WiceGrid Object). I think it is very good use case though. It will allow any export format without a need to mess with wice_grid internals. It would be acceptable to require a partial with grid to return records properly, something like this:

  def index
    @objects_grid = initialize_grid(Users)
    unless export_grid_if_requested
      respond_to do |format|
        format.html
        format.xml  { render :xml => @objects_grid.current_page_records(:partial => 'users_grid') }
      end
    end
  end

Any recommendations?

SUM column and ordering

Hello Yuri,

another thing I just ran into: I have a few grids where there are functions as columns, i.e. sum, like this

SELECT ..., SUM(QUANTITY) AS QTY_SUM, ...

Now in the grid, I am not able to sort this column because the column isn't an attribute, but the result of a calculation on an attribute.
MySQL itself has no problems doing an ORDER BY SUM(QUANTITY), but I have no idea how to get Wice Grid to bypass the check if the column name is present. Is there a way? If not, it would be great to have this feature, as it is often needed, and I hereby request it.

Thank you

Date filter and timezone

It appears that the dates entered into the datetime filter are UTC, while the grid shows the datetimes in timezone set by config.time_zone

I fiddled around, and this change to the wice_grid_config.rb seems to be sufficient to make it honor the config setting:

  Wice::Defaults::DATETIME_PARSER = lambda{|datetime_string| Time.zone.parse(datetime_string) }

(Using Time.zone.parse instead of DateTime.parse)
Same change looks appropriate for DATE_PARSER.

:select

See if it is possible to add :select to initialize_grid

group omitted from ar options

Hi Yuri,

I would like to be able to pass a group option to the wice grid options because I want to display sums in my resultset. Glancing over the code, I see no particular problem why GROUP BY might be omitted from the available wice grid options. It could be passed along just like conditions or select.

Was there any reason I might be overlooking which led you to not include the GROUP BY option? If not, I'll try to give it a shot.

Thank you
Ben

Foot row total have a bug!

My data table had 20 million+ rows,I don't need all row total, because I too slow with count(*) from big tables.

I need a param to set toggle show/hide Row Total.

uninitialized constant Wice::JsAdaptor

I'm using latest wice_grid with Rails 2.3.8. Error log:

Showing app/views/layouts/application.html.erb where line #10 raised:

uninitialized constant Wice::JsAdaptor

Extracted source (around line #10):

7:
8: <%= stylesheet_link_tag 'formtastic', 'formtastic_changes' %>
9: <%= javascript_include_tag :defaults %>
10: <%= include_wice_grid_assets %>
11: <%= yield :head %>
12:
13:

RAILS_ROOT: /home/max/Rails/cts2
Application Trace | Framework Trace | Full Trace

/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:440:in load_missing_constant' /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:inconst_missing'
/home/max/Rails/cts2/vendor/plugins/wice_grid/lib/helpers/wice_grid_misc_view_helpers.rb:62:in include_wice_grid_assets' /home/max/Rails/cts2/app/views/layouts/application.html.erb:10:in_run_erb_app47views47layouts47application46html46erb'
/home/max/Rails/cts2/app/controllers/records_controller.rb:27:in `index'


I have not found the JsAdaptor declaration in the plugin files.
Thanks god I don't need calendar widget :)

Add filter to virtual column

Hi!
I have a virtual column: STATUS that comes from a few terms. I plan to use Detach_with_id.
How can I do this without having to create a new column?

PS.: I stated in the model attr_accessor :status but still have problems.

Browser this message:
WiceGrid: Column 'status' is not found in table 'transacoes'! If 'status' belongs to another table you should declare it in :include or :join when initialising the grid, and specify :model_class in column declaration.

ajaxification

Ability of WiceGrid to reload itself inside its container

CSV export is not using filters

Yo!!, 1st I'd like to say thanks for this awesome plugin.

Currently I'm migrating from an older version of the plugin (prototype based) to the latest one using jQuery, almost everything is working fine but I'm having a weird issue while trying to export a csv file, it seems like it's skipping the filter, If I try to export a csv file from the current filtered result, the csv is being generated with the initial records instead of the filtered ones :(. Any Idea why this is happening? This is how one of my actions looks now:

def index
  @transports = initialize_grid(Transport, 
    :include => [:survey, :pickup, :client, {:dropoff => :company}],
    :conditions => "surveys.transport_id IS NULL",
    :enable_export_to_csv => true,
    :per_page => 30,
    :csv_file_name => 'transports'
  )
  export_grid_if_requested(:grid => "transports_grid")
end

Any help would be appreciated, thanks!

will_paginate gem is not detected by wice_grid, only works when installed as a plugin

If will_paginate is installed as a gem, e.g. with

jruby -S gem install mislav-will_paginate

the following stacktrace occurs:

$ RAILS_ENV=development jruby script/server
=> Booting WEBrick
=> Rails 2.3.3 application starting on http://0.0.0.0:3000
/home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:443:in load_missing_constant': uninitialized constant WillPaginate (NameError) from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:80:inconst_missing_with_dependencies'
from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:92:in const_missing' from /home/lowry/hobby/buh/vendor/plugins/wice_grid/lib/grid_renderer.rb:9 from /home/lowry/hobby/buh/vendor/plugins/wice_grid/lib/grid_renderer.rb:31:inrequire'
from /home/lowry/lib/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require' from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:156:inrequire'
from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:521:in new_constants_in' from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:156:inrequire'
from /home/lowry/hobby/buh/vendor/plugins/wice_grid/lib/wice_grid.rb:4
from /home/lowry/hobby/buh/vendor/plugins/wice_grid/lib/wice_grid.rb:31:in require' from /home/lowry/lib/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:156:in require' from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:521:innew_constants_in'
from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:156:in require' from /home/lowry/hobby/buh/vendor/plugins/wice_grid/init.rb:1:inevaluate_init_rb'

The usual

config.gem "will_paginate", :version => '2.3'

within the Rails::Initializer.run does not work.

csv export not working in production environment

Used versions:

$ bundle list rails
/home/timo/.rvm/gems/ruby-1.8.7-p334@lempack/gems/rails-3.0.3

$ bundle list wice_grid
/home/timo/.rvm/gems/ruby-1.8.7-p334@lempack/gems/wice_grid-3.0.0.pre3

Symptoms:

In development mode csv export works like a charm:

rails s
...........
Started GET "/admin/orders?orders[export]=csv" for 127.0.0.1 at Wed May 04 16:52:58 +0200 2011
Processing by Admin::OrdersController#index as HTML
Parameters: {"orders"=>{"export"=>"csv"}}
User Load (0.1ms) SELECT users.* FROM users WHERE (users.id = 8) LIMIT 1
Role Load (0.1ms) SELECT roles.* FROM roles INNER JOIN assignments ON roles.id = assignments.role_id WHERE ((assignments.user_id = 8))
Order Load (0.1ms) SELECT orders.* FROM orders ORDER BY orders.magento_id asc
Rendered admin/orders/_orders_grid.html.haml (85.9ms)
Sent file /tmp/orders20110504-15409-u88tk4-0 (0.1ms)
Completed 200 OK in 225ms

-> That's ok, the csv looks good.

Unfortunately the very same request doesnt work in production:

rails s -e production
...................
Started GET "/admin/orders?orders[export]=csv" for 127.0.0.1 at Wed May 04 16:56:17 +0200 2011
Processing by Admin::OrdersController#index as HTML
Parameters: {"orders"=>{"export"=>"csv"}}
Rendered admin/orders/_orders_grid.html.haml (101.6ms)
Sent file /tmp/orders20110504-15877-467q6z-0 (0.1ms)
Completed 200 OK in 105ms

The csv file gets send back, but it's empty. Note that the csv export doesn't work for any of my models in production (all of which are standard AR models).

The problem is apparently that this query isnt executed (among others):

Order Load (0.1ms) SELECT orders. FROM orders ORDER BY orders.magento_id asc*

Seems like an issue with query caching - but this doesn't make sense since the csv export is triggered by a totally separate request (and actually I can see in the logs that this query hasn't been executed ever).

Anything obvious I am missing here?

Sorting of dropdown filters

Automatically populated dropdown filters should be sorted.

I would assume that when the options are provided by the application in array or hash form, it's the responsibility of the app to ensure the ordering, my humble $.02. :)

localization

WiceGrid should optionally support Rails API for localization

CSV import send_file + short living tempfiles + X-Sendfile

CSV import send_file + short living tempfiles + X-Sendfile= problem

send_file in Rails 3 by default uses headers to have the web server send the file. Thus, this is a separate HTTP request and by that time the tempfile in which the CSV data might already have been deleted.

Commenting line config.action_dispatch.x_sendfile_header = "X-Sendfile" forces send_file to send the file the old way, from the same request, but this is not a good solution because it forces all other calls to send_file to do so.

Group actions

Hi

Did you think about group actions? One column with checkboxes and buttons like: "Delete selected", "Mark as read", etc

Thanks

Deleting selected records

Hi!

I'm trying to delete multiple records. Added the g.action_column but can not create the button to send the parameters of the selected records to the controller. Can you help me? Give some idea of how to do?

Thanks so much

Fillipe Norton

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.