From f766f310391565120b1436281b9736f95f91f507 Mon Sep 17 00:00:00 2001 From: yasushiito Date: Tue, 28 Jan 2014 11:50:58 +0900 Subject: [PATCH] fix Manifest lst --- .../javascripts/manifest/work/forms.js.coffee.erb | 2 +- .../javascripts/manifest/work/lists.js.coffee.erb | 771 +++----- .../javascripts/manifest/work/models.js.coffee.erb | 367 +--- app/assets/javascripts/panels.js.coffee | 2 +- app/controllers/application_controller.rb | 11 +- app/controllers/scrolls_controller.rb | 26 +- config/application.rb | 1 - config/environment.rb | 1 + config/environments/development.rb | 1 + config/routes.rb | 74 + lib/manifest.rb | 17 +- lib/manifest/controller.rb | 9 +- lib/manifest/controller/action.rb | 1 + lib/manifest/controller/action/base.rb | 37 + lib/manifest/controller/action/list.rb | 72 +- lib/manifest/controller/action/show.rb | 49 +- lib/manifest/filer.rb | 23 +- lib/manifest/form.rb | 2 +- lib/manifest/list.rb | 49 + lib/manifest/list/base.rb | 96 + lib/manifest/list/element_filter.rb | 29 + lib/manifest/list/filter.rb | 52 + lib/manifest/list/play.rb | 108 ++ lib/manifest/list/private.rb | 26 + lib/manifest/list/public.rb | 35 + lib/manifest/list/system_resource.rb | 23 + lib/manifest/list/through_filter.rb | 29 + lib/manifest/manifest.rb | 4 +- lib/manifest/model.rb | 16 +- lib/manifest/model/association.rb | 7 +- lib/manifest/model/list/base.rb | 120 +- lib/manifest/model/list/element_filter.rb | 48 +- lib/manifest/model/list/filter.rb | 92 +- lib/manifest/model/list/has_many.rb | 120 +- lib/manifest/model/list/has_many_through.rb | 94 +- lib/manifest/model/list/play.rb | 141 +- lib/manifest/model/list/private.rb | 58 +- lib/manifest/model/list/public.rb | 50 +- lib/manifest/model/list/system_resource.rb | 36 +- lib/manifest/model/list/through_filter.rb | 48 +- lib/manifest/profiler.rb | 11 +- lib/view/list/list.rb | 63 + public/manifest.json | 1903 +++++++------------- 43 files changed, 1982 insertions(+), 2742 deletions(-) create mode 100644 lib/manifest/controller/action/base.rb create mode 100644 lib/manifest/list.rb create mode 100644 lib/manifest/list/base.rb create mode 100644 lib/manifest/list/element_filter.rb create mode 100644 lib/manifest/list/filter.rb create mode 100644 lib/manifest/list/play.rb create mode 100644 lib/manifest/list/private.rb create mode 100644 lib/manifest/list/public.rb create mode 100644 lib/manifest/list/system_resource.rb create mode 100644 lib/manifest/list/through_filter.rb create mode 100644 lib/view/list/list.rb diff --git a/app/assets/javascripts/manifest/work/forms.js.coffee.erb b/app/assets/javascripts/manifest/work/forms.js.coffee.erb index 71d45e17..435ba737 100644 --- a/app/assets/javascripts/manifest/work/forms.js.coffee.erb +++ b/app/assets/javascripts/manifest/work/forms.js.coffee.erb @@ -91,7 +91,7 @@ args: { column: 'id', label: { - type: 'none ', + type: 'none', }, tag: { type: 'hidden', diff --git a/app/assets/javascripts/manifest/work/lists.js.coffee.erb b/app/assets/javascripts/manifest/work/lists.js.coffee.erb index 7bc0110a..e26c3d53 100644 --- a/app/assets/javascripts/manifest/work/lists.js.coffee.erb +++ b/app/assets/javascripts/manifest/work/lists.js.coffee.erb @@ -1,574 +1,345 @@ #マニフェスト @lists = { scroll: { - lists: { - public_list: { - type: 'public', - }, - private_list: { - type: 'private', - }, - scroll_panels: { - type: 'has_many', - association_name: 'scroll_panels', - }, - panels: { - type: 'has_many_through', - association_name: 'panels', - }, - by_author: { - type: 'filter', - from: 'author', - filter_key: 'author_id', - }, - by_panel: { - type: 'through_filter', - from: 'panel', - through: 'scroll_panels', - filter_key: 'panel_id', - }, - play: { - type: 'play', - model: 'scroll_panel', - filter_key: 'scroll_id', - }, + public_list: { + }, + private_list: { + }, + by_author: { + type: 'filter', + from: 'author', + filter_key: 'author_id', + }, + by_panel: { + type: 'through_filter', + from: 'panel', + through: 'scroll_panels', + filter_key: 'panel_id', + }, + play: { + type: 'play', + model: 'scroll_panel', + filter_key: 'scroll_id', }, }, scroll_panel: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - private_list: { - type: 'private', - }, - by_scroll: { - type: 'filter', - from: 'scroll', - filter_key: 'scroll_id', - }, - by_panel: { - type: 'filter', - from: 'panel', - filter_key: 'panel_id', - }, + public_list: { + }, + private_list: { + }, + by_scroll: { + type: 'filter', + from: 'scroll', + filter_key: 'scroll_id', + }, + by_panel: { + type: 'filter', + from: 'panel', + filter_key: 'panel_id', }, }, comic: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - private_list: { - type: 'private', - }, - stories: { - type: 'has_many', - association_name: 'stories', - }, - by_author: { - type: 'filter', - from: 'author', - filter_key: 'author_id', - }, + public_list: { + }, + private_list: { + }, + by_author: { + type: 'filter', + from: 'author', + filter_key: 'author_id', }, }, story: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - private_list: { - type: 'private', - }, - story_sheets: { - type: 'has_many', - association_name: 'story_sheets', - }, - sheets: { - type: 'has_many', - association_name: 'sheets', - }, - by_comic: { - type: 'filter', - from: 'comic', - filter_key: 'comic_id', - }, - by_sheet: { - type: 'through_filter', - from: 'sheet', - through: 'story_sheets', - filter_key: 'sheet_id', - }, - by_author: { - type: 'element_filter', - from: 'author', - filter_key: 'author_id', - }, - play: { - type: 'play', - model: 'story_sheet', - filter_key: 'story_id', - }, + public_list: { + }, + private_list: { + }, + by_comic: { + type: 'filter', + from: 'comic', + filter_key: 'comic_id', + }, + by_sheet: { + type: 'through_filter', + from: 'sheet', + through: 'story_sheets', + filter_key: 'sheet_id', + }, + by_author: { + type: 'element_filter', + from: 'author', + filter_key: 'author_id', + }, + play: { + type: 'play', + model: 'story_sheet', + filter_key: 'story_id', }, }, story_sheet: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - private_list: { - type: 'private', - }, - by_story: { - type: 'filter', - from: 'story', - filter_key: 'story_id', - }, - by_sheet: { - type: 'filter', - from: 'sheet', - filter_key: 'sheet_id', - }, + public_list: { + type: 'public', + }, + private_list: { + type: 'private', + }, + by_story: { + type: 'filter', + from: 'story', + filter_key: 'story_id', + }, + by_sheet: { + type: 'filter', + from: 'sheet', + filter_key: 'sheet_id', }, }, sheet: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - private_list: { - type: 'private', - }, - story_sheets: { - type: 'has_many', - association_name: 'story_sheets', - }, - stories: { - type: 'has_many', - association_name: 'stories', - }, - sheet_panels: { - type: 'has_many', - association_name: 'sheet_panels', - }, - panels: { - type: 'has_many', - association_name: 'panels', - }, - by_story: { - type: 'through_filter', - from: 'story', - through: 'story_sheets', - filter_key: 'story_id', - }, - by_panel: { - type: 'through_filter', - from: 'panel', - through: 'sheet_panels', - filter_key: 'panel_id', - }, - by_author: { - type: 'filter', - from: 'author', - filter_key: 'author_id', - }, - play: { - type: 'play', - model: 'sheet_panel', - filter_key: 'sheet_id', - }, + public_list: { + }, + private_list: { + }, + by_story: { + type: 'through_filter', + from: 'story', + through: 'story_sheets', + filter_key: 'story_id', + }, + by_panel: { + type: 'through_filter', + from: 'panel', + through: 'sheet_panels', + filter_key: 'panel_id', + }, + by_author: { + type: 'filter', + from: 'author', + filter_key: 'author_id', + }, + play: { + type: 'play', + model: 'sheet_panel', + filter_key: 'sheet_id', }, }, sheet_panel: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - private_list: { - type: 'private', - }, - by_sheet: { - type: 'filter', - association_name: 'sheet_panels', - from: 'sheet', - filter_key: 'sheet_id', - }, - by_panel: { - type: 'filter', - from: 'panel', - filter_key: 'panel_id', - }, + public_list: { + }, + private_list: { + }, + by_sheet: { + type: 'filter', + association_name: 'sheet_panels', + from: 'sheet', + filter_key: 'sheet_id', + }, + by_panel: { + type: 'filter', + from: 'panel', + filter_key: 'panel_id', }, }, panel: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - private_list: { - type: 'private', - }, - scroll_panels: { - type: 'has_many', - association_name: 'scroll_panels', - }, - scrolls: { - type: 'has_many', - association_name: 'scrolls', - }, - sheet_panels: { - type: 'has_many', - association_name: 'sheet_panels', - }, - sheets: { - type: 'has_many', - association_name: 'sheets', - }, - panel_pictures: { - type: 'has_many', - association_name: 'panel_pictures', - }, - speech_balloons: { - type: 'has_many', - association_name: 'speech_balloons', - }, - ground_pictures: { - type: 'has_many', - association_name: 'ground_pictures', - }, - ground_colors: { - type: 'has_many', - association_name: 'ground_colors', - }, - by_scroll: { - type: 'through_filter', - from: 'scroll', - through: 'scroll_panels', - filter_key: 'scroll_id', - }, - by_sheet: { - type: 'through_filter', - from: 'sheet', - through: 'sheet_panels', - filter_key: 'sheet_id', - }, - by_author: { - type: 'filter', - from: 'author', - filter_key: 'author_id', - }, - by_speech_balloon_template: { - type: 'through_filter', - from: 'speech_balloon_template', - through: 'speech_balloons', - filter_key: 'speech_balloon_template_id', - }, + public_list: { + }, + private_list: { + }, + by_scroll: { + type: 'through_filter', + from: 'scroll', + through: 'scroll_panels', + filter_key: 'scroll_id', + }, + by_sheet: { + type: 'through_filter', + from: 'sheet', + through: 'sheet_panels', + filter_key: 'sheet_id', + }, + by_author: { + type: 'filter', + from: 'author', + filter_key: 'author_id', + }, + by_speech_balloon_template: { + type: 'through_filter', + from: 'speech_balloon_template', + through: 'speech_balloons', + filter_key: 'speech_balloon_template_id', }, }, panel_picture: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - private_list: { - type: 'private', - }, - by_panel: { - type: 'filter', - from: 'panel', - filter_key: 'panel_id', - }, - by_author: { - type: 'element_filter', - from: 'author', - filter_key: 'author_id', - }, + public_list: { + }, + private_list: { + }, + by_panel: { + type: 'filter', + from: 'panel', + filter_key: 'panel_id', + }, + by_author: { + type: 'element_filter', + from: 'author', + filter_key: 'author_id', }, }, speech_balloon: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - private_list: { - type: 'private', - }, - by_panel: { - type: 'filter', - from: 'panel', - filter_key: 'panel_id', - }, - by_speech_balloon_template: { - type: 'filter', - from: 'speech_balloon_template', - filter_key: 'speech_balloon_template_id', - }, - by_author: { - type: 'element_filter', - from: 'author', - filter_key: 'author_id', - }, + public_list: { + }, + private_list: { + }, + by_panel: { + type: 'filter', + from: 'panel', + filter_key: 'panel_id', + }, + by_speech_balloon_template: { + type: 'filter', + from: 'speech_balloon_template', + filter_key: 'speech_balloon_template_id', + }, + by_author: { + type: 'element_filter', + from: 'author', + filter_key: 'author_id', }, }, speech: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - by_speech_balloon: { - type: 'filter', - from: 'speech_balloon', - includes: {speech_balloon: {panel: {}}}, - filter_key: 'speech_balloon_id', - }, - by_writing_format: { - type: 'filter', - from: 'writing_format', - filter_key: 'writing_format_id', - }, + public_list: { + }, + by_speech_balloon: { + type: 'filter', + from: 'speech_balloon', + includes: {speech_balloon: {panel: {}}}, + filter_key: 'speech_balloon_id', + }, + by_writing_format: { + type: 'filter', + from: 'writing_format', + filter_key: 'writing_format_id', }, }, balloon: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - by_speech_balloon: { - type: 'filter', - from: 'speech_balloon', - includes: {speech_balloon: {panel: {}}}, - filter_key: 'speech_balloon_id', - }, - #by_system_picture: { - # type: 'filter', - # from: 'system_picture', - # filter_key: 'system_picture_id', - #}, + public_list: { }, + by_speech_balloon: { + type: 'filter', + from: 'speech_balloon', + includes: {speech_balloon: {panel: {}}}, + filter_key: 'speech_balloon_id', + }, + #by_system_picture: { + # type: 'filter', + # from: 'system_picture', + # filter_key: 'system_picture_id', + #}, }, ground_picture: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - private_list: { - type: 'private', - }, - by_panel: { - type: 'filter', - from: 'panel', - filter_key: 'panel_id', - }, - by_author: { - type: 'element_filter', - from: 'author', - filter_key: 'author_id', - }, + public_list: { + }, + private_list: { + type: 'private', + }, + by_panel: { + type: 'filter', + from: 'panel', + filter_key: 'panel_id', + }, + by_author: { + type: 'element_filter', + from: 'author', + filter_key: 'author_id', }, }, ground_color: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - private_list: { - type: 'private', - }, - by_panel: { - type: 'filter', - from: 'panel', - filter_key: 'panel_id', - }, - by_author: { - type: 'element_filter', - from: 'author', - filter_key: 'author_id', - }, + public_list: { + }, + private_list: { + }, + by_panel: { + type: 'filter', + from: 'panel', + filter_key: 'panel_id', + }, + by_author: { + type: 'element_filter', + from: 'author', + filter_key: 'author_id', }, }, original_picture: { - default_page_size: 20, - lists: { - private_list: { - type: 'private', - }, + private_list: { }, }, picture: { }, resource_picture: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - private_list: { - type: 'private', - }, - by_license: { - type: 'filter', - from: 'license', - filter_key: 'license_id', - }, - by_artist: { - type: 'filter', - from: 'artist', - filter_key: 'artist_id', - }, + public_list: { + }, + private_list: { + }, + by_license: { + type: 'filter', + from: 'license', + filter_key: 'license_id', + }, + by_artist: { + type: 'filter', + from: 'artist', + filter_key: 'artist_id', }, }, speech_balloon_template: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - select_items: { - type: 'system_resource', - }, - speech_balloons: { - type: 'has_many', - association_name: 'speech_balloons', - }, - panels: { - type: 'has_many', - association_name: 'panels', - }, + public_list: { + }, + select_items: { + type: 'system_resource', }, }, writing_format: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - select_items: { - type: 'system_resource', - }, - speeches: { - type: 'has_many', - association_name: 'speeches', - }, - by_system_picture: { - type: 'filter', - from: 'system_picture', - filter_key: 'system_picture_id', - }, + public_list: { + }, + select_items: { + type: 'system_resource', + }, + by_system_picture: { + type: 'filter', + from: 'system_picture', + filter_key: 'system_picture_id', }, }, license_group: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - select_items: { - type: 'system_resource', - }, - licenses: { - type: 'has_many', - association_name: 'licenses', - }, + public_list: { + }, + select_items: { + type: 'system_resource', }, }, license: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - resource_pictures: { - type: 'has_many', - association_name: 'resource_pictures', - }, - by_license_group: { - type: 'filter', - from: 'license_group', - filter_key: 'license_group_id', - }, - by_system_picture: { - type: 'filter', - from: 'system_picture', - filter_key: 'system_picture_id', - }, + public_list: { + }, + by_license_group: { + type: 'filter', + from: 'license_group', + filter_key: 'license_group_id', + }, + by_system_picture: { + type: 'filter', + from: 'system_picture', + filter_key: 'system_picture_id', }, }, author: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - scrolls: { - type: 'has_many', - association_name: 'scrolls', - }, - comics: { - type: 'has_many', - association_name: 'comics', - }, - stories: { - type: 'has_many', - association_name: 'stories', - }, - sheets: { - type: 'has_many', - association_name: 'sheets', - }, - panels: { - type: 'has_many', - association_name: 'panels', - }, - panel_pictures: { - type: 'has_many', - association_name: 'panel_pictures', - }, - speech_balloons: { - type: 'has_many', - association_name: 'speech_balloons', - }, - ground_pictures: { - type: 'has_many', - association_name: 'ground_pictures', - }, - ground_colors: { - type: 'has_many', - association_name: 'ground_colors', - }, + public_list: { }, }, artist: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, - resource_pictures: { - type: 'has_many', - association_name: 'resource_pictures', - }, + public_list: { }, }, system_picture: { - default_page_size: 20, - lists: { - public_list: { - type: 'public', - }, + public_list: { }, }, } diff --git a/app/assets/javascripts/manifest/work/models.js.coffee.erb b/app/assets/javascripts/manifest/work/models.js.coffee.erb index deb3e563..1072ec4b 100644 --- a/app/assets/javascripts/manifest/work/models.js.coffee.erb +++ b/app/assets/javascripts/manifest/work/models.js.coffee.erb @@ -72,39 +72,14 @@ private_list: { type: 'private', }, - scroll_panels: { - type: 'has_many', - args: { - association_name: 'scroll_panels', - }, - }, - panels: { - type: 'has_many_through', - args: { - association_name: 'panels', - }, - }, by_author: { type: 'filter', - args: { - from: 'author', - filter_key: 'author_id', - }, }, by_panel: { type: 'through_filter', - args: { - from: 'panel', - through: 'scroll_panels', - filter_key: 'panel_id', - }, }, play: { type: 'play', - args: { - model_name: 'scroll_panel', - filter_key: 'scroll_id', - }, }, }, }, @@ -176,17 +151,9 @@ }, by_scroll: { type: 'filter', - args: { - from: 'scroll', - filter_key: 'scroll_id', - }, }, by_panel: { type: 'filter', - args: { - from: 'panel', - filter_key: 'panel_id', - }, }, }, }, @@ -259,18 +226,8 @@ private_list: { type: 'private', }, - stories: { - type: 'has_many', - args: { - association_name: 'stories', - }, - }, by_author: { type: 'filter', - args: { - from: 'author', - filter_key: 'author_id', - }, }, }, }, @@ -352,46 +309,17 @@ private_list: { type: 'private', }, - story_sheets: { - type: 'has_many', - args: { - association_name: 'story_sheets', - }, - }, - sheets: { - type: 'has_many', - args: { - association_name: 'sheets', - }, - }, by_comic: { type: 'filter', - args: { - from: 'comic', - filter_key: 'comic_id', - }, }, by_sheet: { type: 'through_filter', - args: { - from: 'sheet', - through: 'story_sheets', - filter_key: 'sheet_id', - }, }, by_author: { type: 'element_filter', - args: { - from: 'author', - filter_key: 'author_id', - }, }, play: { type: 'play', - args: { - model_name: 'story_sheet', - filter_key: 'story_id', - }, }, }, }, @@ -461,17 +389,9 @@ }, by_story: { type: 'filter', - args: { - from: 'story', - filter_key: 'story_id', - }, }, by_sheet: { type: 'filter', - args: { - from: 'sheet', - filter_key: 'sheet_id', - }, }, }, }, @@ -564,59 +484,17 @@ private_list: { type: 'private', }, - story_sheets: { - type: 'has_many', - args: { - association_name: 'story_sheets', - }, - }, - stories: { - type: 'has_many', - args: { - association_name: 'stories', - }, - }, - sheet_panels: { - type: 'has_many', - args: { - association_name: 'sheet_panels', - }, - }, - panels: { - type: 'has_many', - args: { - association_name: 'panels', - }, - }, by_story: { type: 'through_filter', - args: { - from: 'story', - through: 'story_sheets', - filter_key: 'story_id', - }, }, by_panel: { type: 'through_filter', - args: { - from: 'panel', - through: 'sheet_panels', - filter_key: 'panel_id', - }, }, by_author: { type: 'filter', - args: { - from: 'author', - filter_key: 'author_id', - }, }, play: { type: 'play', - args: { - model_name: 'sheet_panel', - filter_key: 'sheet_id', - }, }, }, }, @@ -707,18 +585,9 @@ }, by_sheet: { type: 'filter', - args: { - association_name: 'sheet_panels', - from: 'sheet', - filter_key: 'sheet_id', - }, }, by_panel: { type: 'filter', - args: { - from: 'panel', - filter_key: 'panel_id', - }, }, }, }, @@ -837,84 +706,17 @@ private_list: { type: 'private', }, - scroll_panels: { - type: 'has_many', - args: { - association_name: 'scroll_panels', - }, - }, - scrolls: { - type: 'has_many', - args: { - association_name: 'scrolls', - }, - }, - sheet_panels: { - type: 'has_many', - args: { - association_name: 'sheet_panels', - }, - }, - sheets: { - type: 'has_many', - args: { - association_name: 'sheets', - }, - }, - panel_pictures: { - type: 'has_many', - args: { - association_name: 'panel_pictures', - }, - }, - speech_balloons: { - type: 'has_many', - args: { - association_name: 'speech_balloons', - }, - }, - ground_pictures: { - type: 'has_many', - args: { - association_name: 'ground_pictures', - }, - }, - ground_colors: { - type: 'has_many', - args: { - association_name: 'ground_colors', - }, - }, by_scroll: { type: 'through_filter', - args: { - from: 'scroll', - through: 'scroll_panels', - filter_key: 'scroll_id', - }, }, by_sheet: { type: 'through_filter', - args: { - from: 'sheet', - through: 'sheet_panels', - filter_key: 'sheet_id', - }, }, by_author: { type: 'filter', - args: { - from: 'author', - filter_key: 'author_id', - }, }, by_speech_balloon_template: { type: 'through_filter', - args: { - from: 'speech_balloon_template', - through: 'speech_balloons', - filter_key: 'speech_balloon_template_id', - }, }, }, }, @@ -1022,17 +824,9 @@ }, by_panel: { type: 'filter', - args: { - from: 'panel', - filter_key: 'panel_id', - }, }, by_author: { type: 'element_filter', - args: { - from: 'author', - filter_key: 'author_id', - }, }, }, }, @@ -1128,24 +922,12 @@ }, by_panel: { type: 'filter', - args: { - from: 'panel', - filter_key: 'panel_id', - }, }, by_speech_balloon_template: { type: 'filter', - args: { - from: 'speech_balloon_template', - filter_key: 'speech_balloon_template_id', - }, }, by_author: { type: 'element_filter', - args: { - from: 'author', - filter_key: 'author_id', - }, }, }, }, @@ -1243,24 +1025,12 @@ }, by_panel: { type: 'filter', - args: { - from: 'panel', - filter_key: 'panel_id', - }, }, - by_speech_balloon_template: { + by_speech_balloon: { type: 'filter', - args: { - from: 'speech_balloon_template', - filter_key: 'speech_balloon_template_id', - }, }, by_author: { type: 'element_filter', - args: { - from: 'author', - filter_key: 'author_id', - }, }, }, }, @@ -1394,18 +1164,9 @@ }, by_speech_balloon: { type: 'filter', - args: { - from: 'speech_balloon', - includes: {speech_balloon: {panel: {}}}, - filter_key: 'speech_balloon_id', - }, }, by_writing_format: { type: 'filter', - args: { - from: 'writing_format', - filter_key: 'writing_format_id', - }, }, }, }, @@ -1505,17 +1266,9 @@ }, by_panel: { type: 'filter', - args: { - from: 'panel', - filter_key: 'panel_id', - }, }, by_author: { type: 'element_filter', - args: { - from: 'author', - filter_key: 'author_id', - }, }, }, }, @@ -1614,17 +1367,9 @@ }, by_panel: { type: 'filter', - args: { - from: 'panel', - filter_key: 'panel_id', - }, }, by_author: { type: 'element_filter', - args: { - from: 'author', - filter_key: 'author_id', - }, }, }, }, @@ -1971,17 +1716,9 @@ }, by_license: { type: 'filter', - args: { - from: 'license', - filter_key: 'license_id', - }, }, by_artist: { type: 'filter', - args: { - from: 'artist', - filter_key: 'artist_id', - }, }, }, }, @@ -2069,18 +1806,6 @@ select_items: { type: 'system_resource', }, - speech_balloons: { - type: 'has_many', - args: { - association_name: 'speech_balloons', - }, - }, - panels: { - type: 'has_many', - args: { - association_name: 'panels', - }, - }, }, }, writing_format: { @@ -2154,18 +1879,8 @@ select_items: { type: 'system_resource', }, - speeches: { - type: 'has_many', - args: { - association_name: 'speeches', - }, - }, by_system_picture: { type: 'filter', - args: { - from: 'system_picture', - filter_key: 'system_picture_id', - }, }, }, }, @@ -2230,12 +1945,6 @@ select_items: { type: 'system_resource', }, - licenses: { - type: 'has_many', - args: { - association_name: 'licenses', - }, - }, }, }, license: { @@ -2319,25 +2028,11 @@ public_list: { type: 'public', }, - resource_pictures: { - type: 'has_many', - args: { - association_name: 'resource_pictures', - }, - }, by_license_group: { type: 'filter', - args: { - from: 'license_group', - filter_key: 'license_group_id', - }, }, by_system_picture: { type: 'filter', - args: { - from: 'system_picture', - filter_key: 'system_picture_id', - }, }, }, }, @@ -2404,60 +2099,6 @@ public_list: { type: 'public', }, - scrolls: { - type: 'has_many', - args: { - association_name: 'scrolls', - }, - }, - comics: { - type: 'has_many', - args: { - association_name: 'comics', - }, - }, - stories: { - type: 'has_many', - args: { - association_name: 'stories', - }, - }, - sheets: { - type: 'has_many', - args: { - association_name: 'sheets', - }, - }, - panels: { - type: 'has_many', - args: { - association_name: 'panels', - }, - }, - panel_pictures: { - type: 'has_many', - args: { - association_name: 'panel_pictures', - }, - }, - speech_balloons: { - type: 'has_many', - args: { - association_name: 'speech_balloons', - }, - }, - ground_pictures: { - type: 'has_many', - args: { - association_name: 'ground_pictures', - }, - }, - ground_colors: { - type: 'has_many', - args: { - association_name: 'ground_colors', - }, - }, }, }, artist: { @@ -2507,12 +2148,6 @@ public_list: { type: 'public', }, - resource_pictures: { - type: 'has_many', - args: { - association_name: 'resource_pictures', - }, - }, }, }, system_picture: { diff --git a/app/assets/javascripts/panels.js.coffee b/app/assets/javascripts/panels.js.coffee index a0af1b55..d0834fa4 100644 --- a/app/assets/javascripts/panels.js.coffee +++ b/app/assets/javascripts/panels.js.coffee @@ -11,13 +11,13 @@ $ -> configurations = { controllers: window.controllers, models: window.models, - lists: window.lists, system_resources: window.system_resources, magic_numbers: window.magic_numbers, select_items: window.select_items, locals: { profilers: window.profilers, filers: window.filers, + lists: window.lists, elements: window.elements, forms: window.forms, } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9866d9c5..28f9beb7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -101,7 +101,7 @@ class ApplicationController < ActionController::Base end def self.controller - Manifest.manifest.controller_managers[self.model.item_name] + Manifest.manifest.controllers[self.model.item_name] end def self.profiler_manager @@ -109,9 +109,12 @@ class ApplicationController < ActionController::Base end def public_list - action_name = params[:action] - @action = self.class.controller.open(action_name, params, @operators) - @items = @action.items + c = Manifest.manifest.controllers[self.class.model.item_name] + a = c.actions[params[:action].to_s] + ml = Manifest.manifest.models[a.item_name].lists[a.list_name] + l = Manifest.manifest.lists[a.item_name][a.list_name] + r = l.open({:id => params}, @operators) + @items = r.items respond_to do |format| format.html { @filer = @action.filer diff --git a/app/controllers/scrolls_controller.rb b/app/controllers/scrolls_controller.rb index 3ee8fb23..6bffe7d9 100644 --- a/app/controllers/scrolls_controller.rb +++ b/app/controllers/scrolls_controller.rb @@ -3,7 +3,7 @@ class ScrollsController < ApplicationController before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else - before_filter :authenticate_reader, :only => [:top, :index, :show, :play, :scroll_panels, :panels, :by_author, :by_panel] + before_filter :authenticate_reader, :only => [:top, :index, :show, :play, :by_author, :by_panel] before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] end @@ -16,14 +16,6 @@ class ScrollsController < ApplicationController public_list end - def scroll_panels - has_many_list - end - - def panels - has_many_list - end - def by_author filter_list end @@ -75,6 +67,22 @@ class ScrollsController < ApplicationController end end + def scroll_panels_count + has_many_list + end + + def panels_count + has_many_list + end + + def count_by_author + filter_list + end + + def count_by_panel + filter_list + end + def new @scroll = Scroll.new @scroll.supply_default diff --git a/config/application.rb b/config/application.rb index 1d97308b..346cb0d3 100644 --- a/config/application.rb +++ b/config/application.rb @@ -16,7 +16,6 @@ if defined?(Bundler) # Bundler.require(:default, :assets, Rails.env) end require 'manifest' -Manifest::load JSON.parse(open(File.expand_path('../../public/manifest.json', __FILE__)).read) module Pettanr VERSION = '0.6.2' diff --git a/config/environment.rb b/config/environment.rb index d9a67b03..25c8b0ac 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -15,6 +15,7 @@ require 'owner' require 'content' require 'element' require 'element_part' +# require_dependency 'manifest' require_dependency 'editor/editor' # Initialize the rails application Pettanr::Application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 79542a14..ce877c66 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -2,6 +2,7 @@ Pettanr::Application.configure do ActiveSupport::Dependencies.autoload_paths << File::join( Rails.root, 'lib') ActiveSupport::Dependencies.explicitly_unloadable_constants << 'Editor' + ActiveSupport::Dependencies.explicitly_unloadable_constants << 'Manifest' # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on diff --git a/config/routes.rb b/config/routes.rb index 670f49e4..d1b42eb1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -27,6 +27,10 @@ Pettanr::Application.routes.draw do get :panels get :by_author get :by_panel + get :scroll_panels_count + get :panels_count + get :count_by_author + get :count_by_panel get :play get :edit put :update @@ -46,6 +50,8 @@ Pettanr::Application.routes.draw do member do get :by_panel get :by_scroll + get :count_by_panel + get :count_by_scroll get :edit put :update delete :destroy @@ -65,6 +71,9 @@ Pettanr::Application.routes.draw do get :stories get :by_author get :by_me + get :stories_count + get :count_by_author + get :count_by_me get :play get :edit put :update @@ -86,6 +95,11 @@ Pettanr::Application.routes.draw do get :by_comic get :by_sheet get :by_author + get :story_sheets_count + get :sheets_count + get :count_by_comic + get :count_by_sheet + get :count_by_author get :play get :edit put :update @@ -104,6 +118,8 @@ Pettanr::Application.routes.draw do member do get :by_story get :by_sheet + get :count_by_story + get :count_by_sheet get :edit put :update delete :destroy @@ -127,6 +143,13 @@ Pettanr::Application.routes.draw do get :by_story get :by_panel get :by_author + get :story_sheets_count + get :stories_count + get :sheet_panels_count + get :panels_count + get :count_by_story + get :count_by_panel + get :count_by_author get :play get :edit put :update @@ -145,6 +168,8 @@ Pettanr::Application.routes.draw do member do get :by_sheet get :by_panel + get :count_by_sheet + get :count_by_panel get :edit put :update delete :destroy @@ -172,6 +197,17 @@ Pettanr::Application.routes.draw do get :by_scroll get :by_sheet get :by_author + get :scroll_panels_count + get :scrolls_count + get :sheet_panels_count + get :sheets_count + get :panel_pictures_count + get :speech_balloons_count + get :ground_pictures_count + get :ground_colors_count + get :count_by_scroll + get :count_by_sheet + get :count_by_author get :catch get :edit put :update @@ -190,6 +226,8 @@ Pettanr::Application.routes.draw do member do get :by_panel get :by_author + get :count_by_panel + get :count_by_author get :edit put :update delete :destroy @@ -208,6 +246,8 @@ Pettanr::Application.routes.draw do get :by_panel get :by_author #get :by_speech_balloon_template + get :count_by_panel + get :count_by_author get :edit put :update delete :destroy @@ -221,6 +261,7 @@ Pettanr::Application.routes.draw do member do get :by_speech_balloon #get :by_system_picture + get :count_by_speech_balloon end end resources :speeches do @@ -231,6 +272,8 @@ Pettanr::Application.routes.draw do member do get :by_speech_balloon get :by_writing_format + get :count_by_speech_balloon + get :count_by_writing_format end end resources :ground_pictures do @@ -244,6 +287,8 @@ Pettanr::Application.routes.draw do member do get :by_panel get :by_author + get :count_by_panel + get :count_by_author get :edit put :update delete :destroy @@ -260,6 +305,8 @@ Pettanr::Application.routes.draw do member do get :by_panel get :by_author + get :count_by_panel + get :count_by_author get :edit put :update delete :destroy @@ -305,6 +352,9 @@ Pettanr::Application.routes.draw do get :by_license get :by_license_group get :by_artist + get :count_by_license + get :count_by_license_group + get :count_by_artist delete :destroy get :credit end @@ -318,6 +368,9 @@ Pettanr::Application.routes.draw do get :speech_balloons get :panels get :by_system_picture + get :speech_balloons_count + get :panels_count + get :count_by_system_picture delete :destroy end end @@ -329,6 +382,8 @@ Pettanr::Application.routes.draw do member do get :speeches get :by_system_picture + get :speeches_count + get :count_by_system_picture end end resources :license_groups do @@ -338,6 +393,7 @@ Pettanr::Application.routes.draw do end member do get :licenses + get :licenses_count delete :destroy end end @@ -351,6 +407,9 @@ Pettanr::Application.routes.draw do get :resource_pictures get :by_license_group get :by_system_picture + get :resource_pictures_count + get :count_by_license_group + get :count_by_system_picture end end resources :authors do @@ -376,6 +435,18 @@ Pettanr::Application.routes.draw do get :speech_balloons get :ground_pictures get :ground_colors + get :scrolls_count + get :scroll_panels_count + get :comics_count + get :stories_count + get :story_sheets_count + get :sheets_count + get :sheet_panels_count + get :panels_count + get :panel_pictures_count + get :speech_balloons_count + get :ground_pictures_count + get :ground_colors_count get :edit put :update delete :destroy @@ -393,6 +464,7 @@ Pettanr::Application.routes.draw do end member do get :resource_pictures + get :resource_pictures_count get :edit put :update delete :destroy @@ -407,6 +479,8 @@ Pettanr::Application.routes.draw do #get :balloons get :speech_balloon_templates get :licenses + get :speech_balloon_templates_count + get :licenses_count delete :destroy end end diff --git a/lib/manifest.rb b/lib/manifest.rb index 1121a971..a1975c55 100644 --- a/lib/manifest.rb +++ b/lib/manifest.rb @@ -1,10 +1,13 @@ module Manifest end - require_dependency "manifest/manifest" - require_dependency "manifest/controller" - require_dependency "manifest/model" - require_dependency "manifest/profiler" - require_dependency "manifest/filer" - require_dependency "manifest/form" - require_dependency "manifest/system_resources" +require_dependency "manifest/manifest" +require_dependency "manifest/controller" +require_dependency "manifest/model" +require_dependency "manifest/profiler" +require_dependency "manifest/filer" +require_dependency "manifest/form" +require_dependency "manifest/list" +require_dependency "manifest/system_resources" +Manifest::load JSON.parse(open(File.expand_path('../../public/manifest.json', __FILE__)).read) +Manifest.manifest.init diff --git a/lib/manifest/controller.rb b/lib/manifest/controller.rb index 63d8f66f..ba858e2b 100644 --- a/lib/manifest/controller.rb +++ b/lib/manifest/controller.rb @@ -3,12 +3,11 @@ module Manifest class Controller include ControllerModule def self.manager manifest, my_manifests - my_manifests.map {|controller_name, controller_manifest| - self.new(manifest, controller_name, controller_manifest) + controllers = {} + my_manifests.each {|controller_name, controller_manifest| + controllers[controller_name] = self.new(manifest, controller_name, controller_manifest) } - end - - class Recipe + controllers end attr :manifest, :controller_name, :controller_manifest, :item_name, :actions diff --git a/lib/manifest/controller/action.rb b/lib/manifest/controller/action.rb index 4261e3e2..bf89cd02 100644 --- a/lib/manifest/controller/action.rb +++ b/lib/manifest/controller/action.rb @@ -1,3 +1,4 @@ +require_dependency "manifest/controller/action/base" require_dependency "manifest/controller/action/list" require_dependency "manifest/controller/action/show" module Manifest diff --git a/lib/manifest/controller/action/base.rb b/lib/manifest/controller/action/base.rb new file mode 100644 index 00000000..64700b49 --- /dev/null +++ b/lib/manifest/controller/action/base.rb @@ -0,0 +1,37 @@ +module Manifest + module ControllerModule + module ActionModule + class Base + attr :controller, :action_name, :action_manifest, + :item_name + def initialize controller, action_name, action_manifest + @controller = controller + @action_name = action_name + @action_manifest = action_manifest + self.set_default + self.init + end + + def set_default + @action_manifest['args'] ||= {} + @action_manifest['args']['item_name'] ||= self.controller.item_name + end + + def init + @args = @action_manifest['args'] + @item_name = @args['item_name'] + end + + def controller_name + @controller.controller_name + end + + def controller_manifest + @controller.controller_manifest + end + + end + + end + end +end diff --git a/lib/manifest/controller/action/list.rb b/lib/manifest/controller/action/list.rb index 3cc2dce9..201240c0 100644 --- a/lib/manifest/controller/action/list.rb +++ b/lib/manifest/controller/action/list.rb @@ -1,63 +1,21 @@ module Manifest - module ActionModule - class ActionList - attr :controller, :action_name, :action_manifest, - :item_name, :list_name - def initialize controller, action_name, action_manifest - @controller = controller - @action_name = action_name - @action_manifest = action_manifest - self.set_default - self.init - end - - def set_default - @action_manifest['args'] ||= {} - @action_manifest['args']['item_name'] ||= self.controller.item_name - end - - def init - @args = @action_manifest['args'] - @item_name = @args['item_name'] - raise "undefined list_name for controllers > #{self.controller_name} > actions > #{@action_name} > args\n" unless @args['list_name'] - @list_name = @args['list_name'] - end - - def controller_name - @controller.controller_name - end - - def controller_manifest - @controller.controller_manifest - end - - def list params, operators - Manifest.list_managers[@item_name].open(@list_name) - end - - def ready params, operators - @items = self.list.items params, operators - end - - def exec - end - - def render - format.html { - @filer = self.list.filer - render :template => 'system/filer', :locals => { - :filer => @filer - } - } - end - - def cook params, operators - self.ready params, operators - self.exec - self.render + module ControllerModule + module ActionModule + class ActionList < Base + attr :list_name + + def set_default + super + end + + def init + super + raise "undefined list_name for controllers > #{self.controller_name} > actions > #{@action_name} > args\n" unless @args['list_name'] + @list_name = @args['list_name'] + end + end end - end end diff --git a/lib/manifest/controller/action/show.rb b/lib/manifest/controller/action/show.rb index ed5a27ec..43b745af 100644 --- a/lib/manifest/controller/action/show.rb +++ b/lib/manifest/controller/action/show.rb @@ -1,43 +1,18 @@ module Manifest - module ActionModule - class ActionShow - attr :controller, :action_name, :action_manifest, :item_name - def initialize controller, action_name, action_manifest - @controller = controller - @action_name = action_name - @action_manifest = action_manifest - self.set_default - self.init - end - - def set_default - @action_manifest['item_name'] ||= self.controller.item_name - @action_manifest['args'] ||= {} - end - - def init - @item_name = @action_manifest['item_name'] - end - - def ready params, operators - @item = @model.show(params[:id], operators) - end - - def exec - end - - def render - format.html { - } - end - - def cook params, operators - self.ready params, operators - self.exec - self.render + module ControllerModule + module ActionModule + class ActionShow < Base + + def set_default + super + end + + def init + super + end + end end - end end diff --git a/lib/manifest/filer.rb b/lib/manifest/filer.rb index 408a8567..2b5cbbf2 100644 --- a/lib/manifest/filer.rb +++ b/lib/manifest/filer.rb @@ -6,12 +6,13 @@ require_dependency "manifest/filer/date" require_dependency "manifest/filer/edit" module Manifest class Filer - include FilerModule def self.manager manifest, my_manifests - my_manifests.map {|item_name, filer_manifest| - self.new(manifest, item_name, filer_manifest) + filers = {} + my_manifests.each {|item_name, filer_manifest| + filers[item_name] = self.new(manifest, item_name, filer_manifest) } + filers end attr :filer_manifest, :item_name, :manifest, @@ -34,22 +35,18 @@ module Manifest end def init - @symbol = Symbol.new self, @filer_manifest['symbol'] - @caption = Caption.new self, @filer_manifest['caption'] - @summary = SummaryFactory.factory self, @filer_manifest['summary'] - @icon = IconFactory.factory self, @filer_manifest['icon'] - @date = DateFactory.factory self, @filer_manifest['date'] - @edit = EditFactory.factory self, @filer_manifest['edit'] + @symbol = FilerModule::Symbol.new self, @filer_manifest['symbol'] + @caption = FilerModule::Caption.new self, @filer_manifest['caption'] + @summary = FilerModule::SummaryFactory.factory self, @filer_manifest['summary'] + @icon = FilerModule::IconFactory.factory self, @filer_manifest['icon'] + @date = FilerModule::DateFactory.factory self, @filer_manifest['date'] + @edit = FilerModule::EditFactory.factory self, @filer_manifest['edit'] end def filer_name @item_name end - def open item_name, items, operators, paginate - FilerView.new item_name, items, operators, paginate, @symbol, @caption, @summary, @icon, @date, @edit, @manifest - end - end end diff --git a/lib/manifest/form.rb b/lib/manifest/form.rb index 0801d414..f3e24ad9 100644 --- a/lib/manifest/form.rb +++ b/lib/manifest/form.rb @@ -1,8 +1,8 @@ require_dependency "manifest/form/field" module Manifest class Form - include FormModule + def self.base_manager manifest, my_manifests form = {} base = my_manifests['base'] || {} diff --git a/lib/manifest/list.rb b/lib/manifest/list.rb new file mode 100644 index 00000000..557a4dde --- /dev/null +++ b/lib/manifest/list.rb @@ -0,0 +1,49 @@ +require_dependency "manifest/list/base" +require_dependency "manifest/list/public" +require_dependency "manifest/list/private" +require_dependency "manifest/list/system_resource" +require_dependency "manifest/list/filter" +require_dependency "manifest/list/through_filter" +require_dependency "manifest/list/element_filter" +require_dependency "manifest/list/play" +module Manifest + module ListModule + class ListFactory + @@types = { + 'public' => ListModule::PublicList, 'private' => PrivateList, 'system_resource' => SystemResourceList, + 'filter' => FilterList, + 'through_filter' => ThroughFilterList, 'element_filter' => ElementFilterList, + 'play' => PlayList + } + def self.factory manifest, item_name, my_manifests + lists = {} + my_manifests.each {|list_name, my_manifest| + model_manifest = manifest.models[item_name] + raise "undefined model for lists > #{item_name}\n" unless model_manifest + model_list_manifest = model_manifest.lists[list_name] + raise "undefined model_list for lists > #{item_name} > #{list_name}\n" unless model_list_manifest + type = model_list_manifest.type + raise "undefined type for lists > #{item_name} > #{list_name}\n" unless type + my_class = @@types[type] + raise "undefined class for lists > #{item_name} > #{list_name} > #{type}\n" unless my_class + my_class.new(manifest, item_name, list_name, my_manifest) + } + lists + end + + end + end + + class List + include ListModule + def self.manager manifest, my_manifests + lists = {} + my_manifests.each {|item_name, list_manifest| + lists[item_name] = ListModule::ListFactory.factory(manifest, item_name, list_manifest) + } + lists + end + end + +end + diff --git a/lib/manifest/list/base.rb b/lib/manifest/list/base.rb new file mode 100644 index 00000000..fe3738e8 --- /dev/null +++ b/lib/manifest/list/base.rb @@ -0,0 +1,96 @@ +module Manifest + module ListModule + class Base + class ListResult + attr :items, :paginate + def initialize items, paginate + @items = items + @paginate = paginate + end + + end + + attr :manifest, :item_name, :list_name, :list_manifest, + :default_page_size, :max_page_size + def initialize manifest, item_name, list_name, list_manifest + @manifest = manifest + @item_name = item_name + @list_name = list_name + @list_manifest = list_manifest + self.set_default + self.init + end + + def set_default + @model_manifest = @manifest.models[@item_name] + @model_list_manifest = @model_manifest.lists[@list_name] + @list_manifest['default_page_size'] ||= @model_list_manifest.default_page_size + @list_manifest['max_page_size'] ||= @model_list_manifest.max_page_size + end + + def init + @default_page_size = @list_manifest['default_page_size'] + @max_page_size = @list_manifest['max_page_size'] + + @model = ::Manifest.item_name_to_model @item_name + @table_name = @model.table_name + if @model.content? + @owner_model = @model.owner_model + @owner_table_name = @owner_model.table_name if @owner_model + end + end + + def page_number prm = nil + page = prm.to_i + page = 1 if page < 1 + page + end + + def page_size prm + page_size = prm.to_i + page_size = @max_page_size if page_size > @max_page_size + page_size = @default_page_size if page_size < 1 + page_size + end + + def where + @model.list_where + end + + def includes + if @owner_model + if @owner_model.owner_model + {@owner_model.item_name => {@owner_model.owner_model.item_name => {}}} + else + {@owner_model.item_name => {}} + end + else + {} + end + end + + def order + @model.list_order + end + + def items options, offset, page_size + @model.where(self.where(filter_item)).includes(self.includes).order(self.order).offset(offset).limit(page_size) + end + + def paginate items, offset, page_size + c = items ? items.count : 0 + Kaminari.paginate_array(Array.new(c, nil)).page(offset).per(page_size) + end + + def open operators, options + page = self.page_number(options[:page]) + page_size = self.page_size options[:page_size] + offset = (page -1) * page_size + items = self.items options, offset, page_size + paginate = self.paginate items, offset, page_size + ListResult.new items, paginate + end + + end + end +end diff --git a/lib/manifest/list/element_filter.rb b/lib/manifest/list/element_filter.rb new file mode 100644 index 00000000..b8462686 --- /dev/null +++ b/lib/manifest/list/element_filter.rb @@ -0,0 +1,29 @@ +module Manifest + module ListModule + class ElementFilterList < FilterList + + def set_default + super + end + + def init + super + end + + def includes + {@owner_model.item_name => {}} + end + + def where filter_item + w = @model.list_where + w += ' and ' unless w.blank? + [w + @owner_table_name + '.' + @filter_key + ' = ?', filter_item.id] + end + + def self.add_action item_name, action_name, list_name, list_conf + return + end + end + + end +end diff --git a/lib/manifest/list/filter.rb b/lib/manifest/list/filter.rb new file mode 100644 index 00000000..eb69f3ee --- /dev/null +++ b/lib/manifest/list/filter.rb @@ -0,0 +1,52 @@ +module Manifest + module ListModule + class FilterList < Base + + def set_default + super + end + + def init + super + return + end + + def where filter_item + w = @model.list_where + w += ' and ' unless w.blank? + [w + @table_name + '.' + @filter_key + ' = ?', filter_item.id] + end + + def includes + return @includes if @includes + w = @owner_model ? {@owner_model.item_name => {}} : {} + w.merge({@from => {} }) + end + + def items filter_item + @model.where(self.where(filter_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) + end + + def paginate filter_item + Kaminari.paginate_array(Array.new(@model.where(self.where(filter_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size) + end + + def self._add_action item_name, action_name, list_name, list_conf + return + model = item_name.classify.constantize + controller_name = model.plural + 'Controller' + controller = controller_name.constantize + list_list_conf = Pettanr::Application::manifest.list(item_name).lists[list_name] || {} + from = list_list_conf['from'] + filter_model = from.classify.constantize + filter_key = list_list_conf['filter_key'] + return if controller.method_defined?(action_name) + controller.define_method(action_name) do + filter_list filter_model, params + end + end + + end + + end +end diff --git a/lib/manifest/list/play.rb b/lib/manifest/list/play.rb new file mode 100644 index 00000000..338e2f2d --- /dev/null +++ b/lib/manifest/list/play.rb @@ -0,0 +1,108 @@ +module Manifest + module ListModule + class PlayList + attr :model, :list_name, :list_manifest + + def initialize manifest, item_name, list_name, list_manifest + @manifest = manifest + @item_name = item_name + @list_name = list_name + @list_manifest = list_manifest + self.set_default + self.init + end + + def set_default + return + @default_page_size = @conf['default_page_size'] || 25 + @max_page_size = @conf['max_page_size'] || 100 + @params_offset = params_offset + @params_count = params_count + @list_list_conf = @manifest.list(@item_name).lists[list_name] || {} + @model_name = @list_list_conf['model'] + @filter_key = @list_list_conf['filter_key'] + @model = @model_name.classify.constantize + @table_name = @model.table_name + if @model.content? + @owner_model = @model.owner_model + @owner_table_name = @owner_model.table_name if @owner_model + end + end + + def init + end + + def offset cnt, prm = nil + offset = prm.to_i + offset = cnt - 1 if offset >= cnt + offset = cnt - offset.abs if offset < 0 + offset = 0 if offset < 0 + offset + end + + def limit prm + prm ||= @default_page_size + count = prm.to_i + count = @max_page_size if count > @max_page_size + count = @default_page_size if count < 1 + count + end + + def count filter_item + @count ||= @model.count(:conditions => self.where(filter_item), :include => self.includes).to_i + end + + def where filter_item + w = @model.list_where + w += ' and ' unless w.blank? + [w + @table_name + '.' + @filter_key + ' = ?', filter_item.id] + end + + def includes + {@owner_model.item_name => {}} + end + + def order + @table_name + '.t' + end + + def items filter_item + c = @count || self.count(filter_item) + o = self.offset c, @offset + l = self.limit @count + @model.where(self.where(filter_item)).includes(self.includes).order(self.order).offset(o).limit(l) + end + + def prev_offset filter_item + c = @count || self.count(filter_item) + o = self.offset c, @offset + l = self.limit @count + if o > 0 + if o - l < 0 + 0 + else + o - l + end + else + nil + end + end + + def next_offset filter_item + c = @count || self.count(filter_item) + o = self.offset c, @offset + l = self.limit @count + if o + l > c + nil + else + o + l + end + end + + def self.add_action item_name, action_name, list_name, list_conf + return + end + end + + end +end diff --git a/lib/manifest/list/private.rb b/lib/manifest/list/private.rb new file mode 100644 index 00000000..cb373365 --- /dev/null +++ b/lib/manifest/list/private.rb @@ -0,0 +1,26 @@ +module Manifest + module ListModule + class PrivateList < Base + def where + case @model.owner_type + when :author + operator = @operators.author + when :artist + operator = @operators.artist + end + t = if @owner_model + if @owner_model.owner_model + @owner_model.owner_model.table_name + else + @owner_model.table_name + end + else + @table_name + end + [t + '.' + @model.owner_type.to_s + '_id = ?', operator.id] + end + + end + + end +end diff --git a/lib/manifest/list/public.rb b/lib/manifest/list/public.rb new file mode 100644 index 00000000..767299c0 --- /dev/null +++ b/lib/manifest/list/public.rb @@ -0,0 +1,35 @@ +module Manifest + module ListModule + class PublicList < Base + + def set_default + super + end + + def init + super + end + + def where + @model.list_where + end + + def includes + if @owner_model + if @owner_model.owner_model + {@owner_model.item_name => {@owner_model.owner_model.item_name => {}}} + else + {@owner_model.item_name => {}} + end + else + {} + end + end + + def order + @model.list_order + end + end + + end +end diff --git a/lib/manifest/list/system_resource.rb b/lib/manifest/list/system_resource.rb new file mode 100644 index 00000000..5d272bef --- /dev/null +++ b/lib/manifest/list/system_resource.rb @@ -0,0 +1,23 @@ +module Manifest + module ListModule + class SystemResourceList < Base + + def set_default + super + end + + def init + super + end + + def items + @model.enable_list + end + + def self.add_action item_name, action_name, list_name, list_conf + return + end + end + + end +end diff --git a/lib/manifest/list/through_filter.rb b/lib/manifest/list/through_filter.rb new file mode 100644 index 00000000..d8b35dde --- /dev/null +++ b/lib/manifest/list/through_filter.rb @@ -0,0 +1,29 @@ +module Manifest + module ListModule + class ThroughFilterList < FilterList + attr :list, :list_name, :list_manifest + + def set_default + super + end + + def init + super + return + @through = @list_list_conf['through'] + end + + def includes + {@through => {@from => {}} } + end + + def where filter_item + w = @model.list_where + w += ' and ' unless w.blank? + [w + @through + '.' + @filter_key + ' = ?', filter_item.id] + end + + end + + end +end diff --git a/lib/manifest/manifest.rb b/lib/manifest/manifest.rb index e12d5c03..984233a8 100644 --- a/lib/manifest/manifest.rb +++ b/lib/manifest/manifest.rb @@ -2,7 +2,7 @@ module Manifest class Manifest cattr_accessor :manifest attr :system_resources, :magic_numbers, :select_items, - :controllers, :models, :lists, :profilers, :filers, :forms + :controllers, :models, :lists, :profilers, :filers, :forms, :lists # call me before load routes.rb # routes.rb needs engine_resources manifest in system_resources # ex. it's adding license_groups routes @@ -16,6 +16,7 @@ module Manifest # managers can't initialize at application.rb # call me after configured Rails Application def init + return unless defined? ::Pettanr @controllers = Controller.manager(self, @manifest['controllers']) @models = Model.manager(self, @manifest['models']) @locals = @manifest['locals'] @@ -23,6 +24,7 @@ module Manifest @profilers = Profiler.manager(self, @locals['profilers']) @forms = Form.base_manager(self, @locals['forms']) @forms.merge(Form.extend_manager(self, @locals['forms'])) + @lists = List.manager(self, @locals['lists']) select_items_loader add_action end diff --git a/lib/manifest/model.rb b/lib/manifest/model.rb index 30748c28..087f7919 100644 --- a/lib/manifest/model.rb +++ b/lib/manifest/model.rb @@ -4,15 +4,17 @@ require_dependency "manifest/model/list" module Manifest class Model - include ModelModule def self.manager manifest, my_manifests - my_manifests.map {|model_name, model_manifest| - self.new(manifest, model_name, model_manifest) + models = {} + my_manifests.each {|model_name, model_manifest| + models[model_name] = self.new(manifest, model_name, model_manifest) } + models end - attr :model_name, :model_manifest + attr :model_name, :model_manifest, + :attributes, :associations, :lists def initialize manifest, model_name, model_manifest @manifest = manifest @model_name = model_name @@ -30,15 +32,15 @@ module Manifest def init @attributes = {} @model_manifest['attributes'].each {|attribute_name, attribute_manifest| - @attributes[attribute_name] = Attribute.new(self, attribute_name, attribute_manifest) + @attributes[attribute_name] = ModelModule::Attribute.new(self, attribute_name, attribute_manifest) } @associations = {} @model_manifest['associations'].each {|association_name, association_manifest| - @associations[association_name] = Association.new(self, association_name, association_manifest) + @associations[association_name] = ModelModule::Association.new(self, association_name, association_manifest) } @lists = {} @model_manifest['lists'].each {|list_name, list_manifest| - @lists[list_name] = ListFactory.factory(self, list_name, list_manifest) + @lists[list_name] = ModelModule::ListFactory.factory(self, list_name, list_manifest) } end diff --git a/lib/manifest/model/association.rb b/lib/manifest/model/association.rb index 5d74e667..6a806b19 100644 --- a/lib/manifest/model/association.rb +++ b/lib/manifest/model/association.rb @@ -1,10 +1,9 @@ -require "manifest/model/association/belongs_to" -require "manifest/model/association/has_many" -require "manifest/model/association/has_one" +require_dependency "manifest/model/association/belongs_to" +require_dependency "manifest/model/association/has_many" +require_dependency "manifest/model/association/has_one" module Manifest module ModelModule class Association - include AssociationModule attr :model, :association_name, :association_manifest, :belongs_to, :has_many, :has_one def initialize model, association_name, association_manifest diff --git a/lib/manifest/model/list/base.rb b/lib/manifest/model/list/base.rb index 805f3154..93df4ddf 100644 --- a/lib/manifest/model/list/base.rb +++ b/lib/manifest/model/list/base.rb @@ -1,95 +1,43 @@ module Manifest - module ListModule - class BaseList - attr :model, :list_name, :list_manifest, - :default_page_size, :max_page_size - def initialize model, list_name, list_manifest - @model = model - @list_name = list_name - @list_manifest = list_manifest - self.set_default - self.init + module ModelModule + module ListModule + class Base + attr :model, :list_name, :list_manifest, :type, + :default_page_size, :max_page_size + def initialize model, list_name, list_manifest + @model = model + @list_name = list_name + @list_manifest = list_manifest + self.set_default + self.init + end - @model = ::Manifest.item_name_to_model self.model_name - @table_name = @model.table_name - if @model.content? - @owner_model = @model.owner_model - @owner_table_name = @owner_model.table_name if @owner_model + def set_default + self.list_manifest['args'] ||= {} + @list_manifest['args']['default_page_size'] ||= 25 + @list_manifest['args']['max_page_size'] ||= 100 end - end - - def set_default - self.list_manifest['args'] ||= {} - @list_manifest['args']['default_page_size'] ||= 25 - @list_manifest['args']['max_page_size'] ||= 100 - end - - def init - @args = @list_manifest['args'] - @default_page_size = @list_manifest['args']['default_page_size'] - @max_page_size = @list_manifest['args']['max_page_size'] - end - - def model_name - @model.model_name - end - - def model_manifest - @model.model_manifest - end - - def page_number prm = nil - page = prm.to_i - page = 1 if page < 1 - page - end - - def page_size prm - page_size = prm.to_i - page_size = @max_page_size if page_size > @max_page_size - page_size = @default_page_size if page_size < 1 - page_size - end - - def where - @model.list_where - end - - def includes - if @owner_model - if @owner_model.owner_model - {@owner_model.item_name => {@owner_model.owner_model.item_name => {}}} - else - {@owner_model.item_name => {}} - end - else - {} + + def init + @type = @list_manifest['type'] + @args = @list_manifest['args'] + @default_page_size = @list_manifest['args']['default_page_size'] + @max_page_size = @list_manifest['args']['max_page_size'] + end + + def model_name + @model.model_name + end + + def model_manifest + @model.model_manifest + end + + def self.add_action item_name, action_name, list_name, list_conf + return end end - def order - @model.list_order - end - - def a page, page_size, operators - @page = self.page_number(page) - @page_size = self.page_size page_size - @offset = (@page -1) * @page_size - end - - def items - @model.where(self.where()).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) - end - - def paginate - c = @model.where(self.where()).includes(self.includes).count - Kaminari.paginate_array(Array.new(c, nil)).page(@offset).per(@page_size) - end - - def self.add_action item_name, action_name, list_name, list_conf - return - end end - end end diff --git a/lib/manifest/model/list/element_filter.rb b/lib/manifest/model/list/element_filter.rb index b8462686..2dea906e 100644 --- a/lib/manifest/model/list/element_filter.rb +++ b/lib/manifest/model/list/element_filter.rb @@ -1,29 +1,31 @@ module Manifest - module ListModule - class ElementFilterList < FilterList - - def set_default - super - end - - def init - super - end - - def includes - {@owner_model.item_name => {}} - end - - def where filter_item - w = @model.list_where - w += ' and ' unless w.blank? - [w + @owner_table_name + '.' + @filter_key + ' = ?', filter_item.id] + module ModelModule + module ListModule + class ElementFilterList < FilterList + + def set_default + super + end + + def init + super + end + + def includes + {@owner_model.item_name => {}} + end + + def where filter_item + w = @model.list_where + w += ' and ' unless w.blank? + [w + @owner_table_name + '.' + @filter_key + ' = ?', filter_item.id] + end + + def self.add_action item_name, action_name, list_name, list_conf + return + end end - def self.add_action item_name, action_name, list_name, list_conf - return - end end - end end diff --git a/lib/manifest/model/list/filter.rb b/lib/manifest/model/list/filter.rb index c8eee973..daf0ea23 100644 --- a/lib/manifest/model/list/filter.rb +++ b/lib/manifest/model/list/filter.rb @@ -1,52 +1,54 @@ module Manifest - module ListModule - class FilterList < BaseList - - def set_default - super - end - - def init - super - return - end - - def where filter_item - w = @model.list_where - w += ' and ' unless w.blank? - [w + @table_name + '.' + @filter_key + ' = ?', filter_item.id] - end - - def includes - return @includes if @includes - w = @owner_model ? {@owner_model.item_name => {}} : {} - w.merge({@from => {} }) - end - - def items filter_item - @model.where(self.where(filter_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) - end - - def paginate filter_item - Kaminari.paginate_array(Array.new(@model.where(self.where(filter_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size) - end - - def self._add_action item_name, action_name, list_name, list_conf - return - model = item_name.classify.constantize - controller_name = model.plural + 'Controller' - controller = controller_name.constantize - list_list_conf = Pettanr::Application::manifest.list(item_name).lists[list_name] || {} - from = list_list_conf['from'] - filter_model = from.classify.constantize - filter_key = list_list_conf['filter_key'] - return if controller.method_defined?(action_name) - controller.define_method(action_name) do - filter_list filter_model, params + module ModelModule + module ListModule + class FilterList < Base + + def set_default + super + end + + def init + super + return + end + + def where filter_item + w = @model.list_where + w += ' and ' unless w.blank? + [w + @table_name + '.' + @filter_key + ' = ?', filter_item.id] + end + + def includes + return @includes if @includes + w = @owner_model ? {@owner_model.item_name => {}} : {} + w.merge({@from => {} }) + end + + def items filter_item + @model.where(self.where(filter_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) + end + + def paginate filter_item + Kaminari.paginate_array(Array.new(@model.where(self.where(filter_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size) + end + + def self._add_action item_name, action_name, list_name, list_conf + return + model = item_name.classify.constantize + controller_name = model.plural + 'Controller' + controller = controller_name.constantize + list_list_conf = Pettanr::Application::manifest.list(item_name).lists[list_name] || {} + from = list_list_conf['from'] + filter_model = from.classify.constantize + filter_key = list_list_conf['filter_key'] + return if controller.method_defined?(action_name) + controller.define_method(action_name) do + filter_list filter_model, params + end end + end end - end end diff --git a/lib/manifest/model/list/has_many.rb b/lib/manifest/model/list/has_many.rb index 4a97cdc1..869c9786 100644 --- a/lib/manifest/model/list/has_many.rb +++ b/lib/manifest/model/list/has_many.rb @@ -1,66 +1,68 @@ module Manifest - module ListModule - class HasManyList < BaseList - def initialize list, list_name, list_manifest - super - end - - def set_default - super - return - option_manifest['association_name'] ||= 100 - end - - def init - super - return - @list_list_conf = @manifest.list(@item_name).lists[list_name] || {} - @association_name = @list_list_conf['association_name'] - @has_many_conf = @manifest.model(@item_name).associations['has_many'] || {} - @association_conf = @has_many_conf[@association_name] || {} - @association_model_name = @association_conf['model'] - @association_model = @association_model_name.classify.constantize - @foreign_key = @association_conf['foreign_key'] - if @association_model.content? - @owner_model = @association_model.owner_model - @owner_table_name = @owner_model.table_name if @owner_model + module ModelModule + module ListModule + class HasManyList < Base + def initialize list, list_name, list_manifest + super end - end - - def where parent_item - w = @association_model.list_where - w += ' and ' unless w.blank? - [w + @association_model.table_name + '.' + @foreign_key + ' = ?', parent_item.id] - end - - def includes - # @with_model_name ? {@with_model_name.classify.constantize.table_name => {}} : {} - w = @owner_model ? {@owner_model.item_name => {}} : {} - w.merge({}) - end - - def items parent_item - @association_model.where(self.where(parent_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) - end - - def paginate parent_item - Kaminari.paginate_array(Array.new(@association_model.where(self.where(parent_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size) - end - - def self._add_action item_name, action_name, list_name, list_conf - model = item_name.classify.constantize - controller_name = model.plural + 'Controller' - controller = controller_name.constantize - association_name = list_conf['association_name'] - has_many_conf = Pettanr::Application::manifest.model(item_name).associations['has_many'] || {} - association_conf = has_many_conf[association_name] || {} - association_model_name = association_conf['model'] - return if controller.method_defined?(action_name) - controller.define_method(action_name) do - has_many_list item_name, list_name, association_model_name, params + + def set_default + super + return + option_manifest['association_name'] ||= 100 + end + + def init + super + return + @list_list_conf = @manifest.list(@item_name).lists[list_name] || {} + @association_name = @list_list_conf['association_name'] + @has_many_conf = @manifest.model(@item_name).associations['has_many'] || {} + @association_conf = @has_many_conf[@association_name] || {} + @association_model_name = @association_conf['model'] + @association_model = @association_model_name.classify.constantize + @foreign_key = @association_conf['foreign_key'] + if @association_model.content? + @owner_model = @association_model.owner_model + @owner_table_name = @owner_model.table_name if @owner_model + end + end + + def where parent_item + w = @association_model.list_where + w += ' and ' unless w.blank? + [w + @association_model.table_name + '.' + @foreign_key + ' = ?', parent_item.id] + end + + def includes + # @with_model_name ? {@with_model_name.classify.constantize.table_name => {}} : {} + w = @owner_model ? {@owner_model.item_name => {}} : {} + w.merge({}) + end + + def items parent_item + @association_model.where(self.where(parent_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) + end + + def paginate parent_item + Kaminari.paginate_array(Array.new(@association_model.where(self.where(parent_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size) + end + + def self._add_action item_name, action_name, list_name, list_conf + model = item_name.classify.constantize + controller_name = model.plural + 'Controller' + controller = controller_name.constantize + association_name = list_conf['association_name'] + has_many_conf = Pettanr::Application::manifest.model(item_name).associations['has_many'] || {} + association_conf = has_many_conf[association_name] || {} + association_model_name = association_conf['model'] + return if controller.method_defined?(action_name) + controller.define_method(action_name) do + has_many_list item_name, list_name, association_model_name, params + end end end + end - end end diff --git a/lib/manifest/model/list/has_many_through.rb b/lib/manifest/model/list/has_many_through.rb index a4e1bd66..21c12dff 100644 --- a/lib/manifest/model/list/has_many_through.rb +++ b/lib/manifest/model/list/has_many_through.rb @@ -1,53 +1,55 @@ module Manifest - module ListModule - class HasManyThroughList < BaseList - attr :list, :list_name, :list_manifest, - :belongs_to, :has_many, :has_one - - def set_default - super - end - - def init - super - return - @list_list_conf = @manifest.list(@item_name).lists[list_name] || {} - @association_name = @list_list_conf['association_name'] - @has_many_conf = @manifest.model(@item_name).associations['has_many'] || {} - @association_conf = @has_many_conf[@association_name] || {} - @association_through_model_name = @association_conf['through'] - @association_through_model = @association_through_model_name.classify.constantize - @association_model_name = @association_conf['model'] - @association_model = @association_model_name.classify.constantize - @foreign_key = @association_conf['foreign_key'] - if @association_model.content? - @owner_model = @association_model.owner_model - @owner_table_name = @owner_model.table_name if @owner_model + module ModelModule + module ListModule + class HasManyThroughList < Base + attr :list, :list_name, :list_manifest, + :belongs_to, :has_many, :has_one + + def set_default + super + end + + def init + super + return + @list_list_conf = @manifest.list(@item_name).lists[list_name] || {} + @association_name = @list_list_conf['association_name'] + @has_many_conf = @manifest.model(@item_name).associations['has_many'] || {} + @association_conf = @has_many_conf[@association_name] || {} + @association_through_model_name = @association_conf['through'] + @association_through_model = @association_through_model_name.classify.constantize + @association_model_name = @association_conf['model'] + @association_model = @association_model_name.classify.constantize + @foreign_key = @association_conf['foreign_key'] + if @association_model.content? + @owner_model = @association_model.owner_model + @owner_table_name = @owner_model.table_name if @owner_model + end + end + + def where root_item + w = @association_model.list_where + w += ' and ' unless w.blank? + [w + @association_through_model.table_name + '.' + @foreign_key + ' = ?', root_item.id] + end + + def includes + {@association_through_model.table_name => {@item_name => {}}} + end + + def items root_item + @association_model.where(self.where(root_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) + end + + def paginate root_item + Kaminari.paginate_array(Array.new(@association_model.where(self.where(root_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size) + end + + def self.add_action item_name, action_name, list_name, list_conf + return end end - def where root_item - w = @association_model.list_where - w += ' and ' unless w.blank? - [w + @association_through_model.table_name + '.' + @foreign_key + ' = ?', root_item.id] - end - - def includes - {@association_through_model.table_name => {@item_name => {}}} - end - - def items root_item - @association_model.where(self.where(root_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size) - end - - def paginate root_item - Kaminari.paginate_array(Array.new(@association_model.where(self.where(root_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size) - end - - def self.add_action item_name, action_name, list_name, list_conf - return - end end - end end diff --git a/lib/manifest/model/list/play.rb b/lib/manifest/model/list/play.rb index a916a8cd..9c519ad9 100644 --- a/lib/manifest/model/list/play.rb +++ b/lib/manifest/model/list/play.rb @@ -1,115 +1,46 @@ module Manifest - module ListModule - class PlayList - attr :model, :list_name, :list_manifest - - def initialize model, list_name, list_manifest - @model = model - @list_name = list_name - @list_manifest = list_manifest - self.set_default - self.init - end - - def set_default - return - @default_page_size = @conf['default_page_size'] || 25 - @max_page_size = @conf['max_page_size'] || 100 - @params_offset = params_offset - @params_count = params_count - @list_list_conf = @manifest.list(@item_name).lists[list_name] || {} - @model_name = @list_list_conf['model'] - @filter_key = @list_list_conf['filter_key'] - @model = @model_name.classify.constantize - @table_name = @model.table_name - if @model.content? - @owner_model = @model.owner_model - @owner_table_name = @owner_model.table_name if @owner_model + module ModelModule + module ListModule + class PlayList + attr :model, :list_name, :list_manifest, :type, + :default_page_size, :max_page_size + + def initialize model, list_name, list_manifest + @model = model + @list_name = list_name + @list_manifest = list_manifest + self.set_default + self.init end - end - - def init - end - - def list_name - @list.list_name - end - - def list_manifest - @list.list_manifest - end - - def offset cnt, prm = nil - offset = prm.to_i - offset = cnt - 1 if offset >= cnt - offset = cnt - offset.abs if offset < 0 - offset = 0 if offset < 0 - offset - end - - def limit prm - prm ||= @default_page_size - count = prm.to_i - count = @max_page_size if count > @max_page_size - count = @default_page_size if count < 1 - count - end - - def count filter_item - @count ||= @model.count(:conditions => self.where(filter_item), :include => self.includes).to_i - end - - def where filter_item - w = @model.list_where - w += ' and ' unless w.blank? - [w + @table_name + '.' + @filter_key + ' = ?', filter_item.id] - end - - def includes - {@owner_model.item_name => {}} - end - - def order - @table_name + '.t' - end - - def items filter_item - c = @count || self.count(filter_item) - o = self.offset c, @offset - l = self.limit @count - @model.where(self.where(filter_item)).includes(self.includes).order(self.order).offset(o).limit(l) - end - - def prev_offset filter_item - c = @count || self.count(filter_item) - o = self.offset c, @offset - l = self.limit @count - if o > 0 - if o - l < 0 - 0 - else - o - l + + def set_default + @list_manifest['args'] ||= {} + return + @default_page_size = @conf['default_page_size'] || 25 + @max_page_size = @conf['max_page_size'] || 100 + @params_offset = params_offset + @params_count = params_count + @list_list_conf = @manifest.list(@item_name).lists[list_name] || {} + @model_name = @list_list_conf['model'] + @filter_key = @list_list_conf['filter_key'] + @model = @model_name.classify.constantize + @table_name = @model.table_name + if @model.content? + @owner_model = @model.owner_model + @owner_table_name = @owner_model.table_name if @owner_model end - else - nil end - end - - def next_offset filter_item - c = @count || self.count(filter_item) - o = self.offset c, @offset - l = self.limit @count - if o + l > c - nil - else - o + l + + def init + @type = @list_manifest['type'] + @args = @list_manifest['args'] + end + + def self.add_action item_name, action_name, list_name, list_conf + return end end - def self.add_action item_name, action_name, list_name, list_conf - return - end end - end end diff --git a/lib/manifest/model/list/private.rb b/lib/manifest/model/list/private.rb index 4d9cc1bb..631788d5 100644 --- a/lib/manifest/model/list/private.rb +++ b/lib/manifest/model/list/private.rb @@ -1,38 +1,40 @@ module Manifest - module ListModule - class PrivateList < BaseList - - def set_default - super - end - - def init - super - end - - def where - case @model.owner_type - when :author - operator = @operators.author - when :artist - operator = @operators.artist + module ModelModule + module ListModule + class PrivateList < Base + + def set_default + super end - t = if @owner_model - if @owner_model.owner_model - @owner_model.owner_model.table_name + + def init + super + end + + def where + case @model.owner_type + when :author + operator = @operators.author + when :artist + operator = @operators.artist + end + t = if @owner_model + if @owner_model.owner_model + @owner_model.owner_model.table_name + else + @owner_model.table_name + end else - @owner_model.table_name + @table_name end - else - @table_name + [t + '.' + @model.owner_type.to_s + '_id = ?', operator.id] + end + + def self.add_action item_name, action_name, list_name, list_conf + return end - [t + '.' + @model.owner_type.to_s + '_id = ?', operator.id] end - def self.add_action item_name, action_name, list_name, list_conf - return - end end - end end diff --git a/lib/manifest/model/list/public.rb b/lib/manifest/model/list/public.rb index 3395610e..ae689cd0 100644 --- a/lib/manifest/model/list/public.rb +++ b/lib/manifest/model/list/public.rb @@ -1,30 +1,32 @@ module Manifest - module ListModule - class PublicList < BaseList - - def initialize model, list_name, list_manifest - super - end - - def set_default - super - end - - def init - super - end - - def self.add_action item_name, action_name, list_name, list_conf - return - model = item_name.classify.constantize - controller_name = model.plural + 'Controller' - controller = controller_name.constantize - return if controller.method_defined?(action_name) - controller.define_method(action_name) do - public_list + module ModelModule + module ListModule + class PublicList < Base + + def initialize model, list_name, list_manifest + super + end + + def set_default + super + end + + def init + super + end + + def self.add_action item_name, action_name, list_name, list_conf + return + model = item_name.classify.constantize + controller_name = model.plural + 'Controller' + controller = controller_name.constantize + return if controller.method_defined?(action_name) + controller.define_method(action_name) do + public_list + end end end + end - end end diff --git a/lib/manifest/model/list/system_resource.rb b/lib/manifest/model/list/system_resource.rb index 0378b073..84f26240 100644 --- a/lib/manifest/model/list/system_resource.rb +++ b/lib/manifest/model/list/system_resource.rb @@ -1,23 +1,25 @@ module Manifest - module ListModule - class SystemResourceList < BaseList - - def set_default - super - end - - def init - super + module ModelModule + module ListModule + class SystemResourceList < Base + + def set_default + super + end + + def init + super + end + + def items + @model.enable_list + end + + def self.add_action item_name, action_name, list_name, list_conf + return + end end - def items - @model.enable_list - end - - def self.add_action item_name, action_name, list_name, list_conf - return - end end - end end diff --git a/lib/manifest/model/list/through_filter.rb b/lib/manifest/model/list/through_filter.rb index d8b35dde..9149e37f 100644 --- a/lib/manifest/model/list/through_filter.rb +++ b/lib/manifest/model/list/through_filter.rb @@ -1,29 +1,31 @@ module Manifest - module ListModule - class ThroughFilterList < FilterList - attr :list, :list_name, :list_manifest - - def set_default - super - end - - def init - super - return - @through = @list_list_conf['through'] - end - - def includes - {@through => {@from => {}} } - end - - def where filter_item - w = @model.list_where - w += ' and ' unless w.blank? - [w + @through + '.' + @filter_key + ' = ?', filter_item.id] + module ModelModule + module ListModule + class ThroughFilterList < FilterList + attr :list, :list_name, :list_manifest + + def set_default + super + end + + def init + super + return + @through = @list_list_conf['through'] + end + + def includes + {@through => {@from => {}} } + end + + def where filter_item + w = @model.list_where + w += ' and ' unless w.blank? + [w + @through + '.' + @filter_key + ' = ?', filter_item.id] + end + end end - end end diff --git a/lib/manifest/profiler.rb b/lib/manifest/profiler.rb index 7ab98ba2..1eb54ff6 100644 --- a/lib/manifest/profiler.rb +++ b/lib/manifest/profiler.rb @@ -4,11 +4,12 @@ require_dependency "manifest/profiler/association" module Manifest class Profiler - include ProfilerModule def self.manager manifest, my_manifests - my_manifests.map {|item_name, profiler_manifest| - self.new(manifest, item_name, profiler_manifest) + profilers = {} + my_manifests.each {|item_name, profiler_manifest| + profilers[item_name] = self.new(manifest, item_name, profiler_manifest) } + profilers end attr :profiler_manifest, :item_name, :manifest, @@ -31,9 +32,9 @@ module Manifest @columns = @profiler_manifest['columns'] @lists = {} @profiler_manifest['lists'].each {|list_name, list_manifest| - @lists[list_name] = List.new(self, list_name, list_manifest) + @lists[list_name] = ProfilerModule::List.new(self, list_name, list_manifest) } - @associations = Association.new(self, @profiler_manifest['associations']) + @associations = ProfilerModule::Association.new(self, @profiler_manifest['associations']) end def open item, operators diff --git a/lib/view/list/list.rb b/lib/view/list/list.rb new file mode 100644 index 00000000..523c42a5 --- /dev/null +++ b/lib/view/list/list.rb @@ -0,0 +1,63 @@ + class ListViewFactory + attr :item, :operators + @@types = { + 'public' => PublicListView, 'private' => PrivateListView, 'system_resource' => SystemResourceList, + 'filter' => FilterListView, + 'through_filter' => ThroughFilterList, 'element_filter' => ElementFilterList, + 'play' => PlayListView + } + def initialize item, operators, list_manifest + list_manifest.type + + + + @item = item + @operators = operators + @filer_manifest = filer_manifest + @symbol = SymbolView self, @filer_manifest.symbol.symbol_manifest + end + + class PublicListView + def where + @model.list_where + end + + def includes + if @owner_model + if @owner_model.owner_model + {@owner_model.item_name => {@owner_model.owner_model.item_name => {}}} + else + {@owner_model.item_name => {}} + end + else + {} + end + end + + def order + @model.list_order + end + + class PrivateListView + + def where + case @model.owner_type + when :author + operator = @operators.author + when :artist + operator = @operators.artist + end + t = if @owner_model + if @owner_model.owner_model + @owner_model.owner_model.table_name + else + @owner_model.table_name + end + else + @table_name + end + [t + '.' + @model.owner_type.to_s + '_id = ?', operator.id] + end + + end + diff --git a/public/manifest.json b/public/manifest.json index fc2a2d53..1b235988 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -832,39 +832,14 @@ "private_list": { "type": "private" }, - "scroll_panels": { - "type": "has_many", - "args": { - "association_name": "scroll_panels" - } - }, - "panels": { - "type": "has_many_through", - "args": { - "association_name": "panels" - } - }, "by_author": { - "type": "filter", - "args": { - "from": "author", - "filter_key": "author_id" - } + "type": "filter" }, "by_panel": { - "type": "through_filter", - "args": { - "from": "panel", - "through": "scroll_panels", - "filter_key": "panel_id" - } + "type": "through_filter" }, "play": { - "type": "play", - "args": { - "model_name": "scroll_panel", - "filter_key": "scroll_id" - } + "type": "play" } } }, @@ -934,18 +909,10 @@ "type": "private" }, "by_scroll": { - "type": "filter", - "args": { - "from": "scroll", - "filter_key": "scroll_id" - } + "type": "filter" }, "by_panel": { - "type": "filter", - "args": { - "from": "panel", - "filter_key": "panel_id" - } + "type": "filter" } } }, @@ -1016,18 +983,8 @@ "private_list": { "type": "private" }, - "stories": { - "type": "has_many", - "args": { - "association_name": "stories" - } - }, "by_author": { - "type": "filter", - "args": { - "from": "author", - "filter_key": "author_id" - } + "type": "filter" } } }, @@ -1107,46 +1064,17 @@ "private_list": { "type": "private" }, - "story_sheets": { - "type": "has_many", - "args": { - "association_name": "story_sheets" - } - }, - "sheets": { - "type": "has_many", - "args": { - "association_name": "sheets" - } - }, "by_comic": { - "type": "filter", - "args": { - "from": "comic", - "filter_key": "comic_id" - } + "type": "filter" }, "by_sheet": { - "type": "through_filter", - "args": { - "from": "sheet", - "through": "story_sheets", - "filter_key": "sheet_id" - } + "type": "through_filter" }, "by_author": { - "type": "element_filter", - "args": { - "from": "author", - "filter_key": "author_id" - } + "type": "element_filter" }, "play": { - "type": "play", - "args": { - "model_name": "story_sheet", - "filter_key": "story_id" - } + "type": "play" } } }, @@ -1214,18 +1142,10 @@ "type": "private" }, "by_story": { - "type": "filter", - "args": { - "from": "story", - "filter_key": "story_id" - } + "type": "filter" }, "by_sheet": { - "type": "filter", - "args": { - "from": "sheet", - "filter_key": "sheet_id" - } + "type": "filter" } } }, @@ -1317,59 +1237,17 @@ "private_list": { "type": "private" }, - "story_sheets": { - "type": "has_many", - "args": { - "association_name": "story_sheets" - } - }, - "stories": { - "type": "has_many", - "args": { - "association_name": "stories" - } - }, - "sheet_panels": { - "type": "has_many", - "args": { - "association_name": "sheet_panels" - } - }, - "panels": { - "type": "has_many", - "args": { - "association_name": "panels" - } - }, "by_story": { - "type": "through_filter", - "args": { - "from": "story", - "through": "story_sheets", - "filter_key": "story_id" - } + "type": "through_filter" }, "by_panel": { - "type": "through_filter", - "args": { - "from": "panel", - "through": "sheet_panels", - "filter_key": "panel_id" - } + "type": "through_filter" }, "by_author": { - "type": "filter", - "args": { - "from": "author", - "filter_key": "author_id" - } + "type": "filter" }, "play": { - "type": "play", - "args": { - "model_name": "sheet_panel", - "filter_key": "sheet_id" - } + "type": "play" } } }, @@ -1458,19 +1336,10 @@ "type": "private" }, "by_sheet": { - "type": "filter", - "args": { - "association_name": "sheet_panels", - "from": "sheet", - "filter_key": "sheet_id" - } + "type": "filter" }, "by_panel": { - "type": "filter", - "args": { - "from": "panel", - "filter_key": "panel_id" - } + "type": "filter" } } }, @@ -1588,84 +1457,17 @@ "private_list": { "type": "private" }, - "scroll_panels": { - "type": "has_many", - "args": { - "association_name": "scroll_panels" - } - }, - "scrolls": { - "type": "has_many", - "args": { - "association_name": "scrolls" - } - }, - "sheet_panels": { - "type": "has_many", - "args": { - "association_name": "sheet_panels" - } - }, - "sheets": { - "type": "has_many", - "args": { - "association_name": "sheets" - } - }, - "panel_pictures": { - "type": "has_many", - "args": { - "association_name": "panel_pictures" - } - }, - "speech_balloons": { - "type": "has_many", - "args": { - "association_name": "speech_balloons" - } - }, - "ground_pictures": { - "type": "has_many", - "args": { - "association_name": "ground_pictures" - } - }, - "ground_colors": { - "type": "has_many", - "args": { - "association_name": "ground_colors" - } - }, "by_scroll": { - "type": "through_filter", - "args": { - "from": "scroll", - "through": "scroll_panels", - "filter_key": "scroll_id" - } + "type": "through_filter" }, "by_sheet": { - "type": "through_filter", - "args": { - "from": "sheet", - "through": "sheet_panels", - "filter_key": "sheet_id" - } + "type": "through_filter" }, "by_author": { - "type": "filter", - "args": { - "from": "author", - "filter_key": "author_id" - } + "type": "filter" }, "by_speech_balloon_template": { - "type": "through_filter", - "args": { - "from": "speech_balloon_template", - "through": "speech_balloons", - "filter_key": "speech_balloon_template_id" - } + "type": "through_filter" } } }, @@ -1770,18 +1572,10 @@ "type": "private" }, "by_panel": { - "type": "filter", - "args": { - "from": "panel", - "filter_key": "panel_id" - } + "type": "filter" }, "by_author": { - "type": "element_filter", - "args": { - "from": "author", - "filter_key": "author_id" - } + "type": "element_filter" } } }, @@ -1873,25 +1667,13 @@ "type": "private" }, "by_panel": { - "type": "filter", - "args": { - "from": "panel", - "filter_key": "panel_id" - } + "type": "filter" }, "by_speech_balloon_template": { - "type": "filter", - "args": { - "from": "speech_balloon_template", - "filter_key": "speech_balloon_template_id" - } + "type": "filter" }, "by_author": { - "type": "element_filter", - "args": { - "from": "author", - "filter_key": "author_id" - } + "type": "element_filter" } } }, @@ -1986,25 +1768,13 @@ "type": "private" }, "by_panel": { - "type": "filter", - "args": { - "from": "panel", - "filter_key": "panel_id" - } + "type": "filter" }, - "by_speech_balloon_template": { - "type": "filter", - "args": { - "from": "speech_balloon_template", - "filter_key": "speech_balloon_template_id" - } + "by_speech_balloon": { + "type": "filter" }, "by_author": { - "type": "element_filter", - "args": { - "from": "author", - "filter_key": "author_id" - } + "type": "element_filter" } } }, @@ -2139,23 +1909,10 @@ "type": "public" }, "by_speech_balloon": { - "type": "filter", - "args": { - "from": "speech_balloon", - "includes": { - "speech_balloon": { - "panel": {} - } - }, - "filter_key": "speech_balloon_id" - } + "type": "filter" }, "by_writing_format": { - "type": "filter", - "args": { - "from": "writing_format", - "filter_key": "writing_format_id" - } + "type": "filter" } } }, @@ -2255,18 +2012,10 @@ "type": "private" }, "by_panel": { - "type": "filter", - "args": { - "from": "panel", - "filter_key": "panel_id" - } + "type": "filter" }, "by_author": { - "type": "element_filter", - "args": { - "from": "author", - "filter_key": "author_id" - } + "type": "element_filter" } } }, @@ -2368,18 +2117,10 @@ "type": "private" }, "by_panel": { - "type": "filter", - "args": { - "from": "panel", - "filter_key": "panel_id" - } + "type": "filter" }, "by_author": { - "type": "element_filter", - "args": { - "from": "author", - "filter_key": "author_id" - } + "type": "element_filter" } } }, @@ -2716,18 +2457,10 @@ "type": "private" }, "by_license": { - "type": "filter", - "args": { - "from": "license", - "filter_key": "license_id" - } + "type": "filter" }, "by_artist": { - "type": "filter", - "args": { - "from": "artist", - "filter_key": "artist_id" - } + "type": "filter" } } }, @@ -2813,18 +2546,6 @@ }, "select_items": { "type": "system_resource" - }, - "speech_balloons": { - "type": "has_many", - "args": { - "association_name": "speech_balloons" - } - }, - "panels": { - "type": "has_many", - "args": { - "association_name": "panels" - } } } }, @@ -2898,18 +2619,8 @@ "select_items": { "type": "system_resource" }, - "speeches": { - "type": "has_many", - "args": { - "association_name": "speeches" - } - }, "by_system_picture": { - "type": "filter", - "args": { - "from": "system_picture", - "filter_key": "system_picture_id" - } + "type": "filter" } } }, @@ -2971,12 +2682,6 @@ }, "select_items": { "type": "system_resource" - }, - "licenses": { - "type": "has_many", - "args": { - "association_name": "licenses" - } } } }, @@ -3058,25 +2763,11 @@ "public_list": { "type": "public" }, - "resource_pictures": { - "type": "has_many", - "args": { - "association_name": "resource_pictures" - } - }, "by_license_group": { - "type": "filter", - "args": { - "from": "license_group", - "filter_key": "license_group_id" - } + "type": "filter" }, "by_system_picture": { - "type": "filter", - "args": { - "from": "system_picture", - "filter_key": "system_picture_id" - } + "type": "filter" } } }, @@ -3140,88 +2831,34 @@ "lists": { "public_list": { "type": "public" - }, - "scrolls": { - "type": "has_many", - "args": { - "association_name": "scrolls" + } + } + }, + "artist": { + "class_name": "Artist", + "table_name": "artists", + "associations": { + "belongs_to": {}, + "has_many": { + "resource_pictures": { + "foreign_key": "artist_id", + "model_name": "resource_picture" } }, - "comics": { - "type": "has_many", - "args": { - "association_name": "comics" + "has_one": {} + }, + "attributes": { + "id": { + "type": "number", + "primary_key": 1, + "rules": { + "number": true } }, - "stories": { - "type": "has_many", - "args": { - "association_name": "stories" - } - }, - "sheets": { - "type": "has_many", - "args": { - "association_name": "sheets" - } - }, - "panels": { - "type": "has_many", - "args": { - "association_name": "panels" - } - }, - "panel_pictures": { - "type": "has_many", - "args": { - "association_name": "panel_pictures" - } - }, - "speech_balloons": { - "type": "has_many", - "args": { - "association_name": "speech_balloons" - } - }, - "ground_pictures": { - "type": "has_many", - "args": { - "association_name": "ground_pictures" - } - }, - "ground_colors": { - "type": "has_many", - "args": { - "association_name": "ground_colors" - } - } - } - }, - "artist": { - "class_name": "Artist", - "table_name": "artists", - "associations": { - "belongs_to": {}, - "has_many": { - "resource_pictures": { - "foreign_key": "artist_id", - "model_name": "resource_picture" - } - }, - "has_one": {} - }, - "attributes": { - "id": { - "type": "number", - "primary_key": 1, - "rules": { - "number": true - } - }, - "name": { - "type": "text", - "rules": { - "required": true + "name": { + "type": "text", + "rules": { + "required": true } }, "author_id": { @@ -3231,669 +2868,88 @@ "number": true } }, - "created_at": { - "type": "datetime" - }, - "updated_at": { - "type": "datetime" - } - }, - "lists": { - "public_list": { - "type": "public" - }, - "resource_pictures": { - "type": "has_many", - "args": { - "association_name": "resource_pictures" - } - } - } - }, - "system_picture": { - "class_name": "SystemPicture", - "table_name": "system_pictures", - "associations": { - "belongs_to": {}, - "has_many": { - "balloons": { - "foreign_key": "system_picture_id", - "model_name": "balloon" - }, - "balloon_templates": { - "foreign_key": "system_picture_id", - "model_name": "balloon_template" - }, - "licenses": { - "foreign_key": "system_picture_id", - "model_name": "license" - } - }, - "has_one": {} - }, - "attributes": { - "id": { - "type": "number", - "primary_key": 1, - "rules": { - "number": true - } - }, - "ext": { - "type": "text", - "rules": { - "required": true - } - }, - "width": { - "type": "number", - "rules": { - "required": true, - "number": true - } - }, - "height": { - "type": "number", - "rules": { - "required": true, - "number": true - } - }, - "filesize": { - "type": "number", - "rules": { - "required": true, - "number": true - } - }, - "md5": { - "type": "text", - "rules": { - "required": true - } - }, - "created_at": { - "type": "datetime" - }, - "updated_at": { - "type": "datetime" - } - }, - "lists": { - "public_list": { - "type": "public" - } - } - } - }, - "lists": { - "scroll": { - "lists": { - "public_list": { - "type": "public" - }, - "private_list": { - "type": "private" - }, - "scroll_panels": { - "type": "has_many", - "association_name": "scroll_panels" - }, - "panels": { - "type": "has_many_through", - "association_name": "panels" - }, - "by_author": { - "type": "filter", - "from": "author", - "filter_key": "author_id" - }, - "by_panel": { - "type": "through_filter", - "from": "panel", - "through": "scroll_panels", - "filter_key": "panel_id" - }, - "play": { - "type": "play", - "model": "scroll_panel", - "filter_key": "scroll_id" - } - } - }, - "scroll_panel": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "private_list": { - "type": "private" - }, - "by_scroll": { - "type": "filter", - "from": "scroll", - "filter_key": "scroll_id" - }, - "by_panel": { - "type": "filter", - "from": "panel", - "filter_key": "panel_id" - } - } - }, - "comic": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "private_list": { - "type": "private" - }, - "stories": { - "type": "has_many", - "association_name": "stories" - }, - "by_author": { - "type": "filter", - "from": "author", - "filter_key": "author_id" - } - } - }, - "story": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "private_list": { - "type": "private" - }, - "story_sheets": { - "type": "has_many", - "association_name": "story_sheets" - }, - "sheets": { - "type": "has_many", - "association_name": "sheets" - }, - "by_comic": { - "type": "filter", - "from": "comic", - "filter_key": "comic_id" - }, - "by_sheet": { - "type": "through_filter", - "from": "sheet", - "through": "story_sheets", - "filter_key": "sheet_id" - }, - "by_author": { - "type": "element_filter", - "from": "author", - "filter_key": "author_id" - }, - "play": { - "type": "play", - "model": "story_sheet", - "filter_key": "story_id" - } - } - }, - "story_sheet": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "private_list": { - "type": "private" - }, - "by_story": { - "type": "filter", - "from": "story", - "filter_key": "story_id" - }, - "by_sheet": { - "type": "filter", - "from": "sheet", - "filter_key": "sheet_id" - } - } - }, - "sheet": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "private_list": { - "type": "private" - }, - "story_sheets": { - "type": "has_many", - "association_name": "story_sheets" - }, - "stories": { - "type": "has_many", - "association_name": "stories" - }, - "sheet_panels": { - "type": "has_many", - "association_name": "sheet_panels" - }, - "panels": { - "type": "has_many", - "association_name": "panels" - }, - "by_story": { - "type": "through_filter", - "from": "story", - "through": "story_sheets", - "filter_key": "story_id" - }, - "by_panel": { - "type": "through_filter", - "from": "panel", - "through": "sheet_panels", - "filter_key": "panel_id" - }, - "by_author": { - "type": "filter", - "from": "author", - "filter_key": "author_id" - }, - "play": { - "type": "play", - "model": "sheet_panel", - "filter_key": "sheet_id" - } - } - }, - "sheet_panel": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "private_list": { - "type": "private" - }, - "by_sheet": { - "type": "filter", - "association_name": "sheet_panels", - "from": "sheet", - "filter_key": "sheet_id" - }, - "by_panel": { - "type": "filter", - "from": "panel", - "filter_key": "panel_id" - } - } - }, - "panel": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "private_list": { - "type": "private" - }, - "scroll_panels": { - "type": "has_many", - "association_name": "scroll_panels" - }, - "scrolls": { - "type": "has_many", - "association_name": "scrolls" - }, - "sheet_panels": { - "type": "has_many", - "association_name": "sheet_panels" - }, - "sheets": { - "type": "has_many", - "association_name": "sheets" - }, - "panel_pictures": { - "type": "has_many", - "association_name": "panel_pictures" - }, - "speech_balloons": { - "type": "has_many", - "association_name": "speech_balloons" - }, - "ground_pictures": { - "type": "has_many", - "association_name": "ground_pictures" - }, - "ground_colors": { - "type": "has_many", - "association_name": "ground_colors" - }, - "by_scroll": { - "type": "through_filter", - "from": "scroll", - "through": "scroll_panels", - "filter_key": "scroll_id" - }, - "by_sheet": { - "type": "through_filter", - "from": "sheet", - "through": "sheet_panels", - "filter_key": "sheet_id" - }, - "by_author": { - "type": "filter", - "from": "author", - "filter_key": "author_id" - }, - "by_speech_balloon_template": { - "type": "through_filter", - "from": "speech_balloon_template", - "through": "speech_balloons", - "filter_key": "speech_balloon_template_id" - } - } - }, - "panel_picture": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "private_list": { - "type": "private" - }, - "by_panel": { - "type": "filter", - "from": "panel", - "filter_key": "panel_id" - }, - "by_author": { - "type": "element_filter", - "from": "author", - "filter_key": "author_id" - } - } - }, - "speech_balloon": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "private_list": { - "type": "private" - }, - "by_panel": { - "type": "filter", - "from": "panel", - "filter_key": "panel_id" - }, - "by_speech_balloon_template": { - "type": "filter", - "from": "speech_balloon_template", - "filter_key": "speech_balloon_template_id" - }, - "by_author": { - "type": "element_filter", - "from": "author", - "filter_key": "author_id" - } - } - }, - "speech": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "by_speech_balloon": { - "type": "filter", - "from": "speech_balloon", - "includes": { - "speech_balloon": { - "panel": {} - } - }, - "filter_key": "speech_balloon_id" - }, - "by_writing_format": { - "type": "filter", - "from": "writing_format", - "filter_key": "writing_format_id" - } - } - }, - "balloon": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "by_speech_balloon": { - "type": "filter", - "from": "speech_balloon", - "includes": { - "speech_balloon": { - "panel": {} - } - }, - "filter_key": "speech_balloon_id" - } - } - }, - "ground_picture": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "private_list": { - "type": "private" - }, - "by_panel": { - "type": "filter", - "from": "panel", - "filter_key": "panel_id" - }, - "by_author": { - "type": "element_filter", - "from": "author", - "filter_key": "author_id" - } - } - }, - "ground_color": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "private_list": { - "type": "private" - }, - "by_panel": { - "type": "filter", - "from": "panel", - "filter_key": "panel_id" - }, - "by_author": { - "type": "element_filter", - "from": "author", - "filter_key": "author_id" - } - } - }, - "original_picture": { - "default_page_size": 20, - "lists": { - "private_list": { - "type": "private" - } - } - }, - "picture": {}, - "resource_picture": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "private_list": { - "type": "private" - }, - "by_license": { - "type": "filter", - "from": "license", - "filter_key": "license_id" - }, - "by_artist": { - "type": "filter", - "from": "artist", - "filter_key": "artist_id" - } - } - }, - "speech_balloon_template": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "select_items": { - "type": "system_resource" - }, - "speech_balloons": { - "type": "has_many", - "association_name": "speech_balloons" - }, - "panels": { - "type": "has_many", - "association_name": "panels" - } - } - }, - "writing_format": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "select_items": { - "type": "system_resource" - }, - "speeches": { - "type": "has_many", - "association_name": "speeches" - }, - "by_system_picture": { - "type": "filter", - "from": "system_picture", - "filter_key": "system_picture_id" - } - } - }, - "license_group": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "select_items": { - "type": "system_resource" + "created_at": { + "type": "datetime" }, - "licenses": { - "type": "has_many", - "association_name": "licenses" + "updated_at": { + "type": "datetime" } - } - }, - "license": { - "default_page_size": 20, + }, "lists": { "public_list": { "type": "public" - }, - "resource_pictures": { - "type": "has_many", - "association_name": "resource_pictures" - }, - "by_license_group": { - "type": "filter", - "from": "license_group", - "filter_key": "license_group_id" - }, - "by_system_picture": { - "type": "filter", - "from": "system_picture", - "filter_key": "system_picture_id" } } }, - "author": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" - }, - "scrolls": { - "type": "has_many", - "association_name": "scrolls" - }, - "comics": { - "type": "has_many", - "association_name": "comics" + "system_picture": { + "class_name": "SystemPicture", + "table_name": "system_pictures", + "associations": { + "belongs_to": {}, + "has_many": { + "balloons": { + "foreign_key": "system_picture_id", + "model_name": "balloon" + }, + "balloon_templates": { + "foreign_key": "system_picture_id", + "model_name": "balloon_template" + }, + "licenses": { + "foreign_key": "system_picture_id", + "model_name": "license" + } }, - "stories": { - "type": "has_many", - "association_name": "stories" + "has_one": {} + }, + "attributes": { + "id": { + "type": "number", + "primary_key": 1, + "rules": { + "number": true + } }, - "sheets": { - "type": "has_many", - "association_name": "sheets" + "ext": { + "type": "text", + "rules": { + "required": true + } }, - "panels": { - "type": "has_many", - "association_name": "panels" + "width": { + "type": "number", + "rules": { + "required": true, + "number": true + } }, - "panel_pictures": { - "type": "has_many", - "association_name": "panel_pictures" + "height": { + "type": "number", + "rules": { + "required": true, + "number": true + } }, - "speech_balloons": { - "type": "has_many", - "association_name": "speech_balloons" + "filesize": { + "type": "number", + "rules": { + "required": true, + "number": true + } }, - "ground_pictures": { - "type": "has_many", - "association_name": "ground_pictures" + "md5": { + "type": "text", + "rules": { + "required": true + } }, - "ground_colors": { - "type": "has_many", - "association_name": "ground_colors" - } - } - }, - "artist": { - "default_page_size": 20, - "lists": { - "public_list": { - "type": "public" + "created_at": { + "type": "datetime" }, - "resource_pictures": { - "type": "has_many", - "association_name": "resource_pictures" + "updated_at": { + "type": "datetime" } - } - }, - "system_picture": { - "default_page_size": 20, + }, "lists": { "public_list": { "type": "public" @@ -5316,13 +4372,165 @@ "ground_color": { "symbol": { "face": { - "type": "template", + "type": "template", + "args": { + "name": "symbol" + } + }, + "link": { + "type": "none" + } + }, + "caption": { + "face": { + "type": "column", + "args": { + "name": "caption" + } + }, + "link": { + "type": "none" + } + }, + "summary": { + "type": "template", + "args": { + "name": "summary" + } + }, + "edit": { + "type": "none" + } + }, + "original_picture": { + "symbol": { + "face": { + "type": "picture", + "args": { + "name": "symbol_option" + } + }, + "link": { + "type": "action", + "args": { + "name": "show" + } + } + }, + "caption": { + "face": { + "type": "method", + "args": { + "name": "revision" + } + }, + "link": { + "type": "action", + "args": { + "name": "history" + } + } + }, + "summary": { + "type": "template", + "args": { + "name": "summary" + } + }, + "edit": { + "type": "template", + "args": { + "name": "publish" + } + } + }, + "picture": { + "symbol": { + "face": { + "type": "picture", + "args": { + "name": "symbol_option" + } + }, + "link": { + "type": "action", + "args": { + "name": "show" + } + } + }, + "caption": { + "face": { + "type": "column", + "args": { + "name": "revision" + } + }, + "link": { + "type": "action", + "args": { + "name": "show" + } + } + }, + "summary": { + "type": "template", + "args": { + "name": "summary" + } + }, + "edit": { + "type": "none" + } + }, + "resource_picture": { + "symbol": { + "face": { + "type": "picture", + "args": { + "name": "symbol_option" + } + }, + "link": { + "type": "action", + "args": { + "name": "show" + } + } + }, + "caption": { + "face": { + "type": "none", + "args": {} + }, + "link": { + "type": "none", + "args": {} + } + }, + "summary": { + "type": "template", + "args": { + "name": "summary" + } + }, + "edit": { + "type": "none" + } + }, + "speech_balloon_template": { + "symbol": { + "face": { + "type": "picture", "args": { - "name": "symbol" + "name": "symbol_option" } }, "link": { - "type": "none" + "type": "action", + "args": { + "name": "show" + } } }, "caption": { @@ -5333,25 +4541,25 @@ } }, "link": { - "type": "none" + "type": "action", + "args": { + "name": "show" + } } }, "summary": { - "type": "template", - "args": { - "name": "summary" - } + "type": "none" }, "edit": { "type": "none" } }, - "original_picture": { + "writing_format": { "symbol": { "face": { - "type": "picture", + "type": "image", "args": { - "name": "symbol_option" + "name": "/assets/item.png" } }, "link": { @@ -5363,37 +4571,31 @@ }, "caption": { "face": { - "type": "method", + "type": "column", "args": { - "name": "revision" + "name": "caption" } }, "link": { "type": "action", "args": { - "name": "history" + "name": "show" } } }, "summary": { - "type": "template", - "args": { - "name": "summary" - } + "type": "none" }, "edit": { - "type": "template", - "args": { - "name": "publish" - } + "type": "none" } }, - "picture": { + "license_group": { "symbol": { "face": { - "type": "picture", + "type": "image", "args": { - "name": "symbol_option" + "name": "/assets/item.png" } }, "link": { @@ -5407,32 +4609,30 @@ "face": { "type": "column", "args": { - "name": "revision" + "name": "caption" } }, "link": { - "type": "action", + "type": "url_column", "args": { - "name": "show" + "name": "url" } } }, "summary": { - "type": "template", - "args": { - "name": "summary" - } + "type": "none", + "args": {} }, "edit": { "type": "none" } }, - "resource_picture": { + "license": { "symbol": { "face": { - "type": "picture", + "type": "image", "args": { - "name": "symbol_option" + "name": "/assets/item.png" } }, "link": { @@ -5444,12 +4644,16 @@ }, "caption": { "face": { - "type": "none", - "args": {} + "type": "method", + "args": { + "name": "caption_with_group" + } }, "link": { - "type": "none", - "args": {} + "type": "url_column", + "args": { + "name": "url" + } } }, "summary": { @@ -5462,12 +4666,12 @@ "type": "none" } }, - "speech_balloon_template": { + "author": { "symbol": { "face": { - "type": "picture", + "type": "image", "args": { - "name": "symbol_option" + "name": "/assets/item.png" } }, "link": { @@ -5481,7 +4685,7 @@ "face": { "type": "column", "args": { - "name": "caption" + "name": "name" } }, "link": { @@ -5492,13 +4696,16 @@ } }, "summary": { - "type": "none" + "type": "template", + "args": { + "name": "summary" + } }, "edit": { - "type": "none" + "type": "account" } }, - "writing_format": { + "artist": { "symbol": { "face": { "type": "image", @@ -5517,7 +4724,7 @@ "face": { "type": "column", "args": { - "name": "caption" + "name": "name" } }, "link": { @@ -5528,18 +4735,21 @@ } }, "summary": { - "type": "none" + "type": "template", + "args": { + "name": "summary" + } }, "edit": { - "type": "none" + "type": "account" } }, - "license_group": { + "system_picture": { "symbol": { "face": { - "type": "image", + "type": "picture", "args": { - "name": "/assets/item.png" + "name": "symbol_option" } }, "link": { @@ -5551,174 +4761,333 @@ }, "caption": { "face": { - "type": "column", - "args": { - "name": "caption" - } + "type": "none", + "args": {} }, "link": { - "type": "url_column", - "args": { - "name": "url" - } + "type": "none", + "args": {} } }, "summary": { - "type": "none", - "args": {} + "type": "none" + }, + "edit": { + "type": "none" + } + } + }, + "lists": { + "scroll": { + "public_list": {}, + "private_list": {}, + "by_author": { + "type": "filter", + "from": "author", + "filter_key": "author_id" + }, + "by_panel": { + "type": "through_filter", + "from": "panel", + "through": "scroll_panels", + "filter_key": "panel_id" + }, + "play": { + "type": "play", + "model": "scroll_panel", + "filter_key": "scroll_id" + } + }, + "scroll_panel": { + "public_list": {}, + "private_list": {}, + "by_scroll": { + "type": "filter", + "from": "scroll", + "filter_key": "scroll_id" + }, + "by_panel": { + "type": "filter", + "from": "panel", + "filter_key": "panel_id" + } + }, + "comic": { + "public_list": {}, + "private_list": {}, + "by_author": { + "type": "filter", + "from": "author", + "filter_key": "author_id" + } + }, + "story": { + "public_list": {}, + "private_list": {}, + "by_comic": { + "type": "filter", + "from": "comic", + "filter_key": "comic_id" + }, + "by_sheet": { + "type": "through_filter", + "from": "sheet", + "through": "story_sheets", + "filter_key": "sheet_id" + }, + "by_author": { + "type": "element_filter", + "from": "author", + "filter_key": "author_id" + }, + "play": { + "type": "play", + "model": "story_sheet", + "filter_key": "story_id" + } + }, + "story_sheet": { + "public_list": { + "type": "public" + }, + "private_list": { + "type": "private" + }, + "by_story": { + "type": "filter", + "from": "story", + "filter_key": "story_id" + }, + "by_sheet": { + "type": "filter", + "from": "sheet", + "filter_key": "sheet_id" + } + }, + "sheet": { + "public_list": {}, + "private_list": {}, + "by_story": { + "type": "through_filter", + "from": "story", + "through": "story_sheets", + "filter_key": "story_id" + }, + "by_panel": { + "type": "through_filter", + "from": "panel", + "through": "sheet_panels", + "filter_key": "panel_id" + }, + "by_author": { + "type": "filter", + "from": "author", + "filter_key": "author_id" + }, + "play": { + "type": "play", + "model": "sheet_panel", + "filter_key": "sheet_id" + } + }, + "sheet_panel": { + "public_list": {}, + "private_list": {}, + "by_sheet": { + "type": "filter", + "association_name": "sheet_panels", + "from": "sheet", + "filter_key": "sheet_id" + }, + "by_panel": { + "type": "filter", + "from": "panel", + "filter_key": "panel_id" + } + }, + "panel": { + "public_list": {}, + "private_list": {}, + "by_scroll": { + "type": "through_filter", + "from": "scroll", + "through": "scroll_panels", + "filter_key": "scroll_id" + }, + "by_sheet": { + "type": "through_filter", + "from": "sheet", + "through": "sheet_panels", + "filter_key": "sheet_id" }, - "edit": { - "type": "none" + "by_author": { + "type": "filter", + "from": "author", + "filter_key": "author_id" + }, + "by_speech_balloon_template": { + "type": "through_filter", + "from": "speech_balloon_template", + "through": "speech_balloons", + "filter_key": "speech_balloon_template_id" } }, - "license": { - "symbol": { - "face": { - "type": "image", - "args": { - "name": "/assets/item.png" - } - }, - "link": { - "type": "action", - "args": { - "name": "show" - } - } + "panel_picture": { + "public_list": {}, + "private_list": {}, + "by_panel": { + "type": "filter", + "from": "panel", + "filter_key": "panel_id" }, - "caption": { - "face": { - "type": "method", - "args": { - "name": "caption_with_group" - } - }, - "link": { - "type": "url_column", - "args": { - "name": "url" - } - } + "by_author": { + "type": "element_filter", + "from": "author", + "filter_key": "author_id" + } + }, + "speech_balloon": { + "public_list": {}, + "private_list": {}, + "by_panel": { + "type": "filter", + "from": "panel", + "filter_key": "panel_id" }, - "summary": { - "type": "template", - "args": { - "name": "summary" - } + "by_speech_balloon_template": { + "type": "filter", + "from": "speech_balloon_template", + "filter_key": "speech_balloon_template_id" }, - "edit": { - "type": "none" + "by_author": { + "type": "element_filter", + "from": "author", + "filter_key": "author_id" } }, - "author": { - "symbol": { - "face": { - "type": "image", - "args": { - "name": "/assets/item.png" - } - }, - "link": { - "type": "action", - "args": { - "name": "show" - } - } - }, - "caption": { - "face": { - "type": "column", - "args": { - "name": "name" + "speech": { + "public_list": {}, + "by_speech_balloon": { + "type": "filter", + "from": "speech_balloon", + "includes": { + "speech_balloon": { + "panel": {} } }, - "link": { - "type": "action", - "args": { - "name": "show" - } - } - }, - "summary": { - "type": "template", - "args": { - "name": "summary" - } + "filter_key": "speech_balloon_id" }, - "edit": { - "type": "account" + "by_writing_format": { + "type": "filter", + "from": "writing_format", + "filter_key": "writing_format_id" } }, - "artist": { - "symbol": { - "face": { - "type": "image", - "args": { - "name": "/assets/item.png" + "balloon": { + "public_list": {}, + "by_speech_balloon": { + "type": "filter", + "from": "speech_balloon", + "includes": { + "speech_balloon": { + "panel": {} } }, - "link": { - "type": "action", - "args": { - "name": "show" - } - } + "filter_key": "speech_balloon_id" + } + }, + "ground_picture": { + "public_list": {}, + "private_list": { + "type": "private" }, - "caption": { - "face": { - "type": "column", - "args": { - "name": "name" - } - }, - "link": { - "type": "action", - "args": { - "name": "show" - } - } + "by_panel": { + "type": "filter", + "from": "panel", + "filter_key": "panel_id" }, - "summary": { - "type": "template", - "args": { - "name": "summary" - } + "by_author": { + "type": "element_filter", + "from": "author", + "filter_key": "author_id" + } + }, + "ground_color": { + "public_list": {}, + "private_list": {}, + "by_panel": { + "type": "filter", + "from": "panel", + "filter_key": "panel_id" }, - "edit": { - "type": "account" + "by_author": { + "type": "element_filter", + "from": "author", + "filter_key": "author_id" } }, - "system_picture": { - "symbol": { - "face": { - "type": "picture", - "args": { - "name": "symbol_option" - } - }, - "link": { - "type": "action", - "args": { - "name": "show" - } - } + "original_picture": { + "private_list": {} + }, + "picture": {}, + "resource_picture": { + "public_list": {}, + "private_list": {}, + "by_license": { + "type": "filter", + "from": "license", + "filter_key": "license_id" }, - "caption": { - "face": { - "type": "none", - "args": {} - }, - "link": { - "type": "none", - "args": {} - } + "by_artist": { + "type": "filter", + "from": "artist", + "filter_key": "artist_id" + } + }, + "speech_balloon_template": { + "public_list": {}, + "select_items": { + "type": "system_resource" + } + }, + "writing_format": { + "public_list": {}, + "select_items": { + "type": "system_resource" }, - "summary": { - "type": "none" + "by_system_picture": { + "type": "filter", + "from": "system_picture", + "filter_key": "system_picture_id" + } + }, + "license_group": { + "public_list": {}, + "select_items": { + "type": "system_resource" + } + }, + "license": { + "public_list": {}, + "by_license_group": { + "type": "filter", + "from": "license_group", + "filter_key": "license_group_id" }, - "edit": { - "type": "none" + "by_system_picture": { + "type": "filter", + "from": "system_picture", + "filter_key": "system_picture_id" } + }, + "author": { + "public_list": {} + }, + "artist": { + "public_list": {} + }, + "system_picture": { + "public_list": {} } }, "elements": [ @@ -5811,7 +5180,7 @@ "args": { "column": "id", "label": { - "type": "none " + "type": "none" }, "tag": { "type": "hidden" -- 2.11.0