Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun
commit
b54eefd122
@ -0,0 +1,11 @@
|
||||
$(document).on('turbolinks:load', function () {
|
||||
if ($('body.admins-projects-index-page').length > 0) {
|
||||
var $form = $('.search-form');
|
||||
|
||||
// 清空
|
||||
$form.on('click', '.clear-btn', function () {
|
||||
$form.find('input[name="search"]').val('');
|
||||
$form.find('input[type="submit"]').trigger('click');
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,12 @@
|
||||
$(document).on('turbolinks:load', function () {
|
||||
if ($('body.admins-shixun-modify-records-index-page').length > 0) {
|
||||
var $form = $('.search-form');
|
||||
|
||||
// 清空
|
||||
$form.on('click', '.clear-btn', function () {
|
||||
$form.find('select[name="date"]').val('weekly');
|
||||
$form.find('input[name="user_name"]').val('');
|
||||
$form.find('input[type="submit"]').trigger('click');
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,14 @@
|
||||
.diff{overflow:auto;}
|
||||
.diff ul{background:#fff;overflow:auto;font-size:13px;list-style:none;margin:0;padding:0;display:table;width:100%;}
|
||||
.diff del, .diff ins{display:block;text-decoration:none;}
|
||||
.diff li{padding:0; display:table-row;margin: 0;height:1em;}
|
||||
.diff li.ins{background:#dfd; color:#080}
|
||||
.diff li.del{background:#fee; color:#b00}
|
||||
.diff li:hover{background:#ffc}
|
||||
|
||||
/* try 'whitespace:pre;' if you don't want lines to wrap */
|
||||
.diff del, .diff ins, .diff span{white-space:pre-wrap;font-family:courier;}
|
||||
.diff del strong{font-weight:normal;background:#fcc;}
|
||||
.diff ins strong{font-weight:normal;background:#9f9;}
|
||||
.diff li.diff-comment { display: none; }
|
||||
.diff li.diff-block-info { background: none repeat scroll 0 0 gray; }
|
@ -0,0 +1,9 @@
|
||||
class Admins::ShixunModifyRecordsController < Admins::BaseController
|
||||
|
||||
def index
|
||||
records = Admins::ShixunModifyRecordQuery.call(params)
|
||||
|
||||
@records = paginate records.includes(:diff_record_content)
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,33 @@
|
||||
class Admins::ShixunModifyRecordQuery < ApplicationQuery
|
||||
attr_reader :params
|
||||
|
||||
def initialize(params)
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
if params[:user_name].blank? || params[:date].blank?
|
||||
records = DiffRecord.none
|
||||
else
|
||||
records = DiffRecord.joins(:user).where("concat(users.lastname, users.firstname) like ?", "%#{params[:user_name].strip}%")
|
||||
if time_range.present?
|
||||
records = records.where(created_at: time_range)
|
||||
end
|
||||
end
|
||||
records.order("diff_records.created_at desc")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def time_range
|
||||
@_time_range ||= begin
|
||||
case params[:date]
|
||||
when 'weekly' then 1.weeks.ago..Time.now
|
||||
when 'monthly' then 1.months.ago..Time.now
|
||||
when 'quarterly' then 3.months.ago..Time.now
|
||||
when 'yearly' then 1.years.ago..Time.now
|
||||
else ''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,25 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('实训修改记录') %>
|
||||
<% end %>
|
||||
|
||||
<div class="box search-form-container shixun-modify-record-list-form">
|
||||
<%= form_tag(admins_shixun_modify_records_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
|
||||
<div class="form-group col-12 col-md-4">
|
||||
<label for="user_name">用户名:</label>
|
||||
<%= text_field_tag :user_name, params[:user_name], class: 'form-control flex-1', placeholder: '真实姓名搜索' %>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-12 col-md-auto">
|
||||
<label for="status">时间范围:</label>
|
||||
<% data_arrs = [['最近一周', 'weekly'], ['最近一个月', 'monthly']] %>
|
||||
<%= select_tag(:date, options_for_select(data_arrs, params[:date]), class: 'form-control') %>
|
||||
</div>
|
||||
|
||||
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
|
||||
<input type="reset" class="btn btn-secondary clear-btn" value="清空"/>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="box admin-list-container shixun-modify-record-list-container">
|
||||
<%= render partial: 'admins/shixun_modify_records/shared/list', locals: { records: @records } %>
|
||||
</div>
|
@ -0,0 +1 @@
|
||||
$('.shixun-modify-record-list-container').html("<%= j( render partial: 'admins/shixun_modify_records/shared/list', locals: { records: @records } ) %>");
|
@ -0,0 +1,38 @@
|
||||
<% if records.present? %>
|
||||
<% records.each do |record| %>
|
||||
<div class="record-item">
|
||||
<div class="record-item-head font-16">
|
||||
<span><%= record.user.real_name %></span>
|
||||
<span class="ml-3"><%= format_time record.created_at %></span>
|
||||
</div>
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
<div class="record-item-info font-14">
|
||||
<span>实训名称:<%= record.container&.shixun&.name %></span>
|
||||
<% if record.container_type == "Challenge" %>
|
||||
<span class="ml-3">/</span>
|
||||
<span class="ml-3">关卡名:<%= record.container&.subject %></span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="diff mt-2 font-12">
|
||||
<ul>
|
||||
<% record.diff_record_content&.content&.split("\n").each do |line| %>
|
||||
<% if line =~ /^[\+]/ %>
|
||||
<li class="ins"><ins><%= line %></ins></li>
|
||||
<% elsif line =~ /^[\-]/ %>
|
||||
<li class="del"><del><%= line %></del></li>
|
||||
<% else %>
|
||||
<li class="unchanged"><span><%= line %></span></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dropdown-divider"></div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render 'admins/shared/no_data_for_table' %>
|
||||
<% end %>
|
||||
|
||||
<%= render partial: 'admins/shared/paginate', locals: { objects: records } %>
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
Reference in new issue