madmin 1.2.8 → 1.2.10

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: 452ba760d0701d79257b2f0ef4282a785dd3bc3e5380802c75220a6e7e8d3113
4
- data.tar.gz: af23fac79122683d21c97866a355b2ebb373f7353610a46e8b83f25504a7e9b2
3
+ metadata.gz: 1f28056e0049fbd6d19f4b686b9742d1a0d81e61bea220e0a815870be83fd426
4
+ data.tar.gz: ccd99dd6809870a31934bc822a4b05a506b0485a42b87b031f2b96deeea9ade9
5
5
  SHA512:
6
- metadata.gz: 0e37320de16647c286f7551e819f290bd040862ba0b209f8ee0a57971c76ee2988fa149a889e6bb366e5fe212eb98c93f101cb010ac65af34f64a9144ec34800
7
- data.tar.gz: 0ff60d8bca0aeb06769542e1d550ed468cad26213ab04259335dbec5e61e03890fc253babb78ac09358c15345f6c98d7b1fc55acaf77fe2115939b93d0d7005c
6
+ metadata.gz: bcc1478dd032b27ef03c7707ff15bb390b44e452169404b936274971a68c72cbbd83bdcccab4498dd385f0a4c0f22d1481cbccf970596d7cc1ef44a3ccc255bf
7
+ data.tar.gz: c55e2a66753ca675a7906a7c12114fdc956f68da3deb1119bd83761f47c3fd42396c658baab2c5a57b7c1d42047c7f0d34f95d29c1f99dc305c95d0b96ae73f9
@@ -2,6 +2,37 @@
2
2
  <%= stylesheet_link_tag "https://unpkg.com/flatpickr/dist/flatpickr.min.css", "data-turbo-track": "reload" %>
3
3
  <%= stylesheet_link_tag "https://unpkg.com/trix/dist/trix.css", "data-turbo-track": "reload" %>
4
4
  <%= stylesheet_link_tag "https://unpkg.com/tom-select/dist/css/tom-select.min.css", "data-turbo-track": "reload" %>
5
+ <style type="text/tailwindcss">
6
+ .pagy {
7
+ @apply isolate inline-flex rounded-md;
8
+
9
+ a:first-child {
10
+ @apply rounded-l-md;
11
+ }
12
+ a:last-child {
13
+ @apply rounded-r-md;
14
+ }
15
+
16
+ a {
17
+ @apply relative -ml-px inline-flex items-center bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-100 focus:z-10;
18
+
19
+ &:not([href]) {
20
+ @apply text-gray-300 cursor-default;
21
+ }
22
+
23
+ &.current {
24
+ @apply text-white bg-blue-500 ring-blue-500;
25
+ }
26
+ }
27
+
28
+ label {
29
+ @apply inline-block whitespace-nowrap bg-gray-200 rounded-lg px-3 py-0.5;
30
+ input {
31
+ @apply bg-gray-100 border-none rounded-md;
32
+ }
33
+ }
34
+ }
35
+ </style>
5
36
 
6
37
  <script type="importmap" data-turbo-track="reload">
7
38
  {
@@ -13,7 +44,7 @@
13
44
  "@rails/activestorage": "https://unpkg.com/@rails/activestorage@<%= npm_rails_version %>/app/assets/javascripts/activestorage.esm.js",
14
45
  "flatpickr": "https://unpkg.com/flatpickr/dist/esm/index.js",
15
46
  "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",
47
+ "tailwindcss-stimulus-components": "https://unpkg.com/tailwindcss-stimulus-components/dist/tailwindcss-stimulus-components.module.js",
17
48
  "tom-select": "https://unpkg.com/tom-select/dist/esm/tom-select.complete.js",
18
49
  "trix": "https://unpkg.com/trix"
19
50
  }
@@ -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>
@@ -1,7 +1,7 @@
1
1
  <h1 class="text-xl mb-4">
