diff --git a/app/frontend/styles/_custom-rails-admin.scss b/app/frontend/styles/_custom-rails-admin.scss new file mode 100644 index 000000000..4a831625e --- /dev/null +++ b/app/frontend/styles/_custom-rails-admin.scss @@ -0,0 +1,15 @@ +.rails-admin-sidescroll { + overflow-x: scroll; +} + +.rails-admin-description_field { + min-width: 500px; +} + +.rails-admin-case_field { + min-width: 500px; +} + +.rails-admin-error_message_field { + min-width: 500px; +} \ No newline at end of file diff --git a/app/frontend/styles/application.scss b/app/frontend/styles/application.scss index 3e75107bd..94135074e 100644 --- a/app/frontend/styles/application.scss +++ b/app/frontend/styles/application.scss @@ -48,6 +48,7 @@ $govuk-breakpoints: ( @import "search"; @import "sub-navigation"; @import "unread-notification"; +@import "custom-rails-admin"; // App utilities .app-\!-colour-muted { diff --git a/app/views/rails_admin/main/dashboard.html.erb b/app/views/rails_admin/main/dashboard.html.erb new file mode 100644 index 000000000..b89f23b7e --- /dev/null +++ b/app/views/rails_admin/main/dashboard.html.erb @@ -0,0 +1,64 @@ +<% if @abstract_models %> + + + + + + + + + + + <% @abstract_models.each do |abstract_model| %> + <% if authorized? :index, abstract_model %> + <% index_path = index_path(model_name: abstract_model.to_param) %> + <% row_class = "#{cycle("odd", "even")}#{" link" if index_path} #{abstract_model.param_key}_links" %> + + <% last_created = @most_recent_created[abstract_model.model.name] %> + <% active = last_created.try(:today?) %> + + + + + + <% end %> + <% end %> + +
+ <%= t "admin.table_headers.model_name" %> + + <%= t "admin.table_headers.last_created" %> + + <%= t "admin.table_headers.records" %> +
+ + <%= link_to abstract_model.config.label_plural, index_path %> + + + <% 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")}" %> + <% end %> + + <% 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 %> +
+
+ <%= @count[abstract_model.model.name] %> +
+
+
+<% end %> +<% if @history && authorized?(:history_index) %> +
+
+

+ <%= t("admin.actions.history_index.menu") %> +

+ <%= render partial: 'rails_admin/main/dashboard_history' %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/rails_admin/main/index.html.erb b/app/views/rails_admin/main/index.html.erb new file mode 100644 index 000000000..ac31aae74 --- /dev/null +++ b/app/views/rails_admin/main/index.html.erb @@ -0,0 +1,184 @@ +<% + query = params[:query] + params = request.params.except(:authenticity_token, :action, :controller, :utf8, :bulk_export) + params.delete(:query) if params[:query].blank? + params.delete(:sort_reverse) unless params[:sort_reverse] == 'true' + sort_reverse = params[:sort_reverse] + sort = params[:sort] + 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 = nil unless export_action && authorized?(export_action.authorization_key, @abstract_model) + 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 + checkboxes = @model_config.list.checkboxes? + table_table_header_count = begin + count = checkboxes ? 1 : 0 + count = count + properties.count + end +%> + +<% content_for :contextual_tabs do %> + <% if filterable_fields.present? %> + + <% end %> + <% if checkboxes %> + <%= bulk_menu %> + <% end %> +<% end %> + + + +
+ <%= form_tag(index_path(params.except(*%w[page f query])), method: :get) do %> +
+
+
+
+
+
+ " type="search" value="<%= query %>" /> + + +
+ <% if @model_config.list.search_help.present? %> +
<%= @model_config.list.search_help %>
+ <% end %> +
+
+ <% if export_action %> + <%= govuk_link_to wording_for(:link, export_action), export_path(params.except('page')), class: 'btn btn-info' %> + <% end %> +
+
+
+ <% end %> + <% unless @model_config.list.scopes.empty? %> + + <% end %> + <%= form_tag bulk_action_path(model_name: @abstract_model.to_param), method: :post, id: "bulk_form", class: ["form", "mb-3"] do %> + <%= hidden_field_tag :bulk_action %> + <% if description.present? %> +

+ + <%= description %> + +

+ <% end %> +
+ + + + <% if checkboxes %> + + <% end %> + <% properties.each do |property| %> + <% selected = (sort == property.name.to_s) %> + <% 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_direction = (sort_reverse == 'true' ? "headerSortUp" : "headerSortDown" if selected) %> + <% end %> + + <% end %> + + + + + <% @objects.each do |object| %> + + <% if checkboxes %> + + <% end %> + <% properties.map{ |property| property.bind(:object, object) }.each do |property| %> + <% 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 %> + <%= value %> + <% end %> + <% end %> + + + <% end %> + <% if @objects.empty? %> + + + + <% end %> + +
+ + " data-href="<%= property.sortable && sort_location %>" rel="tooltip" title="<%= property.hint %>"> + <%= property.label %> +
+ <%= check_box_tag "bulk_ids[]", object.id.to_s, false %> +
+ <%= I18n.t('admin.actions.index.no_records') %> +
+
+ <% if @model_config.list.limited_pagination %> +
+
+ <%= paginate(@objects, theme: 'ra-twitter-bootstrap/without_count', total_pages: Float::INFINITY) %> +
+
+ <% elsif @objects.respond_to?(:total_count) %> + <% total_count = @objects.total_count.to_i %> +
+
+ <%= paginate(@objects, theme: 'ra-twitter-bootstrap') %> +
+
+
+
+ <%= 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 %> +
+
+
+ <%= "#{total_count} #{@model_config.pluralize(total_count).downcase}" %> +
+ <% else %> +
+ <%= "#{@objects.size} #{@model_config.pluralize(@objects.size).downcase}" %> +
+ <% end %> + <% end %> +
\ No newline at end of file