madmin 1.2.7 → 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cd4e0b3d14780dd13db0a21a57a63e750a750298ea78cc93ec5eb327b1714e7
4
- data.tar.gz: 92f273ea140b603a887660b36802de9e6c0021a56cbeeb49cef5318696ae7bf6
3
+ metadata.gz: d4711c582952084164bfafbad483a4b5cb520ff505f96c0f9a87a7b61732068c
4
+ data.tar.gz: 3eed3f7cbd6969f14b499c3c51bc91cacf423b9554c590c612000d23ccafea8f
5
5
  SHA512:
6
- metadata.gz: 677c4da0f37a96e2515584a02e6d0c941d59fae91b43a15e19386a723d1bdeb6a4e47db8bdc987c59e59c1b75ae2f507d055603a8a996dc5c45b3731d95aac13
7
- data.tar.gz: b06f7fa04b747a761f956fccaa81e9f4535757db2276427e0cbda7a63d901295c9e275faf22a9753459290d530808f6b118806813e7858aeada501b3cb220cbf
6
+ metadata.gz: 3464c6efd9b1561a49c437b8f994616e212d88ba0ec37eebbdac78cccaa0f700ef28bb5c90c20133eea98dfbc71cd7f008b8db38e055602bacc7a7bddcafb0e8
7
+ data.tar.gz: dff80cd6e7c84008618f61381ec0551519305f6ab8434d0742a85f37e50202740a5d146beb27989308426f8bd7ffd218fb86bf0903074bb4d89ec2238b55dbf2
@@ -15,7 +15,7 @@ module Madmin
15
15
  end
16
16
 
17
17
  def clear_search_params
18
- resource.index_path(params.permit(:sort, :direction))
18
+ resource.index_path(sort: params[:sort], direction: params[:direction])
19
19
  end
20
20
  end
21
21
  end
@@ -2,13 +2,13 @@ module Madmin
2
2
  module SortHelper
3
3
  def sortable(column, title, options = {})
4
4
  matching_column = (column.to_s == sort_column)
5
- direction = sort_direction == "asc" ? "desc" : "asc"
5
+ direction = (sort_direction == "asc") ? "desc" : "asc"
6
6
 
7
7
  link_to resource.index_path(sort: column, direction: direction), options do
8
8
  concat title
9
9
  if matching_column
10
10
  concat " "
11
- concat tag.i(sort_direction == "asc" ? "▲" : "▼")
11
+ concat tag.i((sort_direction == "asc") ? "▲" : "▼")
12
12
  end
13
13
  end
14
14
  end
@@ -13,7 +13,7 @@
13
13
  "@rails/activestorage": "https://unpkg.com/@rails/activestorage@<%= npm_rails_version %>/app/assets/javascripts/activestorage.esm.js",
14
14
  "flatpickr": "https://unpkg.com/flatpickr/dist/esm/index.js",
15
15
  "stimulus-flatpickr": "https://unpkg.com/stimulus-flatpickr@3.0.0-0/dist/index.m.js",
16
- "tailwindcss-stimulus-components": "https://unpkg.com/tailwindcss-stimulus-components/dist/tailwindcss-stimulus-components.modern.js",
16
+ "tailwindcss-stimulus-components": "https://unpkg.com/tailwindcss-stimulus-components/dist/tailwindcss-stimulus-components.module.js",
17
17
  "tom-select": "https://unpkg.com/tom-select/dist/esm/tom-select.complete.js",
18
18
  "trix": "https://unpkg.com/trix"
19
19
  }
@@ -0,0 +1,7 @@
1
+ <% Madmin.resources.each do |resource| %>
2
+ <%= nav_link_to resource.friendly_name.pluralize, resource.index_path, class: "block p-2 rounded hover:bg-gray-100", starts_with: resource.index_path, active_class: "font-bold text-black" %>
3
+ <% end %>
4
+
5
+ <div class="mt-auto">
6
+ <%= link_to "View Madmin on GitHub", "https://github.com/excid3/madmin", target: :_blank, class: "block p-2 rounded text-gray-500 hover:bg-gray-100" %>
7
+ </div>
@@ -1,4 +1,4 @@
1
- <div class="flex flex-col h-full text-sm" data-controller="dropdown">
1
+ <div class="flex flex-col h-full text-sm">
2
2
  <div class="flex md:block justify-between items-center">
3
3
  <div class="flex md:block items-center">