2
- <%= link_to resource.friendly_name.pluralize, resource.index_path, class: "text-indigo-500" %>
2
+ <%= link_to resource.friendly_name.pluralize, resource.index_path, class: "text-blue-500" %>
3
3
  /
4
- <strong>Edit <%= link_to resource.display_name(@record), resource.show_path(@record), class: "text-indigo-500" %></strong>
4
+ <strong>Edit <%= link_to resource.display_name(@record), resource.show_path(@record), class: "text-blue-500" %></strong>
5
5
  </h1>
6
6
 
7
7
  <%= render partial: "form", locals: { record: @record, resource: resource } %>
@@ -4,7 +4,7 @@
4
4
  <div class="flex-grow flex md:justify-end gap-4">
5
5
  <form class="flex items-center gap-2 relative">
6
6
  <%= hidden_field_tag :page, params[:page], value: 1, class: "hidden" %>
7
- <%= search_field_tag :q, params[:q], placeholder: "Search", class: "rounded-full px-4 focus:bg-white focus:border-indigo-500" %>
7
+ <%= search_field_tag :q, params[:q], placeholder: "Search", class: "rounded-full px-4 focus:bg-white focus:border-blue-500" %>
8
8
  <%= link_to clear_search_params, class: "absolute top-1/2 right-3 text-gray-500 bg-white transform -translate-y-1/2" do %>
9
9
  <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
10
10
  <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" />
@@ -51,12 +51,12 @@
51
51
  <% end %>
52
52
 
53
53
  <td class="px-4 py-2 text-center">
54
- <%= link_to "View", resource.show_path(record), class: "text-indigo-500" %>
55
- <%= link_to "Edit", resource.edit_path(record), class: "text-indigo-500" %>
54
+ <%= link_to "View", resource.show_path(record), class: "text-blue-500" %>
55
+ <%= link_to "Edit", resource.edit_path(record), class: "text-blue-500" %>
56
56
  </td>
57
57
  </tr>
58
58
  <% end %>
59
59
  </tbody>
60
60
  </table>
61
61
  </div>
62
- <%== render(partial: 'madmin/pagy/nav', locals: { pagy: @pagy }) if @pagy.pages > 1 %>
62
+ <%== pagy_nav @pagy %>
@@ -1,5 +1,5 @@
1
1
  <h1 class="text-xl mb-4">
2
- <%= link_to resource.friendly_name.pluralize, resource.index_path, class: "text-indigo-500" %>
2
+ <%= link_to resource.friendly_name.pluralize, resource.index_path, class: "text-blue-500" %>
3
3
  /
4
4
  <strong>New <%= resource.friendly_name %></strong>
5
5
  </h1>
@@ -1,13 +1,13 @@
1
1
  <div class="md:flex items-center justify-between mb-4">
2
2
  <h1 class="text-xl">
3
- <%= link_to resource.friendly_name.pluralize, resource.index_path, class: "text-indigo-500" %>
3
+ <%= link_to resource.friendly_name.pluralize, resource.index_path, class: "text-blue-500" %>
4
4
  /
5
- <%= link_to resource.display_name(@record), resource.show_path(@record), class: "text-indigo-500 font-bold" %>
5
+ <%= link_to resource.display_name(@record), resource.show_path(@record), class: "text-blue-500 font-bold" %>
6
6
  </h1>
7
7
 
8
8
  <div class="flex gap-2 items-center px-4">
9
9
  <% resource.member_actions.each do |action| %>
10
- <%= instance_eval &action %>
10
+ <%= instance_eval(&action) %>
11
11
  <% end %>
12
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" %>
13
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" %>
@@ -4,6 +4,6 @@
4
4
  <%= image_tag main_app.url_for(attachment), class: "max-h-32" %>
5
5
  <% end %>
6
6
  <% else %>
7
- <%= link_to attachment.filename, main_app.url_for(attachment), target: :_blank, class: "text-indigo-500 underline" %>
7
+ <%= link_to attachment.filename, main_app.url_for(attachment), target: :_blank, class: "text-blue-500 underline" %>
8
8
  <% end %>
9
9
  <% end %>
@@ -5,7 +5,7 @@
5
5
  <%= image_tag main_app.url_for(attachment), class: "max-h-32" %>
6
6
  <% end %>
7
7
  <% else %>
8
- <%= link_to attachment.filename, main_app.url_for(attachment), target: :_blank, class: "text-indigo-500 underline" %>
8
+ <%= link_to attachment.filename, main_app.url_for(attachment), target: :_blank, class: "text-blue-500 underline" %>
9
9
  <% end %>
10
10
  <% end %>
11
11
  <% end %>
@@ -1,3 +1,3 @@
1
1
  <% if (object = field.value(record)) %>
2
- <%= link_to Madmin.resource_for(object).display_name(object), Madmin.resource_for(object).show_path(object), class: "text-indigo-500 underline" %>
2
+ <%= link_to Madmin.resource_for(object).display_name(object), Madmin.resource_for(object).show_path(object), class: "text-blue-500 underline" %>
3
3
  <% end %>
@@ -1,6 +1,6 @@
1
1
  <% value = field.value(record) %>
2
2
  <% if value.respond_to?(:url) %>
3
- <%= link_to value.url, value.url, target: :_blank, class: "text-indigo-500 underline" %>
3
+ <%= link_to value.url, value.url, target: :_blank, class: "text-blue-500 underline" %>
4
4
  <% else %>
5
5
  <%= value %>
6
6
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <% field.value(record).each do |object| %>
2
2
  <div>
3
- <%= link_to Madmin.resource_for(object).display_name(object), Madmin.resource_for(object).show_path(object), class: "text-indigo-500 underline" %>
3
+ <%= link_to Madmin.resource_for(object).display_name(object), Madmin.resource_for(object).show_path(object), class: "text-blue-500 underline" %>
4
4
  </div>
5
5
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <% if field.attribute_name == :id %>
2
- <%= link_to field.value(record), resource.show_path(record), class: "text-indigo-500 underline" %>
2
+ <%= link_to field.value(record), resource.show_path(record), class: "text-blue-500 underline" %>
3
3
  <% else %>
4
4
  <%= field.value(record) %>
5
5
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <% field.value(record).each do |object| %>
2
2
  <div>
3
- <%= link_to Madmin.resource_for(object).display_name(object), Madmin.resource_for(object).show_path(object), class: "text-indigo-500 underline" %>
3
+ <%= link_to Madmin.resource_for(object).display_name(object), Madmin.resource_for(object).show_path(object), class: "text-blue-500 underline" %>
4
4
  </div>
5
5
  <% end %>
@@ -1,3 +1,3 @@
1
1
  <% if (object = field.value(record)) %>
2
- <%= link_to Madmin.resource_for(object).display_name(object), Madmin.resource_for(object).show_path(object), class: "text-indigo-500 underline" %>
2
+ <%= link_to Madmin.resource_for(object).display_name(object), Madmin.resource_for(object).show_path(object), class: "text-blue-500 underline" %>
3
3
  <% end %>
@@ -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,3 +1,5 @@
1
+ require "ostruct"
2
+
1
3
  module Madmin
2
4
  class Resource
3
5
  class_attribute :attributes, default: ActiveSupport::OrderedHash.new
@@ -114,8 +116,6 @@ module Madmin
114
116
  member_actions << block
115
117
  end
116
118
 
117
- private
118
-
119
119
  def field_for_type(type)
