fix all bugs and simplify code and add the feature that user can see the file logs on the web

This commit is contained in:
BOHUNG 2019-09-30 19:04:37 +08:00
parent 2695e0ff67
commit 5977c8224d
4 changed files with 298 additions and 243 deletions

View File

@ -20,18 +20,25 @@ class Admin::PatchfilesController < OrbitAdminController
end
end
def edit
params["filefield"]["file_show"].each_with_index do |(key,value),index|
@key = @file_to_show.file_show.keys[index]
@file_to_show.file_show[@key] = value.to_i
params["filefield"]["file_show"].each do |name,status|
@file_to_show.file_show[name][:status] = status.to_i
end
params["filefield"]["sub_file_fields"].each do |name,files|
files.each do |index,file_and_status|
file_and_status.each do |file_name,status|
@file_to_show["file_show"][name]["files"][file_name]["status"] = status.to_i
end
end
end
if params["filefield"]["recovery_btn"] == "true"
@file_to_show.recovery = "true"
@file_to_show.update
redirect_to admin_patchfiles_path and return
else
@file_to_show.update
redirect_to admin_patchfiles_path and return
@file_to_show.recovery = "false"
end
@file_to_show.num = 0
@file_to_show.update
@file_to_show = Filefield.where("title"=>@app_title).first
redirect_to admin_patchfiles_path and return
end
def showckeditor
end
@ -203,13 +210,22 @@ class Admin::PatchfilesController < OrbitAdminController
else
@default_field = Filefield.new()
@file_to_show = Filefield.where("title"=>@app_title).first
@default_field.file_show.each do |check,istrue|
if @file_to_show.file_show[check] == nil
@file_to_show.file_show[check] = istrue
@default_field.file_show.each do |name,property|
if @file_to_show.file_show[name] == nil
@file_to_show.file_show[name] = property
@file_to_show.save
@file_to_show = Filefield.where("title"=>@app_title).first
end
end
@default_field.file_show.each do |name,property|
property[:files].each do |file_name,sub_property|
if @file_to_show.file_show[name][:files][file_name] == nil
@file_to_show.file_show[name][:files][file_name] = sub_property
@file_to_show.save
@file_to_show = Filefield.where("title"=>@app_title).first
end
end
end
end
end
end

View File

@ -1,25 +1,15 @@
# encoding: utf-8
require 'fileutils'
class Filefield
include Mongoid::Document
include Mongoid::Timestamps
field :title, :type=> String ,default:"patchfile"
field :file_show, :type=> Hash ,default:{"ckeditor"=>0,"site-preference(two-site-logo)"=>0,"member"=>0,"accessibility"=>0}
field :recovery, :type=> String , default:"false"
after_update :updatefile
def enabled_for?(lang)
if lang.nil?
return true
else
return self.choose_lang.include?(lang)
end
end
def lastpath dir_path
@ckeditor_path = Rails.root.to_s + '/app/assets/javascripts/ckeditor/'
@model_path = Rails.root.to_s + '/app/models/'
@helper_path = Rails.root.to_s + '/app/helpers/'
@views_path = Rails.root.to_s + '/app/views/'
@controller_path = Rails.root.to_s + '/app/controllers/'
@app_path = File.expand_path(__dir__)
def self.prevpath(dir_path)
dir_path = dir_path.gsub('\\','/')
dir_arr= dir_path.split('/')
dir_str=''
@ -32,178 +22,154 @@ class Filefield
end
return dir_str
end
def updatefile
if self.recovery == "true"
self.file_show.each do |key,value|
if value == 1
@model_path = Rails.root.to_s + '/app/models/'
@helper_path = Rails.root.to_s + '/app/helpers/'
@views_path = Rails.root.to_s + '/app/views/'
@controller_path = Rails.root.to_s + '/app/controllers/'
if key == "ckeditor"
@ckeditor_path = Rails.root.to_s + '/app/assets/javascripts/ckeditor/'
puts 'recovery CKEDITOR'
begin
FileUtils.cd(@ckeditor_path)
FileUtils.cp('config.js.erb_back' , 'config.js.erb')
rescue
puts Dir.pwd
puts 'error recovery'
end
elsif key == "site-preference(two-site-logo)"
puts 'recovery site'
begin
FileUtils.cd(@model_path)
FileUtils.cp('site.rb_back' , 'site.rb')
FileUtils.cd(@helper_path)
FileUtils.cp('application_helper.rb_back' , 'application_helper.rb')
FileUtils.cd(@views_path+'admin/sites/')
FileUtils.cp('preference.html.erb_back','preference.html.erb')
rescue
puts Dir.pwd
Dir.chdir(Rails.root.to_s)
puts 'error recovery'
end
elsif key == "member"
puts 'recovery member'
begin
FileUtils.cd(@model_path)
FileUtils.cp('member_profile.rb_back' , 'member_profile.rb')
FileUtils.cd(@controller_path+'admin/')
FileUtils.cp('members_controller.rb_back' , 'members_controller.rb')
FileUtils.cd(@views_path+'admin/members/')
FileUtils.cp('_user_basic_passwd.html.erb_back' , '_user_basic_passwd.html.erb')
rescue
puts Dir.pwd
Dir.chdir(Rails.root.to_s)
puts 'error recovery'
end
elsif key == "accessibility"
puts 'recovery accessibility'
begin
FileUtils.cd(@views_path+'layouts/')
FileUtils.cp('back_end.html.erb_back' , 'back_end.html.erb')
FileUtils.cd(@views_path+'page_parts/')
FileUtils.cp('_form.html.erb_back' , '_form.html.erb')
rescue
puts Dir.pwd
Dir.chdir(Rails.root.to_s)
puts 'error recovery'
end
end
Dir.chdir(Rails.root.to_s)
FileUtils.cd(Rails.root.to_s)
end
end
@app_path = self.prevpath(@app_path)
@app_path = self.prevpath(@app_path)
field :title, :type=> String ,default:"patchfile"
#field :file_show, :type=> Hash ,default:{"ckeditor"=>0,"site-preference(two-site-logo)"=>0,"member"=>0,"accessibility"=>0}
field :file_show, :type=> Hash ,default:{"ckeditor"=>{:files=>{'config@js@erb'=>{:status=>0, :sc=>@app_path+'/updatefiles/', :dest=> @ckeditor_path}},:status=>0} ,
"site-preference(two-site-logo)"=>{:files=>{'site@rb'=>{:status=>0, :sc=>@app_path+'/updatefiles/', :dest=>@model_path},
'application_helper@rb'=>{:status=>0, :sc=>@app_path+'/updatefiles/', :dest=>@helper_path},
'preference@html@erb'=>{:status=>0, :sc=>@app_path+'/updatefiles/admin/', :dest=>@views_path+'admin/sites/'}
},:status=>0} ,
"member"=>{:files=>{'member_profile@rb'=>{:status=>0, :sc=>@app_path+'/updatefiles/', :dest=>@model_path},
'members_controller@rb'=>{:status=>0, :sc=>@app_path+'/updatefiles/admin/', :dest=>@controller_path+'admin/'},
'_user_basic_passwd@html@erb'=>{:status=>0, :sc=>@app_path+'/updatefiles/admin/', :dest=>@views_path+'admin/members/'}
},:status=>0} ,
"accessibility"=>{:files=>{'back_end@html@erb'=>{:status=>0, :sc=>@app_path+'/updatefiles/accessibility/', :dest=>@views_path+'layouts/'},
'_form@html@erb'=>{:status=>0, :sc=>@app_path+'/updatefiles/accessibility/', :dest=>@views_path+'page_parts/'},
'jquery-ui-1@12@1/'=>{:status=>0, :sc=>@app_path+'/updatefiles/accessibility/', :dest=>Rails.root.to_s + '/app/assets/stylesheets/lib/jquery-ui-1.12.1/'}
},:status=>0}
}
field :recovery, :type=> String , default:"false"
field :last_message , :type=> String , default:""
field :num , default: 0
after_update :updatefile
def enabled_for?(lang)
if lang.nil?
return true
else
self.file_show.each do |key,value|
if value == 1
@model_path = Rails.root.to_s + '/app/models/'
@helper_path = Rails.root.to_s + '/app/helpers/'
@views_path = Rails.root.to_s + '/app/views/'
@controller_path = Rails.root.to_s + '/app/controllers/'
if key == "ckeditor"
@app_path = File.expand_path(__dir__)
@app_path = lastpath(@app_path)
@app_path = lastpath(@app_path)
@ckeditor_path = Rails.root.to_s + '/app/assets/javascripts/ckeditor/'
puts 'copying CKEDITOR'
begin
Dir.chdir(@ckeditor_path)
File.rename('config.js.erb','config.js.erb_back')
rescue
puts Dir.pwd
end
FileUtils.cd(@app_path+'/updatefiles/')
begin
FileUtils.cp('config.js.erb' , @ckeditor_path)
puts @ckeditor_path
rescue
puts Dir.pwd
puts 'error copy'
end
elsif key == "site-preference(two-site-logo)"
@app_path = File.expand_path(__dir__)
@app_path = lastpath(@app_path)
@app_path = lastpath(@app_path)
puts @app_path
puts 'copying site'
begin
Dir.chdir(@model_path)
File.rename('site.rb','site.rb_back')
Dir.chdir(@helper_path)
File.rename('application_helper.rb','application_helper.rb_back')
Dir.chdir(@views_path+'admin/sites/')
File.rename('preference.html.erb','preference.html.erb_back')
rescue
puts Dir.pwd
end
FileUtils.cd(@app_path+'/updatefiles/')
begin
FileUtils.cp('site.rb' , @model_path)
FileUtils.cp('application_helper.rb' , @helper_path)
FileUtils.cd('admin/')
FileUtils.cp('preference.html.erb',@views_path+'admin/sites/')
rescue
puts Dir.pwd
Dir.chdir(Rails.root.to_s)
puts 'error copy'
end
elsif key == "member"
@app_path = File.expand_path(__dir__)
@app_path = lastpath(@app_path)
@app_path = lastpath(@app_path)
begin
Dir.chdir(@model_path)
File.rename('member_profile.rb','member_profile.rb_back')
Dir.chdir(@controller_path+'admin/')
File.rename('members_controller.rb','members_controller.rb_back')
Dir.chdir(@views_path+'admin/members/')
File.rename('_user_basic_passwd.html.erb','_user_basic_passwd.html.erb_back')
rescue
puts Dir.pwd
end
FileUtils.cd(@app_path+'/updatefiles/')
puts 'copying member'
begin
FileUtils.cp('member_profile.rb' , @model_path)
FileUtils.cd('admin/')
FileUtils.cp('members_controller.rb' , @controller_path+'admin/')
FileUtils.cp('_user_basic_passwd.html.erb' , @views_path+'admin/members/')
rescue
puts Dir.pwd
Dir.chdir(Rails.root.to_s)
puts 'error copy'
end
elsif key == "accessibility"
@app_path = File.expand_path(__dir__)
@app_path = lastpath(@app_path)
@app_path = lastpath(@app_path)
begin
Dir.chdir(@views_path+'layouts/')
File.rename('back_end.html.erb','back_end.html.erb_back')
Dir.chdir(@views_path+'page_parts/')
File.rename('_form.html.erb','_form.html.erb_back')
rescue
puts Dir.pwd
end
FileUtils.cd(@app_path+'/updatefiles/accessibility/')
puts 'copying accessibility'
begin
FileUtils.cp('back_end.html.erb' , @views_path+'layouts/')
FileUtils.cp('_form.html.erb' , @views_path+'page_parts/')
FileUtils.cp_r('jquery-ui-1.12.1/' ,Rails.root.to_s + '/app/assets/stylesheets/lib/jquery-ui-1.12.1/')
rescue
puts Dir.pwd
Dir.chdir(Rails.root.to_s)
puts 'error copy'
end
end
Dir.chdir(Rails.root.to_s)
FileUtils.cd(Rails.root.to_s)
end
end
return self.choose_lang.include?(lang)
end
end
def backup_file(file_name,file_path)
FileUtils.cd(file_path)
if (file_name.include? "/") == false
FileUtils.cp(file_name , file_name+'_back')
else
@back_foler =file_path.dup #very important,don't just use '=',it will change original value when it change
@back_foler[-1] = "_back/"
FileUtils.cp_r(file_name , @back_foler)
end
end
def recover_file(file_name,file_path)
FileUtils.cd(file_path)
if (file_name.include? "/") == false
FileUtils.cp(file_name+'_back', file_name)
else
FileUtils.cd('..')
@back_foler = file_name.dup #very important,don't just use '=',it will change original value when it change
@back_foler[-1] = "_back/"
FileUtils.cp_r(@back_foler, file_name)
end
end
def copy_file(file_name,source_file_path,dest_file_path)
FileUtils.cd(source_file_path)
if (file_name.include? "/") == false
FileUtils.cp(file_name , dest_file_path)
else
FileUtils.cp_r(file_name , dest_file_path)
end
end
def updatefile
if self.num == 0
self.last_message = ""
if self.recovery == "true"
self.file_show.each do |name,property|
if property[:status].to_i == 1
puts 'recovering all files of '+ name
self.last_message += ('recovering all files of '+ name+'</br>')
else
@i = 0
property[:files].each do |file_name,sub_property|
if sub_property[:status].to_i == 1
@i = @i + 1
end
end
if(@i != 0)
puts 'recovering part of files:'+ name
self.last_message += ('recovering part of files:'+ name+'</br>')
end
end
property[:files].each do |file_name,sub_property|
file_name = file_name.gsub("@",".")
if sub_property[:status].to_i == 1
puts 'recovering '+file_name
self.last_message += ('recovering '+file_name+'</br>')
begin
recover_file(file_name,sub_property[:dest])
puts 'finish recovery'
self.last_message += '<span style="color:green;">finish recovery</span></br>'
rescue
puts Dir.pwd
puts 'error recovery'
self.last_message += ('<span style="color:red;">Dir: '+Dir.pwd+'</span></br>')
self.last_message += '<span style="color:red;">error recovery</span></br>'
end
end
end
end
else
self.file_show.each do |name,property|
if property[:status].to_i == 1
puts 'copying all files of '+ name
self.last_message += ('copying all files of '+name+'</br>')
else
@i = 0
property[:files].each do |file_name,sub_property|
if sub_property[:status].to_i == 1
@i = @i + 1
end
end
if(@i != 0)
puts 'copying part of files:'+ name
self.last_message += ('copying part of files: '+name+'</br>')
end
end
property[:files].each do |file_name,sub_property|
file_name = file_name.gsub("@",".")
if sub_property[:status].to_i == 1
puts 'backuping '+file_name
self.last_message += ('backuping '+file_name+'</br>')
begin
backup_file(file_name,sub_property[:dest])
puts 'finish backup</br>'
self.last_message += '<span style="color:green;">finish backup</span></br>'
rescue
puts Dir.pwd
puts 'error backup</br>'
self.last_message += ('<span style="color:red;">Dir: '+Dir.pwd+'</span></br>')
self.last_message += '<span style="color:red;">error backup</span></br>'
end
puts 'copying '+file_name
self.last_message += ('copying '+file_name+'</br>')
begin
copy_file(file_name,sub_property[:sc],sub_property[:dest])
puts 'finish copy'
self.last_message += '<span style="color:green;">finish copy</span></br>'
rescue
puts Dir.pwd
self.last_message += ('<span style="color:red;">Dir: '+Dir.pwd+'</span></br>')
puts 'error copy'
self.last_message += '<span style="color:red;">error copy</span></br>'
end
end
end
end
end
self.num = 1
self.save
end
Dir.chdir(Rails.root.to_s)
end
end

