Coder Social home page Coder Social logo

sology / smart_listing Goto Github PK

View Code? Open in Web Editor NEW
478.0 16.0 137.0 401 KB

Ruby on Rails data listing gem with built-in sorting, filtering and in-place editing.

Home Page: http://showcase.sology.eu/smart_listing

License: MIT License

Ruby 70.17% HTML 26.90% JavaScript 2.22% CSS 0.70%

smart_listing's Introduction

SmartListing

SmartListing helps creating AJAX-enabled lists of ActiveRecord collections or arrays with pagination, filtering, sorting and in-place editing.

See it in action

Installation

Add to your Gemfile:

gem "smart_listing"

Then run:

$ bundle install

Also, you need to add SmartListing to your asset pipeline:

//= require smart_listing

Rails >= 5.1 users: Rails 5.1 has dropped jQuery dependency from the default stack in favour of rails-ujs. SmartListing still requires jQuery so make sure that you use jquery_ujs from jquery-rails gem and have following requires in your asset pipeline before smart_listing:

//= require jquery
//= require jquery_ujs

Initializer

Optionally you can also install some configuration initializer:

$ rails generate smart_listing:install

It will be placed in config/initializers/smart_listing.rb and will allow you to tweak some configuration settings like HTML classes and data attributes names.

Custom views

SmartListing comes with some built-in views which are by default compatible with Bootstrap 3. You can easily change them after installing:

$ rails generate smart_listing:views

Files will be placed in app/views/smart_listing.

Usage

Let's start with a controller. In order to use SmartListing, in most cases you need to include controller extensions and SmartListing helper methods:

include SmartListing::Helper::ControllerExtensions
helper  SmartListing::Helper

Next, put following code in controller action you desire:

@users = smart_listing_create(:users, User.active, partial: "users/listing")

This will create SmartListing named :users consisting of ActiveRecord scope User.active elements and rendered by partial users/listing. You can also use arrays instead of ActiveRecord collections. Just put array: true option just like for Kaminari.

In the main view (typically something like index.html.erb or index.html.haml), use this method to render listing:

smart_listing_render(:users)

smart_listing_render does some magic and renders users/listing partial which may look like this (in HAML):

- unless smart_listing.empty?
  %table
    %thead
      %tr
        %th User name
        %th Email
    %tbody
      - smart_listing.collection.each do |user|
        %tr
          %td= user.name
          %td= user.email

  = smart_listing.paginate
- else
  %p.warning No records!

You can see that listing template has access to special smart_listing local variable which is basically an instance of SmartListing::Helper::Builder. It provides you with some helper methods that ease rendering of SmartListing:

  • Builder#paginate - renders Kaminari pagination,
  • Builder#pagination_per_page_links - display some link that allow you to customize Kaminari's per_page,
  • Builder#collection - accesses underlying list of items,
  • Builder#empty? - checks if collection is empty,
  • Builder#count - returns collection count,
  • Builder#render - basic template's render wrapper that automatically adds smart_listing local variable,

There are also other methods that will be described in detail below.

If you are using SmartListing with AJAX on (by default), one last thing required to make pagination (and other features) work is to create JS template for main view (typically something like index.js.erb):

<%= smart_listing_update(:users) %>

Sorting

SmartListing supports two modes of sorting: implicit and explicit. Implicit mode is enabled by default. In this mode, you define sort columns directly in the view:

- unless smart_listing.empty?
  %table
    %thead
      %tr
        %th= smart_listing.sortable "User name", :name
        %th= smart_listing.sortable "Email", :email
    %tbody
      - smart_listing.collection.each do |user|
        %tr
          %td= user.name
          %td= user.email

  = smart_listing.paginate
- else
  %p.warning No records!

In this case :name and :email are sorting column names. Builder#sortable renders special link containing column name and sort order (either asc, desc, or empty value).

You can also specify default sort order in the controller:

@users = smart_listing_create(:users, User.active, partial: "users/listing", default_sort: {name: "asc"})

Implicit mode is convenient with simple data sets. In case you want to sort by joined column names, we advise you to use explicit sorting:

