contour 2.4.0.beta1 → 2.4.0.beta2

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: 437703b7d56331d9247a43445a273ee060fa74db
4
- data.tar.gz: 89c9bc5675e5a46655db7c0d885010c89fb09780
3
+ metadata.gz: 310fce2685f889fe7272d0164e812429bb03ce5e
4
+ data.tar.gz: b82b531a51e1b45ae6b3b7d2e914d9314da8d7d8
5
5
  SHA512:
6
- metadata.gz: fc137f49fc6f6e226f0d050bced540b6c06ebfa5dd0dad53246854303d34277c279a993e2e1fe8438e38d874d85398dffb6bffda8d4ce8c83a31a156e0bb279a
7
- data.tar.gz: 9211c3702b21caa44288c4fef3886e6c79259396dcea424950f24992afdb083c2641c19599557e50528bfc9087b074484de59179f830d75b127cd8d4481e2c24
6
+ metadata.gz: 8b1f0ea2d95e77751a1fa0da7107751f41b96d9e6fd542240dbd4cfe61fa0d81b1b91d33e7768db58c59247957b9b6a794fd2238604a9b367e1a027aa86f2c59
7
+ data.tar.gz: c18c9dff02ed41227eee41d73c842bd44992a9cd15201ca2023a3259d0f1060b93f612075db46b30980be0e190a4bf8b9f9f4574ab79941eb22f675f3f1f1740
data/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@
4
4
  - Updated Bootstrap to 3.1.0
5
5
  - **Gem Changes**
6
6
  - Updated to devise 3.2.2
7
+ - Added the suppress-click data-object
8
+ - <a href="#" data-object="suppress-click">Ignore Click</a>
9
+ - Updated layout for contour per page header
10
+
11
+ ### Breaking Changes
12
+ - Removed pagination AJAX methods to reduce overall contour JavaScript footprint
13
+ - `sort_field_helper` updated to work with turbolinks and no longer uses AJAX
14
+
15
+ ### Bug Fix
16
+ - Fixed the per page links to no longer include starting and ending links when the max page is reached
7
17
 
8
18
  ## 2.3.0 (February 3, 2014)
9
19
 
@@ -30,18 +30,6 @@ $(document)
30
30
  catch error
31
31
  # Nothing
32
32
  )
