administration-zero 0.0.14 → 0.0.17

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: a291ddd1aa06b883bcbd143aeef64c9d2d87045b12fa4f33fc048987fe67ac79
4
- data.tar.gz: ac6de3699a5db5e9f02052c70b4bbf7ea80558801a7e930df4c44fb17356124b
3
+ metadata.gz: 48700b15bc64b0480184e97ff4ceae284e8a4c2403d9bf0ae083291570a3147e
4
+ data.tar.gz: ac351aa3ffc2eefb5b588adb3a5076ea790b00e5f360152126db725690dc4ef2
5
5
  SHA512:
6
- metadata.gz: 4dc53a371733b5a796bded1aed343f94e9db143f65393a2e2f1aca27339c57df2aca9bca84458a35534ce21be2a46cc68a51f51b0386429fe8d4d7cd7d2155ec
7
- data.tar.gz: d9a3abf79a2c4b3c5e95fa040b2ed4af7cbeb1d47ecdf99416820e3872ff7ef2c746e24dc062c81cdaf7e9e38b7fd6ac6f5eb98ed34a8bba9aadda21a00389f4
6
+ metadata.gz: 77646b36ce47942d583972f37e99fd83d886cdbf759f12054fd0b3982916130ca5c0936c98c654e90aa2438d03f53889397f1bae4636cadfd59b506ae8c35ea4
7
+ data.tar.gz: 6ea59ae1da5b860d1c80be4575fd5abe828d0c12aff33c0a5b09a97eae2ddb6f83c7f748a8d6251d9738d7c825e98f8fdf65729b341c115c6ee73178bf5e5e3b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- administration-zero (0.0.14)
4
+ administration-zero (0.0.17)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -11,6 +11,7 @@ The purpose of administration zero is to generate a pre-built administration pan
11
11
  - [Sortable and filterable](https://github.com/activerecord-hackery/ransack)
12
12
  - [Exportable data](https://github.com/westonganger/spreadsheet_architect)
13
13
  - [Toastr for flash messages](https://getbootstrap.com/docs/5.1/components/toasts)
14
+ - Show fields with errors in red
14
15
  - Determine time zone automatically
15
16
  - Easy authentication system
16
17
  - Admin scaffolds
@@ -1,3 +1,3 @@
1
1
  module AdministrationZero
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.17"
3
3
  end
@@ -7,6 +7,17 @@ module Admin
7
7
 
8
8
  source_root File.expand_path("templates", __dir__)
9
9
 
10
+ def add_field_error_proc
11
+ field_error_proc_code = <<~RUBY
12
+ # Provides an HTML generator for displaying errors that come from Active Model
13
+ config.action_view.field_error_proc = Proc.new do |html_tag, instance|
14
+ raw Nokogiri::HTML.fragment(html_tag).child.add_class("is-invalid")
15
+ end
16
+ RUBY
17
+
18
+ environment field_error_proc_code
19
+ end
20
+
10
21
  def add_gems
11
22
  uncomment_lines "Gemfile", /"bcrypt"/
12
23
  gem "pagy", comment: "Use Pagy to add paginated results [https://github.com/ddnexus/pagy]"
@@ -24,7 +24,7 @@ class Admin::PasswordResetsController < Admin::BaseController
24
24
  if @user.update(user_params)
25
25
  redirect_to admin_sign_in_path, notice: "Your password was reset successfully. Please sign in"
26
26
  else
27
- render :edit, status: :unprocessable_entity
27
+ redirect_to edit_admin_password_reset_path(token: params[:token]), alert: @user.errors.first.full_message
28
28
  end
29
29
  end
30
30
 
@@ -1,6 +1,6 @@
1
1
  <% message = notice || alert %>
2
2
 
3
- <% if message %>
3
+ <% if message.present? %>
4
4
  <div class="position-fixed start-50 translate-middle-x" style="z-index: 1030; top: 8rem;">
5
5
  <div class="toast hide text-center text-white bg-dark border-0" data-controller="flash-message">
6
6
  <div class="toast-body">
@@ -1,47 +1,29 @@
1
1
  <!-- Tabler Core -->
2
- <script src="https://unpkg.com/@tabler/core@1.0.0-beta9/dist/js/tabler.min.js"></script>
2
+ <script src="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-beta11/dist/js/tabler.min.js"></script>
3
3
 
4
- <!-- set time zone cookie -->
5
- <script>
6
- const { timeZone } = new Intl.DateTimeFormat().resolvedOptions();
7
- setCookie("time_zone", timeZone);
8
-
9
- function setCookie(name, value) {
10
- const twentyYears = 20 * 365 * 24 * 60 * 60 * 1000;
11
- const body = [ name, value ].map(encodeURIComponent).join("=");
12
- const expires = new Date(Date.now() + twentyYears).toUTCString();
13
- const cookie = `${body}; path=/; expires=${expires}`;
14
- document.cookie = cookie;
15
- }
4
+ <!-- Time zone cookie -->
5
+ <script type="module">
6
+ import cookies from "https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.mjs"
7
+ const { timeZone } = new Intl.DateTimeFormat().resolvedOptions()
8
+ cookies.set("time_zone", timeZone, { expires: 365 })
16
9
  </script>
17
10
 
18
- <!-- bring back data-confirm -->
19
- <script>
11
+ <!-- Data confirm -->
12
+ <script type="module">
20
13
  document.addEventListener("click", (event) => {
21
- if (!event.target.matches("[data-confirm]")) return;
22
- if (!window.confirm(event.target.dataset["confirm"])) event.preventDefault();
23
- });
24
- </script>
25
-
26
- <!-- validation rails -->
27
- <script>
28
- document.addEventListener("DOMContentLoaded", () => {
29
- document.querySelectorAll(".field_with_errors").forEach((element) => {
30
- element.firstChild.classList.add("is-invalid");
31
-
32
- element.parentNode.insertBefore(element.firstChild, element);
33
- element.parentNode.removeChild(element);
34
- });
35
- });
14
+ if (!event.target.matches("[data-confirm]")) return
15
+ if (!window.confirm(event.target.dataset["confirm"])) event.preventDefault()
16
+ })
36
17
  </script>
37
18
 
38
- <!-- flash message -->
39
- <script>
40
- document.addEventListener("DOMContentLoaded", () => {
41
- const selector = "[data-controller='flash-message']";
19
+ <!-- Stimulus controllers -->
20
+ <script type="module">
21
+ import { Application, Controller } from "https://cdn.jsdelivr.net/npm/@hotwired/stimulus@3.1.0/dist/stimulus.min.js"
22
+ window.Stimulus = Application.start()
42
23
 
43
- document.querySelectorAll(selector).forEach((thiz) => {
44
- new bootstrap.Toast(thiz).show();
45
- });
46
- });
24
+ Stimulus.register("flash-message", class extends Controller {
25
+ connect() {
26
+ new bootstrap.Toast(this.element).show()
27
+ }
28
+ })
47
29
  </script>
@@ -4,9 +4,9 @@
4
4
  <span class="navbar-toggler-icon"></span>
5
5
  </button>
6
6
  <h1 class="navbar-brand navbar-brand-autodark d-none-navbar-horizontal pe-0 pe-md-3">
7
- <a href=".">
7
+ <%= link_to admin_path do %>
8
8
  <%= image_tag "admin/logo.svg", width: 110, height: 32, alt: "Tabler", class: "navbar-brand-image" %>
9
- </a>
9
+ <% end %>
10
10
  </h1>
11
11
  <div class="navbar-nav flex-row order-md-last">
12
12
  <div class="nav-item d-none d-md-flex me-3">
@@ -1,5 +1,5 @@
1
1
  <!-- Tabler Core -->
2
- <link rel="stylesheet" href="https://unpkg.com/@tabler/core@1.0.0-beta9/dist/css/tabler.min.css">
2
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-beta11/dist/css/tabler.min.css">
3
3
 
4
4
  <!-- Customize tabler here -->
5
5
  <style>body {
@@ -7,13 +7,11 @@
7
7
  <div class="mb-3">
8
8
  <%= form.label :password, "New password", class: "form-label" %>
9
9
  <%= form.password_field :password, required: true, autofocus: true, autocomplete: "new-password", class: "form-control" %>
10
- <%= tag.div @user.errors[:password].first, class: "invalid-feedback d-block" %>
11
10
  </div>
12
11
 
13
12
  <div>
14
13
  <%= form.label :password_confirmation, "Confirm new password", class: "form-label" %>
15
14
  <%= form.password_field :password_confirmation, required: true, autocomplete: "new-password", class: "form-control" %>
16
- <%= tag.div @user.errors[:password_confirmation].first, class: "invalid-feedback d-block" %>
17
15
  </div>
18
16
 
19
17
  <div class="form-footer">
@@ -25,6 +25,6 @@
25
25
 
26
26
  <div class="form-footer">
27
27
  <%= form.submit class: "btn btn-primary" %>
28
- <%= link_to "Cancel", admin_users_path, class: "btn btn-light" %>
28
+ <%= link_to "Cancel", admin_users_path, class: "btn btn-white" %>
29
29
  </div>
30
30
  <% end %>
@@ -4,7 +4,7 @@
4
4
  <% end %>
5
5
 
6
6
  <%= render "page_header_actions" do %>
7
- <%= link_to "Filters", "#offcanvas_filters", "data-bs-toggle": "offcanvas", class: "btn btn-light" %>
7
+ <%= link_to "Filters", "#offcanvas_filters", "data-bs-toggle": "offcanvas", class: "btn btn-white" %>
8
8
  <%= link_to "New user", new_admin_user_path, class: "btn btn-primary" %>
9
9
  <% end %>
10
10
  <% end %>
@@ -29,9 +29,9 @@
29
29
  <td><%= user.email %></td>
30
30
  <td><%= l(user.created_at, format: :long) %></td>
31
31
  <td>
32
- <%= link_to "View", user, class: "btn btn-light btn-sm" %>
33
- <%= link_to "Edit", edit_admin_user_path(user), class: "btn btn-light btn-sm" %>
34
- <%= button_to "Delete", user, method: :delete, "data-confirm": "Are you sure?", form_class: "d-inline", class: "btn btn-light btn-sm" %>
32
+ <%= link_to "View", user, class: "btn btn-white btn-sm" %>
33
+ <%= link_to "Edit", edit_admin_user_path(user), class: "btn btn-white btn-sm" %>
34
+ <%= button_to "Delete", user, method: :delete, "data-confirm": "Are you sure?", form_class: "d-inline", class: "btn btn-white btn-sm" %>
35
35
  </td>
36
36
  </tr>
37
37
  <% end %>
@@ -67,6 +67,6 @@
67
67
  </div>
68
68
 
69
69
  <%= f.submit "Filter", class: "btn btn-primary" %>
70
- <%= link_to "Clear Filter", admin_users_path, class: "btn btn-light" %>
70
+ <%= link_to "Clear Filter", admin_users_path, class: "btn btn-white" %>
71
71
  <% end %>
72
72
  </div>
@@ -6,7 +6,7 @@
6
6
 
7
7
  <%= render "page_header_actions" do %>
8
8
  <%= link_to "Edit user", edit_admin_user_path(@user), class: "btn btn-primary" %>
9
- <%= button_to "Delete user", @user, method: :delete, "data-confirm": "Are you sure?", form_class: "d-inline", class: "btn btn-light" %>
9
+ <%= button_to "Delete user", @user, method: :delete, "data-confirm": "Are you sure?", form_class: "d-inline", class: "btn btn-white" %>
10
10
  <% end %>
11
11
  <% end %>
12
12
 
@@ -36,6 +36,6 @@
36
36
  <% end -%>
37
37
  <div class="form-footer">
38
38
  <%%= form.submit class: "btn btn-primary" %>
39
- <%%= link_to "Cancel", <%= index_helper(type: :path) %>, class: "btn btn-light" %>
39
+ <%%= link_to "Cancel", <%= index_helper(type: :path) %>, class: "btn btn-white" %>
40
40
  </div>
41
41
  <%% end %>
@@ -4,7 +4,7 @@
4
4
  <%% end %>
5
5
 
6
6
  <%%= render "page_header_actions" do %>
7
- <%%= link_to "Filters", "#offcanvas_filters", "data-bs-toggle": "offcanvas", class: "btn btn-light" %>
7
+ <%%= link_to "Filters", "#offcanvas_filters", "data-bs-toggle": "offcanvas", class: "btn btn-white" %>
8
8
  <%%= link_to "New <%= human_name.downcase %>", <%= new_helper(type: :path) %>, class: "btn btn-primary" %>
9
9
  <%% end %>
10
10
  <%% end %>
@@ -37,9 +37,9 @@
37
37
  <% end -%>
38
38
  <% end -%>
39
39
  <td>
40
- <%%= link_to "View", <%= model_resource_name %>, class: "btn btn-light btn-sm" %>
41
- <%%= link_to "Edit", <%= edit_helper(singular_table_name, type: :path) %>, class: "btn btn-light btn-sm" %>
42
- <%%= button_to "Delete", <%= model_resource_name %>, method: :delete, "data-confirm": "Are you sure?", form_class: "d-inline", class: "btn btn-light btn-sm" %>
40
+ <%%= link_to "View", <%= model_resource_name %>, class: "btn btn-white btn-sm" %>
41
+ <%%= link_to "Edit", <%= edit_helper(singular_table_name, type: :path) %>, class: "btn btn-white btn-sm" %>
42
+ <%%= button_to "Delete", <%= model_resource_name %>, method: :delete, "data-confirm": "Are you sure?", form_class: "d-inline", class: "btn btn-white btn-sm" %>
43
43
  </td>
44
44
  </tr>
45
45
  <%% end %>
@@ -48,7 +48,7 @@
48
48
  </div>
49
49
  <div class="card-footer d-flex align-items-center fs-5">
50
50
  <div class="d-none d-md-block">
51
- <div>Download: <%%= link_to "CSV", <%= index_helper(type: :path) %>(format: :csv, q: request.params[:q]) %></div>
51
+ <div>Download: <%%= link_to "CSV", url_for(format: :csv, q: request.params[:q]) %></div>
52
52
  <%%= raw pagy_info(@pagy) %>
53
53
  </div>
54
54
  <div class="ms-auto">
@@ -69,6 +69,6 @@
69
69
  <%%# f.text_field :name_cont, class: "form-control mb-3" %>
70
70
 
71
71
  <%%= f.submit "Filter", class: "btn btn-primary" %>
72
- <%%= link_to "Clear Filter", <%= index_helper(type: :path) %>, class: "btn btn-light" %>
72
+ <%%= link_to "Clear Filter", <%= index_helper(type: :path) %>, class: "btn btn-white" %>
73
73
  <%% end %>
74
74
  </div>
@@ -6,7 +6,7 @@
6
6
 
7
7
  <%%= render "page_header_actions" do %>
8
8
  <%%= link_to "Edit <%= human_name.downcase %>", <%= edit_helper(type: :path) %>, class: "btn btn-primary" %>
9
- <%%= button_to "Delete <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, method: :delete, "data-confirm": "Are you sure?", form_class: "d-inline", class: "btn btn-light" %>
9
+ <%%= button_to "Delete <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, method: :delete, "data-confirm": "Are you sure?", form_class: "d-inline", class: "btn btn-white" %>
10
10
  <%% end %>
11
11
  <%% end %>
12
12
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: administration-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-28 00:00:00.000000000 Z
11
+ date: 2022-08-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: