jav_madmin 3.3.1 → 3.3.3

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: 8851921f59e223564ae393dcca61c00e2b03aeabe258f6e81a7094cae3a17a75
4
- data.tar.gz: 50cde4226e316d257c897f21cc33ea1f0b4eadfc2ec87650a4e8d715e3008911
3
+ metadata.gz: de5e112e317fa81235e17c2d449ed30233b5f7de20bb646ba17eb587065f914c
4
+ data.tar.gz: 28360b51195be493c260b182df03a08b7a5d4de3ed419a46682ecdcb7fde8f36
5
5
  SHA512:
6
- metadata.gz: a7806677198d529826ad3ed638e34f6bbd79c5ae7cc3513931ec6bcb156ef6961d66523055f0b7481739d0c687791826e58bcd3a336cd8fd981ed40d598e4691
7
- data.tar.gz: bf42482ce949754a19245f272e78f2a34974c9bcba08fef199b23f410a15d973a5b9f0bdb07fcf380870c17fd864a42ca69c3f689d286b553bbfbca7dbd243e7
6
+ metadata.gz: 7283c6f7073392ef550e9e5be2813ffbeb2a2cb5d30dbf345ed2fa22e10848e0785f406f23f98170ba90ccadb86453b7eb5cc696a3981c75fd179e933bf03dee
7
+ data.tar.gz: 6770f1fde2084d0657c6b578b4fb392deebbbf2d85f9dbaa19dd8dbce60095aa5827d1daf916bd99f229cd70942e270739844955895bb4622cabd15f02e047ab
@@ -3,13 +3,13 @@
3
3
 
4
4
  <% Madmin.menu.render do |item| %>
5
5
  <% if item.url %>
6
- <%= nav_link_to item.human_label, item.url, starts_with: item.url %>
6
+ <%= nav_link_to item.label, item.url, starts_with: item.url %>
7
7
  <% else %>
8
- <h4><%= item.human_label %></h4>
8
+ <h4><%= item.label %></h4>
9
9
  <% end %>
10
10
 
11
11
  <% item.items.each do |item| %>
12
- <%= nav_link_to item.human_label, item.url, starts_with: item.url %>
12
+ <%= nav_link_to item.label, item.url, starts_with: item.url %>
13
13
  <% end %>
14
14
  <% end %>
15
15
  </nav>
@@ -13,7 +13,7 @@
13
13
  <% end %>
14
14
  <% unless resource.readonly? %>
15
15
  <%= link_to t("madmin.actions.edit"), resource.edit_path(@record), class: "btn btn-secondary" %>
16
- <%= button_to t("madmin.actions.delete"), resource.show_path(@record), method: :delete, data: { turbo_confirm: t("madmin.confirmations.delete", resource: resource.friendly_name, name: resource.display_name(@record)) }, class: "btn btn-danger" %>
16
+ <%= button_to t("madmin.actions.delete"), resource.show_path(@record), method: :delete, data: { turbo_confirm: resource.delete_confirmation(@record) }, class: "btn btn-danger" %>
17
17
  <% end %>
18
18
  </div>
19
19
  </header>
@@ -26,6 +26,9 @@ class <%= class_name %>Resource < Madmin::Resource
26
26
  # Customize the display name of records in the admin area.
27
27
  # def self.display_name(record) = record.name
28
28
 
29
+ # Customize the confirmation shown before deleting a record. Return nil to skip it.
30
+ # def self.delete_confirmation(record) = "Delete #{record.name}? This can't be undone."
31
+
29
32
  # Customize the default sort column and direction.
30
33
  # def self.default_sort_column = "created_at"
31
34
  #
data/lib/madmin/menu.rb CHANGED
@@ -45,7 +45,7 @@ module Madmin
45
45
  def items
46
46
  @children.values.sort do |a, b|
47
47
  result = a.position <=> b.position
48
- result = a.human_label <=> b.human_label if result == 0 # sort alphabetically for the same position
48
+ result = a.label <=> b.label if result == 0 # sort alphabetically for the same position
49
49
  result
50
50
  end
51
51
  end
@@ -67,13 +67,6 @@ module Madmin
67
67
  @children = {}
68
68
  end
69
69
 
70
- def human_label
71
- @human_label ||= if label.is_a?(Symbol)
72
- I18n.t("activerecord.models.#{label}", count: 2, default: [:"madmin.navigation.#{label}", label.to_s.pluralize(I18n.locale).titleize])
73
- else
74
- label
75
- end
76
- end
77
70
  end
78
71
  end
79
72
  end
@@ -150,6 +150,14 @@ module Madmin
150
150
  "#{record.model_name.human} ##{record.id}"
151
151
  end
152
152
 
153
+ # Override for wording that needs more than the display name. Return nil to skip the confirmation.
154
+ def delete_confirmation(record)
155
+ I18n.t("madmin.resources.#{model.model_name.i18n_key}.confirmations.delete",
156
+ default: :"madmin.confirmations.delete",
157
+ resource: friendly_name,
158
+ name: display_name(record))
159
+ end
160
+
153
161
  def friendly_model?
154
162
  model.respond_to? :friendly
155
163
  end
@@ -1,3 +1,3 @@
1
1
  module Madmin
2
- VERSION = "3.3.1"
2
+ VERSION = "3.3.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jav_madmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 3.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver