OSDN Git Service

fix filer index
authoryasushiito <yas@pen-chan.jp>
Sun, 24 Aug 2014 22:29:36 +0000 (07:29 +0900)
committeryasushiito <yas@pen-chan.jp>
Sun, 24 Aug 2014 22:29:36 +0000 (07:29 +0900)
45 files changed:
Gemfile
app/assets/javascripts/ap.js
app/assets/javascripts/controllers/artists.js.coffee
app/assets/javascripts/controllers/authors.js.coffee
app/assets/javascripts/controllers/balloons.js.coffee
app/assets/javascripts/controllers/comic_stories.js.coffee
app/assets/javascripts/controllers/comics.js.coffee
app/assets/javascripts/controllers/demanders.js.coffee
app/assets/javascripts/controllers/folders.js.coffee
app/assets/javascripts/controllers/ground_colors.js.coffee
app/assets/javascripts/controllers/ground_pictures.js.coffee
app/assets/javascripts/controllers/license_groups.js.coffee
app/assets/javascripts/controllers/licenses.js.coffee
app/assets/javascripts/controllers/original_picture_license_groups.js.coffee
app/assets/javascripts/controllers/original_picture_licenses.js.coffee
app/assets/javascripts/controllers/original_pictures.js.coffee
app/assets/javascripts/controllers/panel_pictures.js.coffee
app/assets/javascripts/controllers/panels.js.coffee
app/assets/javascripts/controllers/pictures.js.coffee
app/assets/javascripts/controllers/resource_pictures.js.coffee
app/assets/javascripts/controllers/scroll_panels.js.coffee
app/assets/javascripts/controllers/scrolls.js.coffee
app/assets/javascripts/controllers/sheet_panels.js.coffee
app/assets/javascripts/controllers/sheets.js.coffee
app/assets/javascripts/controllers/speech_balloon_templates.js.coffee
app/assets/javascripts/controllers/speech_balloons.js.coffee
app/assets/javascripts/controllers/speeches.js.coffee
app/assets/javascripts/controllers/stories.js.coffee
app/assets/javascripts/controllers/story_sheets.js.coffee
app/assets/javascripts/controllers/system_pictures.js.coffee
app/assets/javascripts/controllers/users.js.coffee
app/assets/javascripts/controllers/writing_formats.js.coffee
app/assets/javascripts/locmare/filer.js.coffee
app/assets/javascripts/locmare/filer/body/file_body.js.coffee
app/assets/javascripts/locmare/filer/body/file_body/file_item/symbol/default.js.coffee
app/assets/javascripts/locmare/filer/pager.js.coffee
app/assets/javascripts/manifest/controller.js.coffee
app/assets/javascripts/manifest/manifest.js.coffee
app/assets/javascripts/manifest/model/association/has_many.js.coffee
app/assets/javascripts/models/artist.js.coffee
app/assets/javascripts/pettanr.js.coffee
app/assets/javascripts/routes.js.coffee
app/assets/javascripts/views/filer.js.coffee [moved from app/assets/javascripts/views/filer_view.js.coffee with 63% similarity]
app/assets/javascripts/work/controllers.js.coffee.erb
public/manifest.json

diff --git a/Gemfile b/Gemfile
index 8f22731..eab107b 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -6,6 +6,7 @@ gem 'rest-client'
 gem 'underscore-rails'
 gem 'backbone-rails'
 gem 'backbone-relational-rails'
+gem 'backbone-paginator-rails'
 gem 'kaminari'
 gem 'sanitize'
 gem 'aws-s3'
index b33ed3b..905c87c 100644 (file)
@@ -14,6 +14,7 @@
 //= require underscore
 //= require backbone
 //= require backbone-relational
+//= require backbone.paginator
 //= require i18n
 //= require ./manifest_base/manifest_base
 //= require ./manifest_base/base
 //= require ./locmare/filer/body/file_body/file_item/edit/none
 //= require ./locmare/filer/body/file_body/file_item/edit/account
 //= require ./locmare/filer/body/file_body/file_item/edit/template
