admin-panel 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d576adba9f3f426390beb98ce565a2dd3f9cad6c
4
- data.tar.gz: b0b7c5cbabace377af3932220d4b8b259b5bc64d
3
+ metadata.gz: 1bf5b58ee1a00b74bdb5a6024a683cbbeeb43e06
4
+ data.tar.gz: c19d95f38cc2e2ea6749ba2727da21f4c5616306
5
5
  SHA512:
6
- metadata.gz: 7767e7da9205c126aa2b6a90595f7d65fb0c2445009e948dd6ced8c64d4390695a51932487be12d255d13e1e313126e7c9e5162d844fd8cdfaaa4e207f4487c3
7
- data.tar.gz: c67f7de6a57171029cf9b55db6140691629254c6ac261a001cc55ffc9ec77556d70ec8ad89398b9d51f9f6920ddf8fdb6144e0e1d9c1c1b397723d49f73e235c
6
+ metadata.gz: 76a72acf852f9706c05b987f870b440749738995e5d99270283cf6d28c7da3f54c39b19b01189b4415c1faacbba1cf17948b65503a09a21792e924037eeebb24
7
+ data.tar.gz: fdad1aea621dd26acb342a792b730f22ed0880d1a04f4a7c3a1fcffb3bd5f790522e1082bbd8ab67c7821386ae134a0ed6f098cca7eb89d4f94abc9ea47a1cfc
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- admin-panel (0.1.2)
4
+ admin-panel (0.1.3)
5
5
  bootstrap-sass (~> 3.1)
6
6
  devise (~> 3.2)
7
7
  kaminari (~> 0.16)
data/README.md CHANGED
@@ -57,3 +57,5 @@ Things that'd be nice to have:
57
57
  - ~~kaminari/will_paginate support~~
58
58
  - I liked the idea of copying the files to your project during install at first but now it just seems silly; I should probably rewrite everything from scratch to work more similarly to Devise, including the ability to extend default controllers where necessary
59
59
  - I was also supposed to add Carrierwave support too but ran out of time
60
+ - sorting
61
+ - ~~per page count selector~~
@@ -1,3 +1,3 @@
1
1
  module AdminPanel
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
@@ -1 +1,5 @@
1
- @import 'bootstrap';
1
+ @import 'bootstrap';
2
+
3
+ .per-page {
4
+ margin: $line-height-computed 0;
5
+ }
@@ -16,4 +16,8 @@ module AdminHelper
16
16
  end
17
17
  end.compact
18
18
  end
19
+
20
+ def per_page_class(klass, i)
21
+ (params[:per_page].to_i == i || (params[:per_page].nil? && klass.default_per_page == i)) ? 'btn-primary' : 'btn-default'
22
+ end
19
23
  end
@@ -9,7 +9,7 @@ class <%= prefixed_controller_class_name %>Controller < <%= parent_controller_cl
9
9
 
10
10
  # GET <%= prefixed_route_url %>
11
11
  def index
12
- @<%= plural_table_name %> = <%= class_name %>.page params[:page]
12
+ @<%= plural_table_name %> = <%= class_name %>.page(params[:page]).per(params[:per_page])
13
13
  end
14
14
 
15
15
  # GET <%= prefixed_route_url %>/1
@@ -34,6 +34,15 @@
34
34
  </tbody>
35
35
  </table>
36
36
 
37
- <div class="text-center">
38
- <%%= paginate @<%= plural_table_name %>, theme: 'admin-bootstrap' %>
39
- </div>
37
+ <div class="row">
38
+ <div class="col-md-8">
39
+ <%%= paginate @<%= plural_table_name %>, theme: 'admin-bootstrap' %>
40
+ </div>
41
+ <div class="col-md-4 text-right">
42
+ <div class="btn-group per-page">
43
+ <%% [ 10, 25, 100, 250, 500, 1000 ].each do |i| %>
44
+ <%%= link_to i, { action: :index, page: params[:page], per_page: i }, class: "btn #{per_page_class(<%= class_name %>, i)}" %>
45
+ <%% end %>
46
+ </div>
47
+ </div>
48
+ </div>
@@ -29,5 +29,10 @@
29
29
  %td.text-right
30
30
  = link_to 'Destroy', <%= "[:#{prefix}, #{singular_table_name}]" %>, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger'
31
31
 
32
- .text-center
33
- = paginate @<%= plural_table_name %>, theme: 'admin-bootstrap'
32
+ .row
33
+ .col-md-8
34
+ = paginate @<%= plural_table_name %>, theme: 'admin-bootstrap'
35
+ .col-md-4.text-right
36
+ .btn-group.per-page
37
+ - [ 10, 25, 100, 250, 500, 1000 ].each do |i|
38
+ = link_to i, { action: :index, page: params[:page], per_page: i }, class: "btn #{per_page_class(<%= class_name %>, i)}"
@@ -18,7 +18,12 @@ describe AdminPanel::Generators::ScaffoldGenerator do
18
18
  subject { file('app/controllers/admin/posts_controller.rb') }
19
19
  it { should exist }
20
20
  it { should contain 'include Administrable' }
21
- it { should contain '@posts = Post.all' }
21
+ it { should contain '@posts = Post.page(params[:page]).per(params[:per_page])' }
22
+
23
+ [ :index, :new, :edit, :create, :update, :show, :destroy ].each do |action|
24
+ it { should contain "def #{action.to_s}" }
25
+ end
26
+
22
27
  end
23
28
 
24
29
  it_should_exist 'app/views/admin/posts/index.html.erb'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: admin-panel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michał Matyas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-25 00:00:00.000000000 Z
11
+ date: 2014-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler