Browse Source

lint

pull/2879/head
Kat 4 months ago
parent
commit
64f27ce9cc
  1. 4
      app/views/layouts/rails_admin/_navigation.html.erb
  2. 4
      app/views/layouts/rails_admin/application.html.erb
  3. 14
      app/views/rails_admin/main/dashboard.html.erb
  4. 58
      app/views/rails_admin/main/index.html.erb
  5. 2
      config/initializers/assets.rb

4
app/views/layouts/rails_admin/_navigation.html.erb

@ -4,6 +4,6 @@
navigation_classes: "govuk-header__navigation--end", navigation_classes: "govuk-header__navigation--end",
) do |component| ) do |component|
component.with_product_name(name: t("service_name")) component.with_product_name(name: t("service_name"))
component.with_navigation_item(text: "Your account", href: Rails.application.routes.url_helpers.account_path) component.with_navigation_item(text: "Your account", href: Rails.application.routes.url_helpers.account_path)
component.with_navigation_item(text: "Sign out", href: Rails.application.routes.url_helpers.destroy_user_session_path) component.with_navigation_item(text: "Sign out", href: Rails.application.routes.url_helpers.destroy_user_session_path)
end %> end %>

4
app/views/layouts/rails_admin/application.html.erb

@ -53,14 +53,14 @@
<div class="govuk-width-container"> <div class="govuk-width-container">
<main class="govuk-main-wrapper govuk-main-wrapper--auto-spacing" id="main-content" role="main"> <main class="govuk-main-wrapper govuk-main-wrapper--auto-spacing" id="main-content" role="main">
<%= render template: 'layouts/rails_admin/content' %> <%= render template: "layouts/rails_admin/content" %>
</main> </main>
</div> </div>
<%= render partial: "layouts/feedback" %> <%= render partial: "layouts/feedback" %>
<%= render partial: "layouts/footer", locals: { <%= render partial: "layouts/footer", locals: {
accessibility_statement_path: Rails.application.routes.url_helpers.accessibility_statement_path, accessibility_statement_path: Rails.application.routes.url_helpers.accessibility_statement_path,
privacy_notice_path: Rails.application.routes.url_helpers.privacy_notice_path, privacy_notice_path: Rails.application.routes.url_helpers.privacy_notice_path,
cookies_path: Rails.application.routes.url_helpers.cookies_path cookies_path: Rails.application.routes.url_helpers.cookies_path,
} %> } %>
</body> </body>
</html> </html>

14
app/views/rails_admin/main/dashboard.html.erb

@ -18,7 +18,7 @@
<% @abstract_models.each do |abstract_model| %> <% @abstract_models.each do |abstract_model| %>
<% if authorized? :index, abstract_model %> <% if authorized? :index, abstract_model %>
<% index_path = index_path(model_name: abstract_model.to_param) %> <% index_path = index_path(model_name: abstract_model.to_param) %>
<% row_class = "#{cycle("odd", "even")}#{" link" if index_path} #{abstract_model.param_key}_links" %> <% row_class = "#{cycle('odd', 'even')}#{' link' if index_path} #{abstract_model.param_key}_links" %>
<tr class="<%= row_class %>" data-link="<%= index_path %>"> <tr class="<%= row_class %>" data-link="<%= index_path %>">
<% last_created = @most_recent_created[abstract_model.model.name] %> <% last_created = @most_recent_created[abstract_model.model.name] %>
<% active = last_created.try(:today?) %> <% active = last_created.try(:today?) %>
@ -29,13 +29,17 @@
</td> </td>
<td> <td>
<% if last_created %> <% if last_created %>
<%= t "admin.misc.time_ago", time: time_ago_in_words(last_created), default: "#{time_ago_in_words(last_created)} #{t("admin.misc.ago")}" %> <%= t "admin.misc.time_ago", time: time_ago_in_words(last_created), default: "#{time_ago_in_words(last_created)} #{t('admin.misc.ago')}" %>
<% end %> <% end %>
</td> </td>
<td> <td>
<% count = @count[abstract_model.model.name] %> <% count = @count[abstract_model.model.name] %>
<% percent = count > 0 ? (@max <= 1 ? count : ((Math.log(count+1) * 100.0) / Math.log(@max+1)).to_i) : -1 %> <% percent = if count.positive?
<div class="<%= active ? 'active progress-bar-striped ' : '' %>progress" style="margin-bottom:0px"> @max <= 1 ? count : ((Math.log(count + 1) * 100.0) / Math.log(@max + 1)).to_i
else
-1
end %>
<div class="<%= active ? "active progress-bar-striped " : "" %>progress" style="margin-bottom:0px">
<div class="bg-<%= get_indicator(percent) %> progress-bar animate-width-to" data-animate-length="<%= ([1.0, percent].max.to_i * 20) %>" data-animate-width-to="<%= [2.0, percent].max.to_i %>%" style="width:2%"> <div class="bg-<%= get_indicator(percent) %> progress-bar animate-width-to" data-animate-length="<%= ([1.0, percent].max.to_i * 20) %>" data-animate-width-to="<%= [2.0, percent].max.to_i %>%" style="width:2%">
<%= @count[abstract_model.model.name] %> <%= @count[abstract_model.model.name] %>
</div> </div>
@ -58,7 +62,7 @@
<h2> <h2>
<%= t("admin.actions.history_index.menu") %> <%= t("admin.actions.history_index.menu") %>
</h2> </h2>
<%= render partial: 'rails_admin/main/dashboard_history' %> <%= render partial: "rails_admin/main/dashboard_history" %>
</div> </div>
</div> </div>
<% end %> <% end %>

58
app/views/rails_admin/main/index.html.erb

@ -1,19 +1,18 @@
<% query = params[:query]
query = params[:query]
params = request.params.except(:authenticity_token, :action, :controller, :utf8, :bulk_export) params = request.params.except(:authenticity_token, :action, :controller, :utf8, :bulk_export)
params.delete(:query) if params[:query].blank? params.delete(:query) if params[:query].blank?
params.delete(:sort_reverse) unless params[:sort_reverse] == 'true' params.delete(:sort_reverse) unless params[:sort_reverse] == "true"
sort_reverse = params[:sort_reverse] sort_reverse = params[:sort_reverse]
sort = params[:sort] sort = params[:sort]
params.delete(:sort) if params[:sort] == @model_config.list.sort_by.to_s params.delete(:sort) if params[:sort] == @model_config.list.sort_by.to_s
export_action = RailsAdmin::Config::Actions.find(:export, { controller: self.controller, abstract_model: @abstract_model }) export_action = RailsAdmin::Config::Actions.find(:export, { controller: controller, abstract_model: @abstract_model })
export_action = nil unless export_action && authorized?(export_action.authorization_key, @abstract_model) export_action = nil unless export_action && authorized?(export_action.authorization_key, @abstract_model)
description = RailsAdmin.config(@abstract_model.model_name).description description = RailsAdmin.config(@abstract_model.model_name).description
properties = @model_config.list.with(controller: self.controller, view: self, object: @abstract_model.model.new).fields_for_table properties = @model_config.list.with(controller: controller, view: self, object: @abstract_model.model.new).fields_for_table
checkboxes = @model_config.list.checkboxes? checkboxes = @model_config.list.checkboxes?
table_table_header_count = begin table_table_header_count = begin
count = checkboxes ? 1 : 0 count = checkboxes ? 1 : 0
count = count + properties.count count += properties.count
end end
%> %>
@ -21,7 +20,7 @@
<% if filterable_fields.present? %> <% if filterable_fields.present? %>
<li class="nav-item dropdown"> <li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#"> <a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#">
<%= t('admin.misc.add_filter') %> <%= t("admin.misc.add_filter") %>
<b class="caret"></b> <b class="caret"></b>
</a> </a>
<ul class="dropdown-menu dropdown-menu-end" id="filters"> <ul class="dropdown-menu dropdown-menu-end" id="filters">
@ -30,8 +29,7 @@
<a <a
href="#" href="#"
class="dropdown-item" class="dropdown-item"
data-options="<%= field.with(view: self).filter_options.to_json %>" data-options="<%= field.with(view: self).filter_options.to_json %>">
>
<%= field.label %> <%= field.label %>
</a> </a>
</li> </li>
@ -45,7 +43,7 @@
<% end %> <% end %>
<style> <style>
<% properties.select{ |p| p.column_width.present? }.each do |property| %> <% properties.select { |p| p.column_width.present? }.each do |property| %>
<%= "#list th.#{property.css_class} { width: #{property.column_width}px; min-width: #{property.column_width}px; }" %> <%= "#list th.#{property.css_class} { width: #{property.column_width}px; min-width: #{property.column_width}px; }" %>
<%= "#list td.#{property.css_class} { max-width: #{property.column_width}px;}" %> <%= "#list td.#{property.css_class} { max-width: #{property.column_width}px;}" %>
<% end %> <% end %>
@ -55,16 +53,16 @@
<%= form_tag(index_path(params.except(*%w[page f query])), method: :get) do %> <%= form_tag(index_path(params.except(*%w[page f query])), method: :get) do %>
<div class="card mb-3 p-3 bg-light"> <div class="card mb-3 p-3 bg-light">
<div class="row" data-options="<%= ordered_filter_options.to_json %>" id="filters_box"></div> <div class="row" data-options="<%= ordered_filter_options.to_json %>" id="filters_box"></div>
<hr class="filters_box" style="display:<%= ordered_filters.empty? ? 'none' : 'block' %>"/> <hr class="filters_box" style="display:<%= ordered_filters.empty? ? "none" : "block" %>">
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<div class="input-group"> <div class="input-group">
<input class="form-control" name="query" placeholder="<%= t("admin.misc.filter") %>" type="search" value="<%= query %>" /> <input class="form-control" name="query" placeholder="<%= t("admin.misc.filter") %>" type="search" value="<%= query %>">
<button class="btn btn-primary" data-disable-with="<%= '<i class="fas fa-sync"></i>' + t('admin.misc.refresh') %>" type="submit"> <button class="btn btn-primary" data-disable-with="<%= "<i class=\"fas fa-sync\"></i>#{t('admin.misc.refresh')}" %>" type="submit">
<i class="fas fa-sync"></i> <i class="fas fa-sync"></i>
<%= t('admin.misc.refresh') %> <%= t("admin.misc.refresh") %>
</button> </button>
<button class="btn btn-info" id="remove_filter" title="<%= t('admin.misc.reset_filters') %>"> <button class="btn btn-info" id="remove_filter" title="<%= t("admin.misc.reset_filters") %>">
<i class="fas fa-times"></i> <i class="fas fa-times"></i>
</button> </button>
</div> </div>
@ -74,7 +72,7 @@
</div> </div>
<div class="col-sm-6 text-end"> <div class="col-sm-6 text-end">
<% if export_action %> <% if export_action %>
<%= govuk_link_to wording_for(:link, export_action), export_path(params.except('page')), class: 'btn btn-info' %> <%= govuk_link_to wording_for(:link, export_action), export_path(params.except("page")), class: "btn btn-info" %>
<% end %> <% end %>
</div> </div>
</div> </div>
@ -83,16 +81,16 @@
<% unless @model_config.list.scopes.empty? %> <% unless @model_config.list.scopes.empty? %>
<ul class="nav nav-tabs" id="scope_selector"> <ul class="nav nav-tabs" id="scope_selector">
<% @model_config.list.scopes.each_with_index do |scope, index| %> <% @model_config.list.scopes.each_with_index do |scope, index| %>
<% scope = '_all' if scope.nil? %> <% scope = "_all" if scope.nil? %>
<li class="nav-item"> <li class="nav-item">
<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) %>"> <a href="<%= index_path(params.merge(scope:, page: nil)) %>" class="nav-link <%= "active" if scope.to_s == params[:scope] || (params[:scope].blank? && index.zero?) %>">
<%= I18n.t("admin.scopes.#{@abstract_model.to_param}.#{scope}", default: I18n.t("admin.scopes.#{scope}", default: scope.to_s.titleize)) %> <%= I18n.t("admin.scopes.#{@abstract_model.to_param}.#{scope}", default: I18n.t("admin.scopes.#{scope}", default: scope.to_s.titleize)) %>
</a> </a>
</li> </li>
<% end %> <% end %>
</ul> </ul>
<% end %> <% end %>
<%= form_tag bulk_action_path(model_name: @abstract_model.to_param), method: :post, id: "bulk_form", class: ["form", "mb-3"] do %> <%= form_tag bulk_action_path(model_name: @abstract_model.to_param), method: :post, id: "bulk_form", class: %w[form mb-3] do %>
<%= hidden_field_tag :bulk_action %> <%= hidden_field_tag :bulk_action %>
<% if description.present? %> <% if description.present? %>
<p> <p>
@ -107,16 +105,18 @@
<tr> <tr>
<% if checkboxes %> <% if checkboxes %>
<th class="shrink sticky"> <th class="shrink sticky">
<input class="toggle" type="checkbox" /> <input class="toggle" type="checkbox">
</th> </th>
<% end %> <% end %>
<% properties.each do |property| %> <% properties.each do |property| %>
<% selected = (sort == property.name.to_s) %> <% selected = (sort == property.name.to_s) %>
<% if property.sortable %> <% if property.sortable %>
<% sort_location = index_path params.except('sort_reverse').except('page').merge(sort: property.name).merge(selected && sort_reverse != "true" ? {sort_reverse: "true"} : {}) %> <% sort_location = index_path params.except("sort_reverse").except("page").merge(sort: property.name).merge(selected && sort_reverse != "true" ? { sort_reverse: "true" } : {}) %>
<% sort_direction = (sort_reverse == 'true' ? "headerSortUp" : "headerSortDown" if selected) %> <% sort_direction = (if selected
sort_reverse == "true" ? "headerSortUp" : "headerSortDown"
end) %>
<% end %> <% end %>
<th class="<%= [property.sortable && "header", property.sortable && sort_direction, property.sticky? && 'sticky', property.css_class, property.type_css_class].select(&:present?).join(' ') %>" data-href="<%= property.sortable && sort_location %>" rel="tooltip" title="<%= property.hint %>"> <th class="<%= [property.sortable && "header", property.sortable && sort_direction, property.sticky? && "sticky", property.css_class, property.type_css_class].select(&:present?).join(" ") %>" data-href="<%= property.sortable && sort_location %>" rel="tooltip" title="<%= property.hint %>">
<%= property.label %> <%= property.label %>
</th> </th>
<% end %> <% end %>
@ -125,15 +125,15 @@
</thead> </thead>
<tbody class="table-group-divider"> <tbody class="table-group-divider">
<% @objects.each do |object| %> <% @objects.each do |object| %>
<tr class="<%= @abstract_model.param_key %>_row <%= @model_config.list.with(object: object).row_css_class %>"> <tr class="<%= @abstract_model.param_key %>_row <%= @model_config.list.with(object:).row_css_class %>">
<% if checkboxes %> <% if checkboxes %>
<td class="sticky"> <td class="sticky">
<%= check_box_tag "bulk_ids[]", object.id.to_s, false %> <%= check_box_tag "bulk_ids[]", object.id.to_s, false %>
</td> </td>
<% end %> <% end %>
<% properties.map{ |property| property.bind(:object, object) }.each do |property| %> <% properties.map { |property| property.bind(:object, object) }.each do |property| %>
<% value = property.pretty_value %> <% value = property.pretty_value %>
<%= content_tag(:td, class: [property.sticky? && 'sticky', property.css_class, property.type_css_class].select(&:present?).map {|x| "rails-admin-#{x}"}, title: strip_tags(value.to_s)) do %> <%= content_tag(:td, class: [property.sticky? && "sticky", property.css_class, property.type_css_class].select(&:present?).map { |x| "rails-admin-#{x}" }, title: strip_tags(value.to_s)) do %>
<%= value %> <%= value %>
<% end %> <% end %>
<% end %> <% end %>
@ -147,7 +147,7 @@
<% if @objects.empty? %> <% if @objects.empty? %>
<tr class="empty_row"> <tr class="empty_row">
<td colspan="<%= table_table_header_count %>"> <td colspan="<%= table_table_header_count %>">
<%= I18n.t('admin.actions.index.no_records') %> <%= I18n.t("admin.actions.index.no_records") %>
</td> </td>
</tr> </tr>
<% end %> <% end %>
@ -157,14 +157,14 @@
<% if @model_config.list.limited_pagination %> <% if @model_config.list.limited_pagination %>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<%= paginate(@objects, theme: 'ra-twitter-bootstrap/without_count', total_pages: Float::INFINITY) %> <%= paginate(@objects, theme: "ra-twitter-bootstrap/without_count", total_pages: Float::INFINITY) %>
</div> </div>
</div> </div>
<% elsif @objects.respond_to?(:total_count) %> <% elsif @objects.respond_to?(:total_count) %>
<% total_count = @objects.total_count.to_i %> <% total_count = @objects.total_count.to_i %>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<%= paginate(@objects, theme: 'ra-twitter-bootstrap') %> <%= paginate(@objects, theme: "ra-twitter-bootstrap") %>
</div> </div>
</div> </div>
<div class="row"> <div class="row">

2
config/initializers/assets.rb

@ -6,4 +6,4 @@ Rails.application.config.assets.version = "1.0"
# Add additional assets to the asset load path. # Add additional assets to the asset load path.
Rails.application.config.assets.paths << Rails.root.join("node_modules/@fortawesome/fontawesome-free/webfonts") Rails.application.config.assets.paths << Rails.root.join("node_modules/@fortawesome/fontawesome-free/webfonts")
Rails.application.config.assets.precompile += %w( rails_admin/rails_admin.css rails_admin/rails_admin.js ) Rails.application.config.assets.precompile += %w[rails_admin/rails_admin.css rails_admin/rails_admin.js]

Loading…
Cancel
Save