fix bug about recovery font and delete font and add edit all font
This commit is contained in:
1 parent
7eb02f0d1c
commit
44188cb614
5 files changed
+103
-54
No files matched your search
+8
-13
@@ -168,22 +168,17 @@ class Fontfile
|
||||
def change_font_name
|
||||
if self.old_title !="" && self.old_title != self.title
|
||||
@field = Patchfilefield.where("title"=>"patchfile").first
|
||||
@index
|
||||
@font_old_name
|
||||
@field.font_array.each do |index,font_hash|
|
||||
font_hash.each do |font,istrue|
|
||||
if font == self.old_title
|
||||
@index = index
|
||||
@font_old_name = font
|
||||
break
|
||||
end
|
||||
@field.font_array.each do |font,istrue|
|
||||
if font == self.old_title
|
||||
@font_old_name = font
|
||||
break
|
||||
end
|
||||
break if @index != nil
|
||||
end
|
||||
if @font_old_name.nil? == false && @index.nil? == false
|
||||
@istrue = @field.font_array[@index.to_s][@font_old_name]
|
||||
@field.font_array[@index.to_s][self.title] = @istrue
|
||||
@field.font_array[@index.to_s].delete(@font_old_name)
|
||||
if @font_old_name.nil? == false
|
||||
@istrue = @field.font_array[@font_old_name]
|
||||
@field.font_array[self.title] = @istrue
|
||||
@field.font_array.delete(@font_old_name)
|
||||
@field.delete_font = @font_old_name
|
||||
@field.update
|
||||
@field = Patchfilefield.where("title"=>"patchfile").first
|
||||
|
||||
@@ -24,11 +24,9 @@ class Patchfilefield
|
||||
after_save :set_config
|
||||
#before_create :set_expire
|
||||
def delete_empty_font
|
||||
self.font_array.each do |index,font_hash|
|
||||
font_hash.each do |font,istrue|
|
||||
if font.strip == ""
|
||||
self.font_array.delete(index.to_s)
|
||||
end
|
||||
self.font_array.each do |font,istrue|
|
||||
if font.strip == ""
|
||||
self.font_array.delete(font)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -70,30 +68,28 @@ class Patchfilefield
|
||||
@font_array.each do |font|
|
||||
@i = 0
|
||||
if font != self.delete_font
|
||||
self.font_array.values.each do |each_font|
|
||||
if each_font.keys.first == font
|
||||
self.font_array.keys.each do |each_font|
|
||||
if each_font == font
|
||||
@i = 1
|
||||
end
|
||||
break if @i == 1
|
||||
end
|
||||
if @i == 0
|
||||
@count = (self.font_array.keys[-1].to_i + 1).to_s
|
||||
self.font_array = self.font_array.merge({@count =>{font => true}})
|
||||
self.font_array = self.font_array.merge({font => true})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.new_add_font.strip !=""
|
||||
@i = 0
|
||||
self.font_array.values.each do |each_font|
|
||||
if each_font.keys.first == self.new_add_font
|
||||
self.font_array.keys.each do |each_font|
|
||||
if each_font == self.new_add_font
|
||||
@i = 1
|
||||
end
|
||||
break if @i == 1
|
||||
end
|
||||
if @i == 0
|
||||
@count = (self.font_array.keys[-1].to_i + 1).to_s
|
||||
self.font_array = self.font_array.merge({@count =>{self.new_add_font.strip => true}})
|
||||
self.font_array = self.font_array.merge({self.new_add_font.strip => true})
|
||||
end
|
||||
self.new_add_font = ""
|
||||
end
|
||||
@@ -104,22 +100,18 @@ class Patchfilefield
|
||||
# end
|
||||
def set_un_used_font
|
||||
@un_use_font = []
|
||||
self.font_array.each do |index,font_hash|
|
||||
font_hash.each do |font,istrue|
|
||||
if istrue == false
|
||||
@un_use_font.push font.strip
|
||||
end
|
||||
self.font_array.each do |font,istrue|
|
||||
if istrue == false
|
||||
@un_use_font.push font.strip
|
||||
end
|
||||
end
|
||||
self.un_used_font = @un_use_font
|
||||
end
|
||||
def set_used_font
|
||||
@use_font = []
|
||||
self.font_array.each do |index,font_hash|
|
||||
font_hash.each do |font,istrue|
|
||||
if istrue == true
|
||||
@use_font.push font.strip
|
||||
end
|
||||
self.font_array.each do |font,istrue|
|
||||
if istrue == true
|
||||
@use_font.push font.strip
|
||||
end
|
||||
end
|
||||
@use_font.delete("")
|
||||
|
||||
Reference in new issue
Block a user