active_list 6.10.0 → 7.0.0

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: 5baaa0da5fd9dd52b02bc136ea12da6ebe1ae498
4
- data.tar.gz: b4b7bb336a78617923273ff0fae085552a7d8669
3
+ metadata.gz: '022092abfbb1ef56a9e935ba1f815b5f13dd7fc4'
4
+ data.tar.gz: c15a78e14c48e10bfe281e2f735e5b3bc9084ea7
5
5
  SHA512:
6
- metadata.gz: f8bc42dfee4953d3a2b3d260e8afd18ef54a5fd66bb8e4976e5a155897b4c0f1dfa4381f2736f463b0fd8b1270c382342401d63f2059c0048bcc0ab52f2d35a7
7
- data.tar.gz: e03b4bc03ddfd5f31d5c4a1b90c98920d62021a9f1f9c4ef44feafc234299a6d7e2c0e85231533751de7db6f1f71d0bb62e6dc0bc5685c5f73e42daacfa5b750
6
+ metadata.gz: 51bed46ba112355efe2aadbeae3e652296fbe9071d63d915a73d4189b87c21b933c44b3af2eefc14032827bcf13e5e370f6310f6f30dc66c30ddbaf658330013
7
+ data.tar.gz: edc59cfcb98fa9f621d67f1f6b593657ca2e1ede60c22631884c0ec749ed455e5ff0e8724c6559e2a2e8a915288d22311d8d72a6247aaea69687b7df29eb5fd5
@@ -23,7 +23,7 @@ ActiveList = {}
23
23
  content = $(data)
24
24
  list_data = content.find(".list-data")
25
25
  list_control = content.find(".list-control")
26
- for type in ["actions", "pagination", "settings"]
26
+ for type in ["actions", "pagination", "footer-pagination","settings"]
27
27
  $("*[data-list-ref='#{list_id}'].list-#{type}").replaceWith list_control.find(".list-#{type}")
28
28
  list.find(".list-data").html(list_data)
29
29
  selection = list.prop('selection')