@users = smart_listing_create :users, User.active.joins(:stats), partial: "users/listing",
                              sort_attributes: [[:last_signin, "stats.last_signin_at"]],
                              default_sort: {last_signin: "desc"}

Note that :sort_attributes are array which of course means, that order of attributes matters.

There's also a possibility to specify available sort directions using :sort_dirs option which is by default [nil, "asc", "desc"].

List item management and in-place editing

In order to allow managing and editing list items, we need to reorganize our views a bit. Basically, each item needs to have its own partial:

- unless smart_listing.empty?
  %table
    %thead
      %tr
        %th= smart_listing.sortable "User name", "name"
        %th= smart_listing.sortable "Email", "email"
        %th
    %tbody
      - smart_listing.collection.each do |user|
        %tr.editable{data: {id: user.id}}
          = smart_listing.render partial: 'users/user', locals: {user: user}
      = smart_listing.item_new colspan: 3, link: new_user_path

  = smart_listing.paginate
- else
  %p.warning No records!

<tr> has now editable class and data-id attribute. These are essential to make it work. We've used also a new helper: Builder#new_item. It renders new row which is used for adding new items. :link needs to be valid url to new resource action which renders JS:

<%= smart_listing_item :users, :new, @new_user, "users/form" %>

Note that new action does not need to create SmartListing (via smart_listing_create). It just initializes @new_user and renders JS view.

New partial for user (users/user) may look like this:

%td= user.name
%td= user.email
%td.actions= smart_listing_item_actions [{name: :show, url: user_path(user)}, {name: :edit, url: edit_user_path(user)}, {name: :destroy, url: user_path(user)}]

smart_listing_item_actions renders here links that allow to edit and destroy user item. :show, :edit and :destroy are built-in actions, you can also define your :custom actions. Again. <td>'s class actions is important.

Controller actions referenced by above urls are again plain Ruby on Rails actions that render JS like:

<%= smart_listing_item :users, :new, @user, "users/form" %>
<%= smart_listing_item :users, :edit, @user, "users/form" %>
<%= smart_listing_item :users, :destroy, @user %>

Partial name supplied to smart_listing_item (users/form) references @user as object and may look like this:

%td{colspan: 3}
  - if object.persisted?
    %p Edit user
  - else
    %p Add user

  = form_for object, url: object.new_record? ? users_path : user_path(object), remote: true do |f|
    %p
      Name:
      = f.text_field :name
    %p
      Email:
      = f.text_field :email
    %p= f.submit "Save"

And one last thing are create and update controller actions JS view:

<%= smart_listing_item :users, :create, @user, @user.persisted? ? "users/user" : "users/form" %>
<%= smart_listing_item :users, :update, @user, @user.valid? ? "users/user" : "users/form" %>

Controls (filtering)

SmartListing controls allow you to change somehow presented data. This is typically used for filtering records. Let's see how view with controls may look like:

= smart_listing_controls_for(:users) do
  .filter.input-append
    = text_field_tag :filter, '', class: "search", placeholder: "Type name here", autocomplete: "off"
    %button.btn.disabled{type: "submit"}
      %span.glyphicon.glyphicon-search

This gives you nice Bootstrap-enabled filter field with keychange handler. Of course you can use any other form fields in controls too.

When form field changes its value, form is submitted and request is made. This needs to be handled in controller:

users_scope = User.active.joins(:stats)
users_scope = users_scope.like(params[:filter]) if params[:filter]
@users = smart_listing_create :users, users_scope, partial: "users/listing"

Then, JS view is rendered and your SmartListing updated. That's it!

Simplified views

You don't need to create all the JS views in case you want to simply use one SmartListing per controller. Just use helper methods without their first attribute (name) ie. smart_listing_create(User.active, partial: "users/listing"). Then define two helper methods:

  • smart_listing_resource returning single object,
  • smart_listing_collection returning collection of objects.

SmartListing default views will user these methods to render your list properly.

More customization

Apart from standard SmartListing initializer, you can also define custom config profiles. In order to do this, use following syntax:

SmartListing.configure(:awesome_profile) do |config|
  # put your definitions here
end

