Merge branch 'master' into 'master'

Fix bug.



See merge request !16
This commit is contained in:
chiu 2021-07-02 17:34:47 +08:00
commit 0f7a77f3cc
2 changed files with 70 additions and 66 deletions

View File

@ -1,39 +1,41 @@
<% active_module = @custom_data_field[:bind_module_app] rescue nil %> <% active_module = @custom_data_field[:bind_module_app] rescue nil %>
<% active_uid = @custom_data_field[:bind_uid] rescue nil %> <% active_uid = @custom_data_field[:bind_uid] rescue nil %>
<% active_module = @custom_configs.first.module if active_module.nil? %> <% active_module = @custom_configs.first.module rescue nil if active_module.nil? %>
<div class="control-group input-content"> <% if @custom_configs.length != 0 %>
<label class="control-label muted" for="custom_bind_module_app"><%=t("custom_announcement.use_module")%> :</label> <div class="control-group input-content">
<div class="controls"> <label class="control-label muted" for="custom_bind_module_app"><%=t("custom_announcement.use_module")%> :</label>
<%= select_tag("#{@field_name}[custom_data_field][bind_module_app]", options_for_select(@custom_configs.map{|c| [t("module_name.#{c.module}"),c.module]},active_module),{:id=>"custom_bind_module_app"})%> <div class="controls">
</div> <%= select_tag("#{@field_name}[custom_data_field][bind_module_app]", options_for_select(@custom_configs.map{|c| [t("module_name.#{c.module}"),c.module]},active_module),{:id=>"custom_bind_module_app"})%>
</div> </div>
<div class="control-group input-content"> </div>
<label class="control-label muted" for="custom_bind_uid"><%=t("custom_announcement.use_content")%> :</label> <div class="control-group input-content">
<div class="controls"> <label class="control-label muted" for="custom_bind_uid"><%=t("custom_announcement.use_content")%> :</label>
<% @custom_configs.each do |c| %> <div class="controls">
<% title_field = c.title_field <% @custom_configs.each do |c| %>
uid_field = c.uid_field <% title_field = c.title_field
bind_model = c.bind_model.constantize rescue nil uid_field = c.uid_field
%> bind_model = c.bind_model.constantize rescue nil
<% if bind_model %> %>
<div class="<%=(c.module == active_module) ? "show bind_modules" : "hide bind_modules" %>" data-module="<%= c.module %>"> <% if bind_model %>
<%= select_tag("#{@field_name}[custom_data_field][bind_uid]", options_for_select(bind_model.where(title_field.to_sym.nin=>[nil,""]).map{|target_model| [target_model.send(title_field),target_model.send(uid_field)]},active_uid),{:id=>"custom_bind_uid"})%> <div class="<%=(c.module == active_module) ? "show bind_modules" : "hide bind_modules" %>" data-module="<%= c.module %>">
</div> <%= select_tag("#{@field_name}[custom_data_field][bind_uid]", options_for_select(bind_model.where(title_field.to_sym.nin=>[nil,""]).map{|target_model| [target_model.send(title_field),target_model.send(uid_field)]},active_uid),{:id=>"custom_bind_uid"})%>
</div>
<% end %>
<% end %> <% end %>
<% end %> </div>
</div> </div>
</div> <script type="text/javascript">
<script type="text/javascript">
if($(".bind_modules.hide").length != 0){
$(".bind_modules.hide").eq(-1).after($(".bind_modules.show"));
}
$("#custom_bind_module_app").change(function(){
var value = $(this).val();
console.log(value)
$(".bind_modules").removeClass("show").addClass("hide");
$("[data-module=\""+value+"\"]").removeClass("hide").addClass("show");
if($(".bind_modules.hide").length != 0){ if($(".bind_modules.hide").length != 0){
$(".bind_modules.hide").eq(-1).after($(".bind_modules.show")); $(".bind_modules.hide").eq(-1).after($(".bind_modules.show"));
} }
}) $("#custom_bind_module_app").change(function(){
</script> var value = $(this).val();
console.log(value)
$(".bind_modules").removeClass("show").addClass("hide");
$("[data-module=\""+value+"\"]").removeClass("hide").addClass("show");
if($(".bind_modules.hide").length != 0){
$(".bind_modules.hide").eq(-1).after($(".bind_modules.show"));
}
})
</script>
<% end %>

