4 changed files with 264 additions and 0 deletions
@ -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; |
||||
} |
@ -0,0 +1,64 @@
|
||||
<% if @abstract_models %> |
||||
<table class="table table-condensed table-striped table-hover"> |
||||
<thead> |
||||
<tr> |
||||
<th class="shrink model-name"> |
||||
<%= t "admin.table_headers.model_name" %> |
||||
</th> |
||||
<th class="shrink last-created"> |
||||
<%= t "admin.table_headers.last_created" %> |
||||
</th> |
||||
<th class="records"> |
||||
<%= t "admin.table_headers.records" %> |
||||
</th> |
||||
<th class="shrink controls"></th> |
||||
</tr> |
||||
</thead> |
||||
<tbody class="table-group-divider"> |
||||
<% @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" %> |
||||
<tr class="<%= row_class %>" data-link="<%= index_path %>"> |
||||
<% last_created = @most_recent_created[abstract_model.model.name] %> |
||||
<% active = last_created.try(:today?) %> |
||||
<td> |
||||
<span class="show"> |
||||
<%= link_to abstract_model.config.label_plural, index_path %> |
||||
</span> |
||||
</td> |
||||
<td> |
||||
<% 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 %> |
||||
</td> |
||||
<td> |
||||
<% 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 %> |
||||
<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%"> |
||||
<%= @count[abstract_model.model.name] %> |
||||
</div> |
||||
</div> |
||||
</td> |
||||
<td class="links"> |
||||
<ul class="nav d-inline list-inline"> |
||||
<%= menu_for :collection, abstract_model, nil, true %> |
||||
</ul> |
||||
</td> |
||||
</tr> |
||||
<% end %> |
||||
<% end %> |
||||
</tbody> |
||||
</table> |
||||
<% end %> |
||||
<% if @history && authorized?(:history_index) %> |
||||
<div class="block" id="block-tables"> |
||||
<div class="content"> |
||||
<h2> |
||||
<%= t("admin.actions.history_index.menu") %> |
||||
</h2> |
||||
<%= render partial: 'rails_admin/main/dashboard_history' %> |
||||
</div> |
||||
</div> |
||||
<% end %> |
@ -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? %> |
||||
<li class="nav-item dropdown"> |
||||
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#"> |
||||
<%= t('admin.misc.add_filter') %> |
||||
<b class="caret"></b> |
||||
</a> |
||||
<ul class="dropdown-menu dropdown-menu-end" id="filters"> |
||||
<% filterable_fields.each do |field| %> |
||||
<li> |
||||
<a |
||||
href="#" |
||||
class="dropdown-item" |
||||
data-options="<%= field.with(view: self).filter_options.to_json %>" |
||||
> |
||||
<%= field.label %> |
||||
</a> |
||||
</li> |
||||
<% end %> |
||||
</ul> |
||||
</li> |
||||
<% end %> |
||||
<% if checkboxes %> |
||||
<%= bulk_menu %> |
||||
<% end %> |
||||
<% end %> |
||||
|
||||
<style> |
||||
<% 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 td.#{property.css_class} { max-width: #{property.column_width}px;}" %> |
||||
<% end %> |
||||
</style> |
||||
|
||||
<div id="list"> |
||||
<%= form_tag(index_path(params.except(*%w[page f query])), method: :get) do %> |
||||
<div class="card mb-3 p-3 bg-light"> |
||||
<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' %>"/> |
||||
<div class="row"> |
||||
<div class="col-sm-6"> |
||||
<div class="input-group"> |
||||
<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"> |
||||
<i class="fas fa-sync"></i> |
||||
<%= t('admin.misc.refresh') %> |
||||
</button> |
||||
<button class="btn btn-info" id="remove_filter" title="<%= t('admin.misc.reset_filters') %>"> |
||||
<i class="fas fa-times"></i> |
||||
</button> |
||||
</div> |
||||
<% if @model_config.list.search_help.present? %> |
||||
<div class="form-text"><%= @model_config.list.search_help %></div> |
||||
<% end %> |
||||
</div> |
||||
<div class="col-sm-6 text-end"> |
||||
<% if export_action %> |
||||
<%= govuk_link_to wording_for(:link, export_action), export_path(params.except('page')), class: 'btn btn-info' %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<% end %> |
||||
<% unless @model_config.list.scopes.empty? %> |
||||
<ul class="nav nav-tabs" id="scope_selector"> |
||||
<% @model_config.list.scopes.each_with_index do |scope, index| %> |
||||
<% scope = '_all' if scope.nil? %> |
||||
<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) %>"> |
||||
<%= I18n.t("admin.scopes.#{@abstract_model.to_param}.#{scope}", default: I18n.t("admin.scopes.#{scope}", default: scope.to_s.titleize)) %> |
||||
</a> |
||||
</li> |
||||
<% end %> |
||||
</ul> |
||||
<% 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? %> |
||||
<p> |
||||
<strong> |
||||
<%= description %> |
||||
</strong> |
||||
</p> |
||||
<% end %> |
||||
<div id="sidescroll" class="rails-admin-sidescroll"> |
||||
<table class="table table-condensed table-striped table-hover"> |
||||
<thead> |
||||
<tr> |
||||
<% if checkboxes %> |
||||
<th class="shrink sticky"> |
||||
<input class="toggle" type="checkbox" /> |
||||
</th> |
||||
<% 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 %> |
||||
<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 %> |
||||
</th> |
||||
<% end %> |
||||
<th class="last shrink"></th> |
||||
</tr> |
||||
</thead> |
||||
<tbody class="table-group-divider"> |
||||
<% @objects.each do |object| %> |
||||
<tr class="<%= @abstract_model.param_key %>_row <%= @model_config.list.with(object: object).row_css_class %>"> |
||||
<% if checkboxes %> |
||||
<td class="sticky"> |
||||
<%= check_box_tag "bulk_ids[]", object.id.to_s, false %> |
||||
</td> |
||||
<% 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 %> |
||||
<td class="last links ra-sidescroll-frozen"> |
||||
<ul class="nav d-inline list-inline"> |
||||
<%= menu_for :member, @abstract_model, object, true %> |
||||
</ul> |
||||
</td> |
||||
</tr> |
||||
<% end %> |
||||
<% if @objects.empty? %> |
||||
<tr class="empty_row"> |
||||
<td colspan="<%= table_table_header_count %>"> |
||||
<%= I18n.t('admin.actions.index.no_records') %> |
||||
</td> |
||||
</tr> |
||||
<% end %> |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
<% if @model_config.list.limited_pagination %> |
||||
<div class="row"> |
||||
<div class="col-md-6"> |
||||
<%= paginate(@objects, theme: 'ra-twitter-bootstrap/without_count', total_pages: Float::INFINITY) %> |
||||
</div> |
||||
</div> |
||||
<% elsif @objects.respond_to?(:total_count) %> |
||||
<% total_count = @objects.total_count.to_i %> |
||||
<div class="row"> |
||||
<div class="col-md-6"> |
||||
<%= paginate(@objects, theme: 'ra-twitter-bootstrap') %> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-md-6"> |
||||
<%= 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 %> |
||||
</div> |
||||
</div> |
||||
<div class="clearfix total-count"> |
||||
<%= "#{total_count} #{@model_config.pluralize(total_count).downcase}" %> |
||||
</div> |
||||
<% else %> |
||||
<div class="clearfix total-count"> |
||||
<%= "#{@objects.size} #{@model_config.pluralize(@objects.size).downcase}" %> |
||||
</div> |
||||
<% end %> |
||||
<% end %> |
||||
</div> |
Loading…
Reference in new issue