View File

@ -5,20 +5,41 @@
<%=form_for @file_to_show ,:url=>{:controller=>"patchfiles" ,:action=>"edit"} do |file|%>
<%= file.fields_for :file_show do |filefield|%>
<div id="fileform">
<% @file_to_show.file_show.each do |show| %>
<%if show[1] == 1%>
<%=filefield.check_box "file_show"+@i.to_s,{:checked=>true,:id=>"checkbox"+@i.to_s,:class=>"checkbox",:style=>"float:left;"}%>
<% @file_to_show.file_show.each do |name,property| %>
<span style="clear:both;">
<%if property[:status].to_i == 1%>
<%=filefield.check_box name,{:checked=>true,:id=>"checkbox"+@i.to_s,:class=>"checkbox",:style=>"float:left;"}%>
<%else%>
<%=filefield.check_box "file_show"+@i.to_s,{:checked=>false,:id=>"checkbox"+@i.to_s,:class=>"checkbox",:style=>"float:left;"}%>
<%=filefield.check_box name,{:checked=>false,:id=>"checkbox"+@i.to_s,:class=>"checkbox",:style=>"float:left;"}%>
<%end%>
<label for="<%="checkbox"+@i.to_s%>" class="checklabel" style="float:left;"><%=show[0]%></label>
<% @i = @i+1 %>
<label for="<%="checkbox"+@i.to_s%>" class="checklabel" style="float:left;"><%=name%></label>
<div style="clear:both;"></div>
<% @i = @i+1 %>
<% @j = 0 %>
<%= file.fields_for :sub_file_fields do |each_files|%>
<%= each_files.fields_for name do |each_file|%>
<% property[:files].each do |file_name,sub_property| %>
<%if sub_property[:status].to_i == 1%>
<%=each_file.check_box file_name,{:checked=>true,:id=>"checkbox"+@i.to_s,:class=>"sub_checkbox",:style=>"float:left;margin-left:1em;",:index=>@j}%>
<%else%>
<%=each_file.check_box file_name,{:checked=>false,:id=>"checkbox"+@i.to_s,:class=>"sub_checkbox",:style=>"float:left;margin-left:1em;",:index=>@j}%>
<%end%>
<% file_name = file_name.gsub("@",".") %>
<label for="<%="checkbox"+@i.to_s%>" class="sub_checklabel" style="float:left;"><%=file_name%></label>
<div style="clear:both;"></div>
<% @i = @i+1 %>
<% @j = @j+1 %>
<% end %>
<%end%>
<%end%>
</span>
<%end%>
</div>
<%end%>
<%=file.submit "#{t(:updatefont)}",{:id=>"updatebtn",:onclick=>"return updatefcn()"}%>
<%=file.text_field :recovery_btn, {:id=>"hidden-recovery",:type => "hidden",:value=>"false"} %>
<button id="seemessage" onclick="return seelogfcn()"><%=(I18n.locale.to_s =="zh_tw") ? "查看上次更新的logs" : "see logs of prev update "%></button>
<button id="recoverybtn" onclick="return recoveryfcn()"><%=(I18n.locale.to_s =="zh_tw") ? "復原到上次更新的檔案狀態" : "recovery to prev file status"%></button>
<%end%>
<li id ="ckeditorFont" class="show_li">
@ -49,48 +70,65 @@
$('.Toggleclass').off("click").on("click",function(){
$(this).parent().find(">ul").slideToggle();
});
$('.checkbox').off('click').on('click',function(){
for(var i = 0;i<$(this).parent().find('.sub_checkbox').length;i++){
if($(this).is(":checked") == false){
if($(this).parent().find('.sub_checkbox').eq(i).is(":checked") == true)
$(this).parent().find('.sub_checkbox').eq(i).click();
}else{
if($(this).parent().find('.sub_checkbox').eq(i).is(":checked") == false)
$(this).parent().find('.sub_checkbox').eq(i).click();
};
};
});
$('.sub_checkbox').off('click').on('click',function(){
var num = 0;
var index = 0;
for(var i = 0;i<$(this).parent().find('.sub_checkbox').length;i++){
if($(this).parent().find('.sub_checkbox').eq(i).is(":checked") == true){
num += 1;
};
};
if( num == $(this).parent().find('.sub_checkbox').length){
if( $(this).parent().find('.checkbox').is(":checked") == false)
$(this).parent().find('.checkbox').click();
}else{
if( $(this).parent().find('.checkbox').is(":checked") == true){
$(this).parent().find('.checkbox').click();
for(var i = 0;i<$(this).parent().find('.sub_checkbox').length;i++){
if($(this).parent().find('.sub_checkbox').eq(i).attr('id') != $(this).attr('id'))
$(this).parent().find('.sub_checkbox').eq(i).click();
}
};
}
});
$("#clickall").off("click").on("click",function(){
for(var i =0;i<$(".checkbox").length ; i++){
for(var i =0;i<$(".sub_checkbox").length ; i++){
if($(".checkbox").eq(i).is(":checked") == false)
$(".checklabel").eq(i).click();
$(".checkbox").eq(i).click();
}
});
$("#unclickall").off("click").on("click",function(){
for(var i =0;i<$(".checkbox").length ; i++){
for(var i =0;i<$(".sub_checkbox").length ; i++){
if($(".checkbox").eq(i).is(":checked") == true)
$(".checklabel").eq(i).click();
$(".checkbox").eq(i).click();
}
});
function updatefcn(){
var str="";
var num =1;
for(var i =0;i<$(".checkbox").length ; i++){
if($(".checkbox").eq(i).is(":checked") == true){
str += ("<i style='color:red;'>"+num+". "+$(".checklabel").eq(i).html()+"\n"+"</i>");
num += 1;
}
}
function seelogfcn(){
if($( "#dialog-confirm" ).length != 0)
$( "#dialog-confirm" ).remove();
if(I18n.locale == "zh_tw"){
$('body').after("<div id='dialog-confirm' title='你確定要更新嗎?'>"+
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span>"+
"按下確認鍵後,你將更新你所選的檔案。\n"+str+"</p>"
+"</div>");
$('body').after("<div id='dialog-confirm' title='上次更新的logs'></div>");
}else{
$('body').after("<div id='dialog-confirm' title='Are you sure to update'>"+
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span>"+
"After click confirm button,you will update the selected file.\n"+str+"</p>"
+"</div>");
}
var flag = 0;
$('body').after("<div id='dialog-confirm' title='logs of prev update'></div>");
};
$( "#dialog-confirm" ).append($.parseHTML("<%= @file_to_show.last_message.gsub("\"","\'").html_safe %>"));
$( "#dialog-confirm" ).dialog({
resizable: false,
resizable: true,
height:200,
modal: true,
buttons: {
<%=(I18n.locale == "zh_tw") ? "確認" : "confirm"%>: function(){
flag = 1;
$( this ).dialog( "close" );
},
<%=(I18n.locale == "zh_tw") ? "取消" : "Cancel"%>: function() {
@ -98,17 +136,52 @@
}
}
});
if( flag == 1)
return true;
else
return false;
};
function updatefcn(){
var str="";
var num =1;
for(var i =0;i<$(".sub_checkbox").length ; i++){
if($(".sub_checkbox").eq(i).is(":checked") == true){
str += ("</br><i style='color:red;'>"+num+". "+$(".sub_checklabel").eq(i).html()+"</i>");
num += 1;
}
}
if($( "#dialog-confirm" ).length != 0)
$( "#dialog-confirm" ).remove();
if(I18n.locale == "zh_tw"){
$('body').after("<div id='dialog-confirm' title='你確定要更新嗎?'>"+
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+
"按下確認鍵後,你將更新你所選的檔案。"+str+"</p>"
+"</div>");
}else{
$('body').after("<div id='dialog-confirm' title='Are you sure to update'>"+
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+
"After click confirm button,you will update the selected file."+str+"</p>"
+"</div>");
};
$( "#dialog-confirm" ).dialog({
resizable: true,
height:200,
modal: true,
buttons: {
<%=(I18n.locale == "zh_tw") ? "確認" : "confirm"%>: function(){
$( this ).dialog( "close" );
$('.edit_filefield').submit();
},
<%=(I18n.locale == "zh_tw") ? "取消" : "Cancel"%>: function() {
$( this ).dialog( "close" );
}
}
});
return false;
};
function recoveryfcn(){
var str="";
var num =1;
for(var i =0;i<$(".checkbox").length ; i++){
if($(".checkbox").eq(i).is(":checked") == true){
str += ("<i style='color:red;'>"+num+". "+$(".checklabel").eq(i).html()+"\n"+"</i>");
for(var i =0;i<$(".sub_checkbox").length ; i++){
if($(".sub_checkbox").eq(i).is(":checked") == true){
str += ("</br><i style='color:red;'>"+num+". "+$(".sub_checklabel").eq(i).html()+"</i>");
num += 1;
}
}
@ -116,24 +189,24 @@
$( "#dialog-confirm" ).remove();
if(I18n.locale == "zh_tw"){
$('body').after("<div id='dialog-confirm' title='你確定要還原嗎?'>"+
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span>"+
"按下確認鍵後,你將還原你所選的檔案。\n"+str+"</p>"
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+
"按下確認鍵後,你將還原你所選的檔案。"+str+"</p>"
+"</div>");
}else{
$('body').after("<div id='dialog-confirm' title='Are you sure to recover'>"+
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span>"+
"After click confirm button,you will recover the selected file.\n"+str+"</p>"
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+
"After click confirm button,you will recover the selected file."+str+"</p>"
+"</div>");
}
$( "#dialog-confirm" ).dialog({
resizable: false,
resizable: true,
height:200,
modal: true,
buttons: {
<%=(I18n.locale == "zh_tw") ? "確認" : "confirm"%>: function(){
$('#hidden-recovery').val("true");
$('#updatebtn').click();
$( this ).dialog( "close" );
$('.edit_filefield').submit();
},
<%=(I18n.locale == "zh_tw") ? "取消" : "Cancel"%>: function() {
$('#hidden-recovery').val("false");

View File

@ -1,6 +1,6 @@
在 目前專案/app/assets/stylesheets/lib中插入jquery-ui-12.1資料夾
在 目前專案/app/views/layouts/back_end.html.erb和
目前專案/app/views/page_parts_form.html.erb中插入以下內容
目前專案/app/views/page_parts/_form.html.erb中插入以下內容
<script src="/assets/lib/jquery-ui-1.12.1/jquery-ui.min.js"></script>
<script type="text/javascript">
/* 修正bootstap.js和jquery-ui.js間的衝突,使tab按鈕能正常運作 */