4
4
  <h1 class="mr-2 md:p-2 text-xl font-semibold">Madmin</h1>
@@ -9,7 +9,7 @@
9
9
  <% end %>
10
10
  </div>
11
11
 
12
- <div class="-mr-2 flex items-center md:hidden">
12
+ <div class="-mr-2 flex items-center md:hidden relative" data-controller="dropdown">
13
13
  <button data-action="click->dropdown#toggle touch->dropdown#toggle click@window->dropdown#hide touch@window#dropdown->hide" type="button" class="bg-white rounded-md p-2 inline-flex items-center justify-center text-gray-400 hover:bg-gray-200 focus:outline-none focus:ring-2 focus-ring-inset focus:ring-white" id="main-menu" aria-haspopup="true">
14
14
  <span class="sr-only">Open main menu</span>
15
15
  <!-- Heroicon name: outline/menu -->
@@ -17,16 +17,13 @@
17
17
  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path>
18
18
  </svg>
19
19
  </button>
20
- </div>
21
- </div>
22
20
 
23
- <div class="hidden md:flex flex-col flex-grow justify-between" data-dropdown-target="menu">
24
- <% Madmin.resources.each do |resource| %>
25
- <%= nav_link_to resource.friendly_name.pluralize, resource.index_path, class: "block p-2 rounded hover:bg-gray-100", starts_with: resource.index_path, active_class: "font-bold text-black" %>
26
- <% end %>
27
-
28
- <div class="mt-auto">
29
- <%= link_to "View Madmin on GitHub", "https://github.com/excid3/madmin", target: :_blank, class: "block p-2 rounded text-gray-500 hover:bg-gray-100" %>
21
+ <div class="absolute top-12 right-0 bg-white rounded-lg min-w-64 shadow-lg hidden md:flex flex-col flex-grow justify-between" data-dropdown-target="menu">
22
+ <%= render "menu_resources" %>
23
+ </div>
24
+ </div>
25
+ <div class="hidden md:block">
26
+ <%= render "menu_resources" %>
30
27
  </div>
31
28
  </div>
32
29
  </div>
@@ -5,10 +5,11 @@
5
5
  <%= link_to resource.display_name(@record), resource.show_path(@record), class: "text-indigo-500 font-bold" %>
6
6
  </h1>
7
7
 
8
- <div class="flex items-center px-4">
9
- <div class="mr-2">
10
- <%= link_to "Edit", resource.edit_path(@record), class: "block bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 px-4 border border-gray-400 rounded shadow" %>
11
- </div>
8
+ <div class="flex gap-2 items-center px-4">
9
+ <% resource.member_actions.each do |action| %>
10
+ <%= instance_eval(&action) %>
11
+ <% end %>
12
+ <%= link_to "Edit", resource.edit_path(@record), class: "block bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 px-4 border border-gray-400 rounded shadow" %>
12
13
  <%= button_to "Delete", resource.show_path(@record), method: :delete, data: { turbo_confirm: "Are you sure?" }, class: "bg-white hover:bg-gray-100 text-red-500 font-semibold py-2 px-4 border border-red-500 rounded shadow pointer-cursor" %>
13
14
  </div>
14
15
  </div>
@@ -2,7 +2,7 @@ require "madmin/generator_helpers"
2
2
 
3
3
  module Madmin
4
4
  module Generators
5
- class InstallGenerator < Rails::Generators::Base
5
+ class InstallGenerator < ::Rails::Generators::Base
6
6
  include Madmin::GeneratorHelpers
7
7
 
8
8
  source_root File.expand_path("../templates", __FILE__)
@@ -43,12 +43,12 @@ module Madmin
43
43
  # Skip Abstract classes, ActiveRecord::Base, and auto-generated HABTM models
44
44
  def generateable_models
45
45
  active_record_models.reject do |model|
46
- model.abstract_class? || model == ActiveRecord::Base || model.name.start_with?("HABTM_")
46
+ model.abstract_class? || model == ::ActiveRecord::Base || model.name.start_with?("HABTM_")
47
47
  end
48
48
  end
49
49
 
50
50
  def active_record_models
51
- ObjectSpace.each_object(ActiveRecord::Base.singleton_class)
51
+ ObjectSpace.each_object(::ActiveRecord::Base.singleton_class)
52
52
  end
53
53
  end
54
54
  end
@@ -12,7 +12,7 @@ module Madmin
12
12
  end
13
13
 
14
14
  def to_param
