fix bug about recovery font and delete font and add edit all font

This commit is contained in:
chiu committed 2019-09-29 12:18:19 +08:00
1 parent 7eb02f0d1c
commit 44188cb614
5 files changed
+103 -54

No files matched your search

+38 -10
View File
@@ -76,22 +76,50 @@ class Admin::PatchfilesController < OrbitAdminController
def newfont
if params["patchfilefield"]["initial_btn"] == "true"
#render :html => @field.id and return
@field_to_copy = Patchfilefield.where("title"=>@app_title + "_back").first
@id = @field.id
@field = @field_to_copy
@field.id = @id
@field.title = @app_title
@field_to_copy = Patchfilefield.where("title"=>(@app_title + "_back")).take_while{true}.last
@field_to_copy.attributes.each do |copy_field,value|
if copy_field != "_id" || copy_field != "title"
@field[copy_field] = value
end
end
@field.update
@field = Patchfilefield.where("title"=>@app_title).first
@field.update
@field = Patchfilefield.where("title"=>@app_title).first
@font_arr = []
@field.font_array.each do |font,istrue|
@font_arr.push font
end
@font_arr.each do |font,istrue|
if (@field_to_copy.font_array.keys.include? font) == false
@field.font_array.delete(font)
@field.delete_font = font
@field.update
@field = Patchfilefield.where("title"=>@app_title).first
end
end
redirect_to admin_patchfiles_editckeditor_path and return
elsif params["patchfilefield"]["delete_btn"] == "true"
params["patchfilefield"]["font_array"] = {} if params["patchfilefield"]["font_array"].nil? == true
params["patchfilefield"]["font_array"].each do |font,istrue|
if istrue =="1"
@field.font_array.delete(font)
@field.delete_font = font
@field.update
@field = Patchfilefield.where("title"=>@app_title).first
end
end
redirect_to admin_patchfiles_editckeditor_path and return
else
params["patchfilefield"]["new_add_font"] = params["patchfilefield"]["new_add_font"].gsub('\"','').gsub("\'",'').gsub(";",'')
@field.new_add_font = params["patchfilefield"]["new_add_font"] rescue (redirect_to admin_patchfiles_showckeditor_path and return)
@key_arr = @field.font_array.keys
params["patchfilefield"]["font_array"].each_with_index do |(font,istrue),index|
params["patchfilefield"]["font_array"] = {} if params["patchfilefield"]["font_array"].nil? == true
params["patchfilefield"]["font_array"].each do |font,istrue|
if istrue =="0"
@field.font_array[@key_arr[index]][font] = false
@field.font_array[font] = false
elsif istrue =="1"
@field.font_array[@key_arr[index]][font] = true
@field.font_array[font] = true
end
end
@field.update
@@ -138,9 +166,9 @@ class Admin::PatchfilesController < OrbitAdminController
end
end
def create_first_field
if Patchfilefield.where("title"=>@app_title + "_back").take_while{true}.count == 0
if Patchfilefield.where("title"=>(@app_title + "_back")).take_while{true}.count == 0
@field = Patchfilefield.new()
@field.title=@app_title +"_back"
@field.title = @app_title +"_back"
@field.save
end
@field