micro_admin 0.1.5 → 0.1.7

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
  SHA256:
3
- metadata.gz: fbc36e79da63da2607b132bf6e55b0e1b2400467dbcd19b40d340ffe5f110c0c
4
- data.tar.gz: 0df51b88800c8905663bad749125bead5dd07c1f29f1931d921cd80492e74098
3
+ metadata.gz: 4ef9c9cf36590429429c9bb922021df4473240ed73cd9c64d4e849f2a5bfe7f6
4
+ data.tar.gz: f1658bc3709bc5a2a90877ee8cf691cd8362e523212172706ca76290f498d599
5
5
  SHA512:
6
- metadata.gz: b6348702f27b3b84e9cc9174086b171640b84e16c61674d0099cfb7f9bd291371adcf28e9134aea134c96a026609823e3bbd0764810a92fd58f22a388cccfd92
7
- data.tar.gz: 3bef1a30c276e7e10ac42a0c1c01bf21563ca6fd56749bfd6ee8f9cff593a4878afb2ac164a15282e7da0029de218b2cd0530735bc983a9ae5d1c5db96a7d94c
6
+ metadata.gz: 3ad036e5122bc5b4f438b1ab1007bcee4cb389629c197cc146bb232de7ebf3c8e7f2350607f0f4331c0013b53c6c681d10656693f36881202b78879f6661f5bc
7
+ data.tar.gz: 6c4c2f8e42bc58a198e744cdb048fdcedfbd1ac7e972b6bc9283cd95c6f9cb4bd1c253a9deb1937167240569dcebdbcf6ff4897ccf7916355f862bf216fd007f
data/README.md CHANGED
@@ -24,6 +24,7 @@ Or install it yourself as:
24
24
  class ApplicationDashboard < MicroAdmin::Dashboard::Base
25
25
  # example:
26
26
  self.view_paths = [Rails.root.join("app", "views", "dashboards")]
27
+ self.url_base = "/admin"
27
28
  end
28
29
  ```
29
30
 
@@ -47,40 +48,157 @@ class UserDashboard < ApplicationDashboard
47
48
  end
48
49
  ```
49
50
 
51
+ Setup routing.
52
+
53
+ ```ruby
54
+ namespace :admin do
55
+ resources :users
56
+ end
57
+ ```
58
+
50
59
  `/app/views/dashboards/user_dashboard/new/name.erb`:
51
60
 
52
61
  ```html
53
- <input type="text" name="name">
62
+ <input type="text" name="name" class="form-control">
54
63
  ```
55
64
 
56
65
  `/app/views/dashboards/user_dashboard/edit/name.erb`:
57
66
 
67
+ `value` is available.s
68
+
58
69
  ```html
59
- <input type="text" name="name" value="<%= value %>">
70
+ <input type="text" name="name" value="<%= value %>" class="form-control">
60
71
  ```
61
72
 
62
73
  ```ruby
63
74
  smith = User.new(id: 1, name: "Smith")
64
- jams = User.new(id: 1, name: "Jams")
75
+ james = User.new(id: 1, name: "James")
65
76
  dashboard = UserDashboard.new
66
77
  ```
67
78
 
68
79
  ```erb
69
- <%= dashboard.index([smith, jams]) %>
80
+ <%= dashboard.index([smith, james]) %>
70
81
  ```
71
82
 
83
+ output:
84
+ ```html
85
+ <header class="navbar border-bottom p-4">
86
+ <h2 class="m-0">User</h2>
87
+ <div>
88
+ <a href="/admin/users/new" class="btn btn-primary">
89
+ new
90
+ </a>
91
+ </div>
92
+ </header>
93
+
94
+ <main class="p-4">
95
+ <table class="table">
96
+ <thead>
97
+ <tr>
98
+ <th scope="col">id</th>
99
+ <th scope="col">name</th>
100
+ <th scope="col">show</th>
101
+ <th scope="col">edit</th>
102
+ </tr>
103
+ </thead>
104
+ <tbody>
105
+ <tr>
106
+ <td>1</td>
107
+ <td>Smith</td>
108
+ <td><a href="/admin/users/1">show</a></td>
109
+ <td><a href="/admin/users/1/edit">edit</a>
110
+ </td>
111
+ </tr>
112
+ <tr>
113
+ <td>2</td>
114
+ <td>James</td>
115
+ <td><a href="/admin/users/2">show</a></td>
116
+ <td><a href="/admin/users/2/edit">edit</a>
117
+ </td>
118
+ </tr>
119
+ </tbody>
120
+ </table>
121
+ </main>
122
+ ```
123
+
124
+
72
125
  ```erb
73
126
  <%= dashboard.show(smith) %>
74
127
  ```
75
128
 
129
+ output:
130
+
131
+ ```html
132
+ <header class="navbar border-bottom p-4">
133
+ <h2 class="m-0">Show User</h2>
134
+ <div>
135
+ <a href="/admin/users" class="btn btn-primary">
136
+ Back
137
+ </a>
138
+ </div>
139
+ </header>
140
+
141
+ <main class="p-4">
142
+ <dl>
143
+ <dt>id></dt>
144
+ <dd>1</dd>
145
+ <dt>name</dt>
146
+ <dd>Smith</dd>
147
+ </dl>
148
+ </main>
149
+ ```
150
+
76
151
  ```erb
77
152
  <%= dashboard.new(errors: ["Name is required!"]) %>
78
153
  ```
79
154
 