In order to use this profile, create helper method named smart_listing_config_profile returning profile name and put into your JS SmartListing.config.merge() function call. merge() function expects parameter with config attributes hash or reads body data-attribute named smart-listing-config. Hash of config attributes can be obtained by using helper method SmartListing.config(:awesome_profile).to_json.

Not enough?

For more information and some use cases, see the Showcase

Credits

SmartListing uses great pagination gem Kaminari https://github.com/amatsuda/kaminari

Created by Sology http://www.sology.eu

Initial development sponsored by Smart Language Apps Limited http://smartlanguageapps.com/

smart_listing's People

Contributors

aaklak avatar akostadinov avatar ardahaal avatar blackcofla avatar boy-papan avatar bval avatar gcorbel avatar georgedewar avatar kitabatake avatar korun avatar ljachymczyk avatar marcintichoniuk avatar nfilzi avatar phoffer avatar sevgibson avatar tylerhunt avatar wynksaiddestroy 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

smart_listing's Issues

Update row

Hi

I have a very simple smart_listing with an action, based on the in place editing example :

    %tbody
      - smart_listing.collection.decorate.each do |golf|
        %tr.editable
          = smart_listing.render object: golf, partial: "admin/homepage/promoted_golfs/row", locals: { object: golf }
%td.actions= smart_listing_item_actions [ { name: :custom, url:  toggle_admin_homepage_promoted_golf_path(object), method: :put, icon: "glyphicon #{object.promoted? ? 'glyphicon-remove-circle' : 'glyphicon-ok-circle' }", remote: true } ]

The call is ok and returns :

var smart_listing = $('#golfs').smart_listing();
smart_listing.update(41, true, "<td>41<\/td>\n<td>Golf de Guerville<\/td>\n<td>35.0<\/td>\n<td>55<\/td>\n<td>\n  <span class=\'glyphicon glyphicon-ok\'><\/span>\n<\/td>\n<td class=\'actions\'>\n  <span>\n  <a data-method=\"put\" data-remote=\"true\" href=\"/admin/homepage/promoted_golfs/golf-de-guerville/toggle\" name=\"custom\" rel=\"nofollow\"><span class=\"glyphicon glyphicon-remove-circle\"><\/span><\/a>\n  <\/span>\n<\/td>\n");

But the row is not updated, and there's no js errors showing up

If you have any idea why, I've been stucked on this for an hour now

Incompatible with Turbolinks?

I've experienced an issue with smart_listing and turbolinks. If a site is rendered via turbolinks (without a full reload) jQuerys ready() method won't be triggered. Therefore parts like

$(function() {
  $('.smart-listing').smart_listing();
  return $('.smart-listing-controls').smart_listing_controls();
});

wont' work. I simply installed the jquery-turbolinks gem to solve the problem, but maybe you want to have look at the issue.

Thanks for your effort and passion you put in this lovely gem

Group by issue

How can I use smat listing with group by?

I have within the controller:

@stats = smart_listing_create(:stats, Log.group('cmd').order('1 DESC').count(:cmd), partial: "stats/list")

I can see at the console:

Started GET "/stats" for 10.0.16.12 at 2015-02-25 18:28:24 +0100
Processing by StatsController#index as HTML
   (31.9ms)  SELECT COUNT("logs"."cmd") AS count_cmd, cmd AS cmd FROM "logs" GROUP BY cmd
Completed 500 Internal Server Error in 35ms

