OSDN Git Service

fix:js filer folder
authoryasushiito <yas@pen-chan.jp>
Mon, 18 Aug 2014 23:02:50 +0000 (08:02 +0900)
committeryasushiito <yas@pen-chan.jp>
Mon, 18 Aug 2014 23:02:50 +0000 (08:02 +0900)
app/assets/javascripts/ap.js
app/assets/javascripts/controllers/folders.js.coffee
app/assets/javascripts/models/folder.js.coffee
app/controllers/folders_controller.rb
spec/local_manifests/scroll_spec.rb

index c516859..b33ed3b 100644 (file)
@@ -4,7 +4,9 @@
 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
 // the compiled file.
 //
-//= require jquery.ui.all
+//= require jquery
+//= require jquery_ujs
+// require jquery.ui.all
 //require jquery.validate
 //require additional-methods
 //require jquery.validate.localization/messages_ja
index 272e946..58526ad 100644 (file)
@@ -14,7 +14,7 @@ class Pettanr.FoldersController extends Pettanr.AppController
     _this = this\r
     item.fetch({}).done () ->\r
       if item.is_remote()\r
-        window.router.navigate(item.remote_name(), true)\r
+        window.router[item.event_name()]() # call action event in router for redirect\r
       else\r
         list_result = new Pettanr.Folder.Children({id: item.id})\r
         new Pettanr.FilerRender('folder', list_result, 'default', window.operators)\r
index a1fe0f9..cf271bd 100644 (file)
@@ -24,15 +24,22 @@ class Pettanr.Folder extends Peta.Owner
   remote_name: () ->\r
     Pettanr.to_s(@get('controller_name')) + '/' + Pettanr.to_s(@get('action_name'))\r
   \r
+  event_name: () ->\r
+    a = if Pettanr.is_blank(@get('action_name'))\r
+      'index'\r
+    else\r
+      @get('action_name')\r
+    Pettanr.to_s(@get('controller_name')) + '_' + a\r
+  \r
   initialize: () ->\r
     if @id\r
       @url = @url + @id\r
   \r
 class Pettanr.FolderWatch extends Pettanr.Folder\r
-  url: 'watch/'\r
+  url: ''\r
   initialize: () ->\r
-    if @id\r
-      @url = @url + @id\r
+    super()\r
+    @url = @url + '?ref=1'\r
 class Pettanr.Folder.Collection extends Backbone.Collection\r
   model: Pettanr.Folder\r
   url: 'folders'\r
index 76d017b..b4b14cf 100644 (file)
@@ -14,8 +14,8 @@ class FoldersController < ApplicationController
     set_model
     @item = Folder.root
     respond_to do |format|
-      show_html_format format
-      show_json_format format
+      children_html_format format
+      children_json_format format
     end
   end
   
@@ -30,14 +30,14 @@ class FoldersController < ApplicationController
     filer_list
   end
   
-  def show_html_format format
+  def children_html_format format
     format.html {
       @filer = Locmare::Filer.new self.class.model.item_name, @item.children, nil, :none, @operators
       render :action => :show
     }
   end
   
-  def show_json_format format
+  def children_json_format format
     format.json {
       @items = @item.children
       render json: @items.to_json(self.class.model.list_json_opt)
@@ -46,14 +46,20 @@ class FoldersController < ApplicationController
   
   def show
     set_show
-    if @item.category_id == 10
-      redirect_to @item.remote_name
-    else
+    if params[:ref]
       respond_to do |format|
-        show_html_format format
-        show_prof_format format
         show_json_format format
       end
+    else
+      if @item.category_id == 10
+        redirect_to @item.remote_name
+      else
+        respond_to do |format|
+          children_html_format format
+          show_prof_format format
+          children_json_format format
+        end
+      end
     end
   end
   
index 0a2dcf1..7761eeb 100644 (file)
@@ -145,7 +145,8 @@ describe Scroll do
     describe 'columnsに於いて' do
       before do
         @columns = @my_local_manifest.columns
-        @names = ['id', 'title', 'description', 'visible', 'author_id', 'created_at', 'updated_at']
+        @names = ['id', 'title', 'description', 'visible', 'author_id', 
+        'created_at', 'updated_at']
       end
       it 'これらのカラムが定義されている' do
         set_columns? @columns, @names
@@ -203,7 +204,9 @@ describe Scroll do
         expect(@column_names.size).to eq 4 + 3
       end
       it '順序が守られている' do
-        expect(@column_names).to eq ['id', 'title', 'description', 'visible', 'author_id', 'created_at', 'updated_at']
+        expect(@column_names).to eq ['id', 
+        'title', 'description', 'visible', 'author_id', 
+        'created_at', 'updated_at']
       end
     end
     describe 'extend_settingsに於いて' do