uchi 0.1.4 → 0.1.5
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/app/components/uchi/field/belongs_to/show.html.erb +5 -3
- data/app/components/uchi/field/belongs_to.rb +8 -1
- data/app/components/uchi/ui/page_header/page_header.html.erb +2 -2
- data/app/views/layouts/uchi/application.html.erb +2 -2
- data/app/views/uchi/repository/edit.html.erb +3 -3
- data/app/views/uchi/repository/index.html.erb +3 -3
- data/app/views/uchi/repository/new.html.erb +3 -3
- data/app/views/uchi/repository/show.html.erb +3 -3
- data/lib/uchi/repository/translate.rb +103 -19
- data/lib/uchi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 89d20ec9aa3f6dad006bcf717d489b69fd889d6f8ad37ac484b9a146b52ef843
|
|
4
|
+
data.tar.gz: f6e3c52325eff6be90d814a2158083cf3f2f521f689539c9a23bf30d20246ab4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cf626c8ce1d6a0d5e22ca6df5f190c5def32b4e02d81510429b281cfa54ab79f95fe57745cdce76c4fb54487ce66547521778be78b319cedbcb283de17b5c121
|
|
7
|
+
data.tar.gz: e913266e035d095b1e5c801ba6da2867d9dad9dec026bc8e1cc379d49b9bc6693517416b76ac3393798f09468a9090688ecfb7cb2ab7ffe59eb2fe2a55cffc97
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<% if associated_record %>
|
|
2
|
+
<%= render(Flowbite::Link.new(
|
|
3
|
+
href: associated_repository.routes.path_for(:show, id: associated_record.id)
|
|
4
|
+
).with_content(associated_record.to_s)) %>
|
|
5
|
+
<% end %>
|
|
@@ -25,11 +25,18 @@ module Uchi
|
|
|
25
25
|
|
|
26
26
|
def collection_for_select
|
|
27
27
|
repository = associated_repository
|
|
28
|
-
|
|
28
|
+
items = []
|
|
29
|
+
items << ["", nil] if optional?
|
|
30
|
+
items + collection.map do |item|
|
|
29
31
|
[repository.title(item), item.id]
|
|
30
32
|
end
|
|
31
33
|
end
|
|
32
34
|
|
|
35
|
+
# Returns true if the association is optional.
|
|
36
|
+
def optional?
|
|
37
|
+
reflection.options[:optional] == true
|
|
38
|
+
end
|
|
39
|
+
|
|
33
40
|
def options
|
|
34
41
|
options = {
|
|
35
42
|
attribute: attribute_name,
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
<% end %>
|
|
6
6
|
</div>
|
|
7
7
|
|
|
8
|
-
<div class="items-
|
|
8
|
+
<div class="items-start justify-between space-x-6 md:flex md:px-0">
|
|
9
9
|
<div>
|
|
10
|
-
<h1 class="
|
|
10
|
+
<h1 class="text-3xl font-semibold tracking-tight text-gray-900 dark:text-white group"><%= title %></h1>
|
|
11
11
|
<% if description.present? %>
|
|
12
12
|
<div class="text-lg text-gray-500 lg:mb-0 dark:text-gray-400 lg:max-w-2xl"><%= description %></div>
|
|
13
13
|
<% end %>
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
<div class="md:flex">
|
|
14
14
|
<nav class="w-64 h-full px-3 py-4 overflow-y-auto shrink-0 bg-gray-50 dark:bg-gray-800" aria-label="Main">
|
|
15
15
|
<ul class="space-y-2 font-medium">
|
|
16
|
-
<% Uchi::Repository.all.map { |repository| repository.new }.sort_by { |repository| repository.translate.
|
|
16
|
+
<% Uchi::Repository.all.map { |repository| repository.new }.sort_by { |repository| repository.translate.navigation_label.downcase }.each do |repository| %>
|
|
17
17
|
<li>
|
|
18
18
|
<%= link_to(repository.routes.path_for(:index), :class => "flex items-center p-2 text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700 group") do %>
|
|
19
|
-
<span class="ms-3"><%= repository.translate.
|
|
19
|
+
<span class="ms-3"><%= repository.translate.navigation_label %></span>
|
|
20
20
|
<% end %>
|
|
21
21
|
</li>
|
|
22
22
|
<% end %>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<%- content_for(:page_title) { @repository.translate.
|
|
1
|
+
<%- content_for(:page_title) { @repository.translate.title_for_edit(@record) } %>
|
|
2
2
|
|
|
3
3
|
<%= render(
|
|
4
4
|
Uchi::Ui::PageHeader.new(
|
|
5
5
|
description: @repository.translate.description(:edit),
|
|
6
|
-
title: @repository.translate.
|
|
6
|
+
title: @repository.translate.title_for_edit(@record),
|
|
7
7
|
)) do |header| %>
|
|
8
8
|
<% header.with_breadcrumb(items: [
|
|
9
|
-
{href: @repository.routes.root_path, label:
|
|
9
|
+
{href: @repository.routes.root_path, label: @repository.translate.breadcrumb_label_for_root },
|
|
10
10
|
{href: @repository.routes.path_for(:index), label: @repository.translate.breadcrumb_label(:index) },
|
|
11
11
|
{href: @repository.routes.path_for(:show, id: @record.id), label: @repository.translate.breadcrumb_label(:show, record: @record) },
|
|
12
12
|
{href: @repository.routes.path_for(:edit, id: @record.id), label: @repository.translate.breadcrumb_label(:edit, record: @record) }
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
<%- content_for(:page_title) { @repository.translate.
|
|
1
|
+
<%- content_for(:page_title) { @repository.translate.title_for_index } %>
|
|
2
2
|
|
|
3
3
|
<%= render(
|
|
4
4
|
Uchi::Ui::PageHeader.new(
|
|
5
5
|
description: @repository.translate.description(:index),
|
|
6
|
-
title: @repository.translate.
|
|
6
|
+
title: @repository.translate.title_for_index,
|
|
7
7
|
)) do |header| %>
|
|
8
8
|
<% header.with_action do %>
|
|
9
9
|
<%= link_to(@repository.translate.link_to_new, @repository.routes.path_for(:new), class: Flowbite::Button.classes) %>
|
|
10
10
|
<% end %>
|
|
11
11
|
<% header.with_breadcrumb(items: [
|
|
12
|
-
{href: @repository.routes.root_path, label:
|
|
12
|
+
{href: @repository.routes.root_path, label: @repository.translate.breadcrumb_label_for_root },
|
|
13
13
|
{href: @repository.routes.path_for(:index), label: @repository.translate.breadcrumb_label(:index) }
|
|
14
14
|
]) %>
|
|
15
15
|
<% end %>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<%- content_for(:page_title) { @repository.translate.
|
|
1
|
+
<%- content_for(:page_title) { @repository.translate.title_for_new } %>
|
|
2
2
|
|
|
3
3
|
<%= render(
|
|
4
4
|
Uchi::Ui::PageHeader.new(
|
|
5
5
|
description: @repository.translate.description(:new),
|
|
6
|
-
title: @repository.translate.
|
|
6
|
+
title: @repository.translate.title_for_new,
|
|
7
7
|
)) do |header| %>
|
|
8
8
|
<% header.with_breadcrumb(items: [
|
|
9
|
-
{href: @repository.routes.root_path, label:
|
|
9
|
+
{href: @repository.routes.root_path, label: @repository.translate.breadcrumb_label_for_root },
|
|
10
10
|
{href: @repository.routes.path_for(:index), label: @repository.translate.breadcrumb_label(:index) },
|
|
11
11
|
{href: @repository.routes.path_for(:new), label: @repository.translate.breadcrumb_label(:new) }
|
|
12
12
|
]) %>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<%- content_for(:page_title) { @repository.translate.
|
|
1
|
+
<%- content_for(:page_title) { @repository.translate.title_for_show(@record) } %>
|
|
2
2
|
|
|
3
3
|
<%= render(
|
|
4
4
|
Uchi::Ui::PageHeader.new(
|
|
5
5
|
description: @repository.translate.description(:show, record: @record),
|
|
6
|
-
title: @repository.translate.
|
|
6
|
+
title: @repository.translate.title_for_show(@record),
|
|
7
7
|
)
|
|
8
8
|
) do |header| %>
|
|
9
9
|
<% header.with_action do %>
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<% end %>
|
|
24
24
|
|
|
25
25
|
<% header.with_breadcrumb(items: [
|
|
26
|
-
{href: @repository.routes.root_path, label:
|
|
26
|
+
{href: @repository.routes.root_path, label: @repository.translate.breadcrumb_label_for_root },
|
|
27
27
|
{href: @repository.routes.path_for(:index), label: @repository.translate.breadcrumb_label(:index) },
|
|
28
28
|
{href: @repository.routes.path_for(:show, id: @record.id), label: @repository.translate.breadcrumb_label(:show, record: @record) }
|
|
29
29
|
]) %>
|
|
@@ -39,11 +39,23 @@ module Uchi
|
|
|
39
39
|
translate(i18n_scope("breadcrumb.index.label"), default: nil),
|
|
40
40
|
translate(i18n_scope("index.title"), default: nil),
|
|
41
41
|
plural_name,
|
|
42
|
-
translate("common.index"),
|
|
42
|
+
translate("common.index", default: nil),
|
|
43
43
|
"Index"
|
|
44
44
|
)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
+
# Returns the label for the root breadcrumb item. Defaults to the
|
|
48
|
+
# application name.
|
|
49
|
+
#
|
|
50
|
+
# To customize this provide a translation for the key:
|
|
51
|
+
# `uchi.breadcrumb.root.label`
|
|
52
|
+
def breadcrumb_label_for_root
|
|
53
|
+
first_present_value(
|
|
54
|
+
translate("breadcrumb.root.label", default: nil),
|
|
55
|
+
Rails.application.name.titlecase
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
|
|
47
59
|
# Returns a description for the given page, or nil if none is found.
|
|
48
60
|
# This description is intended to provide additional context for the page
|
|
49
61
|
# being shown.
|
|
@@ -126,30 +138,53 @@ module Uchi
|
|
|
126
138
|
end
|
|
127
139
|
|
|
128
140
|
def link_to_destroy(record)
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
141
|
+
first_present_value(
|
|
142
|
+
translate(
|
|
143
|
+
"link_to_destroy",
|
|
144
|
+
default: nil,
|
|
145
|
+
model: singular_name,
|
|
146
|
+
record: repository.title(record),
|
|
147
|
+
scope: i18n_scope("button")
|
|
148
|
+
),
|
|
149
|
+
translate(
|
|
150
|
+
"common.destroy",
|
|
151
|
+
default: nil,
|
|
152
|
+
model: singular_name,
|
|
153
|
+
record: repository.title(record)
|
|
154
|
+
),
|
|
155
|
+
"Delete"
|
|
135
156
|
)
|
|
136
157
|
end
|
|
137
158
|
|
|
138
159
|
def link_to_edit(record)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
160
|
+
first_present_value(
|
|
161
|
+
translate(
|
|
162
|
+
"link_to_edit",
|
|
163
|
+
default: nil,
|
|
164
|
+
model: singular_name,
|
|
165
|
+
record: repository.title(record),
|
|
166
|
+
scope: i18n_scope("button")
|
|
167
|
+
),
|
|
168
|
+
translate(
|
|
169
|
+
"common.edit",
|
|
170
|
+
default: nil,
|
|
171
|
+
model: singular_name,
|
|
172
|
+
record: repository.title(record)
|
|
173
|
+
),
|
|
174
|
+
"Edit"
|
|
145
175
|
)
|
|
146
176
|
end
|
|
147
177
|
|
|
148
178
|
# Returns the text for the "new" action link.
|
|
179
|
+
#
|
|
180
|
+
# Returns the first of the following translations that is present:
|
|
181
|
+
# 1. Translation from "uchi.repository.[name].button.link_to_new"
|
|
182
|
+
# 2. Translation from "uchi.common.new" with interpolation key %{model}
|
|
183
|
+
# 3. Default string "New %{model}"
|
|
149
184
|
def link_to_new
|
|
150
185
|
translate(
|
|
151
186
|
"link_to_new",
|
|
152
|
-
default: "New %{model}",
|
|
187
|
+
default: translate("common.new", default: "New %{model}"),
|
|
153
188
|
model: singular_name,
|
|
154
189
|
scope: i18n_scope("button")
|
|
155
190
|
)
|
|
@@ -159,6 +194,21 @@ module Uchi
|
|
|
159
194
|
translate("loading", default: "Loading...", scope: "uchi.repository.common")
|
|
160
195
|
end
|
|
161
196
|
|
|
197
|
+
# Returns the label for the navigation link to this repository's index
|
|
198
|
+
# page.
|
|
199
|
+
#
|
|
200
|
+
# Returns the first of the following that is present:
|
|
201
|
+
# 1. Translation from "uchi.repository.[name].navigation.label"
|
|
202
|
+
# 2. Translation from "uchi.repository.[name].index.title"
|
|
203
|
+
# 3. plural name of the model
|
|
204
|
+
def navigation_label
|
|
205
|
+
first_present_value(
|
|
206
|
+
translate(i18n_scope("navigation.label"), default: nil),
|
|
207
|
+
translate(i18n_scope("index.title"), default: nil),
|
|
208
|
+
plural_name
|
|
209
|
+
)
|
|
210
|
+
end
|
|
211
|
+
|
|
162
212
|
# Returns the localized, human-readable plural name of the model this
|
|
163
213
|
# repository manages.
|
|
164
214
|
def plural_name
|
|
@@ -222,16 +272,50 @@ module Uchi
|
|
|
222
272
|
)
|
|
223
273
|
end
|
|
224
274
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
275
|
+
def title_for_edit(record)
|
|
276
|
+
first_present_value(
|
|
277
|
+
translate(
|
|
278
|
+
"title",
|
|
279
|
+
default: nil,
|
|
280
|
+
model: singular_name,
|
|
281
|
+
record: repository.title(record),
|
|
282
|
+
scope: i18n_scope(:edit)
|
|
283
|
+
),
|
|
284
|
+
link_to_edit(record)
|
|
285
|
+
)
|
|
286
|
+
end
|
|
228
287
|
|
|
288
|
+
def title_for_index
|
|
229
289
|
translate(
|
|
230
290
|
"title",
|
|
231
291
|
default: plural_name,
|
|
232
292
|
model: singular_name,
|
|
233
|
-
|
|
234
|
-
|
|
293
|
+
scope: i18n_scope(:index)
|
|
294
|
+
)
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
def title_for_show(record)
|
|
298
|
+
return repository.title(record) if record
|
|
299
|
+
|
|
300
|
+
translate(
|
|
301
|
+
"title",
|
|
302
|
+
default: plural_name,
|
|
303
|
+
model: singular_name,
|
|
304
|
+
scope: i18n_scope(:show)
|
|
305
|
+
)
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
# Returns the title for the "new" page.
|
|
309
|
+
#
|
|
310
|
+
# Returns the first of the following translations that is present:
|
|
311
|
+
# 1. Translation from "uchi.repository.[name].new.title"
|
|
312
|
+
# 2. Translation from "uchi.repository.[name].button.link_to_new"
|
|
313
|
+
# 3. Translation from "uchi.common.new" with interpolation key %{model}
|
|
314
|
+
# 4. Default string "New %{model}"
|
|
315
|
+
def title_for_new
|
|
316
|
+
first_present_value(
|
|
317
|
+
translate(i18n_scope("new.title"), default: nil),
|
|
318
|
+
link_to_new
|
|
235
319
|
)
|
|
236
320
|
end
|
|
237
321
|
|
data/lib/uchi/version.rb
CHANGED