NoMethodError (undefined method `page' for #<Hash:0x007f62a9a98270>):
  app/controllers/stats_controller.rb:11:in `index'

Is it possible to use the group by? Can you help me?

Performance Issue

The page rendering is too slow in my app, could it be due to that i'm using slim as template engine?.

Here are some logs.

Started GET "/groups?groups_smart_listing%5Bpage%5D=&groups_smart_listing%5Bper_page%5D=10&groups_smart_listing%5Bsort%5D%5Bname%5D=desc" for 10.0.2.2 at 2014-05-22 21:13:27 -0400
Processing by GroupsController#index as JS
  Parameters: {"groups_smart_listing"=>{"page"=>"", "per_page"=>"10", "sort"=>{"name"=>"desc"}}}
   (2.0ms)  SELECT COUNT(*) FROM "groups"
  Rendered smart_listing/_sortable.html.slim (1.5ms)
  Group Load (7.5ms)  SELECT  "groups".* FROM "groups"   ORDER BY name desc LIMIT 10 OFFSET 0
  Rendered smart_listing/_action_delete.html.slim (0.5ms)
  Rendered groups/_group.html.slim (310.0ms)
  Rendered smart_listing/_action_delete.html.slim (0.7ms)
  Rendered groups/_group.html.slim (494.2ms)
  Rendered smart_listing/_action_delete.html.slim (0.8ms)
  Rendered groups/_group.html.slim (396.5ms)
  Rendered smart_listing/_action_delete.html.slim (0.9ms)
  Rendered groups/_group.html.slim (459.3ms)
  Rendered smart_listing/_action_delete.html.slim (0.7ms)
  Rendered groups/_group.html.slim (472.6ms)
  Rendered smart_listing/_action_delete.html.slim (1.8ms)
  Rendered groups/_group.html.slim (474.5ms)
  Rendered smart_listing/_action_delete.html.slim (4.4ms)
  Rendered groups/_group.html.slim (456.4ms)
  Rendered smart_listing/_action_delete.html.slim (1.4ms)
  Rendered groups/_group.html.slim (435.2ms)
  Rendered smart_listing/_action_delete.html.slim (0.5ms)
  Rendered groups/_group.html.slim (473.0ms)
  Rendered smart_listing/_action_delete.html.slim (0.6ms)
  Rendered groups/_group.html.slim (551.8ms)
  CACHE (0.0ms)  SELECT COUNT(*) FROM "groups"
  Rendered smart_listing/_pagination_per_page_link.html.slim (0.3ms)
  Rendered smart_listing/_pagination_per_page_link.html.slim (0.3ms)
  Rendered smart_listing/_pagination_per_page_link.html.slim (0.5ms)
  Rendered smart_listing/_pagination_per_page_links.html.slim (1412.1ms)
  Rendered groups/_list.html.slim (11373.5ms)
  Rendered /usr/local/rvm/gems/ruby-2.1.0@betsman/gems/smart_listing-1.0.0/app/views/smart_listing/_update_list.js.erb (11879.7ms)
  Rendered groups/index.js.slim (12185.2ms)
Completed 200 OK in 12716ms (Views: 12701.6ms | ActiveRecord: 9.6ms)

CSS issue for smart_listing show action

Hello,

I' ve noticed, that automatically generated show action link has something like this in its CSS:

a.show
    display: block !important

The issue is I did not want for it to be displayed as block, so I had to overwrite this in my CSS with more classes and another !important. This is a problem, because !important is generally a bad practice in CSS, as people can wonder why their modifications don' t just work if they oversee it or don' t look into the CSS, and also I think that it should have the same options as other actions by default - the user can then change it for their project if they want to.

Missing show-action for in-place editing

I tried to add a show-action that works in-place, but I just saw, that there are several places, where I have to dig into your code:

  • a new show.js.erb
  • additions in smart_listing.coffee.erb
  • adding :showto smart_listing_item in helpers/smart_listing/helper.rb
  • etc...
    I would appreciate just having it in your next release. Should be really simple for you :-)

The functional need is simple: I have got a lot of more fields in a data entity than I will show as table columns.

multiple filters in controls_for

When creating an array for bulk actions, only the last id gets passed to params on submit.

I created 12 checkboxes with the name status_id[]. At any given point, it would only pass in the last id instead of an array. A short term "workaround" i found was adding passing in the id into the array, but then instead of an array of values, you would get an array of key value pairs.

Config not effective

Hi,

I tried to configure the default per_page through the SmartListing.configure block, with the helper and all, but it did not work. I tried to doi through Kaminari, but it does not work either !
I want a per_page to 25 but it seems stucked to 10.
Event with the page_size option (wich I have to implement manually as config does not works at all) when I click 25, it keeps 10 rows, same for 30, but it does works for 50.
This drive me crazy,

any idea ?

Sort link don't work with sort_attributes

Hi,

When I activate the option sort_attributes in my controller, links to sort in my view no longer work. sorts are blockes on asc.

