OSDN Git Service

manifest list mg
authoryasushiito <yas@pen-chan.jp>
Mon, 24 Feb 2014 01:46:19 +0000 (10:46 +0900)
committeryasushiito <yas@pen-chan.jp>
Mon, 24 Feb 2014 01:46:19 +0000 (10:46 +0900)
app/controllers/application_controller.rb
lib/manifest/list/base.rb
lib/manifest/list/filter.rb
lib/manifest/list/foreign_filter.rb
lib/manifest/list/through_filter.rb
public/manifest.json

index 90a5947..679c1a1 100644 (file)
@@ -144,6 +144,20 @@ class ApplicationController < ActionController::Base
     @item = @my_model_class.show(params[:id], @operators)
   end
   
+ def show_prof_format format
+    format.prof {
+      self.formats = [:html]
+      @profiler = Manifest::View::Profiler.new @my_model.model_name, @item, @operators
+      render @profiler.template_name, :locals => {
+        :profiler => @profiler
+      }
+    }
+  end
+  
+  def show_json_format format
+    format.json { render json: @item.to_json(@my_model_class.show_json_opt) }
+  end
+  
   def set_new
     set_model
     @item = @my_model_class.new
index be0a0a1..a771846 100644 (file)
@@ -59,13 +59,17 @@ module Manifest
         page_size
       end
       
-      def where_condition
+      def base_where_condition
         method_name = @where.conditions do |name|
           name
         end
         @model.__send__ method_name
       end
       
+      def where_condition
+        base_where_condition
+      end
+      
       def include_hash
         @includes.includes
       end
index da0eefa..b5a0d56 100644 (file)
@@ -13,7 +13,7 @@ module Manifest
       end
       
       def where_condition filter_item_id
-        w = super
+        w = self.base_where_condition
         w += ' and ' unless w.blank?
         [w + @table_name + '.' + @filter_key + ' = ?', filter_item_id] 
       end
index 3ad7b0f..899edb1 100644 (file)
@@ -1,6 +1,6 @@
 module Manifest
   module ListModule
-    class ForeignFilterList < FilterList
+    class ForeignFilterList <  FilterList
       
       def set_default
         super
@@ -8,12 +8,13 @@ module Manifest
       
       def init
         super
+        @filter_table_name = ::Manifest.manifest.models[@filter_item_name].classify.table_name
       end
       
-      def where_condition filter_item
-        w = super
+      def where_condition filter_item_id
+        w = super()
         w += ' and ' unless w.blank?
-        [w + @filter_item_name + '.id' + ' = ?', filter_item.id] 
+        [w + @filter_table_name + '.id' + ' = ?', filter_item_id] 
       end
       
       def self.add_action item_name, action_name, list_name, list_conf
index b2bf563..8e84937 100644 (file)
@@ -10,16 +10,17 @@ module Manifest
       def init
         super
         @through = @model_list_manifest.through
+        @filter_table_name = ::Manifest.manifest.models[@filter_item_name].classify.table_name
       end
       
-      def includes
+      def include_hash
         {@through => {@filter_item_name => {}} }
       end
       
-      def where filter_item_id
-        w = @model.list_where
+      def where_condition filter_item_id
+        w = self.base_where_condition
         w += ' and ' unless w.blank?
-        [w + @through + '.' + @filter_key + ' = ?', filter_item_id] 
+        [w + @filter_table_name + '.id' + ' = ?', filter_item_id] 
       end
       
     end
index cbfcedd..58a76fc 100644 (file)
           "type": "private"\r
         },\r
         "by_scroll": {\r
-          "type": "foreign_filter"\r
+          "type": "filter"\r
         },\r
         "by_panel": {\r
-          "type": "foreign_filter"\r
+          "type": "filter"\r
         }\r
       }\r
     },\r