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 +4 -4
- data/app/helpers/edgarj/drawer/base.rb +89 -51
- data/app/helpers/edgarj/list_drawer.rb +4 -10
- data/lib/edgarj/version.rb +1 -1
- metadata +69 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b85226a81bc685286fb981e9d053285003c05ee0
|
4
|
+
data.tar.gz: 6245bfb278a85c97ae27512f6f686b4a431fae9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
# *
|
8
|
-
# * css_style
|
7
|
+
# * label
|
9
8
|
# * sort_key
|
10
|
-
# * column_header_label
|
11
9
|
# * column_value
|
12
10
|
#
|
13
|
-
#
|
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
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
32
|
-
|
28
|
+
def sort_key
|
29
|
+
raise 'derived should implement'
|
33
30
|
end
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
47
|
-
|
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
|
-
#
|
54
|
-
#
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
-
|
54
|
+
_label += '▲'
|
63
55
|
dir = 'desc'
|
64
56
|
else
|
65
|
-
|
57
|
+
_label += '▼'
|
66
58
|
end
|
67
59
|
end
|
68
|
-
|
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 =
|
85
|
-
|
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
|
-
|
111
|
+
drawer.vc.datetime_fmt(rec.send(name))
|
90
112
|
when :date
|
91
|
-
|
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(
|
131
|
-
super(
|
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
|
-
|
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
|
-
|
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::
|
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(@
|
423
|
+
ColumnInfo::BelongsTo.new(@model, col_name, parent, false)
|
386
424
|
else
|
387
|
-
ColumnInfo::Normal.new(@
|
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
|
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
|
data/lib/edgarj/version.rb
CHANGED
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.
|
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-
|
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.
|
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/
|
368
|
-
- test/
|
369
|
-
- test/
|
370
|
-
- test/
|
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/
|
375
|
-
- test/dummy/
|
376
|
-
- test/dummy/
|
377
|
-
- test/dummy/
|
378
|
-
- test/dummy/
|
379
|
-
- test/dummy/
|
380
|
-
- test/dummy/
|
381
|
-
- test/dummy/
|
382
|
-
- test/dummy/
|
383
|
-
- test/dummy/
|
384
|
-
- test/dummy/
|
385
|
-
- test/dummy/
|
386
|
-
- test/dummy/
|
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/
|
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/
|
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/
|
408
|
-
- test/dummy/config/initializers/
|
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/
|
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/
|
423
|
+
- test/dummy/public/404.html
|
422
424
|
- test/dummy/public/422.html
|
423
|
-
- test/dummy/
|
424
|
-
- test/dummy/
|
425
|
-
- test/dummy/
|
426
|
-
- test/dummy/
|
427
|
-
- test/dummy/
|
428
|
-
- test/dummy/
|
429
|
-
- test/dummy/
|
430
|
-
- test/dummy/
|
431
|
-
- test/dummy/
|
432
|
-
- test/
|
433
|
-
- test/
|
434
|
-
- test/
|
435
|
-
- test/
|
436
|
-
- test/
|
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/
|
446
|
-
- test/
|
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:
|