rails_admin_next 3.0.2 → 4.0.0
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 +4 -4
- data/Gemfile +3 -0
- data/README.md +25 -7
- data/app/assets/stylesheets/rails_admin/skin.css +240 -7
- data/app/assets/stylesheets/rails_admin/tokens.css +4 -0
- data/app/controllers/rails_admin_next/bulk_deletions_controller.rb +27 -0
- data/app/controllers/rails_admin_next/main_controller.rb +34 -5
- data/app/helpers/rails_admin_next/application_helper.rb +17 -2
- data/app/helpers/rails_admin_next/main_helper.rb +64 -0
- data/app/jobs/rails_admin_next/bulk_delete_job.rb +65 -0
- data/app/views/layouts/rails_admin_next/_head.html.erb +14 -6
- data/app/views/layouts/rails_admin_next/content.html.erb +1 -0
- data/app/views/rails_admin_next/bulk_deletions/_banner.html.erb +30 -0
- data/app/views/rails_admin_next/main/_batch.html.erb +9 -0
- data/app/views/rails_admin_next/main/_history_row.html.erb +32 -0
- data/app/views/rails_admin_next/main/_list_row.html.erb +19 -0
- data/app/views/rails_admin_next/main/_next_batch.html.erb +21 -0
- data/app/views/rails_admin_next/main/_selection_bar.html.erb +30 -0
- data/app/views/rails_admin_next/main/bulk_delete.html.erb +26 -6
- data/app/views/rails_admin_next/main/export.html.erb +1 -0
- data/app/views/rails_admin_next/main/history.html.erb +5 -36
- data/app/views/rails_admin_next/main/index.html.erb +28 -57
- data/config/importmap.rails_admin.rb +7 -2
- data/config/locales/rails_admin_next.en.yml +37 -4
- data/config/routes.rb +2 -0
- data/docs/UPGRADING.md +195 -2
- data/docs/security.md +18 -8
- data/docs/upstream-parity.md +1 -1
- data/lib/rails_admin_next/adapters/active_record.rb +7 -0
- data/lib/rails_admin_next/bulk_deletion/progress.rb +70 -0
- data/lib/rails_admin_next/bulk_deletion.rb +99 -0
- data/lib/rails_admin_next/config/actions/base.rb +7 -0
- data/lib/rails_admin_next/config/actions/bulk_delete.rb +94 -31
- data/lib/rails_admin_next/config/actions/export.rb +4 -0
- data/lib/rails_admin_next/config/actions/history_index.rb +1 -1
- data/lib/rails_admin_next/config/actions/history_show.rb +1 -1
- data/lib/rails_admin_next/config/actions/index.rb +6 -1
- data/lib/rails_admin_next/config/fields/types/action_text.rb +11 -0
- data/lib/rails_admin_next/config/sections/list.rb +1 -2
- data/lib/rails_admin_next/engine.rb +1 -0
- data/lib/rails_admin_next/extensions/paper_trail/auditing_adapter.rb +8 -3
- data/lib/rails_admin_next/support/action_text_editor.rb +36 -0
- data/lib/rails_admin_next/support/paginated_collection.rb +4 -5
- data/lib/rails_admin_next/version.rb +4 -5
- data/lib/rails_admin_next.rb +3 -0
- data/skills/rails-admin-next/SKILL.md +3 -3
- data/src/rails_admin/controllers/alert_controller.js +3 -1
- data/src/rails_admin/controllers/bulk_progress_controller.js +53 -0
- data/src/rails_admin/controllers/bulk_selection_controller.js +151 -0
- data/src/rails_admin/controllers/dropdown_controller.js +7 -5
- data/src/rails_admin/controllers/filtering_multiselect_controller.js +4 -0
- data/src/rails_admin/controllers/filtering_select_controller.js +4 -0
- data/src/rails_admin/controllers/index.js +6 -0
- data/src/rails_admin/controllers/infinite_scroll_controller.js +79 -0
- data/src/rails_admin/controllers/modal_controller.js +3 -1
- data/src/rails_admin/controllers/nested_form_controller.js +3 -2
- data/src/rails_admin/controllers/sidescroll_controller.js +41 -10
- data/src/rails_admin/interactions.js +4 -12
- metadata +24 -5
- data/app/views/rails_admin_next/main/_pagination.html.erb +0 -54
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RailsAdminNext
|
|
4
|
+
# Destroys one slice of a confirmed bulk delete. The request already decided authorization,
|
|
5
|
+
# since the adapters need the live controller; this job only walks the keys it was given.
|
|
6
|
+
class BulkDeleteJob < ActiveJob::Base
|
|
7
|
+
# What `audit_with` is evaluated against in a job: the submitting user and no request, so an
|
|
8
|
+
# auditing adapter learns who deleted each record from the job rather than from a controller.
|
|
9
|
+
AuditContext = Struct.new(:_current_user) do
|
|
10
|
+
def auditing_adapter
|
|
11
|
+
instance_eval(&RailsAdminNext::Config.audit_with)
|
|
12
|
+
@auditing_adapter
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Often enough for a banner that polls every two seconds, rarely enough to keep cache
|
|
17
|
+
# writes far below record destroys.
|
|
18
|
+
REPORT_EVERY = 100
|
|
19
|
+
REPORT_INTERVAL = 30.seconds
|
|
20
|
+
|
|
21
|
+
def perform(model_name, keys, progress_id, slice_index, whodunnit = nil, submitter = nil)
|
|
22
|
+
# A backend retry resumes from this slice's own entry, so records an earlier attempt
|
|
23
|
+
# destroyed stay counted as deleted instead of turning up as already gone.
|
|
24
|
+
counts = BulkDeletion::Progress.slice_counts(progress_id, slice_index) || BulkDeletion::Counts.zero
|
|
25
|
+
report = ->(state) { BulkDeletion::Progress.write_slice(progress_id, slice_index, counts, state:) }
|
|
26
|
+
report.call(:running)
|
|
27
|
+
reported_at = Time.current
|
|
28
|
+
|
|
29
|
+
abstract_model = AbstractModel.new(model_name)
|
|
30
|
+
user = locate(submitter)
|
|
31
|
+
auditing_adapter = AuditContext.new(user).auditing_adapter
|
|
32
|
+
audit = ->(record) { auditing_adapter&.delete_object(record, abstract_model, user) }
|
|
33
|
+
|
|
34
|
+
attributed(whodunnit) do
|
|
35
|
+
BulkDeletion.new(abstract_model, keys).destroy(audit:, start: counts, progress: lambda { |latest|
|
|
36
|
+
counts = latest
|
|
37
|
+
if (counts.done % REPORT_EVERY).zero? || reported_at < REPORT_INTERVAL.ago
|
|
38
|
+
report.call(:running)
|
|
39
|
+
reported_at = Time.current
|
|
40
|
+
end
|
|
41
|
+
})
|
|
42
|
+
end
|
|
43
|
+
report.call(:finished)
|
|
44
|
+
rescue
|
|
45
|
+
report&.call(:errored)
|
|
46
|
+
raise
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
# A user deleted since the request leaves the audit unattributed.
|
|
52
|
+
def locate(submitter)
|
|
53
|
+
gid = GlobalID.parse(submitter) if submitter.is_a?(String)
|
|
54
|
+
gid ? GlobalID::Locator.locate_many([gid], ignore_missing: true).first : submitter
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# PaperTrail writes each version from the model callback, reading the whodunnit the
|
|
58
|
+
# request had.
|
|
59
|
+
def attributed(whodunnit, &)
|
|
60
|
+
return yield unless whodunnit && defined?(::PaperTrail)
|
|
61
|
+
|
|
62
|
+
::PaperTrail.request(whodunnit:, &)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -18,14 +18,22 @@
|
|
|
18
18
|
<% end %>
|
|
19
19
|
<%# Date/time fields use native HTML5 inputs; the picker UI is the browser's. Icons are inline SVG (no icon font). %>
|
|
20
20
|
<%= stylesheet_link_tag "rails_admin", media: :all, nonce: true, data: {'turbo-track': 'reload'} %>
|
|
21
|
-
<%#
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<% if
|
|
25
|
-
<%= stylesheet_link_tag
|
|
21
|
+
<%# On every page, not just rich-text forms: a modal form arrives with no head of its own. %>
|
|
22
|
+
<% editor = RailsAdminNext::ActionTextEditor.current %>
|
|
23
|
+
<% editor_assets = editor && RailsAdminNext::ActionTextEditor.assets(editor) %>
|
|
24
|
+
<% if editor_assets %>
|
|
25
|
+
<%= stylesheet_link_tag editor_assets.stylesheet, media: :all, nonce: true, data: {'turbo-track': 'reload'} %>
|
|
26
26
|
<% end %>
|
|
27
|
+
<%# Both editors inject <style> elements at runtime and take their nonce from this meta, so without it
|
|
28
|
+
a nonce-based style-src blocks them (Trix's link dialog would never hide). Renders nothing when
|
|
29
|
+
no policy is configured. %>
|
|
30
|
+
<%= csp_meta_tag %>
|
|
27
31
|
<%# Zero-build delivery: browser-native ESM pinned by the engine-owned importmap, served by Propshaft.
|
|
28
32
|
The importmap-rails helpers thread the request CSP nonce onto every inline <script> they emit. %>
|
|
29
33
|
<%= javascript_inline_importmap_tag(RailsAdminNext::Engine.importmap.to_json(resolver: self)) %>
|
|
30
|
-
<%= javascript_importmap_module_preload_tags(RailsAdminNext::Engine.importmap) %>
|
|
34
|
+
<%= javascript_importmap_module_preload_tags(RailsAdminNext::Engine.importmap, entry_point: editor_assets&.entry_point || "application") %>
|
|
31
35
|
<%= javascript_import_module_tag 'rails_admin' %>
|
|
36
|
+
<%# The editor gets its own module script: one unresolvable import stops every module in its script. %>
|
|
37
|
+
<% if editor_assets %>
|
|
38
|
+
<%= javascript_import_module_tag(*editor_assets.modules) %>
|
|
39
|
+
<% end %>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<%# locals: (id:, summary:) -%>
|
|
2
|
+
<%= turbo_frame_tag bulk_deletion_frame_id(id), class: "bulk-deletion", target: "_top" do %>
|
|
3
|
+
<% name = summary.model_name && RailsAdminNext::AbstractModel.new(summary.model_name).config.label_plural %>
|
|
4
|
+
<% case summary.state %>
|
|
5
|
+
<% when :running %>
|
|
6
|
+
<div class="alert alert-info bulk-deletion-banner" role="status" data-controller="bulk-progress" data-bulk-progress-url-value="<%= bulk_deletion_path(id) %>" data-bulk-progress-interval-value="2000">
|
|
7
|
+
<label for="<%= bulk_deletion_frame_id(id) %>_bar"><%= t("admin.bulk_deletion.running", name:, done: number_with_delimiter(summary.done), total: number_with_delimiter(summary.total)) %></label>
|
|
8
|
+
<progress id="<%= bulk_deletion_frame_id(id) %>_bar" max="<%= summary.total %>" value="<%= summary.done %>"></progress>
|
|
9
|
+
</div>
|
|
10
|
+
<% else %>
|
|
11
|
+
<% alert_class = {finished: (summary.failed.zero? ? "alert-success" : "alert-warning"), stopped: "alert-danger", unavailable: "alert-warning"}.fetch(summary.state) %>
|
|
12
|
+
<div class="alert <%= alert_class %> alert-dismissible bulk-deletion-banner" role="status" data-controller="alert">
|
|
13
|
+
<% case summary.state %>
|
|
14
|
+
<% when :finished %>
|
|
15
|
+
<%= t("admin.bulk_deletion.finished", name:, deleted: number_with_delimiter(summary.deleted), failed: number_with_delimiter(summary.failed)) %>
|
|
16
|
+
<% unless summary.gone.zero? %>
|
|
17
|
+
<%= t("admin.bulk_deletion.gone", count: summary.gone, formatted_count: number_with_delimiter(summary.gone)) %>
|
|
18
|
+
<% end %>
|
|
19
|
+
<% when :stopped %>
|
|
20
|
+
<%= t("admin.bulk_deletion.stopped", name:, deleted: number_with_delimiter(summary.deleted), failed: number_with_delimiter(summary.failed), total: number_with_delimiter(summary.total)) %>
|
|
21
|
+
<% if summary.list_path %>
|
|
22
|
+
<%= link_to t("admin.bulk_deletion.remaining"), summary.list_path, class: "alert-link" %>
|
|
23
|
+
<% end %>
|
|
24
|
+
<% when :unavailable %>
|
|
25
|
+
<%= t("admin.bulk_deletion.unavailable") %>
|
|
26
|
+
<% end %>
|
|
27
|
+
<button type="button" class="btn-close" data-action="alert#dismiss" aria-label="<%= t("admin.misc.close", default: "Close") %>"></button>
|
|
28
|
+
</div>
|
|
29
|
+
<% end %>
|
|
30
|
+
<% end %>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<%# locals: (collection: @objects, row_partial: "list_row", row_locals: {properties: list_properties, checkboxes: @model_config.list.checkboxes?}, url_proc: method(:list_batch_url)) -%>
|
|
2
|
+
<%= turbo_frame_tag "list_batch_#{collection.current_page}" do %>
|
|
3
|
+
<%= turbo_stream.append "list_rows" do %>
|
|
4
|
+
<% collection.each do |object| %>
|
|
5
|
+
<%= render row_partial, object:, **row_locals %>
|
|
6
|
+
<% end %>
|
|
7
|
+
<% end %>
|
|
8
|
+
<%= render 'next_batch', collection:, url_proc: %>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<%# locals: (object:) -%>
|
|
2
|
+
<%= tag.tr id: ("history_row_#{object.id}" if object.respond_to?(:id)) do %>
|
|
3
|
+
<% unless object.created_at.nil? %>
|
|
4
|
+
<td>
|
|
5
|
+
<%= l(object.created_at, format: :long, default: l(object.created_at, format: :long)) %>
|
|
6
|
+
</td>
|
|
7
|
+
<% end %>
|
|
8
|
+
<td>
|
|
9
|
+
<%= object.username %>
|
|
10
|
+
</td>
|
|
11
|
+
<% if @general %>
|
|
12
|
+
<% if o = @abstract_model.get(object.item) %>
|
|
13
|
+
<% label = o.send(@abstract_model.config.object_label_method) %>
|
|
14
|
+
<% if show_action = action(:show, @abstract_model, o) %>
|
|
15
|
+
<td>
|
|
16
|
+
<%= link_to(label, url_for(action: show_action.action_name, model_name: @abstract_model.to_param, id: o.id)) %>
|
|
17
|
+
</td>
|
|
18
|
+
<% else %>
|
|
19
|
+
<td>
|
|
20
|
+
<%= label %>
|
|
21
|
+
</td>
|
|
22
|
+
<% end %>
|
|
23
|
+
<% else %>
|
|
24
|
+
<td>
|
|
25
|
+
<%= "#{@abstract_model.config.label} ##{object.item}" %>
|
|
26
|
+
</td>
|
|
27
|
+
<% end %>
|
|
28
|
+
<% end %>
|
|
29
|
+
<td>
|
|
30
|
+
<%= object.message.in?(['delete', 'new']) ? t("admin.actions.#{object.message}.done").capitalize : object.message %>
|
|
31
|
+
</td>
|
|
32
|
+
<% end %>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<%# locals: (object:, properties:, checkboxes:) -%>
|
|
2
|
+
<%= tag.tr id: (dom_id(object, :row) if object.to_key.present?), class: "#{@abstract_model.param_key}_row #{@model_config.list.with(object: object).row_css_class}", data: { sidescroll_target: "row" } do %>
|
|
3
|
+
<% if checkboxes %>
|
|
4
|
+
<td class="sticky">
|
|
5
|
+
<%= check_box_tag "bulk_ids[]", @abstract_model.format_id(object.id), false, data: {bulk_selection_target: "row", action: "bulk-selection#rowChanged"} %>
|
|
6
|
+
</td>
|
|
7
|
+
<% end %>
|
|
8
|
+
<% properties.map{ |property| property.bind(:object, object) }.each do |property| %>
|
|
9
|
+
<% value = property.pretty_value %>
|
|
10
|
+
<%= content_tag(:td, class: [property.sticky? && 'sticky', property.css_class, property.type_css_class].select(&:present?), title: strip_tags(value.to_s)) do %>
|
|
11
|
+
<%= value %>
|
|
12
|
+
<% end %>
|
|
13
|
+
<% end %>
|
|
14
|
+
<td class="last links ra-sidescroll-frozen">
|
|
15
|
+
<ul class="nav d-inline list-inline">
|
|
16
|
+
<%= menu_for :member, @abstract_model, object, true %>
|
|
17
|
+
</ul>
|
|
18
|
+
</td>
|
|
19
|
+
<% end %>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<%# locals: (collection:, url_proc:) -%>
|
|
2
|
+
<%# full_page? is the count-free test: next_page and last_page? would run a COUNT. %>
|
|
3
|
+
<% if collection.full_page? %>
|
|
4
|
+
<% next_page = collection.current_page + 1 %>
|
|
5
|
+
<% next_url = url_proc.call(next_page) %>
|
|
6
|
+
<%= turbo_frame_tag "list_batch_#{next_page}", class: "list-batch", data: {
|
|
7
|
+
controller: "infinite-scroll",
|
|
8
|
+
action: "turbo:fetch-request-error->infinite-scroll#failed:self turbo:frame-missing->infinite-scroll#missing:self",
|
|
9
|
+
infinite_scroll_src_value: next_url,
|
|
10
|
+
infinite_scroll_error_value: t('admin.pagination.error'),
|
|
11
|
+
infinite_scroll_retry_label_value: t('admin.pagination.retry')
|
|
12
|
+
} do %>
|
|
13
|
+
<div class="list-batch-status">
|
|
14
|
+
<span class="list-batch-loading"><%= t('admin.loading') %></span>
|
|
15
|
+
<span class="list-batch-error" role="status" data-infinite-scroll-target="error"></span>
|
|
16
|
+
<%= link_to t('admin.pagination.load_more'), next_url, class: "list-batch-link btn btn-light", data: { infinite_scroll_target: "link", action: "infinite-scroll#load" } %>
|
|
17
|
+
</div>
|
|
18
|
+
<% end %>
|
|
19
|
+
<% elsif collection.current_page > 1 %>
|
|
20
|
+
<p class="list-end"><%= t('admin.pagination.end') %></p>
|
|
21
|
+
<% end %>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<%# locals: (total_count:) -%>
|
|
2
|
+
<% if total_count %>
|
|
3
|
+
<% models_name = @model_config.pluralize(total_count).downcase %>
|
|
4
|
+
<% offer_label = t("admin.misc.select_all_matching", count: number_with_delimiter(total_count), models_name:) %>
|
|
5
|
+
<% short_offer_label = t("admin.misc.select_all_matches", count: number_with_delimiter(total_count)) %>
|
|
6
|
+
<% selected_label = t("admin.misc.all_matching_selected", count: number_with_delimiter(total_count), models_name:) %>
|
|
7
|
+
<% else %>
|
|
8
|
+
<% models_name = @model_config.label_plural.downcase %>
|
|
9
|
+
<% offer_label = t("admin.misc.select_all_matching_uncounted", models_name:) %>
|
|
10
|
+
<% short_offer_label = t("admin.misc.select_all_matches_uncounted") %>
|
|
11
|
+
<% selected_label = t("admin.misc.all_matching_selected_uncounted", models_name:) %>
|
|
12
|
+
<% end %>
|
|
13
|
+
<div class="selection-bar">
|
|
14
|
+
<span class="selection-count" data-bulk-selection-target="count"><%= t("admin.misc.selected_count", count: 0) %></span>
|
|
15
|
+
<span class="selection-all-matching" data-bulk-selection-target="allMatchingText"><%= selected_label %></span>
|
|
16
|
+
<%# type="button" because the bar sits inside the bulk form. %>
|
|
17
|
+
<button type="button" class="btn btn-link selection-offer" aria-label="<%= offer_label %>" data-action="bulk-selection#selectAllMatching">
|
|
18
|
+
<span class="selection-offer-full"><%= offer_label %></span>
|
|
19
|
+
<span class="selection-offer-short"><%= short_offer_label %></span>
|
|
20
|
+
</button>
|
|
21
|
+
<button type="button" class="btn btn-link selection-clear" data-action="bulk-selection#clear"><%= t("admin.misc.clear_selection") %></button>
|
|
22
|
+
<ul class="nav selection-menu">
|
|
23
|
+
<%= bulk_menu %>
|
|
24
|
+
</ul>
|
|
25
|
+
<%# Disabled, it submits nothing, so an explicit selection posts exactly the ticked ids. %>
|
|
26
|
+
<fieldset class="all-matching" disabled hidden data-bulk-selection-target="allMatching">
|
|
27
|
+
<%= hidden_field_tag :all_matching, "true", id: nil %>
|
|
28
|
+
<%= list_filter_hidden_fields %>
|
|
29
|
+
</fieldset>
|
|
30
|
+
</div>
|
|
@@ -1,13 +1,33 @@
|
|
|
1
|
+
<% heading = @count ? t("admin.form.bulk_delete_count", name: pluralize(number_with_delimiter(@count), @model_config.label, plural: @model_config.label_plural)) : t("admin.form.bulk_delete") %>
|
|
1
2
|
<h4>
|
|
2
|
-
<%=
|
|
3
|
+
<%= heading %>
|
|
3
4
|
</h4>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
<% if @confirmed_digest %>
|
|
6
|
+
<div class="bulk-delete-summary">
|
|
7
|
+
<%= bulk_delete_filter_summary %>
|
|
8
|
+
<% if @authorization_adapter %>
|
|
9
|
+
<p><%= t("admin.form.bulk_delete_unauthorized_skipped") %></p>
|
|
10
|
+
<% end %>
|
|
11
|
+
</div>
|
|
12
|
+
<% elsif !@count %>
|
|
13
|
+
<ul>
|
|
14
|
+
<%= render partial: "delete_notice", collection: @objects %>
|
|
15
|
+
</ul>
|
|
16
|
+
<% end %>
|
|
17
|
+
<%# The selection travels in the body: a few hundred ids would overflow the URL. %>
|
|
18
|
+
<%= form_tag bulk_delete_path(model_name: @abstract_model.to_param, scope: params[:scope].presence), method: :delete do %>
|
|
19
|
+
<% if @confirmed_digest %>
|
|
20
|
+
<%= hidden_field_tag :all_matching, "true", id: nil %>
|
|
21
|
+
<%= list_filter_hidden_fields %>
|
|
22
|
+
<%= hidden_field_tag :confirmed_digest, @confirmed_digest, id: nil %>
|
|
23
|
+
<% else %>
|
|
24
|
+
<% @objects.each do |object| %>
|
|
25
|
+
<%= hidden_field_tag "bulk_ids[]", @abstract_model.format_id(object.id), id: nil %>
|
|
26
|
+
<% end %>
|
|
27
|
+
<% end %>
|
|
8
28
|
<div class="form-actions">
|
|
9
29
|
<input name="return_to" type="<%= :hidden %>" value="<%= (params[:return_to].presence || request.referer) %>" />
|
|
10
|
-
<button class="btn btn-danger" data-disable-with="<%= t("admin.form.confirmation") %>" data-turbo-confirm="<%=
|
|
30
|
+
<button class="btn btn-danger" data-disable-with="<%= t("admin.form.confirmation") %>" data-turbo-confirm="<%= heading %>" type="submit">
|
|
11
31
|
<%= rails_admin_icon(:check) %>
|
|
12
32
|
<%= t("admin.form.confirmation") %>
|
|
13
33
|
</button>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<% params = request.params.except(:action, :controller, :utf8, :page, :per_page, :format, :authenticity_token) %>
|
|
2
|
+
<% params = params.except(:bulk_ids) if params[:all_matching].present? %>
|
|
2
3
|
<% visible_fields = @model_config.export.with(view: self, object: @abstract_model.model.new, controller: self.controller).visible_fields %>
|
|
3
4
|
<%= form_tag export_path(params.merge(all: true)), method: 'post', class: "main", data: {turbo: false} do %>
|
|
4
5
|
<input name="send_data" type="hidden" value="true" />
|
|
@@ -38,43 +38,12 @@
|
|
|
38
38
|
<% end %>
|
|
39
39
|
</tr>
|
|
40
40
|
</thead>
|
|
41
|
-
<tbody class="table-group-divider">
|
|
42
|
-
<% @history.
|
|
43
|
-
|
|
44
|
-
<% unless object.created_at.nil? %>
|
|
45
|
-
<td>
|
|
46
|
-
<%= l(object.created_at, format: :long, default: l(object.created_at, format: :long)) %>
|
|
47
|
-
</td>
|
|
48
|
-
<% end %>
|
|
49
|
-
<td>
|
|
50
|
-
<%= object.username %>
|
|
51
|
-
</td>
|
|
52
|
-
<% if @general %>
|
|
53
|
-
<% if o = @abstract_model.get(object.item) %>
|
|
54
|
-
<% label = o.send(@abstract_model.config.object_label_method) %>
|
|
55
|
-
<% if show_action = action(:show, @abstract_model, o) %>
|
|
56
|
-
<td>
|
|
57
|
-
<%= link_to(label, url_for(action: show_action.action_name, model_name: @abstract_model.to_param, id: o.id)) %>
|
|
58
|
-
</td>
|
|
59
|
-
<% else %>
|
|
60
|
-
<td>
|
|
61
|
-
<%= label %>
|
|
62
|
-
</td>
|
|
63
|
-
<% end %>
|
|
64
|
-
<% else %>
|
|
65
|
-
<td>
|
|
66
|
-
<%= "#{@abstract_model.config.label} ##{object.item}" %>
|
|
67
|
-
</td>
|
|
68
|
-
<% end %>
|
|
69
|
-
<% end %>
|
|
70
|
-
<td>
|
|
71
|
-
<%= object.message.in?(['delete', 'new']) ? t("admin.actions.#{object.message}.done").capitalize : object.message %>
|
|
72
|
-
</td>
|
|
73
|
-
</tr>
|
|
41
|
+
<tbody class="table-group-divider" id="list_rows">
|
|
42
|
+
<% @history.each do |object| %>
|
|
43
|
+
<%= render 'history_row', object: %>
|
|
74
44
|
<% end %>
|
|
75
45
|
</tbody>
|
|
76
46
|
</table>
|
|
77
|
-
<%
|
|
78
|
-
<%= render '
|
|
79
|
-
<%= link_to(t("admin.misc.show_all"), send(path_method, params.merge(all: true)), class: "show-all btn btn-light") unless (tc = @history.total_count) <= @history.size || tc > 100 %>
|
|
47
|
+
<% if @history.respond_to?(:full_page?) && !params[:all] %>
|
|
48
|
+
<%= render 'next_batch', collection: @history, url_proc: method(:history_batch_url) %>
|
|
80
49
|
<% end %>
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
<%
|
|
2
2
|
query = params[:query]
|
|
3
|
-
|
|
4
|
-
params.delete(:query) if params[:query].blank?
|
|
5
|
-
params.delete(:sort_reverse) unless params[:sort_reverse] == 'true'
|
|
6
|
-
sort_reverse = params[:sort_reverse]
|
|
3
|
+
sort_reverse = ('true' if params[:sort_reverse] == 'true')
|
|
7
4
|
sort = params[:sort]
|
|
8
|
-
params
|
|
5
|
+
params = list_params
|
|
9
6
|
export_action = RailsAdminNext::Config::Actions.find(:export, { controller: self.controller, abstract_model: @abstract_model })
|
|
10
7
|
export_action = nil unless export_action && authorized?(export_action.authorization_key, @abstract_model)
|
|
11
8
|
description = RailsAdminNext.config(@abstract_model.model_name).description
|
|
12
|
-
properties =
|
|
9
|
+
properties = list_properties
|
|
13
10
|
checkboxes = @model_config.list.checkboxes?
|
|
14
11
|
table_table_header_count = begin
|
|
15
12
|
count = checkboxes ? 1 : 0
|
|
@@ -41,9 +38,6 @@
|
|
|
41
38
|
</ul>
|
|
42
39
|
</li>
|
|
43
40
|
<% end %>
|
|
44
|
-
<% if checkboxes %>
|
|
45
|
-
<%= bulk_menu %>
|
|
46
|
-
<% end %>
|
|
47
41
|
<% end %>
|
|
48
42
|
|
|
49
43
|
<style nonce="<%= content_security_policy_nonce %>">
|
|
@@ -88,13 +82,27 @@
|
|
|
88
82
|
<% scope = '_all' if scope.nil? %>
|
|
89
83
|
<li class="nav-item">
|
|
90
84
|
<a href="<%= index_path(params.merge(scope: scope, page: nil)) %>" class="nav-link <%= 'active' if scope.to_s == params[:scope] || (params[:scope].blank? && index == 0) %>">
|
|
91
|
-
<%=
|
|
85
|
+
<%= scope_label(scope) %>
|
|
92
86
|
</a>
|
|
93
87
|
</li>
|
|
94
88
|
<% end %>
|
|
95
89
|
</ul>
|
|
96
90
|
<% end %>
|
|
97
|
-
|
|
91
|
+
<% total_count = (@objects.respond_to?(:total_count) ? @objects.total_count.to_i : @objects.to_a.size) unless @model_config.list.limited_pagination %>
|
|
92
|
+
<% if total_count %>
|
|
93
|
+
<div class="total-count">
|
|
94
|
+
<%= "#{number_with_delimiter(total_count)} #{@model_config.pluralize(total_count).downcase}" %>
|
|
95
|
+
</div>
|
|
96
|
+
<% end %>
|
|
97
|
+
<%= form_tag bulk_action_path(model_name: @abstract_model.to_param), method: :post, id: "bulk_form", class: ["form", "mb-3"], data: ({
|
|
98
|
+
controller: "bulk-selection",
|
|
99
|
+
action: "turbo:before-stream-render@document->bulk-selection#carryTicks formdata->bulk-selection#dropIds",
|
|
100
|
+
bulk_selection_selected_count_value: t("admin.misc.selected_count"),
|
|
101
|
+
bulk_selection_loaded_selected_count_value: t("admin.misc.loaded_selected_count"),
|
|
102
|
+
bulk_selection_rows_selected_message_value: t("admin.misc.selection_announcements.rows_selected"),
|
|
103
|
+
bulk_selection_all_loaded_message_value: t("admin.misc.selection_announcements.all_loaded"),
|
|
104
|
+
bulk_selection_cleared_message_value: t("admin.misc.selection_announcements.cleared")
|
|
105
|
+
} if checkboxes) do %>
|
|
98
106
|
<%= hidden_field_tag :bulk_action %>
|
|
99
107
|
<%= hidden_field_tag :scope, params[:scope] if params[:scope].present? %>
|
|
100
108
|
<% if description.present? %>
|
|
@@ -104,13 +112,18 @@
|
|
|
104
112
|
</strong>
|
|
105
113
|
</p>
|
|
106
114
|
<% end %>
|
|
115
|
+
<% if checkboxes %>
|
|
116
|
+
<%= render "selection_bar", total_count: %>
|
|
117
|
+
<%# Outside the bar, which is display: none while nothing is ticked: a hidden region announces nothing. %>
|
|
118
|
+
<div class="visually-hidden selection-announcement" role="status" data-bulk-selection-target="announcement"></div>
|
|
119
|
+
<% end %>
|
|
107
120
|
<div id="sidescroll" data-controller="sidescroll">
|
|
108
121
|
<table class="table table-condensed table-striped table-hover">
|
|
109
122
|
<thead>
|
|
110
123
|
<tr>
|
|
111
124
|
<% if checkboxes %>
|
|
112
125
|
<th class="shrink sticky">
|
|
113
|
-
<input class="toggle" type="checkbox" />
|
|
126
|
+
<input class="toggle" type="checkbox" aria-label="<%= t("admin.misc.select_all_loaded") %>" data-bulk-selection-target="header" data-action="bulk-selection#toggleAll" />
|
|
114
127
|
</th>
|
|
115
128
|
<% end %>
|
|
116
129
|
<% properties.each do |property| %>
|
|
@@ -126,26 +139,9 @@
|
|
|
126
139
|
<th class="last shrink"></th>
|
|
127
140
|
</tr>
|
|
128
141
|
</thead>
|
|
129
|
-
<tbody class="table-group-divider">
|
|
142
|
+
<tbody class="table-group-divider" id="list_rows">
|
|
130
143
|
<% @objects.each do |object| %>
|
|
131
|
-
|
|
132
|
-
<% if checkboxes %>
|
|
133
|
-
<td class="sticky">
|
|
134
|
-
<%= check_box_tag "bulk_ids[]", object.id.to_s, false %>
|
|
135
|
-
</td>
|
|
136
|
-
<% end %>
|
|
137
|
-
<% properties.map{ |property| property.bind(:object, object) }.each do |property| %>
|
|
138
|
-
<% value = property.pretty_value %>
|
|
139
|
-
<%= content_tag(:td, class: [property.sticky? && 'sticky', property.css_class, property.type_css_class].select(&:present?), title: strip_tags(value.to_s)) do %>
|
|
140
|
-
<%= value %>
|
|
141
|
-
<% end %>
|
|
142
|
-
<% end %>
|
|
143
|
-
<td class="last links ra-sidescroll-frozen">
|
|
144
|
-
<ul class="nav d-inline list-inline">
|
|
145
|
-
<%= menu_for :member, @abstract_model, object, true %>
|
|
146
|
-
</ul>
|
|
147
|
-
</td>
|
|
148
|
-
</tr>
|
|
144
|
+
<%= render 'list_row', object:, properties:, checkboxes: %>
|
|
149
145
|
<% end %>
|
|
150
146
|
<% if @objects.empty? %>
|
|
151
147
|
<tr class="empty_row">
|
|
@@ -157,31 +153,6 @@
|
|
|
157
153
|
</tbody>
|
|
158
154
|
</table>
|
|
159
155
|
</div>
|
|
160
|
-
|
|
161
|
-
<div class="row">
|
|
162
|
-
<div class="col-md-6">
|
|
163
|
-
<%= render 'pagination', collection: @objects, mode: :limited, url_proc: ->(page) { index_path(params.except('page', :page).merge(page: page)) } %>
|
|
164
|
-
</div>
|
|
165
|
-
</div>
|
|
166
|
-
<% elsif @objects.respond_to?(:total_count) %>
|
|
167
|
-
<% total_count = @objects.total_count.to_i %>
|
|
168
|
-
<div class="row">
|
|
169
|
-
<div class="col-md-6">
|
|
170
|
-
<%= render 'pagination', collection: @objects, mode: :numbered, url_proc: ->(page) { index_path(params.except('page', :page).merge(page: page)) } %>
|
|
171
|
-
</div>
|
|
172
|
-
</div>
|
|
173
|
-
<div class="row">
|
|
174
|
-
<div class="col-md-6">
|
|
175
|
-
<%= link_to(t("admin.misc.show_all"), index_path(params.merge(all: true)), class: "show-all btn btn-light clearfix") unless total_count > 100 || total_count <= @objects.to_a.size %>
|
|
176
|
-
</div>
|
|
177
|
-
</div>
|
|
178
|
-
<div class="clearfix total-count">
|
|
179
|
-
<%= "#{total_count} #{@model_config.pluralize(total_count).downcase}" %>
|
|
180
|
-
</div>
|
|
181
|
-
<% else %>
|
|
182
|
-
<div class="clearfix total-count">
|
|
183
|
-
<%= "#{@objects.size} #{@model_config.pluralize(@objects.size).downcase}" %>
|
|
184
|
-
</div>
|
|
185
|
-
<% end %>
|
|
156
|
+
<%= render 'next_batch', collection: @objects, url_proc: method(:list_batch_url) if @objects.respond_to?(:full_page?) %>
|
|
186
157
|
<% end %>
|
|
187
158
|
</div>
|
|
@@ -25,5 +25,10 @@ pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
|
|
|
25
25
|
# data-turbo-confirm attributes, and date/time fields use native HTML5 inputs (no JS library).
|
|
26
26
|
pin "@rails/actioncable", to: "actioncable.esm.js"
|
|
27
27
|
pin "@rails/activestorage", to: "activestorage.esm.js"
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
|
|
29
|
+
# Rich-text editors preload only under their own entry point. The Trix pins stay on every host so a
|
|
30
|
+
# host entrypoint that imports "trix" itself keeps resolving. lexxy ships no pin of its own, and a
|
|
31
|
+
# pin to a file missing from the load path logs on every request, so it is pinned only with the gem.
|
|
32
|
+
pin "@rails/actiontext", to: "actiontext.esm.js", preload: "trix"
|
|
33
|
+
pin "trix", to: "trix.js", preload: "trix"
|
|
34
|
+
pin "lexxy", to: "lexxy.min.js", preload: "lexxy" if defined?(Lexxy::Engine)
|
|
@@ -26,15 +26,15 @@ en:
|
|
|
26
26
|
home:
|
|
27
27
|
name: "Home"
|
|
28
28
|
pagination:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
end: "End of list"
|
|
30
|
+
error: "The next rows could not be loaded."
|
|
31
|
+
load_more: "Load more"
|
|
32
|
+
retry: "Retry"
|
|
32
33
|
misc:
|
|
33
34
|
search: "Search"
|
|
34
35
|
filter: "Filter"
|
|
35
36
|
reset_filters: "Reset filters"
|
|
36
37
|
refresh: "Refresh"
|
|
37
|
-
show_all: "Show all"
|
|
38
38
|
add_filter: "Add filter"
|
|
39
39
|
bulk_menu_title: "Selected items"
|
|
40
40
|
remove: "Remove"
|
|
@@ -50,11 +50,38 @@ en:
|
|
|
50
50
|
time_ago: "%{time} ago"
|
|
51
51
|
ago: "ago"
|
|
52
52
|
more: "Plus %{count} more %{models_name}"
|
|
53
|
+
all_matching_selected: "All %{count} matching %{models_name} are selected"
|
|
54
|
+
all_matching_selected_uncounted: "All matching %{models_name} are selected"
|
|
55
|
+
clear_selection: "Clear selection"
|
|
56
|
+
loaded_selected_count: "%{count} loaded rows selected"
|
|
57
|
+
select_all_loaded: "Select every loaded row"
|
|
58
|
+
select_all_matching: "Select all %{count} matching %{models_name}"
|
|
59
|
+
select_all_matching_uncounted: "Select all matching %{models_name}"
|
|
60
|
+
select_all_matches: "Select all %{count} matches"
|
|
61
|
+
select_all_matches_uncounted: "Select all matches"
|
|
62
|
+
selected_count: "%{count} selected"
|
|
63
|
+
selection_announcements:
|
|
64
|
+
all_loaded: "All %{count} loaded rows selected"
|
|
65
|
+
cleared: "Selection cleared"
|
|
66
|
+
rows_selected: "%{count} selected"
|
|
67
|
+
bulk_deletion:
|
|
68
|
+
finished: "Deleting %{name} finished: %{deleted} deleted, %{failed} failed."
|
|
69
|
+
gone:
|
|
70
|
+
one: "%{formatted_count} was already gone."
|
|
71
|
+
other: "%{formatted_count} were already gone."
|
|
72
|
+
remaining: "Delete the remaining records from the list"
|
|
73
|
+
running: "Deleting %{name}: %{done} of %{total}"
|
|
74
|
+
stopped: "Deleting %{name} stopped early: %{deleted} deleted, %{failed} failed of %{total}. The records not yet deleted still match the list."
|
|
75
|
+
unavailable: "The progress of a background delete is no longer available. Check the list to see what is left."
|
|
53
76
|
flash:
|
|
54
77
|
successful: "%{name} successfully %{action}"
|
|
55
78
|
error: "%{name} failed to be %{action}"
|
|
56
79
|
delete_restricted: "%{name} failed to be deleted: %{reason}"
|
|
57
80
|
noaction: "No actions were taken"
|
|
81
|
+
bulk_delete_background: "%{name} are being deleted in the background."
|
|
82
|
+
bulk_delete_changed: "The matching records changed since this confirmation was shown, so nothing was deleted. Check the new set and confirm again."
|
|
83
|
+
bulk_delete_nothing_left: "Nothing was left to delete"
|
|
84
|
+
bulk_delete_too_many: "%{name} are more than the %{limit} whose permissions can be checked in one delete, so nothing was deleted. Narrow the filter and try again."
|
|
58
85
|
model_not_found: "Model '%{model}' could not be found"
|
|
59
86
|
object_not_found: "%{model} with id '%{id}' could not be found"
|
|
60
87
|
table_headers:
|
|
@@ -136,6 +163,12 @@ en:
|
|
|
136
163
|
are_you_sure_you_want_to_delete_the_object: "Are you sure you want to delete this %{model_name}"
|
|
137
164
|
confirmation: "Yes, I'm sure"
|
|
138
165
|
bulk_delete: "The following objects will be deleted, which may delete or orphan some of their related dependencies:"
|
|
166
|
+
bulk_delete_count: "%{name} will be deleted, which may delete or orphan some of their related dependencies."
|
|
167
|
+
bulk_delete_everything: "This is every %{model_label} there is."
|
|
168
|
+
bulk_delete_matching: "They are every one of the %{model_label_plural} that match:"
|
|
169
|
+
bulk_delete_query: "Search: %{query}"
|
|
170
|
+
bulk_delete_scope: "Scope: %{tab}"
|
|
171
|
+
bulk_delete_unauthorized_skipped: "Records you may not delete are skipped and reported as failed."
|
|
139
172
|
new_model: "%{name} (new)"
|
|
140
173
|
export:
|
|
141
174
|
confirmation: "Export to %{name}"
|
data/config/routes.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
RailsAdminNext::Engine.routes.draw do
|
|
4
|
+
# Before the :model_name scope, which would otherwise read the path as a model's show page.
|
|
5
|
+
resources :bulk_deletions, only: :show
|
|
4
6
|
controller "main" do
|
|
5
7
|
RailsAdminNext::Config::Actions.all(:root).each { |action| match "/#{action.route_fragment}", action: action.action_name, as: action.action_name, via: action.http_methods }
|
|
6
8
|
scope ":model_name" do
|