120
120
  {
121
121
  binary: Fields::String,
@@ -184,7 +184,7 @@ module Madmin
184
184
 
185
185
  if model.attribute_types.include?(name_string)
186
186
  column_type = model.attribute_types[name_string]
187
- if column_type.is_a? ActiveRecord::Enum::EnumType
187
+ if column_type.is_a? ::ActiveRecord::Enum::EnumType
188
188
  :enum
189
189
  else
190
190
  column_type.type || :string
@@ -226,7 +226,6 @@ module Madmin
226
226
 
227
227
  def model_store_accessors
228
228
  store_accessors = model.stored_attributes.values
229
-
230
229
  store_accessors.flatten
231
230
  end
232
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.8"
2
+ VERSION = "1.2.10"
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.8
4
+ version: 1.2.10
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: 2023-05-10 00:00:00.000000000 Z
12
+ date: 2024-05-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -63,6 +63,7 @@ files:
63
63
  - app/views/layouts/madmin/application.html.erb
64
64
  - app/views/madmin/application/_form.html.erb
65
65
  - app/views/madmin/application/_javascript.html.erb
66
+ - app/views/madmin/application/_menu_resources.html.erb
66
67
  - app/views/madmin/application/_navigation.html.erb
67
68
  - app/views/madmin/application/edit.html.erb
68
69
  - app/views/madmin/application/index.html.erb
@@ -133,7 +134,6 @@ files:
133
134
  - app/views/madmin/fields/time/_form.html.erb
134
135
  - app/views/madmin/fields/time/_index.html.erb
135
136
  - app/views/madmin/fields/time/_show.html.erb
136
- - app/views/madmin/pagy/_nav.html.erb
137
137
  - app/views/madmin/shared/_label.html.erb
138
138
  - lib/generators/madmin/field/field_generator.rb
139
139
  - lib/generators/madmin/field/templates/_form.html.erb
@@ -191,7 +191,7 @@ homepage: https://github.com/excid3/madmin
191
191
  licenses:
192
192
  - MIT
193
193
  metadata: {}
194
- post_install_message:
194
+ post_install_message:
195
195
  rdoc_options: []
196
196
  require_paths:
197
197
  - lib
@@ -206,8 +206,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
206
  - !ruby/object:Gem::Version
207
207
  version: '0'
208
208
  requirements: []
209
- rubygems_version: 3.4.12
210
- signing_key:
209
+ rubygems_version: 3.5.9
210
+ signing_key:
211
211
  specification_version: 4
212
212
  summary: A modern admin for Ruby on Rails apps
213
213
  test_files: []
@@ -1,20 +0,0 @@
1
- <%#
2
- This template is i18n-ready: if you don't use i18n, then you can replace the pagy_t
3
- calls with the actual strings ("&lsaquo; Prev", "Next &rsaquo;", "&hellip;").
4
- The link variable is set to a proc that returns the link tag.
5
- Usage: link.call( page_number [, text [, extra_attributes_string ]])
6
- -%>
7
- <% link = pagy_link_proc(pagy) -%>
8
- <%# -%><nav aria-label="pager" class="space-x-1 px-2 py-1" role="navigation">
9
- <% if pagy.prev -%> <span><%== link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous" class="text-white bg-indigo-500 rounded-2xl px-3 py-1.5"') %></span>
10
- <% else -%> <span class="text-gray-400 bg-gray-100 rounded-2xl px-3 py-1.5 cursor-not-allowed"><%== pagy_t('pagy.nav.prev') %></span>
11
- <% end -%>
12
- <% pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36] -%>
13
- <% if item.is_a?(Integer) -%> <span><%== link.call(item, item, 'class="text-gray-400 rounded-full px-2.5 py-1.5 hover:bg-indigo-200 hover:text-indigo-500"') %></span>
14
- <% elsif item.is_a?(String) -%> <span class="text-indigo-500 font-semibold px-2.5 py-1.5"><%= item %></span>
15
- <% elsif item == :gap -%> <span class="text-gray-400 text-xl px-1.5 py-1.5"><%== pagy_t('pagy.nav.gap') %></span>
16
- <% end -%>
17
- <% end -%>
18
- <% if pagy.next -%> <span><%== link.call(pagy.next, pagy_t('pagy.nav.next'), 'aria-label="next" class="text-white bg-indigo-500 rounded-2xl px-3 py-1.5"') %></span>
19
- <% else -%> <span class="text-gray-400 bg-gray-100 rounded-2xl px-3 py-1.5 cursor-not-allowed"><%== pagy_t('pagy.nav.next') %></span>
20
- <% end -%>