OSDN Git Service

add: short cut
authoryasushiito <yas@pen-chan.jp>
Tue, 26 May 2015 09:35:47 +0000 (18:35 +0900)
committeryasushiito <yas@pen-chan.jp>
Tue, 26 May 2015 09:35:47 +0000 (18:35 +0900)
app/assets/javascripts/manifest/controller/action/base.js.coffee
app/assets/javascripts/views/users/account.js.coffee
app/controllers/folders_controller.rb

index 5179037..a1cdb5d 100644 (file)
@@ -36,6 +36,7 @@ class Manifest.ControllerModule.ActionModule.Base extends ManifestBase.TypeNameA
     q = []\r
     q.push('page=' + Pettanr.to_s(params['page'])) if params['page']\r
     q.push('page_size=' + Pettanr.to_s(params['page_size'])) if params['page_size']\r
+    q.push('path=' + params['path']) if params['path']\r
     if q.length > 0\r
       '?' + q.join('&')\r
     else\r
index e6a2d2e..991f90f 100644 (file)
@@ -19,6 +19,11 @@ class Pettanr.Views.User.Account extends Backbone.View
       @artist_view = @artist.icon_with_caption_view()\r
       @listenTo(@artist_view, 'click', @artist_click)\r
       this.$el.append(@artist_view.render().el)\r
+    if @author\r
+      @quick = new Pettanr.Views.User.Account.Quick()\r
+      @listenTo(@quick, 'click:mydoc', @click_mydoc)\r
+      @listenTo(@quick, 'click:mynew', @click_mynew)\r
+      this.$el.append(@quick.render().el)\r
     sign_out = new Tag.A({\r
       attr: {href: '/users/sign_out'}, \r
       class_name: 'sign_out', \r
@@ -41,3 +46,94 @@ class Pettanr.Views.User.Account extends Backbone.View
     @trigger('http_post', 'users/sign_out')\r
     return false\r
   \r
+  click_mydoc: (url) ->\r
+    @trigger('http_get', url)\r
+    return false\r
+  \r
+  click_mynew: (url) ->\r
+    @trigger('http_get', url)\r
+    return false\r
+  \r
+class Pettanr.Views.User.Account.Quick extends Backbone.View\r
+  tagName: 'span'\r
+  \r
+  initialize: (options) ->\r
+  \r
+  render: () ->\r
+    this.$el.html('')\r
+    @home()\r
+    @create()\r
+    this\r
+  \r
+  home: () ->\r
+    params = {\r
+      controller: 'folders',\r
+      action: 'index',\r
+      path: '/my documents/create/'\r
+    }\r
+    list = Locmare.ListGroup.list(\r
+      'folders', 'index', params\r
+    )\r
+    list.open(() =>\r
+      if !_.isEmpty(list.items())\r
+        @mydoc = list.items()[0]\r
+        @add_mydoc()\r
+    )\r
+  \r
+  create: () ->\r
+    params = {\r
+      controller: 'folders',\r
+      action: 'index',\r
+      path: '/my documents/'\r
+    }\r
+    list = Locmare.ListGroup.list(\r
+      'folders', 'index', params\r
+    )\r
+    list.open(() =>\r
+      if !_.isEmpty(list.items())\r
+        @mynew = list.items()[0]\r
+        @add_mynew()\r
+    )\r
+  \r
+  add_mydoc: () ->\r
+    mydoc_icon = new  Pettanr.Views.User.Account.LinkedMydocIcon({item: @mydoc, half: true})\r
+    @listenTo(mydoc_icon, 'click', @click_mydoc_icon)\r
+    this.$el.append(mydoc_icon.render().el)\r
+  \r
+  add_mynew: () ->\r
+    mynew_icon = new  Pettanr.Views.User.Account.LinkedCreateIcon({item: @mynew, half: true})\r
+    @listenTo(mynew_icon, 'click', @click_mynew_icon)\r
+    this.$el.append(mynew_icon.render().el)\r
+  \r
+  click_mydoc_icon: () ->\r
+    @trigger('click:mydoc', @mydoc.show_url())\r
+  \r
+  click_mynew_icon: () ->\r
+    @trigger('click:mynew', @mynew.show_url())\r
+  \r
+class Pettanr.Views.User.Account.LinkedMydocIcon extends Tag.A\r
+  \r
+  initialize: (options) ->\r
+    item = options.item\r
+    half = options.half\r
+    img = new Pettanr.Image.SymbolImg({\r
+      attr: {src: '/images/home.gif'}, half: half\r
+    })\r
+    super({\r
+      attr: {href: '/' + item.show_url()}, \r
+      content: img.render().el\r
+    })\r
+  \r
+class Pettanr.Views.User.Account.LinkedCreateIcon extends Tag.A\r
+  \r
+  initialize: (options) ->\r
+    item = options.item\r
+    half = options.half\r
+    img = new Pettanr.Image.SymbolImg({\r
+      attr: {src: '/images/inspire.gif'}, half: half\r
+    })\r
+    super({\r
+      attr: {href: '/' + item.show_url()}, \r
+      content: img.render().el\r
+    })\r
+  \r
index c27442a..f535d7a 100644 (file)
@@ -29,7 +29,20 @@ class FoldersController < ApplicationController
   end
   
   def index
-    filer_list
+    if params['path']  # secret api
+      list = Folder.where(['name = ?', params['path']])
+      respond_to do |format|
+        format.json {
+          res = {
+            :page_status => {:type => :unlimited},
+            :list => list
+          }
+          render json: res.to_json
+        }
+      end
+    else
+      filer_list
+    end
   end
   
   def children_html_format format