155
+ output:
156
+ ```html
157
+ <header class="navbar border-bottom py-4">
158
+ <h2 class="m-0">Create User</h2>
159
+ <div>
160
+ <a href="/admin/users" class="btn btn-primary">
161
+ Back to index
162
+ </a>
163
+ </div>
164
+ </header>
165
+ <main class="p-4">
166
+ <ul class="alert alert-danger">
167
+ <li class="ml-3">Name is required</li>
168
+ </ul>
169
+ <form method="post" action="/admin/users">
170
+ <div class="mb-3">
171
+ <label for="name" class="form-label">name</label>
172
+ <input type="text" name="name" class="form-control"/>
173
+ </div>
174
+ </form>
175
+ </main>
176
+ ```
177
+
80
178
  ```erb
81
179
  <%= dashboard.edit(id: 1, values: {name: "Smith"}, errors: []) %>
82
180
  ```
83
181
 
182
+ output:
183
+ ```html
184
+ <header class="navbar border-bottom py-4">
185
+ <h2 class="m-0">Create User</h2>
186
+ <div>
187
+ <a href="/admin/users" class="btn btn-primary">
188
+ Back to index
189
+ </a>
190
+ </div>
191
+ </header>
192
+ <main class="p-4">
193
+ <form method="patch" action="/admin/users/1">
194
+ <div class="mb-3">
195
+ <label for="name" class="form-label">name</label>
196
+ <input type="text" name="name" value="test" class="form-control"/>
197
+ </div>
198
+ </form>
199
+ </main>
200
+ ```
201
+
84
202
  **You can decorate table and forms with [Bootstrap](https://getbootstrap.com/docs/5.0/getting-started/download/)!**
85
203
 
86
204
  ## Development
@@ -2,7 +2,7 @@
2
2
  <h2 class="m-0">Create <%= model_class.name %></h2>
3
3
  <div>
4
4
  <a
5
- href="<%= "/admin/#{model_class.name.underscore}" %>"
5
+ href="<%= "#{self.class.url_base}/#{model_class.name.underscore.pluralize}" %>"
6
6
  class="btn btn-primary">
7
7
  Back to index
8
8
  </a>
@@ -17,7 +17,7 @@
17
17
  <% end %>
18
18
  </ul>
19
19
  <% end %>
20
- <form method="patch" action="<%= "/admin/#{model_class.name.underscore}/#{@id}" %>">
20
+ <form method="patch" action="<%= "#{self.class.url_base}/#{model_class.name.underscore.pluralize}/#{@id}" %>">
21
21
  <% form_attributes.each do |attribute| %>
22
22
  <div class="mb-3">
23
23
  <label for="<%= attribute %>" class="form-label"><%= attribute %></label>
@@ -2,7 +2,7 @@
2
2
  <h2 class="m-0"><%= model_class.name %></h2>
3
3
  <div>
4
4
  <a
5
- href="<%= "/admin/#{model_class.name.underscore}/new" %>"
5
+ href="<%= "#{self.class.url_base}/#{model_class.name.underscore.pluralize}/new" %>"
6
6
  class="btn btn-primary">
7
7
  new
8
8
  </a>
@@ -13,7 +13,6 @@
13
13
  <table class="table">
14
14
  <thead>
15
15
  <tr>
16
- <th scope="col">#</th>
17
16
  <% index_attributes.each do |attribute| %>
18
17
  <th scope="col"><%= attribute %></th>
19
18
  <% end %>
@@ -28,12 +27,12 @@
28
27
  <td><%= record.send(attribute) %></td>
29
28
  <% end %>
30
29
  <td>
31
- <a href="<%= "/admin/#{model_class.name.underscore}/#{record.id}" %>">
30
+ <a href="<%= "#{self.class.url_base}/#{model_class.name.underscore.pluralize}/#{record.id}" %>">
32
31
  show
33
32
  </a>
34
33
  </td>
35
34
  <td>
36
- <a href="<%= "/admin/#{model_class.name.underscore}/#{record.id}/edit" %>">
35
+ <a href="<%= "#{self.class.url_base}/#{model_class.name.underscore.pluralize}/#{record.id}/edit" %>">
37
36
  edit
38
37
  </a>
39
38
  </td>
@@ -2,7 +2,7 @@
2
2
  <h2 class="m-0">Create <%= model_class.name %></h2>
3
3
  <div>
4
4
  <a
5
- href="<%= "/admin/#{model_class.name.underscore}" %>"
5
+ href="<%= "#{self.class.url_base}/#{model_class.name.underscore.pluralize}" %>"
6
6
  class="btn btn-primary">
7
7
  Back to index
8
8
  </a>
@@ -17,7 +17,7 @@
17
17
  <% end %>
18
18
  </ul>
19
19
  <% end %>
20
- <form method="post" action="/admin/#{model_class.name.underscore}">
20
+ <form method="post" action="#{self.class.url_base}/#{model_class.name.underscore.pluralize}">
21
21
  <% form_attributes.each do |attribute| %>
22
22
  <div class="mb-3">
23
23
  <label for="<%= attribute %>" class="form-label"><%= attribute %></label>
@@ -2,7 +2,7 @@
2
2
  <h2 class="m-0">Show <%= model_class.name %></h2>
3
3
  <div>
4
4
  <a
5
- href="<%= "/admin/#{model_class.name.underscore}" %>"
5
+ href="<%= "#{self.class.url_base}/#{model_class.name.underscore.pluralize}" %>"
6
6
  class="btn btn-primary">
7
7
  Back
8
8
  </a>
@@ -8,6 +8,8 @@ module MicroAdmin
8
8
  __dir__
9
9
  ]
10
10
 
11
+ self.url_base = "/admin"
12
+
11
13
  def index(resources)
12
14
  @resources = resources
13
15
  render
@@ -1,3 +1,3 @@
1
1
  module MicroAdmin
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: micro_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - cc-kawakami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-30 00:00:00.000000000 Z
11
+ date: 2022-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler