thecore_ui_rails_admin 3.7.0 → 3.8.1

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: 50e80608e69b0ee8cfd136957a049fa919a6b332310d89c6c7122e6c35b09444
4
- data.tar.gz: 30dd4923a3702ce54f4f223fddea9b9f29c327d768b8d46174bcdaff09121847
3
+ metadata.gz: cfa8b4e89e10fe5e471aacdd5d3baaba2fa865b064b5b3b898646d692496ced0
4
+ data.tar.gz: f1c02be2b3dab31957c546e4ca7cc29bd5cd0a6182f4417da5bf9327e0a8604f
5
5
  SHA512:
6
- metadata.gz: 7131d117f2d46e39b1a5cb7935e01ed5e0aa2307bb87bf76c4f174db009726cc4be0ca8cb9508d068716d0aa908811461e090411b5c3a6dcbdc8d314afdca9a2
7
- data.tar.gz: 93a7655e5c9aea60c1eeb3157177066728dc1e98660711301a797d2d2899d5cb92e203ed135e3a43bd206b739362281b2c2068b2b1b036e680d7c54f382dd257
6
+ metadata.gz: 1328d3880199a25f33d1365152fe149b72f5dd268339e24e010f319ac3be1a03144e08d975ad6ac051d723b53f8515fa462ea248ebee04f3d189629efaff5486
7
+ data.tar.gz: 6781432241fff99e5459f8b0c406622076b6c7af32a6388874a77529ec860db4a3e813fd2392b2d6f663e286a58dc861f021d137eb5f5d05818602539b2e5c6e
data/README.md CHANGED
@@ -2,6 +2,41 @@ This is part of [Thecore framework](https://github.com/gabrieletassoni/thecore/t
2
2
 
3
3
  ---
4
4
 
5
+ ## Default `navigation_label`/icon for models without a `RailsAdmin::ModelName` concern
6
+
7
+ Per [ADR 0001](https://github.com/gabrieletassoni/thecore/blob/release/3/docs/adr/0001-application-record-defaults-over-generated-concerns.md)
8
+ (host app), any `ApplicationRecord` subclass that does **not** define its own
9
+ `RailsAdmin::ModelName` concern still gets a sensible `navigation_label` and
10
+ a real default icon (`fa fa-table`) in the RailsAdmin sidebar, instead of
11
+ falling back to RailsAdmin's own unconfigured default (no group / no icon).
12
+
13
+ This is provided by `ThecoreUiRailsAdminDefaultNavigationConcern`
14
+ (`config/initializers/concern_default_navigation.rb`), registered into
15
+ [`ThecoreBackendCommons::DefaultModuleRegistry`](../thecore_backend_commons/README.md)
16
+ so it is included automatically into every model at class-definition time —
17
+ no generated concern file required.
18
+
19
+ The default `navigation_label` reuses the exact same i18n key
20
+ (`I18n.t('admin.registries.label')`) that the Thecore VS Code extension's
21
+ `addModel` command already hardcodes into every freshly generated
22
+ `RailsAdmin::ModelName` concern, so a model relying on this default reads
23
+ identically, to an end user, to one whose generated-and-never-customized
24
+ concern was kept around.
25
+
26
+ **Field-level configuration is never defaulted** — `hide`, `sticky`,
27
+ `configure :field`, custom `list`/`edit` blocks, etc. stay exclusively in
28
+ hand-written `RailsAdmin::ModelName` concerns. A model that already has its
29
+ own concern is unaffected: its own `navigation_label`/`navigation_icon` (if
30
+ set) and all field-level config still win over/apply alongside the default.
31
+
32
+ > **Temporary dependency note**: this feature requires
33
+ > `ThecoreBackendCommons::DefaultModuleRegistry`, merged into
34
+ > `thecore_backend_commons`'s `release/3` branch but not yet published to
35
+ > RubyGems. The `Gemfile` pins a git source for this
36
+ > (`github: "gabrieletassoni/thecore_backend_commons", branch: "release/3"`)
37
+ > until a real release ships — remove it once `thecore_backend_commons`
38
+ > cuts a version satisfying the gemspec's `>= 3.4` constraint.
39
+
5
40
  ## Push Notification Test (RailsAdmin root action)
6
41
 
7
42
  A built-in admin UI for sending Web Push test notifications. It lets you pick one or more active subscribers and fire a real notification immediately — useful for verifying the end-to-end VAPID setup without writing any code.
@@ -1,17 +1,27 @@
1
+ <div class="alert alert-info">
2
+ <%= t('admin.actions.change_password.requirements', min_length: User.password_length.min) %>
3
+ </div>
4
+
1
5
  <%= form_for(@object, url: change_password_path, html: { method: :patch }, class: "main") do |f| %>
2
6
 
3
7
  <fieldset>
4
- <div class="control-group row mb-3 string_type password_field " id="user_password_field">
8
+ <div class="control-group row mb-3 string_type password_field <%= 'error' if @object.errors[:password].present? %>" id="user_password_field">
5
9
  <label class="col-sm-2 col-form-label text-md-end" for="user_password">Password</label>
6
- <div class="col-sm-10 controls">
10
+ <div class="col-sm-10 controls <%= 'has-error' if @object.errors[:password].present? %>">
7
11
  <input class="form-control" required="required" size="50" type="password" name="user[password]" id="user_password">
12
+ <% if @object.errors[:password].present? %>
13
+ <span class="help-inline text-danger"><%= @object.errors[:password].to_sentence %></span>
14
+ <% end %>
8
15
  <div class="form-text"><%=t('admin.form.required')%></div>
9
16
  </div>
10
17
  </div>
11
- <div class="control-group row mb-3 string_type password_confirmation_field " id="user_password_confirmation_field">
18
+ <div class="control-group row mb-3 string_type password_confirmation_field <%= 'error' if @object.errors[:password_confirmation].present? %>" id="user_password_confirmation_field">
12
19
  <label class="col-sm-2 col-form-label text-md-end" for="user_password_confirmation">Password Confirmation</label>
13
- <div class="col-sm-10 controls">
20
+ <div class="col-sm-10 controls <%= 'has-error' if @object.errors[:password_confirmation].present? %>">
14
21
  <input class="form-control" required="required" size="50" type="password" name="user[password_confirmation]" id="user_password_confirmation">
22
+ <% if @object.errors[:password_confirmation].present? %>
23
+ <span class="help-inline text-danger"><%= @object.errors[:password_confirmation].to_sentence %></span>
24
+ <% end %>
15
25
  <div class="form-text"><%=t('admin.form.required')%></div>
16
26
  </div>
17
27
  </div>
@@ -47,6 +47,19 @@ Rails.application.configure do
47
47
  Target.send :include, ThecoreUiRailsAdminTargetConcern
48
48
  ThecoreSettings::Setting.send :include, ThecoreUiRailsAdminSettingsConcern
49
49
 
50
+ # Force RailsAdmin::Config::Actions to initialize its base action list
51
+ # (Dashboard, Index, Show, Edit, ...) before any custom action below
52
+ # registers itself. `RailsAdmin::Config::Actions.add_action`'s
53
+ # `@@actions ||= []` means whichever caller touches `@@actions` first
54
+ # decides whether the base actions ever get added at all -- if a custom
55
+ # `add_action` runs first (as can happen when route drawing is lazy,
56
+ # e.g. outside a request/eager-loaded boot), the base actions are
57
+ # silently skipped for the rest of the process, breaking every
58
+ # `edit_path`/`index_path`/... helper call. Calling `.all` here is a
59
+ # no-op once already initialized, so this is safe regardless of order
60
+ # elsewhere.
61
+ RailsAdmin::Config::Actions.all
62
+
50
63
  require "root_actions/general_computation"
51
64
  require "root_actions/active_job_monitor"
52
65
  require "root_actions/push_notification_test"
@@ -0,0 +1,64 @@
1
+ require 'active_support/concern'
2
+
3
+ # Default RailsAdmin `navigation_label`/`navigation_icon` for any
4
+ # `ApplicationRecord` subclass that has no explicit `RailsAdmin::ModelName`
5
+ # concern of its own -- see ADR 0001
6
+ # (vendor/external/thecore/docs/adr/0001-application-record-defaults-over-generated-concerns.md
7
+ # in the host app) and GitHub issue
8
+ # gabrieletassoni/thecore_ui_rails_admin#7.
9
+ #
10
+ # Registered into `ThecoreBackendCommons::DefaultModuleRegistry` below, so
11
+ # it is `include`d automatically into every model at class-definition time
12
+ # (via `ApplicationRecord.inherited`) instead of requiring a per-model
13
+ # `RailsAdmin::ModelName` concern file to be generated just to get these two
14
+ # mechanically-derivable values.
15
+ #
16
+ # Deliberately does NOT default any field-level configuration (`hide`,
17
+ # `sticky`, `configure :field`, custom `list`/`edit` blocks, ...) -- per
18
+ # ADR 0001's research, every existing hand-written `RailsAdmin::ModelName`
19
+ # concern in the `mytask` engine carries real field-level content, so only
20
+ # the navigation bits below are safe to default. Field-level config stays
21
+ # exclusively in hand-written concerns.
22
+ #
23
+ # `navigation_label` intentionally reuses the exact SAME fixed i18n key
24
+ # (`I18n.t('admin.registries.label')`) that the Thecore VS Code extension's
25
+ # `addModel` template
26
+ # (vendor/external/thecore_code_extension/templates/addModel/rails_admin_concern.rb
27
+ # in the host app) already hardcodes into every freshly generated
28
+ # `RailsAdmin::ModelName` concern -- so a model relying on this default
29
+ # looks, to an end user, exactly like one whose generated-and-never-customized
30
+ # concern was kept around. `DEFAULT_ICON` is a real, ready-to-use FontAwesome
31
+ # icon (no "TODO: customize" placeholder needed).
32
+ #
33
+ # == Why an explicit concern's own `navigation_label`/`navigation_icon` wins
34
+ #
35
+ # This module is `include`d into a model class from
36
+ # `ApplicationRecord.inherited`, which fires -- and so evaluates this
37
+ # `included do rails_admin do ... end end` block, registering RailsAdmin's
38
+ # *first* deferred config block for that model -- before the model class
39
+ # body itself runs its own `include RailsAdmin::ModelName` statement, whose
40
+ # block is registered *second*. RailsAdmin evaluates same-origin deferred
41
+ # blocks in registration order (see
42
+ # `RailsAdmin::Config::LazyModel#target` in the `rails_admin` gem), and
43
+ # `navigation_label`/`navigation_icon` are plain last-write-wins setters
44
+ # (see `RailsAdmin::Config::Configurable::ClassMethods#register_instance_option`),
45
+ # so whichever call runs last -- the hand-written concern's, when present --
46
+ # overrides the default set here.
47
+ module ThecoreUiRailsAdminDefaultNavigationConcern
48
+ extend ActiveSupport::Concern
49
+
50
+ DEFAULT_ICON = 'fa fa-table'.freeze
51
+
52
+ included do
53
+ rails_admin do
54
+ navigation_label I18n.t('admin.registries.label')
55
+ navigation_icon ThecoreUiRailsAdminDefaultNavigationConcern::DEFAULT_ICON
56
+ end
57
+ end
58
+ end
59
+
60
+ Rails.application.config.to_prepare do
61
+ ThecoreBackendCommons::DefaultModuleRegistry.register(
62
+ ThecoreUiRailsAdminDefaultNavigationConcern
63
+ )
64
+ end
@@ -42,6 +42,7 @@ en:
42
42
  menu: Change Password
43
43
  success: Your password was changed successfully
44
44
  error: Warning! %{errors}
45
+ requirements: "Password requirements: at least %{min_length} characters, including at least one uppercase letter, one lowercase letter, one number, and one special character (e.g. ! @ # $ % &). The password and its confirmation must match."
45
46
  save_filters:
46
47
  success: Filters saved successfully
47
48
  error: Error while saving filters
@@ -42,6 +42,7 @@ it:
42
42
  menu: Cambia Password
43
43
  success: La tua password è stata cambiata con successo
44
44
  error: "Attenzione! %{errors}"
45
+ requirements: "Requisiti password: almeno %{min_length} caratteri, con almeno una lettera maiuscola, una lettera minuscola, un numero e un carattere speciale (es. ! @ # $ % &). Password e conferma devono coincidere."
45
46
  save_filters:
46
47
  success: Filtri salvati con successo
47
48
  error: Errore durante il salvataggio dei filtri
@@ -13,15 +13,16 @@ RailsAdmin::Config::Actions.add_action "change_password", :base, :member do
13
13
  proc do
14
14
  # if it's a form submission, then update the password
15
15
  if request.patch?
16
- u = ::User.find(@object.id)
17
- if u.update(password: params[:user][:password], password_confirmation: params[:user][:password_confirmation])
16
+ if @object.update(password: params[:user][:password], password_confirmation: params[:user][:password_confirmation])
18
17
  flash[:success] = I18n.t("admin.actions.change_password.success")
18
+ redirect_to index_path(model_name: @abstract_model.to_param)
19
19
  else
20
- # Add errors to the object
21
- flash[:error] = I18n.t("admin.actions.change_password.error", errors: u.errors.full_messages.join(', '))
20
+ # Stay on the change_password page, highlighting the error the same
21
+ # way RailsAdmin's own edit/new forms do on a validation failure --
22
+ # @object keeps its errors for the re-rendered form to read.
23
+ flash.now[:error] = I18n.t("admin.actions.change_password.error", errors: @object.errors.full_messages.join(', '))
24
+ render :change_password, status: :not_acceptable
22
25
  end
23
- # Redirect to the object
24
- redirect_to index_path(model_name: @abstract_model.to_param)
25
26
  end
26
27
  end
27
28
  end
@@ -1,3 +1,3 @@
1
1
  module ThecoreUiRailsAdmin
2
- VERSION = "3.7.0".freeze
2
+ VERSION = "3.8.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_ui_rails_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.0
4
+ version: 3.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
@@ -51,6 +51,20 @@ dependencies:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '1.18'
54
+ - !ruby/object:Gem::Dependency
55
+ name: thecore_backend_commons
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '3.4'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '3.4'
54
68
  description: Holds all base dependencies and configurations to have a thecore integrated
55
69
  with Rails Admin.
56
70
  email:
@@ -103,6 +117,7 @@ files:
103
117
  - config/initializers/assets.rb
104
118
  - config/initializers/concern_action.rb
105
119
  - config/initializers/concern_bulk_delete.rb
120
+ - config/initializers/concern_default_navigation.rb
106
121
  - config/initializers/concern_export.rb
107
122
  - config/initializers/concern_permission.rb
108
123
  - config/initializers/concern_permission_role.rb