js_admin 0.0.1 → 0.2.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 +4 -4
- data/CHANGELOG.md +24 -0
- data/README.md +227 -19
- data/app/assets/javascripts/js_admin/application.js +13 -0
- data/app/assets/javascripts/js_admin/controllers/flash_controller.js +23 -0
- data/app/assets/javascripts/js_admin/controllers/theme_controller.js +62 -0
- data/app/assets/tailwind/js_admin/engine.css +4 -0
- data/app/controllers/js_admin/application_controller.rb +45 -1
- data/app/controllers/js_admin/home_controller.rb +6 -0
- data/app/controllers/js_admin/resources_controller.rb +21 -6
- data/app/helpers/js_admin/application_helper.rb +292 -19
- data/app/views/js_admin/home/index.html.erb +5 -0
- data/app/views/js_admin/models/_index_content.html.erb +20 -0
- data/app/views/js_admin/models/index.html.erb +4 -21
- data/app/views/js_admin/resources/_edit_content.html.erb +11 -0
- data/app/views/js_admin/resources/_form.html.erb +21 -13
- data/app/views/js_admin/resources/_index_content.html.erb +74 -0
- data/app/views/js_admin/resources/_new_content.html.erb +10 -0
- data/app/views/js_admin/resources/_show_content.html.erb +26 -0
- data/app/views/js_admin/resources/destroy.turbo_stream.erb +7 -0
- data/app/views/js_admin/resources/edit.html.erb +4 -12
- data/app/views/js_admin/resources/index.html.erb +3 -52
- data/app/views/js_admin/resources/new.html.erb +4 -11
- data/app/views/js_admin/resources/show.html.erb +3 -26
- data/app/views/layouts/js_admin/_content_frame.html.erb +7 -0
- data/app/views/layouts/js_admin/_flash.html.erb +3 -0
- data/app/views/layouts/js_admin/_flash_messages.html.erb +9 -0
- data/app/views/layouts/js_admin/_sidebar.html.erb +36 -0
- data/app/views/layouts/js_admin/application.html.erb +19 -17
- data/config/locales/js_admin.en.yml +65 -0
- data/config/locales/js_admin.ko.yml +65 -0
- data/config/routes.rb +2 -1
- data/lib/generators/js_admin/install/install_generator.rb +70 -5
- data/lib/js_admin/configuration.rb +82 -3
- data/lib/js_admin/configuration_error.rb +4 -0
- data/lib/js_admin/field.rb +21 -7
- data/lib/js_admin/registry.rb +4 -1
- data/lib/js_admin/resource.rb +17 -5
- data/lib/js_admin/version.rb +1 -1
- data/lib/js_admin.rb +8 -0
- metadata +40 -2
data/lib/js_admin/resource.rb
CHANGED
|
@@ -7,7 +7,7 @@ module JSAdmin
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def model_id
|
|
10
|
-
model_class.name.underscore.
|
|
10
|
+
model_class.name.underscore.gsub("/", "--")
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def label
|
|
@@ -42,14 +42,18 @@ module JSAdmin
|
|
|
42
42
|
page_number = [ page.to_i, 1 ].max
|
|
43
43
|
model_class.all
|
|
44
44
|
.then { |scope| ordered_scope(scope) }
|
|
45
|
-
.limit(
|
|
46
|
-
.offset((page_number - 1) *
|
|
45
|
+
.limit(records_per_page)
|
|
46
|
+
.offset((page_number - 1) * records_per_page)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def count
|
|
50
50
|
model_class.count
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
def total_pages(total_count: count)
|
|
54
|
+
[ (total_count.to_f / records_per_page).ceil, 1 ].max
|
|
55
|
+
end
|
|
56
|
+
|
|
53
57
|
def find(record_id)
|
|
54
58
|
model_class.find(record_id)
|
|
55
59
|
end
|
|
@@ -65,11 +69,15 @@ module JSAdmin
|
|
|
65
69
|
|
|
66
70
|
return record.public_send(display_method).to_s if display_method
|
|
67
71
|
|
|
68
|
-
|
|
72
|
+
I18n.t(
|
|
73
|
+
"js_admin.resource.fallback_display_name",
|
|
74
|
+
resource: singular_label,
|
|
75
|
+
id: record.id
|
|
76
|
+
)
|
|
69
77
|
end
|
|
70
78
|
|
|
71
79
|
def next_page?(page)
|
|
72
|
-
|
|
80
|
+
page.to_i < total_pages
|
|
73
81
|
end
|
|
74
82
|
|
|
75
83
|
def previous_page?(page)
|
|
@@ -84,5 +92,9 @@ module JSAdmin
|
|
|
84
92
|
|
|
85
93
|
scope.order(primary_key => :desc)
|
|
86
94
|
end
|
|
95
|
+
|
|
96
|
+
def records_per_page
|
|
97
|
+
[ JSAdmin.configuration.records_per_page.to_i, 1 ].max
|
|
98
|
+
end
|
|
87
99
|
end
|
|
88
100
|
end
|
data/lib/js_admin/version.rb
CHANGED
data/lib/js_admin.rb
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
require "js_admin/version"
|
|
2
|
+
|
|
3
|
+
require "importmap-rails"
|
|
4
|
+
require "stimulus-rails"
|
|
5
|
+
require "tailwindcss-rails"
|
|
6
|
+
require "turbo-rails"
|
|
7
|
+
|
|
8
|
+
require "js_admin/configuration_error"
|
|
2
9
|
require "js_admin/configuration"
|
|
3
10
|
require "js_admin/field"
|
|
4
11
|
require "js_admin/registry"
|
|
@@ -13,6 +20,7 @@ module JSAdmin
|
|
|
13
20
|
|
|
14
21
|
def configure
|
|
15
22
|
yield configuration
|
|
23
|
+
configuration.validate!
|
|
16
24
|
Registry.reset!
|
|
17
25
|
end
|
|
18
26
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: js_admin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- JoungSik
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-10-17 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rails
|
|
@@ -29,6 +29,26 @@ dependencies:
|
|
|
29
29
|
- - "<"
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
31
|
version: '9.0'
|
|
32
|
+
- !ruby/object:Gem::Dependency
|
|
33
|
+
name: importmap-rails
|
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '2.0'
|
|
39
|
+
- - "<"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '3.0'
|
|
42
|
+
type: :runtime
|
|
43
|
+
prerelease: false
|
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '2.0'
|
|
49
|
+
- - "<"
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: '3.0'
|
|
32
52
|
- !ruby/object:Gem::Dependency
|
|
33
53
|
name: stimulus-rails
|
|
34
54
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -101,24 +121,42 @@ files:
|
|
|
101
121
|
- MIT-LICENSE
|
|
102
122
|
- README.md
|
|
103
123
|
- Rakefile
|
|
124
|
+
- app/assets/javascripts/js_admin/application.js
|
|
125
|
+
- app/assets/javascripts/js_admin/controllers/flash_controller.js
|
|
126
|
+
- app/assets/javascripts/js_admin/controllers/theme_controller.js
|
|
104
127
|
- app/assets/stylesheets/js_admin/application.css
|
|
105
128
|
- app/assets/tailwind/js_admin/engine.css
|
|
106
129
|
- app/controllers/js_admin/application_controller.rb
|
|
130
|
+
- app/controllers/js_admin/home_controller.rb
|
|
107
131
|
- app/controllers/js_admin/models_controller.rb
|
|
108
132
|
- app/controllers/js_admin/resources_controller.rb
|
|
109
133
|
- app/helpers/js_admin/application_helper.rb
|
|
110
134
|
- app/models/js_admin/application_record.rb
|
|
135
|
+
- app/views/js_admin/home/index.html.erb
|
|
136
|
+
- app/views/js_admin/models/_index_content.html.erb
|
|
111
137
|
- app/views/js_admin/models/index.html.erb
|
|
138
|
+
- app/views/js_admin/resources/_edit_content.html.erb
|
|
112
139
|
- app/views/js_admin/resources/_form.html.erb
|
|
140
|
+
- app/views/js_admin/resources/_index_content.html.erb
|
|
141
|
+
- app/views/js_admin/resources/_new_content.html.erb
|
|
142
|
+
- app/views/js_admin/resources/_show_content.html.erb
|
|
143
|
+
- app/views/js_admin/resources/destroy.turbo_stream.erb
|
|
113
144
|
- app/views/js_admin/resources/edit.html.erb
|
|
114
145
|
- app/views/js_admin/resources/index.html.erb
|
|
115
146
|
- app/views/js_admin/resources/new.html.erb
|
|
116
147
|
- app/views/js_admin/resources/show.html.erb
|
|
148
|
+
- app/views/layouts/js_admin/_content_frame.html.erb
|
|
149
|
+
- app/views/layouts/js_admin/_flash.html.erb
|
|
150
|
+
- app/views/layouts/js_admin/_flash_messages.html.erb
|
|
151
|
+
- app/views/layouts/js_admin/_sidebar.html.erb
|
|
117
152
|
- app/views/layouts/js_admin/application.html.erb
|
|
153
|
+
- config/locales/js_admin.en.yml
|
|
154
|
+
- config/locales/js_admin.ko.yml
|
|
118
155
|
- config/routes.rb
|
|
119
156
|
- lib/generators/js_admin/install/install_generator.rb
|
|
120
157
|
- lib/js_admin.rb
|
|
121
158
|
- lib/js_admin/configuration.rb
|
|
159
|
+
- lib/js_admin/configuration_error.rb
|
|
122
160
|
- lib/js_admin/engine.rb
|
|
123
161
|
- lib/js_admin/field.rb
|
|
124
162
|
- lib/js_admin/registry.rb
|