change tab to space and add the feature that repair the module_app multuple existed problem
This commit is contained in:
		
							parent
							
								
									eba222a9da
								
							
						
					
					
						commit
						4b56e7b5ee
					
				|  | @ -9,7 +9,37 @@ class Admin::PatchfilesController < OrbitAdminController | |||
|     super | ||||
|     @app_title = "patchfile" | ||||
|   end | ||||
| 
 | ||||
|   def repair_module | ||||
|     ModuleApp.all.map{|v| v}.group_by{|v| [v.key,v.title]}.select{|k,v| Array(v).length>1}.each do |k,vs| | ||||
|       array_vs = Array(vs) | ||||
|       cats = array_vs.collect{|v| v.categories}.flatten.uniq | ||||
|       tags = array_vs.collect{|v| v.tags}.flatten.uniq | ||||
|       auths = array_vs.collect{|v| v.authorizations}.flatten.uniq | ||||
|       array_vs.reverse.each_with_index do |v,i| | ||||
|         if i == 0 | ||||
|           tags = tags.collect do |tag| | ||||
|             tag.module_app_ids = [v.id] | ||||
|             tag.save | ||||
|             tag | ||||
|           end | ||||
|           cats = cats.collect do |cat| | ||||
|             cat.module_app_id = v.id | ||||
|             cat.save | ||||
|             cat | ||||
|           end | ||||
|           auths = auths.collect do |auth| | ||||
|             auth.module_app_id = v.id | ||||
|             auth.save | ||||
|             auth | ||||
|           end | ||||
|         else | ||||
|           v.tag_ids = [] | ||||
|           v.destroy | ||||
|         end | ||||
|       end | ||||
|     end | ||||
|     render :text => 'repair finish' | ||||
|   end | ||||
|   def index | ||||
|     #@tags = @module_app.tags | ||||
|     #@categories = @module_app.categories.enabled | ||||
|  |  | |||
|  | @ -55,6 +55,8 @@ | |||
| <link rel="stylesheet" href="/assets/lib/jquery-ui-1.12.1/jquery-ui.min.css"> | ||||
| <div style="clear:both;"></div> | ||||
| <% @i = 0 %> | ||||
| <button id="repair_module"><%= (I18n.locale.to_s == "zh_tw") ? "修復模組在admin/item重複出現問題" : "repair module multiple existed in admin/item page" %></button> | ||||
| <br> | ||||
| <button id="clickall"><%= (I18n.locale.to_s == "zh_tw") ? "全選" : "select all" %></button> | ||||
| <button id="unclickall"><%= (I18n.locale.to_s == "zh_tw") ? "取消全選" : "unselect all" %></button> | ||||
| <%=form_for @file_to_show ,:url=>{:controller=>"patchfiles" ,:action=>"edit"} do |file|%> | ||||
|  | @ -125,6 +127,12 @@ | |||
|   } | ||||
| </style> | ||||
| <script> | ||||
|   $("#repair_module").click(function(){ | ||||
|     alert("repairing") | ||||
|     $.get('/admin/patchfiles/repair_module',{},function(data){ | ||||
|       alert(data) | ||||
|     }) | ||||
|   }) | ||||
|   $('.Toggleclass').off("click").on("click",function(){ | ||||
|     $(this).parent().find(">ul").slideToggle(); | ||||
|   }); | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ Rails.application.routes.draw do | |||
|   scope "(:locale)", locale: Regexp.new(locales.join("|")) do | ||||
|    namespace :admin do  | ||||
|     get 'patchfiles' , to:  'patchfiles#index' | ||||
|     get 'patchfiles/repair_module' , to:  'patchfiles#repair_module' | ||||
|     get 'patchfiles/showckeditor' , to: 'patchfiles#showckeditor' | ||||
|     get 'patchfiles/editckeditor' , to: 'patchfiles#editckeditor' | ||||
|     get 'patchfiles/editfontfile' , to: 'patchfiles#editfontfile' | ||||
|  | @ -14,7 +15,6 @@ Rails.application.routes.draw do | |||
|     post 'patchfiles/edit' , to: 'patchfiles#edit' | ||||
|     get 'patchfiles/edit' , to: 'patchfiles#edit' | ||||
|     patch 'patchfiles/edit' , to: 'patchfiles#edit' | ||||
| 	   | ||||
|     resources :patchfiles | ||||
|    end | ||||
|    | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue