diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb
index 67ea8b57..d3336e08 100644
--- a/app/controllers/managements_controller.rb
+++ b/app/controllers/managements_controller.rb
@@ -1481,7 +1481,7 @@ end
redirect_to departments_managements_path
end
- # 修改单位部门列表
+ # 更改单位部门列表
def update_department
dep = Department.find params[:department_id]
@edit_id = params[:department_id]
@@ -1498,6 +1498,22 @@ end
end
end
+ # 修改部门名称
+ def update_depart_name
+ @depart = Department.find(params[:depart_id])
+ @depart.update_attributes(:name => params[:depart_name]) if @depart.school.departments.where(name: params[:depart_name]).count == 0
+ end
+
+ # 检查是否存在同名的部门
+ def check_depart_name
+ depart = Department.find(params[:depart_id])
+ if depart.school.departments.where(name: params[:depart_name]).count == 0
+ render :json => {status: 0, message: ""}
+ else
+ render :json => {status: -1, message: "该名称已存在"}
+ end
+ end
+
def edit_departments_school
begin
dep = Department.find(params[:department_id])
@@ -1511,9 +1527,10 @@ end
# ApplyAddDepartment.where(:department_id =>params[:departments]).update_all(:department_id=>department_id)
# users = UserExtensions.where("department_id = #{alt_dep.department_id}")
# users.update_all(:department_id => department.id)
- apply_dep.destroy_all;
+ apply_dep.destroy_all
users = UserExtensions.where(:department_id => params[:alter_dep_id])
users.update_all(:department_id => dep.id)
+ dep.update_attributes(:identifier => alter_dep.identifier) if dep.identifier.nil? && alter_dep.identifier.present?
alter_dep.destroy
end
rescue Exception => e
diff --git a/app/views/managements/_departments_list.html.erb b/app/views/managements/_departments_list.html.erb
index 26bad842..f9ba8659 100644
--- a/app/views/managements/_departments_list.html.erb
+++ b/app/views/managements/_departments_list.html.erb
@@ -17,7 +17,7 @@
<% @department.each_with_index do |department,index| %>
<%= (@page -1) * @limit + index + 1 %> |
- <%= department.name %> |
+ <%= department.name %> |
<%= School.where(:id => department.school_id).first %> |
<%= UserExtensions.where(:department_id => department.id, :school_id => department.school_id ).count %> |
<%= User.where(:id => UserExtensions.where(:department_id => department.id, :school_id => department.school_id).map(&:user_id),:professional_certification => 1).count %> |
@@ -38,8 +38,9 @@
<%= format_time department.created_at %> |
- 删除
+ 删除
<%= link_to '更改', update_department_managements_path(:school_id=> department.school_id,:department_id => department.id), :remote => true, :class => "application-default-link" %>
+ 修改
|
<% end %>
@@ -78,4 +79,11 @@
$("#update_host_count_depart_id").val(id);
$("input[name='host_count']").val($("#depart_host_count_"+id).html().trim());
}
+
+ function editDepartName(id){
+ var htmlvalue = "<%= escape_javascript(render :partial => 'managements/edit_depart_name') %>";
+ pop_box_new(htmlvalue,400,204);
+ $("#update_depart_name_depart_id").val(id);
+ $("input[name='depart_name']").val($("#department_name_"+id).html().trim());
+ }
diff --git a/app/views/managements/_edit_depart_name.html.erb b/app/views/managements/_edit_depart_name.html.erb
new file mode 100644
index 00000000..fadcf5a2
--- /dev/null
+++ b/app/views/managements/_edit_depart_name.html.erb
@@ -0,0 +1,15 @@
+
\ No newline at end of file
diff --git a/app/views/managements/update_depart_name.js.erb b/app/views/managements/update_depart_name.js.erb
new file mode 100644
index 00000000..24a2e19b
--- /dev/null
+++ b/app/views/managements/update_depart_name.js.erb
@@ -0,0 +1 @@
+$("#department_name_<%= @depart.id %>").html("<%= params[:depart_name] %>");
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 78c35a76..2500a78e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -633,6 +633,8 @@ RedmineApp::Application.routes.draw do ## oauth相关
match 'new_major', :via => [:get, :post]
post 'insert_major'
match 'update_department',:via => [:get, :post]
+ post 'update_depart_name'
+ get 'check_depart_name'
post 'edit_departments_school'
get 'create_departments'
post 'add_department'
diff --git a/public/javascripts/edu/management.js b/public/javascripts/edu/management.js
index f8571035..e755c5fd 100644
--- a/public/javascripts/edu/management.js
+++ b/public/javascripts/edu/management.js
@@ -26,6 +26,27 @@ function submit_depart_host_count(){
}
}
+function submit_depart_name_form(){
+ if($("input[name='depart_name']").val().trim() == ""){
+ $("#update_depart_name_notice").html("名称不能为空").show();
+ } else {
+ $.ajax({
+ type: "GET",
+ url: '/managements/check_depart_name',
+ data: {depart_id: $("#update_depart_name_depart_id").val(), depart_name: $("input[name='depart_name']").val().trim()},
+ success: function (data) {
+ if(data.status == 0){
+ $("#update_depart_name_notice").hide();
+ $('#update_depart_name_form').submit();
+ hideModal();
+ } else{
+ $("#update_depart_name_notice").html("该名称已存在").show();
+ }
+ }
+ });
+ }
+}
+
/*--------------------------- 用户授权全选 -------------------------------*/
$("#all_member_select").live('click', function(){
if($("#all_member_select").is(':checked')){
diff --git a/public/react/public/js/js_min_all.js b/public/react/public/js/js_min_all.js
index 19daead5..0c139046 100644
--- a/public/react/public/js/js_min_all.js
+++ b/public/react/public/js/js_min_all.js
@@ -206,6 +206,7 @@ $(function(){
// window resize
$(window).on('resize', function() {
+ // _resizeVNC_if_needed()
$('.CodeMirror.cm-s-railscasts').css("height", $("#games_repository_contents").height() - repositoryTabHeight);
})
@@ -1182,6 +1183,7 @@ $(function(){ // 这里重新加一次事件监听,不在原有事件的基
dragging = true;
dragDom = lab;
$('#htmlIframe').css('pointer-events', 'none')
+ $('#can-drag').show()
return false;
}
);
@@ -1202,7 +1204,10 @@ $(function(){ // 这里重新加一次事件监听,不在原有事件的基
doc.live("mouseup", function(e) {
// 在大窗口将下边测试集滚动条拖上去后,将窗口缩小,再拖下来就有这种情况 https://www.trustie.net/issues/16326
+ $('#can-drag').hide()
+
if (dragging === true) {
+ // _resizeVNC_if_needed()
window.editor_CodeMirror && window.editor_CodeMirror.refresh()
// 使得iframe可以继续捕获事件
$('#htmlIframe').css('pointer-events', 'inherit')
@@ -1210,6 +1215,27 @@ $(function(){ // 这里重新加一次事件监听,不在原有事件的基
dragging = false;
});
})
+function _resizeVNC_if_needed() {
+ return;
+ if (window.__isVNC) {
+ // $('#screen>div').width('1024px').height('768px')
+ var trueHeight = $('#game_right_contents').height();
+ var width = $('#game_right_contents').width()
+
+ // __rfb && __rfb.get_display().autoscale(width, trueHeight)
+
+ return;
+ if (trueHeight < 768) {
+ var width = $('#game_right_contents').width()
+ var _left = width - $('#screen').width() / 2
+ var scale = (trueHeight / 768).toFixed(5)
+ // _left
+ $('#screen').css('transform', 'scale(' + scale + ', ' + scale +')').css('transform-origin', 0 + 'px 0px')
+ } else {
+ $('#screen').css('transform', 'scale(' + 1 + ', ' + 1 +')')
+ }
+ }
+}
// ---------------------------------------------------------------------------------------------
/**
diff --git a/public/react/src/modules/page/MainContent.js b/public/react/src/modules/page/MainContent.js
index a0ac70f1..6902b7f2 100644
--- a/public/react/src/modules/page/MainContent.js
+++ b/public/react/src/modules/page/MainContent.js
@@ -46,7 +46,8 @@ class MainContent extends Component {
} else {
games_repository_contents_style = {overflow: 'hidden', height: '445px'}
}
- const showIframeContent = shixun && shixun.vnc == true
+ const showIframeContent = shixun && shixun.vnc == true
+ // window.__isVNC = showIframeContent && !!vnc_url
return (
@@ -55,6 +56,18 @@ class MainContent extends Component {
{/* 左侧任务说明等功能的区域 */}
+
+ {showIframeContent && vnc_url &&
}
diff --git a/public/react/src/modules/page/VNCDisplay.js b/public/react/src/modules/page/VNCDisplay.js
index 1e443ed1..57d26731 100644
--- a/public/react/src/modules/page/VNCDisplay.js
+++ b/public/react/src/modules/page/VNCDisplay.js
@@ -13,6 +13,7 @@ class VNCDisplay extends Component {
// When this function is called we have
// successfully connected to a server
function connectedToServer(e) {
+ $('#top_bar').hide()
status("Connected to " + desktopName);
}
// This function is called when we are disconnected
@@ -109,6 +110,8 @@ class VNCDisplay extends Component {
// Set parameters that can be changed on an active connection
rfb.viewOnly = readQueryVariable('view_only', false);
rfb.scaleViewport = readQueryVariable('scale', false);
+ rfb.resizeSession = true
+ window.__rfb = rfb;
}
render() {
@@ -116,7 +119,7 @@ class VNCDisplay extends Component {
return (
-