# My controller
def index
    @plots = smart_listing_create(
              :plots,
              Plot.joins(:camping),
              partial: "plots/listing",
              sort_attributes: [[:camping_name, "campings.name"],[:number, "number"],[:surface, "surface"]],
              #sort_dirs: [nil, "asc", "desc"],
              default_sort: {number: "asc"})
end
# My view
- unless smart_listing.empty?
  %table.table
    %thead
      %tr
        %th= smart_listing.sortable Plot.human_attribute_name(:number), "number"
        %th= smart_listing.sortable Plot.human_attribute_name(:surface), "surface"
        %th= smart_listing.sortable Plot.human_attribute_name(:camping), "camping_name"
        %th= Plot.human_attribute_name(:comment)

Thx

Can't use filters

Can you explain why following your examples exactly for the filtering continues to result in either:

undefined method like' for #<Array or undefined methodlike' for #<ActiveRecord::Relation
?

I've tried using Model.all and Model.scope and it's the same issue every time. It's getting extremely frustrating to try and figure out why I'm forced to set my smart_listing_collection as array: true but then can't use filtering. And if I turn array: true off, I get

undefined method `page' for #<Array:

What is the trick to using filters on my models? I don't want to use a scope, I just want to return all records in my smart_listing table and allow users to filter by name or year (it's a collection of music albums).

Export data

It will be awesome to have a way to export the filtered data.

Smart_listing_create only contains three results

This looks like a fantastic gem, but I'm having a strange issue.

@restaurants = Restaurant.all
returns 32 results, but

@restaurants = smart_listing_create(:restaurants, Restaurant.all, partial: "restaurants/list")
only returns 3. Am I doing something stupid?

Using wrong ajax URL when turbolinks activated

Steps to reproduce in an app with turbolinks:

  1. Visit a page that doesn't use smart_listing (e.g. faq page, /faq)
  2. Click on a link that leads to the page using smart_listing (e.g. /books)
  3. Click on a filter or anything that causes a reload of the results

When using the standard smart_listing configuration, it tries to load the results from /faq?filter1=val&filter2=val. Internally, smart_listing is calling $.rails.handleRemote which cannot find a proper URL/ href so that $.ajax is using a cached version of location.href (which points the initially loaded URL /faq).

Workaround: Adding an explicit href to smart_listing_create call: smart_listing_create ..., href: books_path

Potential fix to discuss: The default value for href is nil (https://github.com/Sology/smart_listing/blob/master/lib/smart_listing.rb#L35), perhaps we should set it the current path via url_for?

Sortable helper not working for me - please help!

Love the gem guys. I successfully implemented it on a previous project. I am building a simple app now and really struggling with an error when trying to sort and paginate a simple table of sent messages in an outbox:

ActionController::UrlGenerationError in Messages#sent

No route matches {:action=>"sent", :authenticity_token=>nil, :controller=>"Messages", :sentbox_smart_listing=>{"page"=>nil, "per_page"=>20, "sort"=>{"receiver_id"=>"asc"}}, :utf8=>nil}

The issue is when I include the sortable helper (also the issue appears when I paginate records), e.g:
%th= smart_listing.sortable "Recipient", :receiver_id

My routes are defined as:

get 'messages/trash' => 'messages#trash'

get 'messages/sent' => 'messages#sent'

resources :messages

My smart_listing create code is as follows:

sentbox_scope = Message.where('sender_id = ?', current_user.id).order("created_at DESC")
sentbox_scope = sentbox_scope.like(params[:filter]) if params[:filter]
@sentbox = smart_listing_create(:sentbox, sentbox_scope, array: true, page_sizes: [20], partial: "messages/sentbox")

I have included the appropriate sent.js.erb file as well as the partial. I can trigger the issue when paginating with just 1 record too - so it seems to me that the helper is not working.

I have successfully used this gem on another project so I am pretty sure it's just me doing something wrong - but can't figure out what!!!

Any help would be much appreciated.

Thanks,
James

Simplification and refactoring

Hi,

I think the project needs a simplification. It would be perfect if, to do an admin interface, we just have to do this :

class UserController < ApplicationController
  smart_listing :crud
end

With this simple function call, the controller must have default actions which have the views to do a in place editing like in the demo.

To have a simple list, it should be possible to replace smart_listing :crud by smart_listing :list. All actions and views must to be overwritable.

I can pass some times to do it but, before to start, I need unit tests and acceptances specs. I also need to have a support from Sology.

Please, can you do the tests?

Thanks!

Feature Request: Store current page, sort, etc. in cookie/session

Several users have complained to me that when they return to the listing page (with Smart Listing) the list has started from the beginning again.

It would be great to be able to store the current details in the users session or a cookie so that when they return to the page it would load to the same spot as before, with sort/filter/paging etc.

I have multiple pages with different lists if that makes a difference.

undefined method `smart_listing_update'