33
- .on('click', ".pagination a, .page a, .next a, .prev a", () ->
34
- return false if $(this).parent().is('.active, .disabled, .per_page')
35
- $.get(this.href, null, null, "script")
36
- false
37
- )
38
- .on("click", ".per_page a", () ->
39
- object_class = $(this).data('object')
40
- $.get($("#"+object_class+"_search").attr("action"), $("#"+object_class+"_search").serialize() + "&"+object_class+"_per_page="+ $(this).data('count'), null, "script")
41
- false
42
- )
43
- .on('click', '[data-object~="order"]', () ->
44
- $('#order').val($(this).data('order'))
45
- $($(this).data('form')).submit()
33
+ .on('click', '[data-object~="suppress-click"]', () ->
46
34
  false
47
35
  )
@@ -4,12 +4,12 @@ module ContourHelper
4
4
  link_to 'Cancel', URI.parse(request.referer.to_s).path.blank? ? root_path : (URI.parse(request.referer.to_s).path), class: 'btn btn-default'
5
5
  end
6
6
 
7
- def sort_field_helper(order, sort_field, display_name, search_form_id = 'search_form')
7
+ def sort_field_helper(order, sort_field, display_name)
8
8
  sort_field_order = (order == sort_field) ? "#{sort_field} DESC" : sort_field
9
9
  symbol = (order == sort_field) ? '&raquo;' : (order == sort_field + ' DESC' ? '&laquo;' : '&laquo;&raquo;')
10
10
  selected_class = (order == sort_field) ? 'selected' : (order == sort_field + ' DESC' ? 'selected' : '')
11
11
  content_tag(:span, class: selected_class) do
12
- display_name.to_s.html_safe + ' ' + link_to(raw(symbol), '#', data: { object: 'order', order: sort_field_order, form: "##{search_form_id}" }, style: 'text-decoration:none')
12
+ display_name.to_s.html_safe + ' ' + link_to(raw(symbol), url_for( params.merge( order: sort_field_order ) ), style: 'text-decoration:none')
13
13
  end.html_safe
14
14
  end
15
15
 
@@ -1,8 +1,29 @@
1
1
  <% pagination_size_hash = { 'large' => 'lg', 'small' => 'sm' } %>
2
+ <% per_page = 20 unless defined?(per_page) and per_page %>
3
+ <% object_count = 0 unless defined?(object_count) and object_count %>
4
+ <% page = params[:page].blank? ? 1 : params[:page].to_i %>
5
+ <% current_page_min = (page - 1)*per_page + 1 %>
6
+ <% current_page_max = page*per_page %>
7
+
2
8
  <ul class="pagination pull-right <%= "pagination-#{pagination_size_hash[pagination_size]}" if defined?(pagination_size) and ['large', 'small'].include?(pagination_size) %>">
3
- <li class="disabled"><span>Per Page</span></li>
4
- <li class="active per_page"><%= link_to (defined?(per_page) && per_page ? per_page : '20'), "#" %></li>
5
- <% if defined?(object_count) and object_count %><li class="disabled"><span>out of <%= object_count %></span></li><% end %>
9
+ <% if current_page_min > 1 %>
10
+ <li><%= link_to '&laquo;'.html_safe, url_for( params.merge( page: page - 1 ) ) %></li>
11
+ <% else %>
12
+ <li class="disabled"><span>&laquo;</span></li>
13
+ <% end %>
14
+
15
+ <li>
16
+ <span style="color:#333">
17
+ <b><%= number_with_delimiter current_page_min %> to <%= number_with_delimiter [current_page_max, object_count].min %></b>
18
+ of <%= number_with_delimiter object_count %>
19
+ </span>
20
+ </li>
21
+
22
+ <% if current_page_max < object_count %>
23
+ <li><%= link_to '&raquo;'.html_safe, url_for( params.merge( page: page + 1 ) ) %></li>
24
+ <% else %>
25
+ <li class="disabled"><span>&raquo;</span></li>
26
+ <% end %>
6
27
  </ul>
7
28
 
8
29
  <div class="clear">&nbsp;</div>
@@ -8,8 +8,8 @@
8
8
  -%>
9
9
  <%= paginator.render do -%>
10
10
  <ul class="pagination pagination-lg">
11
- <%= first_page_tag %> <%# unless current_page.first? %>
12
- <%= prev_page_tag %> <%# unless current_page.first? %>
11
+ <%= first_page_tag unless current_page.first? %>
12
+ <%= prev_page_tag unless current_page.first? %>
13
13
  <% each_page do |page| -%>
14
14
  <% if page.left_outer? || page.right_outer? || page.inside_window? -%>
15
15
  <%= page_tag page %>
@@ -17,7 +17,7 @@
17
17
  <%= gap_tag %>
18
18
  <% end -%>
19
19
  <% end -%>
20
- <%= next_page_tag %> <%# unless current_page.last? %>
21
- <%= last_page_tag %> <%# unless current_page.last? %>
20
+ <%= next_page_tag unless current_page.last? %>
21
+ <%= last_page_tag unless current_page.last? %>
22
22
  </ul>
23
23
  <% end -%>
@@ -8,8 +8,8 @@
8
8
  -%>
9
9
  <%= paginator.render do -%>
10
10
  <ul class="pagination pagination-sm">
11
- <%= first_page_tag %> <%# unless current_page.first? %>
12
- <%= prev_page_tag %> <%# unless current_page.first? %>
11
+ <%= first_page_tag unless current_page.first? %>
12
+ <%= prev_page_tag unless current_page.first? %>
13
13
  <% each_page do |page| -%>
14
14
  <% if page.left_outer? || page.right_outer? || page.inside_window? -%>
15
15
  <%= page_tag page %>
@@ -17,7 +17,7 @@
17
17
  <%= gap_tag %>
18
18
  <% end -%>
19
19
  <% end -%>
20
- <%= next_page_tag %> <%# unless current_page.last? %>
21
- <%= last_page_tag %> <%# unless current_page.last? %>
20
+ <%= next_page_tag unless current_page.last? %>
21
+ <%= last_page_tag unless current_page.last? %>
22
22
  </ul>
23
23
  <% end -%>
@@ -8,8 +8,8 @@
8
8
  -%>
9
9
  <%= paginator.render do -%>
10
10
  <ul class="pagination">
11
- <%= first_page_tag %> <%# unless current_page.first? %>
12
- <%= prev_page_tag %> <%# unless current_page.first? %>
11
+ <%= first_page_tag unless current_page.first? %>
12
+ <%= prev_page_tag unless current_page.first? %>
13
13
  <% each_page do |page| -%>
14
14
  <% if page.left_outer? || page.right_outer? || page.inside_window? -%>
15
15
  <%= page_tag page %>
@@ -17,7 +17,7 @@
17
17
  <%= gap_tag %>
18
18
  <% end -%>
19
19
  <% end -%>
20
- <%= next_page_tag %> <%# unless current_page.last? %>
21
- <%= last_page_tag %> <%# unless current_page.last? %>
20
+ <%= next_page_tag unless current_page.last? %>
21
+ <%= last_page_tag unless current_page.last? %>
22
22
  </ul>
23
23
  <% end -%>
@@ -3,7 +3,7 @@ module Contour
3
3
  MAJOR = 2
4
4
  MINOR = 4
5
5
  TINY = 0
6
- BUILD = "beta1" # nil, "pre", "rc", "rc2"
6
+ BUILD = "beta2" # nil, "pre", "rc", "rc2"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
9
9
  end
@@ -49,7 +49,7 @@ class Contour::ScaffoldGenerator < Rails::Generators::NamedBase
49
49
  end
50
50
 
51
51
  def generate_views
52
- ['_form.html.erb', 'new.html.erb', 'edit.html.erb', 'show.html.erb', 'index.html.erb', 'index.js.erb'].each do |view|
52
+ ['_form.html.erb', 'new.html.erb', 'edit.html.erb', 'show.html.erb', 'index.html.erb'].each do |view|
53
53
  template view, "app/views/#{resource_name_plural}/#{view}"
54
54
  end
55
55
  template '_paginate.html.erb', "app/views/#{resource_name_plural}/_#{resource_name_plural}.html.erb"
@@ -1,10 +1,10 @@
1
- <%%= render partial: 'contour/layouts/per_page', locals: { type: '<%= resource_name_plural %>', per_page: 20, object_count: @<%= resource_name_plural %>.total_count } %>
1
+ <%%= render partial: 'contour/layouts/per_page', locals: { per_page: 20, object_count: @<%= resource_name_plural %>.total_count } %>
2
2
 
3
3
  <table class="table table-striped">
4
4
  <thead>
5
5
  <tr>
6
6
  <%- columns.each do |column| -%>
7
- <th style="white-space:nowrap"><%%== sort_field_helper(@order, '<%= resource_name_plural %>.<%= column.name %>', '<%= column.name.titleize %>', '<%= resource_name_plural %>_search') %></th>
7
+ <th style="white-space:nowrap"><%%== sort_field_helper(@order, '<%= resource_name_plural %>.<%= column.name %>', '<%= column.name.titleize %>') %></th>
8
8
  <%- end -%>
9
9
  <th>Actions</th>
10
10
  </tr>
@@ -2,14 +2,15 @@
2
2
  <div class="page-header">
3
3
  <h1>
4
4
  <%%= @title %>
5
- <%%= link_to "Create <%= resource_title %>", new_<%= resource_name %>_path, class: 'btn btn-xs btn-primary' %>
5
+ <%%= link_to 'Create <%= resource_title %>', new_<%= resource_name %>_path, class: 'btn btn-xs btn-primary' %>
6
6
  </h1>
7
7
  </div>
8
8
 
9
- <%%= form_tag <%= resource_name_plural %>_path, method: :get, remote: true, id: "<%= resource_name_plural %>_search", class: 'form-inline', data: { object: 'form-load', no_turbolink: true } do %>
10
- <%%= hidden_field_tag :order %>
9
+ <%%= form_tag <%= resource_name_plural %>_path, method: :get, class: 'form-inline' do %>
10
+ <%%= hidden_field_tag :order, params[:order] %>
11
11
  <%%= text_field_tag 'search', params[:search], class: 'form-control' %>
12
- <%%= submit_tag 'Search', class: 'btn btn-primary' %>
12
+ <%%= submit_tag 'Search', class: 'btn btn-primary', name: nil %>
13
+ <%%= link_to 'Reset', <%= resource_name_plural %>_path, class: 'btn btn-default' %>
13
14
  <%% end %>
14
15
 
15
- <div id="<%= resource_name_plural %>"><div class="center"><%%= image_tag "contour/ajax-loader.gif" %></div></div>
16
+ <%%= render partial: '<%= resource_name_plural %>/<%= resource_name_plural %>' %>
Binary file
@@ -3,10 +3,14 @@ require 'test_helper'
3
3
  class ContourHelperTest < ActionView::TestCase
4
4
 
5
5
  test "should show sort field helper" do
6
+ params[:controller] = 'welcome'
7
+ params[:action] = 'index'
6
8
  assert sort_field_helper("first_name DESC", "last_name", "First Name").kind_of?(String)
7
9
  end
8
10
 
9
11
  test "should show sort field helper with same order" do
12
+ params[:controller] = 'welcome'
13
+ params[:action] = 'index'
10
14
  assert sort_field_helper("first_name", "first_name", "First Name").kind_of?(String)
11
15
  end
12
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contour
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0.beta1
4
+ version: 2.4.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Remo Mueller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-11 00:00:00.000000000 Z
11
+ date: 2014-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -310,7 +310,6 @@ files:
310
310
  - lib/generators/contour/scaffold/templates/controller.rb
311
311
  - lib/generators/contour/scaffold/templates/edit.html.erb
312
312
  - lib/generators/contour/scaffold/templates/index.html.erb
313
- - lib/generators/contour/scaffold/templates/index.js.erb
314
313
  - lib/generators/contour/scaffold/templates/new.html.erb
315
314
  - lib/generators/contour/scaffold/templates/show.html.erb
316
315
  - test/contour_test.rb
@@ -1 +0,0 @@
1
- $("#<%= resource_name_plural %>").html("<%%= escape_javascript(render("<%= resource_name_plural %>")) %>");