-//  require ./locmare/filer/pager
+//= require ./locmare/filer/pager
 //= require ./peta/peta
 //= require ./peta/item
 //= require ./peta/owner
index 87164c6..37b7bc1 100644 (file)
@@ -1,22 +1,19 @@
 class Pettanr.ArtistsController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.Artist.Collection({})\r
-    new Pettanr.FilerRender('artist', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
-  show_html_format: (format) -> \r
+  show: (params) ->\r
   \r
-  show: () ->\r
+  count: (params) ->\r
   \r
-  count: () ->\r
+  new: (params) ->\r
   \r
-  new: () ->\r
+  edit: (params) ->\r
   \r
-  edit: () ->\r
+  create: (params) ->\r
   \r
-  create: () ->\r
+  update: (params) ->\r
   \r
-  update: () ->\r
-  \r
-  destroy: () ->\r
+  destroy: (params) ->\r
     \r
index 9f49b53..7924ced 100644 (file)
@@ -1,7 +1,5 @@
 class Pettanr.AuthorsController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.Author.Collection({})\r
-    new Pettanr.FilerRender('author', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
-\r
index 62dfcda..475389d 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.BalloonsController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.Balloon.Collection({})\r
-    new Pettanr.FilerRender('balloon', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index 3dbf8b7..600f07a 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.ComicStoriesController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.ComicStory.Collection({})\r
-    new Pettanr.FilerRender('comic_story', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index c6c868b..1a26b9a 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.ComicsController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.Comic.Collection({})\r
-    new Pettanr.FilerRender('comic', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index bede2bc..fea808b 100644 (file)
@@ -1,6 +1,2 @@
 class Pettanr.DemandersController extends Pettanr.AppController\r
   \r
-  index: () ->\r
-    list_result = new Pettanr.Demander.Collection({})\r
-    new Pettanr.FilerRender('demander', list_result, 'default', window.operators)\r
-  \r
index be6e8a6..394af8a 100644 (file)
@@ -1,16 +1,15 @@
 class Pettanr.FoldersController extends Pettanr.AppController\r
   \r
-  index: (params) ->\r
-    list_result = new Pettanr.Folder.Collection({})\r
-    new Pettanr.FilerRender('folder', list_result, 'default', window.operators)\r
+  index: () ->\r
+    @filer_list()\r
   \r
-  root: (params) ->\r
+  root: () ->\r
   \r
   show_html_format: (format) -> \r
   \r
-  show: (params) ->\r
-    console.log(params)\r
-    id = params['id']\r
+  show: () ->\r
+    console.log(@params)\r
+    id = @params['id']\r
     item = new Pettanr.FolderWatch({id: id})\r
     _this = this\r
     item.fetch({}).done () ->\r
@@ -23,11 +22,18 @@ class Pettanr.FoldersController extends Pettanr.AppController
         window.router['c_i'](c, a, '') # 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
+        f = new Locmare.Filer({\r
+          item_name: 'folder', \r
+          items: [], \r
+          list_result: list_result, \r
+          pager_type: 'default', \r
+          operators: window.operators\r
+        })\r
+        $("#pettanr").html(f.render().el)\r
   \r
-  count: (params) ->\r
+  count: () ->\r
   \r
-  new: (params) ->\r
+  new: () ->\r
   \r
-  edit: (params) ->\r
+  edit: () ->\r
   \r
index 8191952..41b74af 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.GroundColorsController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.GroundColor.Collection({})\r
-    new Pettanr.FilerRender('ground_color', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index 08afdc7..2a0cd99 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.GroundPicturesController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.GroundPicture.Collection({})\r
-    new Pettanr.FilerRender('ground_picture', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index a1ab464..12e62c9 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.LicenseGroupsController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.LicenseGroup.Collection({})\r
-    new Pettanr.FilerRender('license_group', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index 2f3c828..cafc562 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.LicensesController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.License.Collection({})\r
-    new Pettanr.FilerRender('license', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index 0faa770..64f71e5 100644 (file)
@@ -1,7 +1,5 @@
 class Pettanr.OriginalPictureLicenseGroupsController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.OriginalPictureLicenseGroup.Collection({})\r
-    new Pettanr.FilerRender('original_picture_license_group', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
-\r
index 274815e..f2e4a2d 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.OriginalPictureLicensesController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.OriginalPictureLicense.Collection({})\r
-    new Pettanr.FilerRender('original_picture_license', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index 5a9c3f0..f5140c0 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.OriginalPicturesController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.OriginalPicture.Collection({})\r
-    new Pettanr.FilerRender('original_picture', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index bc12fb2..ed00229 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.PanelPicturesController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.PanelPicture.Collection({})\r
-    new Pettanr.FilerRender('panel_picture', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index 9615ad4..9bca9e5 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.PanelsController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.Panel.Collection({})\r
-    new Pettanr.FilerRender('panel', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index 0a84cd6..71c9860 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.PicturesController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.Picture.Collection({})\r
-    new Pettanr.FilerRender('picture', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index e31c084..92c6cf9 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.ResourcePicturesController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.ResourcePicture.Collection({})\r
-    new Pettanr.FilerRender('resource_picture', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index e311586..4d89e94 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.ScrollPanelsController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.ScrollPanel.Collection({})\r
-    new Pettanr.FilerRender('scroll_panel', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index f44e078..7ccf95f 100644 (file)
@@ -1,18 +1,13 @@
 class Pettanr.ScrollsController extends Pettanr.AppController\r
   \r
-  index: (params) ->\r
-    list_result = new Pettanr.Scroll.Collection({})\r
-    new Pettanr.FilerRender('scroll', list_result, 'default', window.operators)\r
+  index: () ->\r
+    @filer_list()\r
   \r
-  by_author: (params) ->\r
-    list_result = new Pettanr.Scroll.Collection({})\r
-    new Pettanr.FilerRender('scroll', list_result, 'default', window.operators)\r
+  by_author: () ->\r
+    @filer_list()\r
   \r
-  by_panel: (params) ->\r
-    list_result = new Pettanr.Scroll.Collection({})\r
-    new Pettanr.FilerRender('scroll', list_result, 'default', window.operators)\r
-  \r
-  show_html_format: (format) -> \r
+  by_panel: () ->\r
+    @filer_list()\r
   \r
   show: (params) ->\r
     console.log(params)\r
index 04e4358..d585992 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.SheetPanelsController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.SheetPanel.Collection({})\r
-    new Pettanr.FilerRender('sheet_panel', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index 1b5c159..6e2455a 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.SheetsController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.Sheet.Collection({})\r
-    new Pettanr.FilerRender('sheet', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index 98b33e9..c88c30e 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.SpeechBalloonTemplatesController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.SpeechBalloonTemplate.Collection({})\r
-    new Pettanr.FilerRender('speech_balloon_template', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index 5f46527..2f95c51 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.SpeechBalloonsController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.SpeechBalloon.Collection({})\r
-    new Pettanr.FilerRender('speech_balloon', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index e29adbf..3339618 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.SpeechesController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.Speech.Collection({})\r
-    new Pettanr.FilerRender('speech', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index 7e97d4b..726dcd9 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.StoriesController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.Story.Collection({})\r
-    new Pettanr.FilerRender('story', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index 3bb3f03..30dbdfb 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.StorySheetsController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.StorySheet.Collection({})\r
-    new Pettanr.FilerRender('story_sheet', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index 13bbf9e..6bf8c47 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.SystemPicturesController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.SystemPicture.Collection({})\r
-    new Pettanr.FilerRender('system_picture', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index 184ca09..c01f86c 100644 (file)
@@ -1,6 +1,2 @@
 class Pettanr.UsersController extends Pettanr.AppController\r
   \r
-  index: () ->\r
-    list_result = new Pettanr.User.Collection({})\r
-    new Pettanr.FilerRender('user', list_result, 'default', window.operators)\r
-  \r
index 41091b5..fba0d0c 100644 (file)
@@ -1,6 +1,5 @@
 class Pettanr.WritingFormatsController extends Pettanr.AppController\r
   \r
   index: () ->\r
-    list_result = new Pettanr.WritingFormat.Collection({})\r
-    new Pettanr.FilerRender('writing_format', list_result, 'default', window.operators)\r
+    @filer_list()\r
   \r
index 3a569be..fd39579 100644 (file)
@@ -10,18 +10,26 @@ class Locmare.Filer extends Backbone.View
     @template_dir = 'templates-filer-'\r
     @header = new Locmare.FilerModule.Header({'filer': this})\r
     @body = new Locmare.FilerModule.Body({'filer': this})\r
-    #@init_pager\r
+    @init_pager()\r
+    @render()\r
   \r
   render: () ->\r
+    this.$el.html('')\r
     this.$el.append(@header.render().el)\r
     this.$el.append(@body.render().el)\r
+    this.$el.append(@pager.render().el)\r
     this\r
   \r
   init_pager: () ->\r
-    @pager = self.class.pager[@pager_type].new self\r
+    c = Locmare.Filer.pager()[@pager_type]\r
+    @pager = new c({filer: this})\r
   \r
   @pager: () ->\r
-    {'none': NonePager, 'default': DefaultPager, 'more': MorePager}\r
+    {\r
+      'none': Locmare.FilerModule.NonePager, \r
+      'default': Locmare.FilerModule.DefaultPager, \r
+      'more': Locmare.FilerModule.MorePager\r
+    }\r
   \r
   model: () ->\r
     Manifest.item_name_to_model @item_name\r
index 07f2041..26bb9e3 100644 (file)
@@ -3,16 +3,20 @@ class Locmare.FilerModule.BodyModule.FileBody extends Backbone.View
   \r
   initialize: (options) ->\r
     @body = options.body\r
-    @collection = @filer().list_result\r
+    @collection = []\r
     _this = this\r
-    @collection.fetch().done ->\r
+    c = @filer().list_result\r
+    c.fetch().done ->\r
+      _this.filer().items = c.models\r
+      _this.collection = _.map c.models, (item) ->\r
+        c = _this.file_item_class()\r
+        new c({'file_body': _this, 'item': item})\r
       _this.render()\r
   \r
   render: () ->\r
     _this = this\r
-    _.each @collection.models, (item) ->\r
-      c = _this.file_item_class()\r
-      file_item = new c({'file_body': _this, 'item': item})\r
+    this.$el.html('')\r
+    _.each @collection, (file_item) ->\r
       _this.$el.append(file_item.render().el)\r
     this\r
   \r
index 109a0c0..8aad184 100644 (file)
@@ -9,7 +9,7 @@ class Locmare.FilerModule.BodyModule.FileBodyModule.FileItemModule.SymbolItemCol
     @link = m.LinkFactory.factory this, @my_manifest.link, @item\r
   \r
   render: () ->\r
-    this.$el.html(@face.render().el)\r
+    this.$el.html(@renderer().render().el)\r
     this\r
   \r
   show: () ->\r
index 70bd301..e0ed33d 100644 (file)
@@ -1,84 +1,25 @@
-class Locmare.FilerModule.Pager\r
+class Locmare.FilerModule.Pager extends Backbone.View\r
+  tagName: 'div'\r
   \r
-      def initialize filer\r
-        @filer = filer\r
-      end\r
-      \r
-      def list_result\r
-        @filer.list_result\r
-      end\r
-      \r
-      def api_path\r
-        list_result.path\r
-      end\r
-      \r
-      def template_dir\r
-        @filer.template_dir + "pager/"\r
-      end\r
-      \r
-      def template_name\r
-        self.template_dir + self.template_file_name\r
-      end\r
-      \r
-    end\r
-    \r
-    class NonePager < Pager\r
-      def template_file_name\r
-        "none"\r
-      end\r
-      \r
-    end\r
-    \r
-    class DefaultPager < Pager\r
-      def template_file_name\r
-        "default"\r
-      end\r
-      \r
-      def paginate\r
-        list_result.paginate\r
-      end\r
-      \r
-    end\r
-    \r
-    class MorePager < Pager\r
-      def template_file_name\r
-        "more"\r
-      end\r
-      \r
-    end\r
-   init_pager: () ->\r
-    @pager = self.class.pager[@pager_type].new self\r
+  initialize: (options) ->\r
+    @filer = options.filer\r
   \r
-  @pager: () ->\r
-    {'none' => NonePager, 'default' => DefaultPager, 'more' => MorePager}\r
+  total_result: () ->\r
+    _this = this\r
+    t = @filer.list_result.total\r
+    t.fetch().done ->\r
+      a = t.count\r
+      _this.render()\r
   \r
-  model: () ->\r
-    Manifest.item_name_to_model @item_name\r
+  list_result: () ->\r
+    @filer.list_result\r
   \r
-  # switch body class for dialog\r
-  mybody: () ->\r
-    Body\r
+  api_path: () ->\r
+    list_result().path\r
   \r
-  template_file_name: () ->\r
-    "filer"\r
+class Locmare.FilerModule.NonePager extends Locmare.FilerModule.Pager\r
   \r
-  template_name: () ->\r
-    @template_dir + @template_file_name\r
+class Locmare.FilerModule.DefaultPager extends Locmare.FilerModule.Pager\r
   \r
-  image_dir: () ->\r
-    '/images/'\r
+class Locmare.FilerModule.MorePager extends Locmare.FilerModule.Pager\r
   \r
-  constructor: (@item_name, @items, @list_result, @pager_type, @operators) ->\r
-    @manifest = LocalManifest.manifest().filers[@item_name]\r
-    @template_dir = 'templates/r/filer/'\r
-    @header = new Header(self)\r
-    @body = new @mybody(self)\r
-    @init_pager\r
-    \r
-class Locmare.FilerModule\r
-\r
-require_dependency "locmare/filer/header"\r
-require_dependency "locmare/filer/body"\r
-require_dependency "locmare/filer/pager"\r
-module\r
-     \r
index cd39c9d..3b5b84e 100644 (file)
@@ -4,7 +4,7 @@ class Manifest.Controller extends ManifestBase.Base
     super()\r
     @json\r
     @json.actions ||= {}\r
-    @json.item_name = Manifest.singularize(@name)\r
+    @json.item_name ||= @name\r
     \r
   init: () ->\r
     super()\r
index 6358138..d0826de 100644 (file)
@@ -14,9 +14,6 @@ class Manifest
   @item_name_to_model: (item_name) ->\r
     Pettanr[Pettanr.camelize(item_name)]\r
   \r
-  @singularize: (name) ->\r
-    name.replace(/es$/, '').replace(/s$/, '')\r
-  \r
   @pluralize: (name) ->\r
     name.pluralize\r
   \r
index 1920f35..a5a9f8b 100644 (file)
@@ -2,7 +2,7 @@ class Manifest.ModelModule.AssociationModule.HasMany extends ManifestBase.NameVa
   \r
   set_default: () ->\r
     super()\r
-    @values['model_name'] ||= Manifest.singularize @name\r
+    @values['model_name'] ||= Manifest.manifest().controllers[@name].item_name\r
     @values['foreign_key'] ||= @parent.model_name + '_id'\r
     \r
   init: () ->\r
index aea6ade..d95ebf3 100644 (file)
@@ -16,6 +16,3 @@ class Pettanr.Artist extends Peta.Owner
     if @id\r
       @url = @url + @id\r
   \r
-class Pettanr.Artist.Collection extends Backbone.Collection\r
-  model: Pettanr.Artist\r
-  url: '/artists'\r
index d16a41f..3c45a75 100644 (file)
@@ -104,7 +104,62 @@ class Pettanr
     @distance_of_time_in_words_to_now: (datetime) ->\r
       datetime\r
   \r
+  class Pettanr.CounterModel extends Backbone.Model\r
+    initialize: (attr, options) ->\r
+      @url = options['url']\r
+    \r
+  class Pettanr.FilerCollection extends Backbone.Collection\r
+    \r
+    initialize: (models, options) ->\r
+      params = options['params']\r
+      i = if params['id']\r
+        params['id'] + '/'\r
+      else\r
+        ''\r
+      a = if params['action'] != 'index'\r
+        params['action']\r
+      else\r
+        ''\r
+      \r
+      @page = params['page']\r
+      @page_size = params['page_size']\r
+      q = []\r
+      q.push('page=' + Pettanr.to_s(@page)) if @page\r
+      q.push('page_size=' + Pettanr.to_s(@page_size)) if @page_size\r
+      qry = if q.length > 0\r
+        '?' + q.join('&')\r
+      else\r
+        ''\r
+      @url = '/' + params['controller'] + i + a + qry\r
+      @total = new Pettanr.CounterModel({}, {url: '/' + params['controller'] + i + 'count_' + a})\r
+      @model = options['model']\r
+  \r
   class Pettanr.AppController\r
+    constructor: () ->\r
+      @params = {}\r
+      \r
+    set_model: () ->\r
+      @my_controller = Manifest.manifest().controllers[@params['controller']]\r
+      @my_action = @my_controller.actions[@params['action']]\r
+      @my_model = Manifest.manifest().models[@my_controller.item_name]\r
+      @my_model_class = @my_model.classify()\r
+      \r
+    set_list: () ->\r
+      @set_model()\r
+      @my_list_model = Manifest.manifest().models[@my_action.item_name]\r
+      @my_list_model_class = @my_list_model.classify()\r
+      @list = new Pettanr.FilerCollection({}, {model: @my_list_model_class, params: @params})\r
+    \r
+    filer_list: () ->\r
+      @set_list()\r
+      f = new Locmare.Filer({\r
+        el: "#pettanr",\r
+        item_name: @my_list_model_class.item_name(), \r
+        items: [], \r
+        list_result: @list, \r
+        pager_type: 'default', \r
+        operators: window.operators\r
+      })\r
   \r
   class Pettanr.FilerRender\r
     constructor: (item_name, list_result, pager_type, operators) ->\r
index cc85e2d..b0c9db1 100644 (file)
@@ -37,7 +37,8 @@ class Pettanr.Router extends Backbone.Router
   fire: (params) ->\r
     c = Pettanr[Pettanr.camelize(params['controller']) + 'Controller']\r
     controller = new c\r
-    controller[params['action']](params)\r
+    controller.params = params\r
+    controller[params['action']]()\r
   \r
   initialize: () ->\r
     this['c_i_a'] = (controller, id, action, query_string) ->\r
@@ -11,5 +11,15 @@ FilerView = Backbone.View.extend({
     ,eve: () ->\r
       confirm( 'hoo' )\r
   })\r
+class Pettanr.View\r
+class Pettanr.View.Filer\r
+\r
+class Pettanr.View.Filer.Symbol extends Pettanr.AppHelperImg\r
+  events: {\r
+    'click': 'on_click'\r
+  }\r
+  \r
+  on_click: () ->\r
+    alert 'fire'\r
 \r
 @FilerView = FilerView\r
index 0e35335..cbc03ff 100644 (file)
@@ -1,6 +1,7 @@
 #マニフェスト\r
 @controllers = {\r
   folders: {\r
+    item_name: 'folder',\r
     actions: {\r
       root: {\r
         type: 'show',\r
@@ -35,6 +36,7 @@
     },\r
   },\r
   scrolls: {\r
+    item_name: 'scroll',\r
     actions: {\r
       index: {\r
         type: 'list',\r
@@ -88,6 +90,7 @@
     },\r
   },\r
   scroll_panels: {\r
+    item_name: 'scroll_panel',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   comics: {\r
+    item_name: 'comic',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   comic_stories: {\r
+    item_name: 'comic_story',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   stories: {\r
+    item_name: 'story',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   story_sheets: {\r
+    item_name: 'story_sheet',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   sheets: {\r
+    item_name: 'sheet',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   sheet_panels: {\r
+    item_name: 'sheet_panel',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   panels: {\r
+    item_name: 'panel',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   panel_pictures: {\r
+    item_name: 'panel_picture',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   speech_balloons: {\r
+    item_name: 'speech_balloon',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   speeches: {\r
+    item_name: 'speech',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   balloons: {\r
+    item_name: 'balloon',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   ground_pictures: {\r
+    item_name: 'ground_picture',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   ground_colors: {\r
+    item_name: 'ground_color',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   original_pictures: {\r
+    item_name: 'original_picture',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   pictures: {\r
+    item_name: 'picture',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   resource_pictures: {\r
+    item_name: 'resource_picture',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   speech_balloon_templates: {\r
+    item_name: 'speech_balloon_template',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   writing_formats: {\r
+    item_name: 'writing_format',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   license_groups: {\r
+    item_name: 'license_group',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   licenses: {\r
+    item_name: 'license',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   authors: {\r
+    item_name: 'author',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   artists: {\r
+    item_name: 'artist',\r
     actions: {\r
       index: {\r
         type: 'list',\r
     },\r
   },\r
   system_pictures: {\r
+    item_name: 'system_picture',\r
     actions: {\r
       index: {\r
         type: 'list',\r
index 555e8dd..7626f7a 100644 (file)
   },\r
   "controllers": {\r
     "folders": {\r
+      "item_name": "folder",\r
       "actions": {\r
         "root": {\r
           "type": "show"\r
       }\r
     },\r
     "scrolls": {\r
+      "item_name": "scroll",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "scroll_panels": {\r
+      "item_name": "scroll_panel",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "comics": {\r
+      "item_name": "comic",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "comic_stories": {\r
+      "item_name": "comic_story",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "stories": {\r
+      "item_name": "story",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "story_sheets": {\r
+      "item_name": "story_sheet",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "sheets": {\r
+      "item_name": "sheet",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "sheet_panels": {\r
+      "item_name": "sheet_panel",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "panels": {\r
+      "item_name": "panel",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "panel_pictures": {\r
+      "item_name": "panel_picture",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "speech_balloons": {\r
+      "item_name": "speech_balloon",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "speeches": {\r
+      "item_name": "speech",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "balloons": {\r
+      "item_name": "balloon",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "ground_pictures": {\r
+      "item_name": "ground_picture",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "ground_colors": {\r
+      "item_name": "ground_color",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "original_pictures": {\r
+      "item_name": "original_picture",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "pictures": {\r
+      "item_name": "picture",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "resource_pictures": {\r
+      "item_name": "resource_picture",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "speech_balloon_templates": {\r
+      "item_name": "speech_balloon_template",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "writing_formats": {\r
+      "item_name": "writing_format",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "license_groups": {\r
+      "item_name": "license_group",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "licenses": {\r
+      "item_name": "license",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "authors": {\r
+      "item_name": "author",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "artists": {\r
+      "item_name": "artist",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r
       }\r
     },\r
     "system_pictures": {\r
+      "item_name": "system_picture",\r
       "actions": {\r
         "index": {\r
           "type": "list",\r