View File

@ -1,39 +1,41 @@
<% active_module = @custom_data_field[:bind_module_app] rescue nil %> <% active_module = @custom_data_field[:bind_module_app] rescue nil %>
<% active_uid = @custom_data_field[:bind_uid] rescue nil %> <% active_uid = @custom_data_field[:bind_uid] rescue nil %>
<% active_module = @custom_configs.first.module if active_module.nil? %> <% active_module = @custom_configs.first.module rescue nil if active_module.nil? %>
<div class="control-group input-content"> <% if @custom_configs.length != 0%>
<label class="control-label muted" for="custom_bind_module_app"><%=t("custom_gallery.use_module")%> :</label> <div class="control-group input-content">
<div class="controls"> <label class="control-label muted" for="custom_bind_module_app"><%=t("custom_gallery.use_module")%> :</label>
<%= select_tag("#{@field_name}[custom_data_field][bind_module_app]", options_for_select(@custom_configs.map{|c| [t("module_name.#{c.module}"),c.module]},active_module),{:id=>"custom_bind_module_app"})%> <div class="controls">
</div> <%= select_tag("#{@field_name}[custom_data_field][bind_module_app]", options_for_select(@custom_configs.map{|c| [t("module_name.#{c.module}"),c.module]},active_module),{:id=>"custom_bind_module_app"})%>
</div> </div>
<div class="control-group input-content"> </div>
<label class="control-label muted" for="custom_bind_uid"><%=t("custom_gallery.use_content")%> :</label> <div class="control-group input-content">
<div class="controls"> <label class="control-label muted" for="custom_bind_uid"><%=t("custom_gallery.use_content")%> :</label>
<% @custom_configs.each do |c| %> <div class="controls">
<% title_field = c.title_field <% @custom_configs.each do |c| %>
uid_field = c.uid_field <% title_field = c.title_field
bind_model = c.bind_model.constantize rescue nil uid_field = c.uid_field
%> bind_model = c.bind_model.constantize rescue nil
<% if bind_model %> %>
<div class="<%=(c.module == active_module) ? "show bind_modules" : "hide bind_modules" %>" data-module="<%= c.module %>"> <% if bind_model %>
<%= select_tag("#{@field_name}[custom_data_field][bind_uid]", options_for_select(bind_model.where(title_field.to_sym.nin=>[nil,""]).map{|target_model| [target_model.send(title_field),target_model.send(uid_field)]},active_uid),{:id=>"custom_bind_uid"})%> <div class="<%=(c.module == active_module) ? "show bind_modules" : "hide bind_modules" %>" data-module="<%= c.module %>">
</div> <%= select_tag("#{@field_name}[custom_data_field][bind_uid]", options_for_select(bind_model.where(title_field.to_sym.nin=>[nil,""]).map{|target_model| [target_model.send(title_field),target_model.send(uid_field)]},active_uid),{:id=>"custom_bind_uid"})%>
</div>
<% end %>
<% end %> <% end %>
<% end %> </div>
</div> </div>
</div> <script type="text/javascript">
<script type="text/javascript">
if($(".bind_modules.hide").length != 0){
$(".bind_modules.hide").eq(-1).after($(".bind_modules.show"));
}
$("#custom_bind_module_app").change(function(){
var value = $(this).val();
console.log(value)
$(".bind_modules").removeClass("show").addClass("hide");
$("[data-module=\""+value+"\"]").removeClass("hide").addClass("show");
if($(".bind_modules.hide").length != 0){ if($(".bind_modules.hide").length != 0){
$(".bind_modules.hide").eq(-1).after($(".bind_modules.show")); $(".bind_modules.hide").eq(-1).after($(".bind_modules.show"));
} }
}) $("#custom_bind_module_app").change(function(){
</script> var value = $(this).val();
console.log(value)
$(".bind_modules").removeClass("show").addClass("hide");
$("[data-module=\""+value+"\"]").removeClass("hide").addClass("show");
if($(".bind_modules.hide").length != 0){
$(".bind_modules.hide").eq(-1).after($(".bind_modules.show"));
}
})
</script>
<% end %>