Sortable domain list

This commit is contained in:
Martin Lensment 2014-09-05 14:20:49 +03:00
parent 11319b6f36
commit 46921c3e57
4 changed files with 18 additions and 5 deletions

View file

@ -48,6 +48,9 @@ gem 'nprogress-rails', '~> 0.1.3.1'
# for pagination
gem 'kaminari', '~> 0.16.1'
# for searching
gem 'ransack', '~> 1.3.0'
group :assets do
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby

View file

@ -128,6 +128,8 @@ GEM
cliver (~> 0.3.1)
multi_json (~> 1.0)
websocket-driver (>= 0.2.0)
polyamorous (1.1.0)
activerecord (>= 3.0)
polyglot (0.3.5)
powerpack (0.0.9)
pry (0.10.1)
@ -158,6 +160,12 @@ GEM
rainbow (2.0.0)
raindrops (0.13.0)
rake (10.3.2)
ransack (1.3.0)
actionpack (>= 3.0)
activerecord (>= 3.0)
activesupport (>= 3.0)
i18n
polyamorous (~> 1.1)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
@ -266,6 +274,7 @@ DEPENDENCIES
pry (~> 0.10.1)
pry-byebug (~> 1.3.3)
rails (= 4.1.4)
ransack (~> 1.3.0)
rspec-rails (~> 3.0.2)
sass-rails (~> 4.0.3)
sdoc (~> 0.4.0)

View file

@ -1,5 +1,6 @@
class Admin::DomainsController < ApplicationController
def index
@domains = Domain.order(:name).page(params[:page])
@q = Domain.search(params[:q])
@domains = @q.result.page(params[:page])
end
end

View file

@ -6,13 +6,13 @@
%table.table.table-striped.table-bordered.table-condensed
%tr
%th{class: 'col-xs-2'}
= t('shared.name')
= sort_link(@q, 'name')
%th{class: 'col-xs-2'}
= t('shared.registrar')
= sort_link(@q, 'registrar_name', t('shared.registrar'))
%th{class: 'col-xs-2'}
= t('shared.owner')
= sort_link(@q, 'owner_contact_international_address_name', t('shared.owner'))
%th{class: 'col-xs-1'}
= t('shared.valid_to')
= sort_link(@q, 'valid_to', t('shared.valid_to'))
%th{class: 'col-xs-1'}
= t('shared.action')
- @domains.each do |x|