madmin 1.0.0 → 1.0.1

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: 40199d348bebb973f7b9dc6b6a850bd5c68ff022643384a65acfc59960f86dbb
4
- data.tar.gz: 7f672c9ad00abe803c5be58c57da8c163d944a5a7d152af6e4471830f3460ee9
3
+ metadata.gz: f149452559626564a6b3888b89ddeaf7fb2bf1c3fedbbc4ac4ba3dc2a1df4e58
4
+ data.tar.gz: 8536e397b8d032d704b7e10c938af1ee1eda4911d9c6933ecd9c11f68fbac8f7
5
5
  SHA512:
6
- metadata.gz: c27c66fa995081db788c99036b9a5cd4ea1bec2aaf7d3450a4c633fed0b9e8a9b73658dbc8eda4df0e9f894010f88f4696126c3f1322a886706f8f91195ca3fe
7
- data.tar.gz: 4311d571bca085e92b2dad5902a2ede438347efdb910897fe391efe5764bb9a37b2c1c1228d376e305d11d2fb6712f3d8f4077e4d024dc5d017fdf9e53a14dbe
6
+ metadata.gz: e6a4a123086ee55711728e9f2b1bff5ca90d28c7238690d5f51e9b834f1f5eb15170b7e8e3b1aac7a79e08d4b55ee2500dc11f16d4f62c4a31cc4d0d5ab0b6ba
7
+ data.tar.gz: 49a20396c04c22fbe8001d53ed4cc567b441171943a090cd888b98e94cbf11b31ad5ec89fc67dd9cae98af03282adf8bdacec159075c73605ac743c994338e51
data/README.md CHANGED
@@ -48,6 +48,22 @@ For example, running the following will copy over all of the views into your app
48
48
  rails generate madmin:views
49
49
  ```
50
50
 
51
+ The view files that are copied over in this case includes all of the standard Rails action views (index, new, edit, show, and _form), as well as:
52
+ * `application.html.erb` (layout file)
53
+ * `_javascript.html.erb` (default JavaScript setup)
54
+ * `_navigation.html.erb` (renders the navigation/sidebar menu)
55
+
56
+ As with the other views, you can specifically run the views generator for only the navigation or application layout views:
57
+ ```bash
58
+ rails g madmin:views:navigation
59
+ # -> app/views/madmin/_navigation.html.erb
60
+
61
+ rails g madmin:views:layout # Note the layout generator includes the layout, javascript, and navigation files.
62
+ # -> app/views/madmin/application.html.erb
63
+ # -> app/views/madmin/_javascript.html.erb
64
+ # -> app/views/madmin/_navigation.html.erb
65
+ ```
66
+
51
67
  If you only need to customize specific views, you can restrict which views are copied by the generator:
52
68
  ```bash
53
69
  rails g madmin:views:index
@@ -60,6 +76,11 @@ rails generate madmin:views:index Book
60
76
  # -> app/views/madmin/books/index.html.erb
61
77
  ```
62
78
 
79
+ ## Authentication
80
+
81
+ You can use a couple of strategies to authenticate users who are trying to
82
+ access your madmin panel: [Authentication Docs](docs/authentication.md)
83
+
63
84
  ## 🙏 Contributing
64
85
 
65
86
  This project uses Standard for formatting Ruby code. Please make sure to run standardrb before submitting pull requests.
@@ -1,2 +1,3 @@
1
- <% object = field.value(record) %>
2
- <%= link_to Madmin.resource_for(object).display_name(object), Madmin.resource_for(object).show_path(object) %>
1
+ <% if (object = field.value(record)) %>
2
+ <%= link_to Madmin.resource_for(object).display_name(object), Madmin.resource_for(object).show_path(object) %>
3
+ <% end %>
@@ -1,2 +1,3 @@
1
- <% object = field.value(record) %>
2
- <%= link_to Madmin.resource_for(object).display_name(object), Madmin.resource_for(object).show_path(object) %>
1
+ <% if (object = field.value(record)) %>
2
+ <%= link_to Madmin.resource_for(object).display_name(object), Madmin.resource_for(object).show_path(object) %>
3
+ <% end %>
@@ -1,3 +1,2 @@
1
- ENUM
2
1
  <%= form.label field.attribute_name, class: "inline-block w-32 flex-shrink-0" %>
3
- <%= field.value(record) %>
2
+ <%= form.select field.attribute_name, field.options_for_select(record), { prompt: true }, { class: "form-select" } %>
@@ -1,6 +1,9 @@
1
1
  module Madmin
2
2
  module Fields
3
3
  class Enum < Field
4
+ def options_for_select(record)
5
+ model.defined_enums[attribute_name.to_s].keys
6
+ end
4
7
  end
5
8
  end
6
9
  end
@@ -143,7 +143,12 @@ module Madmin
143
143
  name_string = name.to_s
144
144
 
145
145
  if model.attribute_types.include?(name_string)
146
- model.attribute_types[name_string].type || :string
146
+ column_type = model.attribute_types[name_string]
147
+ if column_type.is_a? ActiveRecord::Enum::EnumType
148
+ :enum
149
+ else
150
+ column_type.type || :string
151
+ end
147
152
  elsif (association = model.reflect_on_association(name))
148
153
  type_for_association(association)
149
154
  elsif model.reflect_on_association(:"rich_text_#{name_string}")
@@ -1,3 +1,3 @@
1
1
  module Madmin
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: madmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-02-05 00:00:00.000000000 Z
12
+ date: 2021-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails