From: yasushiito Date: Tue, 26 May 2015 09:35:47 +0000 (+0900) Subject: add: short cut X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=commitdiff_plain;h=e8fc34342d52acbe9ff8c44ed1766b06ed81ad1a add: short cut --- diff --git a/app/assets/javascripts/manifest/controller/action/base.js.coffee b/app/assets/javascripts/manifest/controller/action/base.js.coffee index 5179037e..a1cdb5d1 100644 --- a/app/assets/javascripts/manifest/controller/action/base.js.coffee +++ b/app/assets/javascripts/manifest/controller/action/base.js.coffee @@ -36,6 +36,7 @@ class Manifest.ControllerModule.ActionModule.Base extends ManifestBase.TypeNameA q = [] q.push('page=' + Pettanr.to_s(params['page'])) if params['page'] q.push('page_size=' + Pettanr.to_s(params['page_size'])) if params['page_size'] + q.push('path=' + params['path']) if params['path'] if q.length > 0 '?' + q.join('&') else diff --git a/app/assets/javascripts/views/users/account.js.coffee b/app/assets/javascripts/views/users/account.js.coffee index e6a2d2e0..991f90f1 100644 --- a/app/assets/javascripts/views/users/account.js.coffee +++ b/app/assets/javascripts/views/users/account.js.coffee @@ -19,6 +19,11 @@ class Pettanr.Views.User.Account extends Backbone.View @artist_view = @artist.icon_with_caption_view() @listenTo(@artist_view, 'click', @artist_click) this.$el.append(@artist_view.render().el) + if @author + @quick = new Pettanr.Views.User.Account.Quick() + @listenTo(@quick, 'click:mydoc', @click_mydoc) + @listenTo(@quick, 'click:mynew', @click_mynew) + this.$el.append(@quick.render().el) sign_out = new Tag.A({ attr: {href: '/users/sign_out'}, class_name: 'sign_out', @@ -41,3 +46,94 @@ class Pettanr.Views.User.Account extends Backbone.View @trigger('http_post', 'users/sign_out') return false + click_mydoc: (url) -> + @trigger('http_get', url) + return false + + click_mynew: (url) -> + @trigger('http_get', url) + return false + +class Pettanr.Views.User.Account.Quick extends Backbone.View + tagName: 'span' + + initialize: (options) -> + + render: () -> + this.$el.html('') + @home() + @create() + this + + home: () -> + params = { + controller: 'folders', + action: 'index', + path: '/my documents/create/' + } + list = Locmare.ListGroup.list( + 'folders', 'index', params + ) + list.open(() => + if !_.isEmpty(list.items()) + @mydoc = list.items()[0] + @add_mydoc() + ) + + create: () -> + params = { + controller: 'folders', + action: 'index', + path: '/my documents/' + } + list = Locmare.ListGroup.list( + 'folders', 'index', params + ) + list.open(() => + if !_.isEmpty(list.items()) + @mynew = list.items()[0] + @add_mynew() + ) + + add_mydoc: () -> + mydoc_icon = new Pettanr.Views.User.Account.LinkedMydocIcon({item: @mydoc, half: true}) + @listenTo(mydoc_icon, 'click', @click_mydoc_icon) + this.$el.append(mydoc_icon.render().el) + + add_mynew: () -> + mynew_icon = new Pettanr.Views.User.Account.LinkedCreateIcon({item: @mynew, half: true}) + @listenTo(mynew_icon, 'click', @click_mynew_icon) + this.$el.append(mynew_icon.render().el) + + click_mydoc_icon: () -> + @trigger('click:mydoc', @mydoc.show_url()) + + click_mynew_icon: () -> + @trigger('click:mynew', @mynew.show_url()) + +class Pettanr.Views.User.Account.LinkedMydocIcon extends Tag.A + + initialize: (options) -> + item = options.item + half = options.half + img = new Pettanr.Image.SymbolImg({ + attr: {src: '/images/home.gif'}, half: half + }) + super({ + attr: {href: '/' + item.show_url()}, + content: img.render().el + }) + +class Pettanr.Views.User.Account.LinkedCreateIcon extends Tag.A + + initialize: (options) -> + item = options.item + half = options.half + img = new Pettanr.Image.SymbolImg({ + attr: {src: '/images/inspire.gif'}, half: half + }) + super({ + attr: {href: '/' + item.show_url()}, + content: img.render().el + }) + diff --git a/app/controllers/folders_controller.rb b/app/controllers/folders_controller.rb index c27442ad..f535d7af 100644 --- a/app/controllers/folders_controller.rb +++ b/app/controllers/folders_controller.rb @@ -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