Merge branch 'master' into 'master'

fix auto multiple creating tag problem



See merge request !9
This commit is contained in:
wmcheng 2019-11-12 22:57:11 +08:00
commit 1ae7ff6d19
3 changed files with 50 additions and 17 deletions

View File

@ -5,23 +5,40 @@ class Admin::GalleriesController < OrbitAdminController
before_action :authenticate_user, :except => "imgs" before_action :authenticate_user, :except => "imgs"
before_action :log_user_action before_action :log_user_action
find_tag = Tag.all.select{|value| value.name==I18n.t('gallery.not_show_desc')} find_tag = Tag.all.select{|value| value.name==I18n.t('gallery.not_show_desc')}
if find_tag.length==0 if find_tag.length==0
module_app_id = ModuleApp.where(:key=>"gallery").first[:_id] module_app_id = ModuleApp.where(:key=>"gallery").first[:_id]
tags = ModuleApp.where(:key=>"gallery").first.tags tags = ModuleApp.where(:key=>"gallery").first.tags
tag0 = Tag.new(is_default: false,module_app_ids: [module_app_id]) tag0 = Tag.new(is_default: false,module_app_ids: [module_app_id])
tag1 = Tag.new(is_default: false,module_app_ids: [module_app_id]) tag1 = Tag.new(is_default: false,module_app_ids: [module_app_id])
nowlocale = I18n.locale nowlocale = I18n.locale
I18n.available_locales.each do |locale| I18n.available_locales.each do |locale|
I18n.locale = locale I18n.locale = locale
tag0.name = I18n.t('gallery.show_desc') tag0.name = I18n.t('gallery.show_desc')
tag1.name = I18n.t('gallery.not_show_desc') tag1.name = I18n.t('gallery.not_show_desc')
end
I18n.locale = nowlocale
tag0.save
tag1.save
tags << tag0
tags << tag1
end end
I18n.locale = nowlocale
tag0.save
tag1.save
tags << tag0
tags << tag1
elsif find_tag.length>1
show_tags = Tag.all.select{|value| value.name==I18n.t('gallery.show_desc')}
show_tags.each_with_index do |show_tag,index1|
if index1>0
if show_tag.taggings.count==0
show_tag.delete
end
end
end
find_tag.each_with_index do |not_show_tag,index1|
if index1>0
if not_show_tag.taggings.count==0
not_show_tag.delete
end
end
end
end
def save_crop def save_crop
begin begin
images = AlbumImage.all.select{|value| params[:id].include? value.id.to_s} images = AlbumImage.all.select{|value| params[:id].include? value.id.to_s}

View File

@ -16,6 +16,22 @@ class GalleriesController < ApplicationController
tag1.save tag1.save
tags << tag0 tags << tag0
tags << tag1 tags << tag1
elsif find_tag.length>1
show_tags = Tag.all.select{|value| value.name==I18n.t('gallery.show_desc')}
show_tags.each_with_index do |show_tag,index1|
if index1>0
if show_tag.taggings.count==0
show_tag.delete
end
end
end
find_tag.each_with_index do |not_show_tag,index1|
if index1>0
if not_show_tag.taggings.count==0
not_show_tag.delete
end
end
end
end end
def index def index

View File

@ -122,7 +122,7 @@
<div id="view-photo-tags" class="nano" style="display:none"> <div id="view-photo-tags" class="nano" style="display:none">
<div class="content"> <div class="content">
<form> <form>
<fieldset> <fieldset style="display: contents;">
<legend>Tags</legend> <legend>Tags</legend>
<ul class="tags-groups"> <ul class="tags-groups">
<% @tags.each do |tag| %> <% @tags.each do |tag| %>