@@ -78,7 +78,7 @@
78
78
  @include background(transparentize(mix($theme-color, #FFF, 40%), 0.7));
79
79
  }
80
80
 
81
- .list-pagination {
81
+ .list-pagination, .list-footer-pagination {
82
82
  & { text-align: left; }
83
83
  html[dir="rtl"] & { text-align: right; }
84
84
  & > * {
@@ -4,6 +4,7 @@ require 'action_dispatch'
4
4
  require 'rails'
5
5
  require 'code_string'
6
6
  require 'i18n-complements'
7
+ require 'tmpdir'
7
8
 
8
9
  module ActiveList
9
10
  # Build and returns a short UID
@@ -6,7 +6,7 @@ module ActiveList
6
6
  end
7
7
 
8
8
  def mime_type
9
- Mime::CSV
9
+ Mime[:csv]
10
10
  end
11
11
 
12
12
  def send_data_code
@@ -9,7 +9,7 @@ module ActiveList
9
9
  end
10
10
 
11
11
  def mime_type
12
- Mime::XCSV
12
+ Mime[:xcsv]
13
13
  end
14
14
 
15
15
  def send_data_code
@@ -19,7 +19,7 @@ module ActiveList
19
19
  end
20
20
 
21
21
  def mime_type
22
- Mime::ODS
22
+ Mime[:ods]
23
23
  end
24
24
 
25
25
  def send_data_code
@@ -83,7 +83,8 @@ module ActiveList
83
83
 
84
84
  def session_initialization_code
85
85
  code = "options = {} unless options.is_a? Hash\n"
86
- code << "options.update(params)\n"
86
+ # For Rails 5
87
+ code << "options.update(params.to_unsafe_h)\n"
87
88
  if defined?(User) && User.instance_methods.include?(:preference)
88
89
  code << "#{var_name(:params)} = YAML::load(current_user.preference('list.#{view_method_name}', YAML::dump({})).value).symbolize_keys\n"
89
90
  code << "#{var_name(:params)} = {} unless #{var_name(:params)}.is_a?(Hash)\n"
@@ -42,6 +42,8 @@ module ActiveList
42
42
  extras = extras_codes
43
43
 
44
44
  code = generator.select_data_code
45
+ # Hack for Rails 5
46
+ code << "__params = params.permit!\n"
45
47
  code << "#{var_name(:tbody)} = '<tbody data-total=\"' + #{var_name(:count)}.to_s + '\""
46
48
  if table.paginate?
47
49
  code << " data-per-page=\"' + #{var_name(:limit)}.to_s + '\""
@@ -54,9 +56,9 @@ module ActiveList
54
56
  code << " #{var_name(:attrs)}['data-' + options[:data].gsub('_', '-')] = #{record}.send(options[:data]) if options[:data]\n"
55
57
  if table.options[:line_class]
56
58
  code << " #{var_name(:attrs)}[:class] = (#{recordify!(table.options[:line_class], record)}).to_s\n"
57
- code << " #{var_name(:attrs)}[:class] << ' focus' if params['#{table.name}-id'].to_i == #{record}.id\n"
59
+ code << " #{var_name(:attrs)}[:class] << ' focus' if __params['#{table.name}-id'].to_i == #{record}.id\n"
58
60
  else
59
- code << " #{var_name(:attrs)}[:class] = 'focus' if params['#{table.name}-id'].to_i == #{record}.id\n"
61
+ code << " #{var_name(:attrs)}[:class] = 'focus' if __params['#{table.name}-id'].to_i == #{record}.id\n"
60
62
  end
61
63
  code << " #{var_name(:tbody)} << content_tag(:tr, #{var_name(:attrs)}) do\n"
62
64
  code << columns_to_cells(:body, record: record).dig(3)
@@ -108,6 +110,7 @@ module ActiveList
108
110
  code << "options[:content_for] ||= {}\n"
109
111
  code << "#{var_name(:extras)} = ''\n"
110
112
  extras.each do |name, ecode|
113
+ next if name == :footer_pagination
111
114
  code << "if options[:content_for][:#{name}]\n"
112
115
  code << " content_for(options[:content_for][:#{name}], (#{ecode}).html_safe)\n"
113
116
  code << "else\n"
@@ -128,10 +131,21 @@ module ActiveList
128
131
  code << "end\n"
129
132
  code << "#{var_name(:content)} << #{var_name(:tbody)}\n"
130
133
  code << "#{var_name(:content)} << '</table></div>'\n"
134
+
135
+ if table.options[:footer_pagination]
136
+ code << " footer_code = ''\n"
137
+ code << " if options[:content_for][:footer_pagination]\n"
138
+ code << " footer_code << content_for(options[:content_for][:pagination])\n"
139
+ code << " else\n"
140
+ code << " footer_code << (#{extras[:footer_pagination]})\n"
141
+ code << " end\n"
142
+ code << " #{var_name(:content)} << content_tag(:div, (footer_code).html_safe, class: 'list-control') unless footer_code.blank?\n"
143
+ end
144
+
131
145
  # code << "return #{var_name(:content)}.html_safe if options[:only] == 'content'\n"
132
146
 
133
147
  # Build whole
134
- code << "return ('<div id=\"#{uid}\" data-list-source=\"'+h(url_for(options.merge(:action => '#{generator.controller_method_name}')))+'\" data-list-redirect=\"' + params[:redirect].to_s + '\" class=\"active-list\">' + #{var_name(:content)} + '</div>').html_safe\n"
148
+ code << "return ('<div id=\"#{uid}\" data-list-source=\"'+h(url_for(options.merge(:action => '#{generator.controller_method_name}')))+'\" data-list-redirect=\"' + __params[:redirect].to_s + '\" class=\"active-list\">' + #{var_name(:content)} + '</div>').html_safe\n"
135
149
  # File.open('debug-activelist', 'w') { |file| file.write code }
136
150
  code
137
151
  end
@@ -283,7 +297,7 @@ module ActiveList
283
297
  menu << '<li class="separator"></li>'
284
298
  # Exports
285
299
  ActiveList.exporters.each do |format, _exporter|
286
- menu << "<li class=\"export export-#{format}\">' + link_to(content_tag(:i) + h('list.export_as'.t(exported: :#{format}.t(scope: 'list.export.formats'))), params.merge(action: :#{generator.controller_method_name}, sort: #{var_name(:params)}[:sort], dir: #{var_name(:params)}[:dir], format: '#{format}')) + '</li>"
300
+ menu << "<li class=\"export export-#{format}\">' + link_to(content_tag(:i) + h('list.export_as'.t(exported: :#{format}.t(scope: 'list.export.formats'))), __params.merge(action: :#{generator.controller_method_name}, sort: #{var_name(:params)}[:sort], dir: #{var_name(:params)}[:dir], format: '#{format}')) + '</li>"
287
301
  end
288
302
  menu << '</ul></span>'
289
303
  menu
@@ -369,6 +383,26 @@ module ActiveList
369
383
 
370
384
  code << "'#{pagination}'"
371
385
  codes[:pagination] = "'#{pagination}'"
386
+
387
+ if table.options[:footer_pagination]
388
+ pagination = ''
389
+ current_page = var_name(:page).to_s
390
+ last_page = var_name(:last).to_s
391
+
392
+ pagination << "<span class=\"list-footer-pagination\" data-list-ref=\"#{uid}\">"
393
+ pagination << "<span class=\"status\">' + 'list.pagination.x_to_y_of_total'.t(x: (#{var_name(:offset)} + (#{var_name(:count)} > 0 ? 1 : 0)), y: ((#{var_name(:last)} == #{var_name(:page)}) ? #{var_name(:count)} : #{var_name(:offset)} + #{var_name(:limit)}), total: #{var_name(:count)}) + '</span>"
394
+
395
+ pagination << '<span class="paginator">'
396
+ pagination << "<a href=\"#\" data-list-move-to-page=\"' + (#{current_page} - 1).to_s + '\" class=\"btn previous-page\"' + (#{current_page} != 1 ? '' : ' disabled=\"true\"') + '><i></i>' + ::I18n.translate('list.pagination.previous') + '</a>"
397
+
398
+ pagination << "<a href=\"#\" data-list-move-to-page=\"' + (#{current_page} + 1).to_s + '\" class=\"btn next-page\"' + (#{current_page} != #{last_page} ? '' : ' disabled=\"true\"') + '><i></i>' + ::I18n.translate('list.pagination.next')+'</a>"
399
+ pagination << '</span>'
400
+
401
+ pagination << '</span>'
402
+
403
+ code << "'#{pagination}'"
404
+ codes[:footer_pagination] = "'#{pagination}'"
405
+ end
372
406
  end
373
407
  codes
374
408
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveList
2
- VERSION = '6.10.0'.freeze
2
+ VERSION = '7.0.0'.freeze
3
3
  end
@@ -1,23 +1,23 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rails', '4.2.10'
3
+ gem 'rails', '~> 5.0'
4
4
 
5
5
  # Bundle edge Rails instead:
6
6
  # gem 'rails', :git => 'git://github.com/rails/rails.git'
7
7
 
8
- gem 'sqlite3'
8
+ gem 'sqlite3', '~> 1.3.6'
9
9
  gem 'active_list', path: '../..'
10
10
 
11
11
  # Gems used only for assets and not required
12
12
  # in production environments by default.
13
13
  group :assets do
14
- gem 'sass-rails', '~> 4'
15
- gem 'coffee-rails', '~> 4'
14
+ gem 'sass-rails'
15
+ gem 'coffee-rails'
16
16
 
17
17
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
18
18
  gem 'therubyracer', platform: :ruby
19
19
 
20
- gem 'uglifier', '>= 1.0.3'
20
+ gem 'uglifier'
21
21
  end
22
22
 
23
23
  gem 'jquery-rails'
@@ -1,4 +1,4 @@
1
- class CreatePeople < ActiveRecord::Migration
1
+ class CreatePeople < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :people do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class CreateContacts < ActiveRecord::Migration
1
+ class CreateContacts < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :contacts do |t|
4
4
  t.integer :person_id
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  # This file is auto-generated from the current state of the database. Instead
3
2
  # of editing this file, please use the migrations feature of Active Record to
4
3
  # incrementally modify your database, and then regenerate this schema definition.
@@ -11,26 +10,26 @@
11
10
  #
12
11
  # It's strongly recommended that you check this file into your version control system.
13
12
 
14
- ActiveRecord::Schema.define(version: 20120510134500) do
13
+ ActiveRecord::Schema.define(version: 2012_05_10_134500) do
15
14
 
16
15
  create_table "contacts", force: :cascade do |t|
17
- t.integer "person_id"
18
- t.text "address"
19
- t.string "phone"
20
- t.string "fax"
21
- t.string "country"
16
+ t.integer "person_id"
17
+ t.text "address"
18
+ t.string "phone"
19
+ t.string "fax"
20
+ t.string "country"
22
21
  t.datetime "created_at", null: false
23
22
  t.datetime "updated_at", null: false
24
23
  end
25
24
 
26
25
  create_table "people", force: :cascade do |t|
27
- t.string "name"
28
- t.date "born_on"
29
- t.decimal "height"
30
- t.decimal "balance_amount"
31
- t.string "currency"
32
- t.datetime "created_at", null: false
33
- t.datetime "updated_at", null: false
26
+ t.string "name"
27
+ t.date "born_on"
28
+ t.decimal "height"
29
+ t.decimal "balance_amount"
30
+ t.string "currency"
31
+ t.datetime "created_at", null: false
32
+ t.datetime "updated_at", null: false
34
33
  end
35
34
 
36
35
  end
@@ -5,10 +5,10 @@ class PeopleControllerTest < ActionController::TestCase
5
5
  get :list
6
6
  assert_response :success
7
7
 
8
- get :list, format: :csv
8
+ get :list, params: {format: :csv}
9
9
  assert_response :success
10
10
 
11
- get :list, format: :ods
11
+ get :list, params: {format: :ods}
12
12
  assert_response :success
13
13
  end
14
14
 
@@ -18,19 +18,19 @@ class PeopleControllerTest < ActionController::TestCase
18
18
  end
19
19
 
20
20
  test 'parameters' do
21
- get :list, 'people-id' => 10
21
+ get :list, params: {'people-id' => 10}
22
22
  assert_response :success
23
23
 
24
- get :list, page: 0
24
+ get :list, params: {page: 0}
25
25
  assert_response :success
26
26
 
27
- get :list, page: 5, per_page: 25
27
+ get :list, params: {page: 5, per_page: 25}
28
28
  assert_response :success
29
29
 
30
- get :list, page: 50, per_page: 25
30
+ get :list, params: {page: 50, per_page: 25}
31
31
  assert_response :success
32
32
 
33
- get :list, page: 500, per_page: 25
33
+ get :list, params: {page: 500, per_page: 25}
34
34
  assert_response :success
35
35
  end
36
36
  end
@@ -23,6 +23,22 @@ ActionMailer::Base.delivery_method = :test
23
23
  ActionMailer::Base.perform_deliveries = true
24
24
  ActionMailer::Base.default_url_options[:host] = 'test.com'
25
25
 
26
+ # Patch from https://github.com/rails/rails/issues/34790#issuecomment-450502805
27
+ if RUBY_VERSION >= '2.6.0'
28
+ if Rails.version < '5'
29
+ class ActionController::TestResponse < ActionDispatch::TestResponse
30
+ def recycle!
31
+ # hack to avoid MonitorMixin double-initialize error:
32
+ @mon_mutex_owner_object_id = nil
33
+ @mon_mutex = nil
34
+ initialize
35
+ end
36
+ end
37
+ else
38
+ puts "Monkeypatch for ActionController::TestResponse no longer needed"
39
+ end
40
+ end
41
+
26
42
  module ActionView
27
43
  class Base
28
44
  module Nomen
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.10.0
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brice Texier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-22 00:00:00.000000000 Z
11
+ date: 2019-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '3.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 5.0.0
22
+ version: '6'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '3.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 5.0.0
32
+ version: '6'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: arel
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -90,16 +90,16 @@ dependencies:
90
90
  name: sqlite3
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - ">="
93
+ - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '0'
95
+ version: 1.3.6
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - ">="
100
+ - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '0'
102
+ version: 1.3.6
103
103
  description: Generates action methods to provide clean tables.
104
104
  email: burisu@oneiros.fr
105
105
  executables: []