I getting this error with this line in the index.js.erb file:
<%= smart_listing_update(:persons) %>

I'm new to Rails and probaly misunderstood some point in the README. I just can't see what I'm doing wrong after go through instructions for some many times now. It might be the the helpers missing or something. I'm including the helpers in the app/controllers/application_controller.rb file.

I'm sorry if it's not an issue. I'm on the 1.0.0 version.

Filter inputs fire off excessive requests to backend when gaining focus

Currently using a filter as per example

.filter.input-append
= text_field_tag :filter, '', class: "search", placeholder: "Type name here", autocomplete: "off"
%button.btn.disabled{type: "submit"}
%i.icon.icon-search

When ever the page containing the filter input gains or loses focus it fires off the request to the backend to retrieve the data. It would make sense to change this so that upon only a keypress up or if the value has actually changed that it sends the request.

Im not sure if there is a use case for it to re send the request every time the page gains focus, for most users tabbing between browser pages is common and its starting to send enormous amounts of traffic without real value.

Changelog is outdated

Although the current version is 1.1.2 the changelog only covers changes up to version 1.1.0.

`jquery-rails` should not be a dependency

It should be up to the gem user to decide how to integrate jQuery in her project.

For example, I use jQuery via bower and I don't want to add jquery-rails as a dependency of my project.

Custom locals for smart_listing partials

I want to be able to pass additional locals for partials used in smart_listing (for example form or list, which are passed by me in smart_listing_item or smart_listing_render). Right now it is not possible.

Sort on an icon column

Is it possible to sort on a column with an icon instead of a standard name?

e.g. I use this to signify a user's email address <i class="fa fa-envelope"></i> (via Font Awesome) and I would like to allow sorting on it.

More sorting options

I would like to have some more options for the sortable helper:

  • Ability to set a default sort order for first click on a column (start with desc instead of asc)
  • Skip nil sort in cycle (3rd click would not trigger a nil sort - this could be a global setting)

Sorting with dates, through methods, ...

1. Methods

Right now we can sort by columns of models and joined models.
Is it possible to sort through a method ?
I tried to use an attr_reader :my_method but it does not work.

class Subscription < ActiveRecord::Base
   ....
  def commitment_end
    @commitment_end = start_at.advance(months: commitment_period.to_i)
  end
end
        %th= smart_listing.sortable t('.end_of_commitment'), :commitment_end

And within sort_attributes : [:commitment_end, 'subscriptions.commitment_end']

2. Dates

When sorting dates, it seems the sort messes up like its a string and sort by alpha...

    smart_listing_create(:users, @users, partial: 'admin/users/listing_red',
                         array: true,
                         kaminari_options: { theme: 'bootstrap3' },
                         sort_attributes: [
                          [:start_at, 'subscriptions.start_at'],
                          [:lastname, 'lastname'],
                          [:firstname, 'firstname'],
                          [:email, 'email']
                         ],
                         default_sort: { start_at: 'desc' }
                         )
        %th= smart_listing.sortable User.human_attribute_name(:lastname), :lastname
        %th= smart_listing.sortable User.human_attribute_name(:firstname), :firstname
        %th= smart_listing.sortable User.human_attribute_name(:email), :email
        %th= smart_listing.sortable t('.started_at'), :start_at

My start_at columns seems not to be sorted at all, whereas others works ok.

The new form is not showed correcly

I'm trying to use this :

