diff --git a/custom_announcement/app/views/custom_announcements/custom_widget_data.html.erb b/custom_announcement/app/views/custom_announcements/custom_widget_data.html.erb index 3f13eaa..caf6e5c 100644 --- a/custom_announcement/app/views/custom_announcements/custom_widget_data.html.erb +++ b/custom_announcement/app/views/custom_announcements/custom_widget_data.html.erb @@ -1,39 +1,41 @@ <% active_module = @custom_data_field[:bind_module_app] rescue nil %> <% active_uid = @custom_data_field[:bind_uid] rescue nil %> -<% active_module = @custom_configs.first.module if active_module.nil? %> -
- -
- <%= 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"})%> -
-
-
- -
- <% @custom_configs.each do |c| %> - <% title_field = c.title_field - uid_field = c.uid_field - bind_model = c.bind_model.constantize rescue nil - %> - <% if bind_model %> -
" data-module="<%= c.module %>"> - <%= 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"})%> -
+<% active_module = @custom_configs.first.module rescue nil if active_module.nil? %> +<% if @custom_configs.length != 0 %> +
+ +
+ <%= 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"})%> +
+
+
+ +
+ <% @custom_configs.each do |c| %> + <% title_field = c.title_field + uid_field = c.uid_field + bind_model = c.bind_model.constantize rescue nil + %> + <% if bind_model %> +
" data-module="<%= c.module %>"> + <%= 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"})%> +
+ <% end %> <% end %> - <% end %> -
-
- \ No newline at end of file + $("#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){ + $(".bind_modules.hide").eq(-1).after($(".bind_modules.show")); + } + }) + +<% end %> \ No newline at end of file diff --git a/custom_gallery/app/views/custom_galleries/custom_widget_data.html.erb b/custom_gallery/app/views/custom_galleries/custom_widget_data.html.erb index 14047bd..d0f4c86 100644 --- a/custom_gallery/app/views/custom_galleries/custom_widget_data.html.erb +++ b/custom_gallery/app/views/custom_galleries/custom_widget_data.html.erb @@ -1,39 +1,41 @@ <% active_module = @custom_data_field[:bind_module_app] rescue nil %> <% active_uid = @custom_data_field[:bind_uid] rescue nil %> -<% active_module = @custom_configs.first.module if active_module.nil? %> -
- -
- <%= 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"})%> -
-
-
- -
- <% @custom_configs.each do |c| %> - <% title_field = c.title_field - uid_field = c.uid_field - bind_model = c.bind_model.constantize rescue nil - %> - <% if bind_model %> -
" data-module="<%= c.module %>"> - <%= 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"})%> -
+<% active_module = @custom_configs.first.module rescue nil if active_module.nil? %> +<% if @custom_configs.length != 0%> +
+ +
+ <%= 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"})%> +
+
+
+ +
+ <% @custom_configs.each do |c| %> + <% title_field = c.title_field + uid_field = c.uid_field + bind_model = c.bind_model.constantize rescue nil + %> + <% if bind_model %> +
" data-module="<%= c.module %>"> + <%= 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"})%> +
+ <% end %> <% end %> - <% end %> -
-
- \ No newline at end of file + $("#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){ + $(".bind_modules.hide").eq(-1).after($(".bind_modules.show")); + } + }) + +<% end %> \ No newline at end of file