15
- {"#{attribute_name.to_s.singularize}_ids".to_sym => []}
15
+ {"#{attribute_name.to_s.singularize}_ids": []}
16
16
  end
17
17
 
18
18
  def index_path
@@ -1,11 +1,15 @@
1
+ require "ostruct"
2
+
1
3
  module Madmin
2
4
  class Resource
3
5
  class_attribute :attributes, default: ActiveSupport::OrderedHash.new
6
+ class_attribute :member_actions, default: []
4
7
  class_attribute :scopes, default: []
5
8
 
6
9
  class << self
7
10
  def inherited(base)
8
11
  base.attributes = attributes.dup
12
+ base.member_actions = scopes.dup
9
13
  base.scopes = scopes.dup
10
14
  super
11
15
  end
@@ -108,7 +112,9 @@ module Madmin
108
112
  attributes.values.select { |a| a.field.searchable? }
109
113
  end
110
114
 
111
- private
115
+ def member_action(&block)
116
+ member_actions << block
117
+ end
112
118
 
113
119
  def field_for_type(type)
114
120
  {
@@ -178,7 +184,7 @@ module Madmin
178
184
 
179
185
  if model.attribute_types.include?(name_string)
180
186
  column_type = model.attribute_types[name_string]
181
- if column_type.is_a? ActiveRecord::Enum::EnumType
187
+ if column_type.is_a? ::ActiveRecord::Enum::EnumType
182
188
  :enum
183
189
  else
184
190
  column_type.type || :string
@@ -220,7 +226,6 @@ module Madmin
220
226
 
221
227
  def model_store_accessors
222
228
  store_accessors = model.stored_attributes.values
223
-
224
229
  store_accessors.flatten
225
230
  end
226
231
  end
data/lib/madmin/search.rb CHANGED
@@ -50,11 +50,11 @@ module Madmin
50
50
  end
51
51
 
52
52
  def query_table_name(attr)
53
- ActiveRecord::Base.connection.quote_column_name(@scoped_resource.table_name)
53
+ ::ActiveRecord::Base.connection.quote_column_name(@scoped_resource.table_name)
54
54
  end
55
55
 
56
56
  def column_to_query(attr)
57
- ActiveRecord::Base.connection.quote_column_name(attr)
57
+ ::ActiveRecord::Base.connection.quote_column_name(attr)
58
58
  end
59
59
  end
60
60
  end
@@ -1,3 +1,3 @@
1
1
  module Madmin
2
- VERSION = "1.2.7"
2
+ VERSION = "1.2.9"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: madmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
8
  - Andrea Fomera
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-09-30 00:00:00.000000000 Z
12
+ date: 2024-04-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -32,9 +32,6 @@ dependencies:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '3.5'
35
- - - "<"
36
- - !ruby/object:Gem::Version
37
- version: '6.0'
38
35
  type: :runtime
39
36
  prerelease: false
40
37
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,9 +39,6 @@ dependencies:
42
39
  - - ">="
43
40
  - !ruby/object:Gem::Version
44
41
  version: '3.5'
45
- - - "<"
46
- - !ruby/object:Gem::Version
47
- version: '6.0'
48
42
  description: It's an admin, obviously.
49
43
  email:
50
44
  - excid3@gmail.com
@@ -69,6 +63,7 @@ files:
69
63
  - app/views/layouts/madmin/application.html.erb
70
64
  - app/views/madmin/application/_form.html.erb
71
65
  - app/views/madmin/application/_javascript.html.erb
66
+ - app/views/madmin/application/_menu_resources.html.erb
72
67
  - app/views/madmin/application/_navigation.html.erb
73
68
  - app/views/madmin/application/edit.html.erb
74
69
  - app/views/madmin/application/index.html.erb
@@ -197,7 +192,7 @@ homepage: https://github.com/excid3/madmin
197
192
  licenses:
198
193
  - MIT
199
194
  metadata: {}
200
- post_install_message:
195
+ post_install_message:
201
196
  rdoc_options: []
202
197
  require_paths:
203
198
  - lib
@@ -212,8 +207,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
207
  - !ruby/object:Gem::Version
213
208
  version: '0'
214
209
  requirements: []
215
- rubygems_version: 3.3.7
216
- signing_key:
210
+ rubygems_version: 3.5.9
211
+ signing_key:
217
212
  specification_version: 4
218
213
  summary: A modern admin for Ruby on Rails apps
219
214
  test_files: []