<%= smart_listing_item :sightings, :new, @sighting, "sightings/form" %>

The form is a simple form but the result appenned is something like <form></form>fields. I made some test and I have this result :

$('table').first().html('<form>a</form>')
$('table').first().html() // return "<form></form>a"
$('.content').first().html('<form>a</form>')
$('.content').first().html() // return "<form>a</form>"

The first case is correct and the second is not. All childs of 'table' do the samething. I am using the latest version of twitter-bootstrap, rails, etc.

It do the same thing with Chrome and Firefox.

I don't have any idea. Do you have a solution?

Thanks.

kaminari pagination views

Hi

This is a truly awesome gem, just what i have been looking for.

Only one issue that i have which is how i can override the kaminari views.

I have generated them as kaminari docs suggest, they are just never used.

i really just need to make them not center align and have the class pagination-sm.

Any thoughts?

And many thanks again for the gem.

undefined method `per' for ActiveRecord

I'm really excited to use this gem, unfortunately I get the error "undefined method `per' for <ActiveRecord::Relation::..." when using smart_listing_create in my controller

def index
    smart_listing_create(:projects, @projects, partial: "projects/list")
end

What is this method and why is it undefined?

Not compatible with Mongoid

So, although this works amazingly well with ActiveRecord, I was concerned because I could not use this gem. So, I made this fork, but I'm still not 100% sure of its backwards compatibility with ActiveRecord. Would this team be willing to support Mongoid and ActiveRecord, or should I continue to pursue this on my own?

Sorting on integer value not numerical order

I have a list that is being sorted on the numerical order

some values in the column = ["3", "5", "8", "4", "1", "2", "9", "10", "7", "6"]

sorted results = ["1", "10", "2", "3", "4", "5", "6", "7", "8", "9"]

How can I get this to be on integer value NOT numerical order?

undefined local variable or method `smart_listing'

I've read through the readme numerous times and, as far as I can tell, am doing everything exactly as you have it, but continue to get this error with the pagination links and I don't understand why.

controller:
class PlayersController < ApplicationController

require 'will_paginate/array'

include SmartListing::Helper::ControllerExtensions
helper SmartListing::Helper

def index
@players = smart_listing_create :players,
Player.includes(:contracts).includes(:subcontracts).text_search(params[:query]),
partial: "players/players_info_fields"
end
...
end

players#index:
<%= smart_listing_render :players %>

/players/_players_info_fields.html.erb (cutting out a lot of stuff here):
<% @players.each do |player| %>
player.blah
player.blah2
etc

<% end %>
<%= smart_listing.paginate %>
<%= smart_listing.pagination_per_page_links %>

That's where I keep getting the errors. I don't get it. I've tried changing both of those to be @players instead of smart_listing and when I do that, I get "wrong number of arguments (0 for 1)" for @players.paginate.

I've tried:
smart_listing(:players).paginate
@players.smart_listing.paginate
smart_listing(@players).paginate

None of them work. I don't understand why and this is getting extremely frustrating.

smart_listing_controls_for not auto-submitting when values changed

@ljachymczyk I'm having some trouble getting smart_listing_controls_for to auto-submit and update the list.. From what I can tell, the HTML is rendered exactly the same as the demo on http://showcase.sology.eu/smart_listing under 'Controls Form'

Here's the code for the filter bar:

<%= smart_listing_controls_for(:photos, {class: "form-inline text-right"}) do %>
  <div class="form-group filter input-append">
    <%= hidden_field_tag :date_start, date_start.to_i %>
    <%= hidden_field_tag :date_end, date_end.to_i %>
  </div>
<% end %>

Does it make a difference if it's a hidden_field_tag versus a text_field_tag? And just to confirm, it should live outside the smart_listing_render partial?

undefined method `like' for ....

Hi,

Firstly great gem!

I'm getting

undefined method `like' for #Assignment::ActiveRecord_Relation:0x007f783b3c9d70

Any ideas? Rails 4.1

Add Search

I'd love to see global search/filtering ability added

config :page_sizes is not update

I try to change config from default [3, 10, 20 ,50, 100] to [300] in production
and [3] in development

but seem like gem doesn't paginate as i expected and js also cache

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.