edgarj 4.03.00 → 4.04.00

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6e9e87b3ebbda6b9e3ad40f1f2f2496208c0674
4
- data.tar.gz: 5539c9053f74354ec35ecae734bc82128c3fe05c
3
+ metadata.gz: b85226a81bc685286fb981e9d053285003c05ee0
4
+ data.tar.gz: 6245bfb278a85c97ae27512f6f686b4a431fae9f
5
5
  SHA512:
6
- metadata.gz: 1b8396a15cb2e18c79b6b5769f98339c89dd560f9816de54fd7b87ca7bc35e5a218a215b961bda07085f6457a4d3c4992fa828fc48fdfc8d64b813f92de8688a
7
- data.tar.gz: 1c2c1f664e0a2a0c1ac95f4e183f8152edc86098a38de0de594877d19cadcd793b1f440c7b419d180af34bb39cf58fda732576f09925574d960c63486632f2fc
6
+ metadata.gz: 8250433bbf91e66228da411c884fc95fd06762ef3839c9468d3b8d2e51ebb142e6c9dc98b37348d788973aded8baf8568fe7e313bc6f6e6bd5fbd64c75d2e231
7
+ data.tar.gz: 37a5510d11531685d9f2ddda6af33b160fc9de6b02e6f5a9ad8f1ee35c008e133eb3b56e962b045d9e7e957704b121337c2c23859e4db60db81f9cc2062101ca
@@ -4,68 +4,60 @@ module Edgarj
4
4
  module Drawer
5
5
  # Column-info classes to provide the following common methods:
6
6
  #
7
- # * name
8
- # * css_style
7
+ # * label
9
8
  # * sort_key
10
- # * column_header_label
11
9
  # * column_value
12
10
  #
13
- # As wells as the following for backward compatibility:
11
+ # and the following optional methods:
12
+ # * css_style
13
+ # * column_header_label
14
+ #
15
+ # as wells as the following for backward compatibility:
16
+ # * name
14
17
  # * type
18
+ #
19
+ # NOTE: ColumnInfo::* classes instances are cached during server process
20
+ # lifetime so that dynamic object (like drawer) cannot be stored.
15
21
  module ColumnInfo
16
- # ActiveRecord::ConnectionAdapters::[DRIVER]::Column wrapper
17
- #
18
- # NOTE: ColumnInfo::* classes instances are cached during server process
19
- # lifetime so that dynamic object (like drawer) cannot be stored.
20
- class Normal
21
- # @param vc [ViewContext]
22
- # @param model [AR]
23
- # @param name [String]
24
- def initialize(vc, model, name)
25
- @vc = vc
26
- @model = model
27
- @name = name
28
- @ar_column_info = model.columns_hash[name]
22
+ # Abstract class for all of ColumnInfo
23
+ class Base
24
+ def label(vc)
25
+ raise 'derived should implement'
29
26
  end
30
27
 
31
- def name
32
- @name
28
+ def sort_key
29
+ raise 'derived should implement'
33
30
  end
34
31
 
35
- def css_style
36
- case @ar_column_info.type
37
- when :integer
38
- {align: 'right'}
39
- when :boolean
40
- {align: 'center'}
41
- else
42
- {}
43
- end
32
+ # @param rec [AR]
33
+ # @param drawer [Edgarj::Drawer::Base]
34
+ def column_value(rec, drawer)
35
+ rec.inspect
44
36
  end
45
37
 
46
- # return table_name + col.name for sort
47
- def sort_key
48
- @model.table_name + '.' + @name
38
+ def css_style
39
+ {}
49
40
  end
50
41
 
51
42
  # draw column header (with sort link)
52
43
  #
53
- # === INPUTS
54
- # options:: options to url_for
55
- def column_header_label(page_info, options)
56
- label = @vc.column_label(@name)
57
- dir = 'asc'
44
+ # @param vc [ViewContext] Rails view_context
45
+ # @param path_info [Edgarj::PageInfo]
46
+ # @param options [Hash] options to url_for
47
+ def column_header_label(vc, page_info, options)
48
+ _label = label(vc)
49
+ dir = 'asc'
58
50
 
59
51
  if page_info.order_by == sort_key
60
52
  # toggle direction
61
53
  if page_info.dir == 'asc' || page_info.dir.blank?
62
- label += '▲'
54
+ _label += '▲'
63
55
  dir = 'desc'
64
56
  else
65
- label += '▼'
57
+ _label += '▼'
66
58
  end
67
59
  end
68
- @vc.link_to(label,
60
+ vc.link_to(_label,
69
61
  {
70
62
  :action => 'page_info_save',
71
63
  :id => page_info.id,
@@ -76,19 +68,49 @@ module Edgarj
76
68
  :method => :put)
77
69
  end
78
70
 
71
+ def name
72
+ raise 'derived should implement'
73
+ end
74
+
75
+ # just for backward compatibility
76
+ def type
77
+ raise 'derived should implement'
78
+ end
79
+ end
80
+
81
+ # ActiveRecord::ConnectionAdapters::[DRIVER]::Column wrapper
82
+ class Normal < Base
83
+ # @param vc [ViewContext]
84
+ # @param model [AR]
85
+ # @param name [String]
86
+ def initialize(model, name)
87
+ @model = model
88
+ @name = name
89
+ @ar_column_info = model.columns_hash[name]
90
+ end
91
+
92
+ def label(vc)
93
+ vc.column_label(@name)
94
+ end
95
+
96
+ # return table_name + col.name for sort
97
+ def sort_key
98
+ @model.table_name + '.' + @name
99
+ end
100
+
79
101
  # draw rec.col other than 'belongs_to'
80
102
  #
81
103
  # === INPUTS
82
104
  # rec:: AR instance
83
105
  def column_value(rec, drawer)
84
- if (enum = @vc.get_enum(rec.class, @ar_column_info))
85
- @vc.draw_column_enum(rec, @ar_column_info, enum)
106
+ if (enum = drawer.vc.get_enum(rec.class, @ar_column_info))
107
+ drawer.vc.draw_column_enum(rec, @ar_column_info, enum)
86
108
  else
87
109
  case @ar_column_info.type
88
110
  when :datetime
89
- @vc.datetime_fmt(rec.send(name))
111
+ drawer.vc.datetime_fmt(rec.send(name))
90
112
  when :date
91
- @vc.date_fmt(rec.send(name))
113
+ drawer.vc.date_fmt(rec.send(name))
92
114
  when :integer
93
115
  rec.send(name).to_s
94
116
  when :boolean
@@ -106,6 +128,22 @@ module Edgarj
106
128
  end
107
129
  end
108
130
 
131
+ def css_style
132
+ case @ar_column_info.type
133
+ when :integer
134
+ {align: 'right'}
135
+ when :boolean
136
+ {align: 'center'}
137
+ else
138
+ {}
139
+ end
140
+ end
141
+
142
+ # just for backward compatibility
143
+ def name
144
+ @name
145
+ end
146
+
109
147
  # just for backward compatibility
110
148
  def type
111
149
  @ar_column_info.type
@@ -127,22 +165,22 @@ module Edgarj
127
165
  #
128
166
  # parent model is assumed to have 'name' method
129
167
  class BelongsTo < Normal
130
- def initialize(vc, model, name, parent_model, belongs_to_link)
131
- super(vc, model, name)
168
+ def initialize(model, name, parent_model, belongs_to_link)
169
+ super(model, name)
132
170
  @parent_model = parent_model
133
171
  @belongs_to_link = belongs_to_link
134
172
  end
135
173
 
136
174
  # column header for 'belongs_to' column prints label without
137
175
  # any sort action unlike Normal-class behavior.
138
- def column_header_label(page_info, options)
139
- @vc.draw_belongs_to_label_sub(@model, name, @parent_model)
176
+ def column_header_label(vc, page_info, options)
177
+ vc.draw_belongs_to_label_sub(@model, name, @parent_model)
140
178
  end
141
179
 
142
180
  def column_value(rec, drawer)
143
181
  @parent_rec = rec.belongs_to_AR(@ar_column_info)
144
182
  if @belongs_to_link
145
- @vc.link_to(@parent_rec.name, drawer.popup_path(self), remote: true)
183
+ drawer.vc.link_to(@parent_rec.name, drawer.popup_path(self), remote: true)
146
184
  else
147
185
  @parent_rec ? @parent_rec.name : ''
148
186
  end
@@ -378,13 +416,13 @@ module Edgarj
378
416
  [].tap do |result|
379
417
  for col_name in column_name_list do
380
418
  result <<
381
- if col_name.is_a?(ColumnInfo::Normal)
419
+ if col_name.is_a?(ColumnInfo::Base)
382
420
  col_name
383
421
  elsif (col = @model.columns_hash[col_name])
384
422
  if (parent = @model.belongs_to_AR(col))
385
- ColumnInfo::BelongsTo.new(@vc, @model, col_name, parent, false)
423
+ ColumnInfo::BelongsTo.new(@model, col_name, parent, false)
386
424
  else
387
- ColumnInfo::Normal.new(@vc, @model, col_name)
425
+ ColumnInfo::Normal.new(@model, col_name)
388
426
  end
389
427
  end
390
428
  end
@@ -13,22 +13,17 @@ module Edgarj
13
13
  # * drawer - Edgarj::Drawer::Base object
14
14
  # * options
15
15
  def initialize(drawer, options = {})
16
- @drawer = drawer
17
- @options = options.dup
18
- @vc = drawer.vc
19
- @bitset_cache = {}
20
- @parent_rec = nil
21
- @belongs_to_link = false # doesn't make link on belongs_to
16
+ @drawer = drawer
22
17
  end
23
18
 
24
19
  def draw_column_header(col, options={})
25
- @vc.content_tag(:th) do
26
- col.column_header_label(@drawer.page_info, options)
20
+ @drawer.vc.content_tag(:th) do
21
+ col.column_header_label(@drawer.vc, @drawer.page_info, options)
27
22
  end
28
23
  end
29
24
 
30
25
  def draw_column(rec, col)
31
- @vc.content_tag(:td, td_options(rec, col)) do
26
+ @drawer.vc.content_tag(:td, td_options(rec, col)) do
32
27
  col.column_value(rec, @drawer)
33
28
  end
34
29
  end
@@ -46,7 +41,6 @@ module Edgarj
46
41
  class Normal < Base
47
42
  def initialize(edgarj_drawer, options = {})
48
43
  super(edgarj_drawer, options)
49
- #@belongs_to_link = true # make link on belongs_to
50
44
  end
51
45
 
52
46
  # <td> options
@@ -1,3 +1,3 @@
1
1
  module Edgarj
2
- VERSION = '4.03.00'
2
+ VERSION = '4.04.00'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edgarj
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.03.00
4
+ version: 4.04.00
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fuminori Ido
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-27 00:00:00.000000000 Z
11
+ date: 2016-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -359,96 +359,96 @@ required_rubygems_version: !ruby/object:Gem::Requirement
359
359
  version: '0'
360
360
  requirements: []
361
361
  rubyforge_project:
362
- rubygems_version: 2.5.2
362
+ rubygems_version: 2.6.4
363
363
  signing_key:
364
364
  specification_version: 4
365
365
  summary: Scaffold with Ajax, search, sort, 'belongs_to' popup, and more.
366
366
  test_files:
367
- - test/dummy/config.ru
368
- - test/dummy/test/controllers/books_controller_test.rb
369
- - test/dummy/test/controllers/authors_controller_test.rb
370
- - test/dummy/test/controllers/authors_popup_controller_test.rb
367
+ - test/models/helpers/edgarj/model_permissions_helper_test.rb
368
+ - test/models/helpers/edgarj/user_group_users_helper_test.rb
369
+ - test/models/edgarj/user_group_user_test.rb
370
+ - test/models/edgarj/sssn_test.rb
371
+ - test/models/edgarj/user_group_test.rb
372
+ - test/models/edgarj/page_info_test.rb
373
+ - test/models/edgarj/model_permission_test.rb
374
+ - test/integration/navigation_test.rb
375
+ - test/support/edgarj/controller_supporter.rb
376
+ - test/controllers/edgarj/user_group_users_controller_test.rb
377
+ - test/controllers/edgarj/edgarj_controller_test.rb
378
+ - test/controllers/edgarj/model_permissions_controller_test.rb
379
+ - test/edgarj_test.rb
380
+ - test/test_helper.rb
371
381
  - test/dummy/test/helpers/authors_helper_test.rb
382
+ - test/dummy/test/models/book_test.rb
372
383
  - test/dummy/test/models/author_test.rb
373
384
  - test/dummy/test/models/rails_config_test.rb
374
- - test/dummy/test/models/book_test.rb
375
- - test/dummy/app/assets/javascripts/application.js
376
- - test/dummy/app/assets/javascripts/authors.js
377
- - test/dummy/app/assets/stylesheets/authors.css
378
- - test/dummy/app/assets/stylesheets/scaffold.css
379
- - test/dummy/app/assets/stylesheets/application.css
380
- - test/dummy/app/decorators/models/edgarj/user_group_decorator.rb
381
- - test/dummy/app/controllers/authors_popup_controller.rb
382
- - test/dummy/app/controllers/dummy_auth_mixin.rb
383
- - test/dummy/app/controllers/application_controller.rb
384
- - test/dummy/app/controllers/books_controller.rb
385
- - test/dummy/app/controllers/authors_controller.rb
386
- - test/dummy/app/helpers/authors_popup_helper.rb
387
- - test/dummy/app/helpers/authors_helper.rb
388
- - test/dummy/app/helpers/books_helper.rb
389
- - test/dummy/app/helpers/application_helper.rb
390
- - test/dummy/app/models/author.rb
391
- - test/dummy/app/models/user.rb
392
- - test/dummy/app/models/book.rb
393
- - test/dummy/app/views/layouts/application.html.erb
394
- - test/dummy/app/views/layouts/login.html.erb
385
+ - test/dummy/test/controllers/authors_controller_test.rb
386
+ - test/dummy/test/controllers/books_controller_test.rb
387
+ - test/dummy/test/controllers/authors_popup_controller_test.rb
388
+ - test/dummy/README.rdoc
389
+ - test/dummy/config.ru
390
+ - test/dummy/bin/bundle
391
+ - test/dummy/bin/rake
392
+ - test/dummy/bin/rails
393
+ - test/dummy/db/schema.rb
394
+ - test/dummy/db/migrate/20131218011851_create_books.rb
395
+ - test/dummy/db/migrate/20140807065420_create_users.rb
396
+ - test/dummy/db/migrate/20140201000000_add_user_group_id_to_authors.rb
397
+ - test/dummy/db/migrate/20131107120635_create_authors.rb
395
398
  - test/dummy/Rakefile
396
- - test/dummy/config/database.yml
397
- - test/dummy/config/settings.yml
399
+ - test/dummy/config/routes.rb
398
400
  - test/dummy/config/boot.rb
399
401
  - test/dummy/config/environment.rb
402
+ - test/dummy/config/database.yml
403
+ - test/dummy/config/settings.yml
404
+ - test/dummy/config/environments/test.rb
405
+ - test/dummy/config/environments/production.rb
406
+ - test/dummy/config/environments/development.rb
407
+ - test/dummy/config/application.rb
400
408
  - test/dummy/config/settings/production.yml
401
409
  - test/dummy/config/settings/development.yml
402
410
  - test/dummy/config/settings/test.yml
403
- - test/dummy/config/routes.rb
404
- - test/dummy/config/application.rb
411
+ - test/dummy/config/edgarj/menu_config.rb
405
412
  - test/dummy/config/locales/en.yml
406
413
  - test/dummy/config/locales/ja.yml
407
- - test/dummy/config/initializers/backtrace_silencers.rb
408
- - test/dummy/config/initializers/filter_parameter_logging.rb
414
+ - test/dummy/config/initializers/config.rb
415
+ - test/dummy/config/initializers/inflections.rb
409
416
  - test/dummy/config/initializers/wrap_parameters.rb
417
+ - test/dummy/config/initializers/session_store.rb
410
418
  - test/dummy/config/initializers/secret_token.rb
419
+ - test/dummy/config/initializers/filter_parameter_logging.rb
411
420
  - test/dummy/config/initializers/mime_types.rb
412
- - test/dummy/config/initializers/session_store.rb
413
- - test/dummy/config/initializers/inflections.rb
414
- - test/dummy/config/initializers/config.rb
415
- - test/dummy/config/edgarj/menu_config.rb
416
- - test/dummy/config/environments/production.rb
417
- - test/dummy/config/environments/development.rb
418
- - test/dummy/config/environments/test.rb
419
- - test/dummy/public/404.html
421
+ - test/dummy/config/initializers/backtrace_silencers.rb
420
422
  - test/dummy/public/favicon.ico
421
- - test/dummy/public/500.html
423
+ - test/dummy/public/404.html
422
424
  - test/dummy/public/422.html
423
- - test/dummy/README.rdoc
424
- - test/dummy/bin/bundle
425
- - test/dummy/bin/rake
426
- - test/dummy/bin/rails
427
- - test/dummy/db/schema.rb
428
- - test/dummy/db/migrate/20140807065420_create_users.rb
429
- - test/dummy/db/migrate/20131218011851_create_books.rb
430
- - test/dummy/db/migrate/20131107120635_create_authors.rb
431
- - test/dummy/db/migrate/20140201000000_add_user_group_id_to_authors.rb
432
- - test/test_helper.rb
433
- - test/integration/navigation_test.rb
434
- - test/controllers/edgarj/user_group_users_controller_test.rb
435
- - test/controllers/edgarj/edgarj_controller_test.rb
436
- - test/controllers/edgarj/model_permissions_controller_test.rb
425
+ - test/dummy/public/500.html
426
+ - test/dummy/app/views/layouts/login.html.erb
427
+ - test/dummy/app/views/layouts/application.html.erb
428
+ - test/dummy/app/decorators/models/edgarj/user_group_decorator.rb
429
+ - test/dummy/app/helpers/authors_helper.rb
430
+ - test/dummy/app/helpers/books_helper.rb
431
+ - test/dummy/app/helpers/application_helper.rb
432
+ - test/dummy/app/helpers/authors_popup_helper.rb
433
+ - test/dummy/app/models/book.rb
434
+ - test/dummy/app/models/author.rb
435
+ - test/dummy/app/models/user.rb
436
+ - test/dummy/app/assets/javascripts/authors.js
437
+ - test/dummy/app/assets/javascripts/application.js
438
+ - test/dummy/app/assets/stylesheets/scaffold.css
439
+ - test/dummy/app/assets/stylesheets/authors.css
440
+ - test/dummy/app/assets/stylesheets/application.css
441
+ - test/dummy/app/controllers/authors_controller.rb
442
+ - test/dummy/app/controllers/books_controller.rb
443
+ - test/dummy/app/controllers/dummy_auth_mixin.rb
444
+ - test/dummy/app/controllers/application_controller.rb
445
+ - test/dummy/app/controllers/authors_popup_controller.rb
437
446
  - test/fixtures/authors.yml
438
- - test/fixtures/books.yml
439
447
  - test/fixtures/users.yml
448
+ - test/fixtures/edgarj/page_infos.yml
440
449
  - test/fixtures/edgarj/user_group_users.yml
441
450
  - test/fixtures/edgarj/user_groups.yml
442
- - test/fixtures/edgarj/page_infos.yml
443
- - test/fixtures/edgarj/sssns.yml
444
451
  - test/fixtures/edgarj/model_permissions.yml
445
- - test/edgarj_test.rb
446
- - test/support/edgarj/controller_supporter.rb
447
- - test/models/helpers/edgarj/model_permissions_helper_test.rb
448
- - test/models/helpers/edgarj/user_group_users_helper_test.rb
449
- - test/models/edgarj/user_group_test.rb
450
- - test/models/edgarj/sssn_test.rb
451
- - test/models/edgarj/model_permission_test.rb
452
- - test/models/edgarj/page_info_test.rb
453
- - test/models/edgarj/user_group_user_test.rb
452
+ - test/fixtures/edgarj/sssns.yml
453
+ - test/fixtures/books.yml
454
454
  has_rdoc: