From e0c8696eab6c0085930bb34bb4b0e82261a8b8b3 Mon Sep 17 00:00:00 2001 From: yasushiito Date: Sun, 22 Jun 2014 10:23:30 +0900 Subject: [PATCH] add dialog --- app/assets/stylesheets/test.css.scss | 7 ++ app/models/ground_picture.rb | 13 ++++ app/models/original_picture_license.rb | 1 + app/models/panel_picture.rb | 13 ++++ app/models/resource_picture.rb | 13 ++++ app/views/templates/r/dialog/_body.html.erb | 6 ++ app/views/templates/r/dialog/_dialog.html.erb | 5 ++ app/views/templates/r/dialog/_file_body.html.erb | 3 + app/views/templates/r/dialog/_file_header.html.erb | 8 ++ app/views/templates/r/dialog/_file_item.html.erb | 8 ++ app/views/templates/r/dialog/_header.html.erb | 4 + .../templates/r/dialog/button/_default.html.erb | 1 + .../templates/r/dialog/caption/_default.html.erb | 1 + .../dialog/caption/_default_without_link.html.erb | 1 + .../templates/r/dialog/caption/_none.html.erb | 0 .../r/dialog/caption_face/_column.html.erb | 1 + .../r/dialog/caption_face/_empty.html.erb | 1 + .../r/dialog/caption_face/_method.html.erb | 1 + .../templates/r/dialog/caption_face/_none.html.erb | 0 .../templates/r/dialog/date/_default.html.erb | 1 + app/views/templates/r/dialog/date/_none.html.erb | 0 app/views/templates/r/dialog/dialog.html.erb | 1 + .../templates/r/dialog/edit/_account.html.erb | 1 + .../templates/r/dialog/edit/_default.html.erb | 2 + app/views/templates/r/dialog/edit/_none.html.erb | 0 .../templates/r/dialog/edit/_template.html.erb | 1 + .../r/dialog/header_column/_none.html.erb | 0 .../r/dialog/header_column/_show.html.erb | 3 + .../templates/r/dialog/icon/_default.html.erb | 1 + app/views/templates/r/dialog/icon/_none.html.erb | 0 .../templates/r/dialog/item_column/_none.html.erb | 0 .../templates/r/dialog/item_column/_show.html.erb | 3 + .../templates/r/dialog/pager/_default.html.erb | 3 + app/views/templates/r/dialog/pager/_more.html.erb | 3 + app/views/templates/r/dialog/pager/_none.html.erb | 0 .../templates/r/dialog/summary/_none.html.erb | 0 .../templates/r/dialog/summary/_template.html.erb | 1 + .../templates/r/dialog/symbol/_default.html.erb | 1 + .../r/dialog/symbol/_default_without_link.html.erb | 1 + .../templates/r/dialog/symbol/_template.html.erb | 1 + .../templates/r/dialog/symbol_face/_image.html.erb | 1 + .../r/dialog/symbol_face/_picture.html.erb | 1 + config/environments/test.rb | 1 - lib/local_manifest/filer.rb | 6 +- lib/local_manifest/filer/button.rb | 22 ++++++ lib/local_manifest/filer/button/base.rb | 30 ++++++++ lib/local_manifest/filer/button/default.rb | 21 ++++++ lib/locmare/dialog.rb | 25 ++++++ lib/locmare/dialog/body.rb | 17 +++++ lib/locmare/dialog/body/file_body.rb | 14 ++++ lib/locmare/dialog/body/file_body/file_item.rb | 18 +++++ .../dialog/body/file_body/file_item/button.rb | 25 ++++++ .../dialog/body/file_body/file_item/button/base.rb | 88 ++++++++++++++++++++++ lib/locmare/dialog/body/file_header.rb | 16 ++++ lib/locmare/filer.rb | 7 +- lib/locmare/filer/body.rb | 12 ++- lib/locmare/filer/body/file_body.rb | 6 +- lib/locmare/locmare.rb | 1 + lib/peta/item.rb | 20 +++++ 59 files changed, 434 insertions(+), 7 deletions(-) create mode 100644 app/views/templates/r/dialog/_body.html.erb create mode 100644 app/views/templates/r/dialog/_dialog.html.erb create mode 100644 app/views/templates/r/dialog/_file_body.html.erb create mode 100644 app/views/templates/r/dialog/_file_header.html.erb create mode 100644 app/views/templates/r/dialog/_file_item.html.erb create mode 100644 app/views/templates/r/dialog/_header.html.erb create mode 100644 app/views/templates/r/dialog/button/_default.html.erb create mode 100644 app/views/templates/r/dialog/caption/_default.html.erb create mode 100644 app/views/templates/r/dialog/caption/_default_without_link.html.erb create mode 100644 app/views/templates/r/dialog/caption/_none.html.erb create mode 100644 app/views/templates/r/dialog/caption_face/_column.html.erb create mode 100644 app/views/templates/r/dialog/caption_face/_empty.html.erb create mode 100644 app/views/templates/r/dialog/caption_face/_method.html.erb create mode 100644 app/views/templates/r/dialog/caption_face/_none.html.erb create mode 100644 app/views/templates/r/dialog/date/_default.html.erb create mode 100644 app/views/templates/r/dialog/date/_none.html.erb create mode 100644 app/views/templates/r/dialog/dialog.html.erb create mode 100644 app/views/templates/r/dialog/edit/_account.html.erb create mode 100644 app/views/templates/r/dialog/edit/_default.html.erb create mode 100644 app/views/templates/r/dialog/edit/_none.html.erb create mode 100644 app/views/templates/r/dialog/edit/_template.html.erb create mode 100644 app/views/templates/r/dialog/header_column/_none.html.erb create mode 100644 app/views/templates/r/dialog/header_column/_show.html.erb create mode 100644 app/views/templates/r/dialog/icon/_default.html.erb create mode 100644 app/views/templates/r/dialog/icon/_none.html.erb create mode 100644 app/views/templates/r/dialog/item_column/_none.html.erb create mode 100644 app/views/templates/r/dialog/item_column/_show.html.erb create mode 100644 app/views/templates/r/dialog/pager/_default.html.erb create mode 100644 app/views/templates/r/dialog/pager/_more.html.erb create mode 100644 app/views/templates/r/dialog/pager/_none.html.erb create mode 100644 app/views/templates/r/dialog/summary/_none.html.erb create mode 100644 app/views/templates/r/dialog/summary/_template.html.erb create mode 100644 app/views/templates/r/dialog/symbol/_default.html.erb create mode 100644 app/views/templates/r/dialog/symbol/_default_without_link.html.erb create mode 100644 app/views/templates/r/dialog/symbol/_template.html.erb create mode 100644 app/views/templates/r/dialog/symbol_face/_image.html.erb create mode 100644 app/views/templates/r/dialog/symbol_face/_picture.html.erb create mode 100644 lib/local_manifest/filer/button.rb create mode 100644 lib/local_manifest/filer/button/base.rb create mode 100644 lib/local_manifest/filer/button/default.rb create mode 100644 lib/locmare/dialog.rb create mode 100644 lib/locmare/dialog/body.rb create mode 100644 lib/locmare/dialog/body/file_body.rb create mode 100644 lib/locmare/dialog/body/file_body/file_item.rb create mode 100644 lib/locmare/dialog/body/file_body/file_item/button.rb create mode 100644 lib/locmare/dialog/body/file_body/file_item/button/base.rb create mode 100644 lib/locmare/dialog/body/file_header.rb diff --git a/app/assets/stylesheets/test.css.scss b/app/assets/stylesheets/test.css.scss index f0a92786..87f1dae6 100644 --- a/app/assets/stylesheets/test.css.scss +++ b/app/assets/stylesheets/test.css.scss @@ -393,6 +393,9 @@ font-family : monospace; .filer-item div { } +.filer-head-button { + width: 66px; +} .filer-head-symbol { width: 66px; } @@ -412,6 +415,10 @@ font-family : monospace; width: 66px; } +.filer-item-button { + float: left; + width: 66px; +} .filer-item-symbol { float: left; width: 66px; diff --git a/app/models/ground_picture.rb b/app/models/ground_picture.rb index 3ca5a11c..29e562a2 100644 --- a/app/models/ground_picture.rb +++ b/app/models/ground_picture.rb @@ -13,6 +13,19 @@ class GroundPicture < Peta::Element @@repeat_texts = ['repeat', 'repeat-x', 'repeat-y', 'no-repeat'] + def self.pickup_item_name + Picture.item_name + end + + def self.pickup_column_name + self.pickup_item_name + '_id' + end + + def pickup_id + # get :picture_id if head revision + self.attributes[self.pickup_column_name] + end + def attr_y self.attributes['y'] end diff --git a/app/models/original_picture_license.rb b/app/models/original_picture_license.rb index 933d3c35..c2596443 100644 --- a/app/models/original_picture_license.rb +++ b/app/models/original_picture_license.rb @@ -26,6 +26,7 @@ class OriginalPictureLicense < Peta::Item :license_group_settings => opl.license.license_group_settings, :credit_picture_settings => opl.license.credit_picture_settings ) + attr.delete :id resource_picture = my_model_class.new resource_picture.attributes = attr resource_picture.overwrite original_picture diff --git a/app/models/panel_picture.rb b/app/models/panel_picture.rb index 5a60b53e..e0da3dca 100644 --- a/app/models/panel_picture.rb +++ b/app/models/panel_picture.rb @@ -13,6 +13,19 @@ class PanelPicture < Peta::Element validates :z, :presence => true, :numericality => {:greater_than => 0} validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0} + def self.pickup_item_name + Picture.item_name + end + + def self.pickup_column_name + self.pickup_item_name + '_id' + end + + def pickup_id + # get :picture_id if head revision + self.attributes[self.pickup_column_name] + end + def attr_y self.attributes['y'] end diff --git a/app/models/resource_picture.rb b/app/models/resource_picture.rb index a43698a1..57c2a8e2 100644 --- a/app/models/resource_picture.rb +++ b/app/models/resource_picture.rb @@ -23,6 +23,19 @@ class ResourcePicture < Peta::Content validates :license_group_settings, :boost => {:boost_name => :license_group} validates :credit_picture_settings, :boost => {:boost_name => :credit_picture} + def self.pickup_item_name + Picture.item_name + end + + def self.pickup_column_name + self.pickup_item_name + '_id' + end + + def pickup_id + # get head picture + self.attributes[self.pickup_column_name] + end + def supply_default end diff --git a/app/views/templates/r/dialog/_body.html.erb b/app/views/templates/r/dialog/_body.html.erb new file mode 100644 index 00000000..332e4b6e --- /dev/null +++ b/app/views/templates/r/dialog/_body.html.erb @@ -0,0 +1,6 @@ + +
+
diff --git a/app/views/templates/r/dialog/_dialog.html.erb b/app/views/templates/r/dialog/_dialog.html.erb new file mode 100644 index 00000000..7c5f52e6 --- /dev/null +++ b/app/views/templates/r/dialog/_dialog.html.erb @@ -0,0 +1,5 @@ +
+ <%= render filer.header.template_name, :header => filer.header %> + <%= render filer.body.template_name, :body => filer.body %> + <%= render filer.pager.template_name, :pager => filer.pager %> +
diff --git a/app/views/templates/r/dialog/_file_body.html.erb b/app/views/templates/r/dialog/_file_body.html.erb new file mode 100644 index 00000000..5430b3af --- /dev/null +++ b/app/views/templates/r/dialog/_file_body.html.erb @@ -0,0 +1,3 @@ +<% file_body.file_items.each do |file_item| %> + <%= render file_item.template_name, :file_item => file_item %> +<% end %> diff --git a/app/views/templates/r/dialog/_file_header.html.erb b/app/views/templates/r/dialog/_file_header.html.erb new file mode 100644 index 00000000..f46b7ad1 --- /dev/null +++ b/app/views/templates/r/dialog/_file_header.html.erb @@ -0,0 +1,8 @@ +
  • + <%= render file_header.button.template_name, :header_column => file_header.button %> + <%= render file_header.symbol.template_name, :header_column => file_header.symbol %> + <%= render file_header.caption.template_name, :header_column => file_header.caption %> + <%= render file_header.summary.template_name, :header_column => file_header.summary %> + <%= render file_header.icon.template_name, :header_column => file_header.icon %> + <%= render file_header.date.template_name, :header_column => file_header.date %> +
  • diff --git a/app/views/templates/r/dialog/_file_item.html.erb b/app/views/templates/r/dialog/_file_item.html.erb new file mode 100644 index 00000000..d6052dda --- /dev/null +++ b/app/views/templates/r/dialog/_file_item.html.erb @@ -0,0 +1,8 @@ +
  • + <%= render file_item.button.column_template_name, :item_column => file_item.button %> + <%= render file_item.symbol.column_template_name, :item_column => file_item.symbol %> + <%= render file_item.caption.column_template_name, :item_column => file_item.caption %> + <%= render file_item.summary.column_template_name, :item_column => file_item.summary %> + <%= render file_item.icon.column_template_name, :item_column => file_item.icon %> + <%= render file_item.date.column_template_name, :item_column => file_item.date %> +
  • diff --git a/app/views/templates/r/dialog/_header.html.erb b/app/views/templates/r/dialog/_header.html.erb new file mode 100644 index 00000000..d2d73dc3 --- /dev/null +++ b/app/views/templates/r/dialog/_header.html.erb @@ -0,0 +1,4 @@ +
    + <%= link_to icon_tag(header.icon_name, :size => header.icon_size), __send__(header.model.path_name + '_path') %> + <%= link_to header.model.model_name.human, __send__(header.model.path_name + '_path') %> +
    diff --git a/app/views/templates/r/dialog/button/_default.html.erb b/app/views/templates/r/dialog/button/_default.html.erb new file mode 100644 index 00000000..f1b62cf1 --- /dev/null +++ b/app/views/templates/r/dialog/button/_default.html.erb @@ -0,0 +1 @@ +select diff --git a/app/views/templates/r/dialog/caption/_default.html.erb b/app/views/templates/r/dialog/caption/_default.html.erb new file mode 100644 index 00000000..4de6a024 --- /dev/null +++ b/app/views/templates/r/dialog/caption/_default.html.erb @@ -0,0 +1 @@ +<%= link_to render(item_column.face.template_name, :face => item_column.face), item_column.link.url %> diff --git a/app/views/templates/r/dialog/caption/_default_without_link.html.erb b/app/views/templates/r/dialog/caption/_default_without_link.html.erb new file mode 100644 index 00000000..5dff30c0 --- /dev/null +++ b/app/views/templates/r/dialog/caption/_default_without_link.html.erb @@ -0,0 +1 @@ +<%= render item_column.face.template_name, :face => item_column.face %> diff --git a/app/views/templates/r/dialog/caption/_none.html.erb b/app/views/templates/r/dialog/caption/_none.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/views/templates/r/dialog/caption_face/_column.html.erb b/app/views/templates/r/dialog/caption_face/_column.html.erb new file mode 100644 index 00000000..40be8bdd --- /dev/null +++ b/app/views/templates/r/dialog/caption_face/_column.html.erb @@ -0,0 +1 @@ +<%= face.face %> diff --git a/app/views/templates/r/dialog/caption_face/_empty.html.erb b/app/views/templates/r/dialog/caption_face/_empty.html.erb new file mode 100644 index 00000000..544012be --- /dev/null +++ b/app/views/templates/r/dialog/caption_face/_empty.html.erb @@ -0,0 +1 @@ +<%= 'empty' %> diff --git a/app/views/templates/r/dialog/caption_face/_method.html.erb b/app/views/templates/r/dialog/caption_face/_method.html.erb new file mode 100644 index 00000000..40be8bdd --- /dev/null +++ b/app/views/templates/r/dialog/caption_face/_method.html.erb @@ -0,0 +1 @@ +<%= face.face %> diff --git a/app/views/templates/r/dialog/caption_face/_none.html.erb b/app/views/templates/r/dialog/caption_face/_none.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/views/templates/r/dialog/date/_default.html.erb b/app/views/templates/r/dialog/date/_default.html.erb new file mode 100644 index 00000000..b2409477 --- /dev/null +++ b/app/views/templates/r/dialog/date/_default.html.erb @@ -0,0 +1 @@ +<%= distance_of_time_in_words_to_now item_column.item.updated_at %> diff --git a/app/views/templates/r/dialog/date/_none.html.erb b/app/views/templates/r/dialog/date/_none.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/views/templates/r/dialog/dialog.html.erb b/app/views/templates/r/dialog/dialog.html.erb new file mode 100644 index 00000000..a2dc13ad --- /dev/null +++ b/app/views/templates/r/dialog/dialog.html.erb @@ -0,0 +1 @@ +<%= render filer.template_name, :filer => filer %> diff --git a/app/views/templates/r/dialog/edit/_account.html.erb b/app/views/templates/r/dialog/edit/_account.html.erb new file mode 100644 index 00000000..7141e054 --- /dev/null +++ b/app/views/templates/r/dialog/edit/_account.html.erb @@ -0,0 +1 @@ +<%= link_to tag(:img, item_column.edit_img_opt),'/home/configure' %> diff --git a/app/views/templates/r/dialog/edit/_default.html.erb b/app/views/templates/r/dialog/edit/_default.html.erb new file mode 100644 index 00000000..2b42f1ed --- /dev/null +++ b/app/views/templates/r/dialog/edit/_default.html.erb @@ -0,0 +1,2 @@ +<%= link_to tag(:img, item_column.edit_img_opt), polymorphic_path(item_column.item, :action => :edit) %> +<%= link_to tag(:img, item_column.remove_img_opt), item_column.item, confirm: 'Are you sure?', :method => :delete %> diff --git a/app/views/templates/r/dialog/edit/_none.html.erb b/app/views/templates/r/dialog/edit/_none.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/views/templates/r/dialog/edit/_template.html.erb b/app/views/templates/r/dialog/edit/_template.html.erb new file mode 100644 index 00000000..8ba1a023 --- /dev/null +++ b/app/views/templates/r/dialog/edit/_template.html.erb @@ -0,0 +1 @@ +<%= render item_column.template_name, :item => item_column.item %> diff --git a/app/views/templates/r/dialog/header_column/_none.html.erb b/app/views/templates/r/dialog/header_column/_none.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/views/templates/r/dialog/header_column/_show.html.erb b/app/views/templates/r/dialog/header_column/_show.html.erb new file mode 100644 index 00000000..129bcd7e --- /dev/null +++ b/app/views/templates/r/dialog/header_column/_show.html.erb @@ -0,0 +1,3 @@ +
    + <%= t 'filer.header.' + header_column.column_name -%> +
    diff --git a/app/views/templates/r/dialog/icon/_default.html.erb b/app/views/templates/r/dialog/icon/_default.html.erb new file mode 100644 index 00000000..899a1fe5 --- /dev/null +++ b/app/views/templates/r/dialog/icon/_default.html.erb @@ -0,0 +1 @@ +<%= link_to tag(:img, :src => item_column.icon_file_name, :width => item_column.icon_size, :height => item_column.icon_size), polymorphic_path(item_column.item, :format => :prof) %> diff --git a/app/views/templates/r/dialog/icon/_none.html.erb b/app/views/templates/r/dialog/icon/_none.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/views/templates/r/dialog/item_column/_none.html.erb b/app/views/templates/r/dialog/item_column/_none.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/views/templates/r/dialog/item_column/_show.html.erb b/app/views/templates/r/dialog/item_column/_show.html.erb new file mode 100644 index 00000000..cd9d10a7 --- /dev/null +++ b/app/views/templates/r/dialog/item_column/_show.html.erb @@ -0,0 +1,3 @@ +
    + <%= render item_column.item_template_name, :item_column => item_column %> +
    diff --git a/app/views/templates/r/dialog/pager/_default.html.erb b/app/views/templates/r/dialog/pager/_default.html.erb new file mode 100644 index 00000000..938994ee --- /dev/null +++ b/app/views/templates/r/dialog/pager/_default.html.erb @@ -0,0 +1,3 @@ +<% if pager.paginate %> + <%= paginate(pager.paginate) %> +<% end %> diff --git a/app/views/templates/r/dialog/pager/_more.html.erb b/app/views/templates/r/dialog/pager/_more.html.erb new file mode 100644 index 00000000..dfa3d9a9 --- /dev/null +++ b/app/views/templates/r/dialog/pager/_more.html.erb @@ -0,0 +1,3 @@ +
    + <%= link_to 'more', pager.api_path %> +
    diff --git a/app/views/templates/r/dialog/pager/_none.html.erb b/app/views/templates/r/dialog/pager/_none.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/views/templates/r/dialog/summary/_none.html.erb b/app/views/templates/r/dialog/summary/_none.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/views/templates/r/dialog/summary/_template.html.erb b/app/views/templates/r/dialog/summary/_template.html.erb new file mode 100644 index 00000000..8ba1a023 --- /dev/null +++ b/app/views/templates/r/dialog/summary/_template.html.erb @@ -0,0 +1 @@ +<%= render item_column.template_name, :item => item_column.item %> diff --git a/app/views/templates/r/dialog/symbol/_default.html.erb b/app/views/templates/r/dialog/symbol/_default.html.erb new file mode 100644 index 00000000..4de6a024 --- /dev/null +++ b/app/views/templates/r/dialog/symbol/_default.html.erb @@ -0,0 +1 @@ +<%= link_to render(item_column.face.template_name, :face => item_column.face), item_column.link.url %> diff --git a/app/views/templates/r/dialog/symbol/_default_without_link.html.erb b/app/views/templates/r/dialog/symbol/_default_without_link.html.erb new file mode 100644 index 00000000..5dff30c0 --- /dev/null +++ b/app/views/templates/r/dialog/symbol/_default_without_link.html.erb @@ -0,0 +1 @@ +<%= render item_column.face.template_name, :face => item_column.face %> diff --git a/app/views/templates/r/dialog/symbol/_template.html.erb b/app/views/templates/r/dialog/symbol/_template.html.erb new file mode 100644 index 00000000..8ba1a023 --- /dev/null +++ b/app/views/templates/r/dialog/symbol/_template.html.erb @@ -0,0 +1 @@ +<%= render item_column.template_name, :item => item_column.item %> diff --git a/app/views/templates/r/dialog/symbol_face/_image.html.erb b/app/views/templates/r/dialog/symbol_face/_image.html.erb new file mode 100644 index 00000000..241bdc8c --- /dev/null +++ b/app/views/templates/r/dialog/symbol_face/_image.html.erb @@ -0,0 +1 @@ +<%= tag :img, face.tag_opt %> diff --git a/app/views/templates/r/dialog/symbol_face/_picture.html.erb b/app/views/templates/r/dialog/symbol_face/_picture.html.erb new file mode 100644 index 00000000..241bdc8c --- /dev/null +++ b/app/views/templates/r/dialog/symbol_face/_picture.html.erb @@ -0,0 +1 @@ +<%= tag :img, face.tag_opt %> diff --git a/config/environments/test.rb b/config/environments/test.rb index 84441a45..3ceac7c9 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,4 +1,3 @@ -require 'element' Pettanr::Application.configure do # Settings specified here will take precedence over those in config/application.rb diff --git a/lib/local_manifest/filer.rb b/lib/local_manifest/filer.rb index 2d5cee53..89919d1e 100644 --- a/lib/local_manifest/filer.rb +++ b/lib/local_manifest/filer.rb @@ -1,12 +1,12 @@ ManifestBase.require_modules "local_manifest/filer/", - %w|symbol caption summary icon date edit| + %w|symbol caption summary icon date edit button| module LocalManifest class Filer < ManifestBase::Base include FilerModule attr :item_class, - :symbol, :caption, :summary, :icon, :date, :edit + :symbol, :caption, :summary, :icon, :date, :edit, :button def set_default super @@ -17,6 +17,7 @@ module LocalManifest @json['icon'] ||= {} @json['date'] ||= {} @json['edit'] ||= {} + @json['button'] ||= {} end def init @@ -27,6 +28,7 @@ module LocalManifest @icon = ManifestBase.load_type_args self, @json, 'icon', IconFactory @date = ManifestBase.load_type_args self, @json, 'date', DateFactory @edit = ManifestBase.load_type_args self, @json, 'edit', EditFactory + @button = ManifestBase.load_type_args self, @json, 'button', ButtonFactory end def item_name diff --git a/lib/local_manifest/filer/button.rb b/lib/local_manifest/filer/button.rb new file mode 100644 index 00000000..665d5c64 --- /dev/null +++ b/lib/local_manifest/filer/button.rb @@ -0,0 +1,22 @@ +ManifestBase.require_modules "local_manifest/filer/button/", + %w|base default| + +module LocalManifest + module FilerModule + class ButtonFactory < ManifestBase::Factory + include ButtonModule + + def self.types + { + 'default' => Default + } + end + + def self.default_type + 'default' + end + + end + + end +end diff --git a/lib/local_manifest/filer/button/base.rb b/lib/local_manifest/filer/button/base.rb new file mode 100644 index 00000000..a63a86c9 --- /dev/null +++ b/lib/local_manifest/filer/button/base.rb @@ -0,0 +1,30 @@ +module LocalManifest + module FilerModule + module ButtonModule + class Base < ManifestBase::TypeArgs + + def set_default + super + end + + def init + super + end + + def filer_name + @parent.name + end + + def filer + @parent + end + + def visible? + true + end + + end + + end + end +end diff --git a/lib/local_manifest/filer/button/default.rb b/lib/local_manifest/filer/button/default.rb new file mode 100644 index 00000000..f8b0677d --- /dev/null +++ b/lib/local_manifest/filer/button/default.rb @@ -0,0 +1,21 @@ + +module LocalManifest + module FilerModule + module ButtonModule + class Default < Base + #attr :face, :link + + def set_default + super + #@args['face'] ||= {} + end + + def init + super + #@face = ManifestBase.load_type_args self, @args, 'face', FaceFactory + end + + end + end + end +end diff --git a/lib/locmare/dialog.rb b/lib/locmare/dialog.rb new file mode 100644 index 00000000..100ab831 --- /dev/null +++ b/lib/locmare/dialog.rb @@ -0,0 +1,25 @@ +require_dependency "locmare/dialog/body" +module Locmare + class Dialog < Filer + # duplicate define + #include DialogModule + + attr :pickup_item_name + + def initialize item_name, items, list_result, pager_type, operators, pickup_item_name + @pickup_item_name = pickup_item_name + super item_name, items, list_result, pager_type, operators + @template_dir = 'templates/r/dialog/' + end + + def mybody + DialogModule::Body + end + + def template_file_name + "dialog" + end + + end +end + diff --git a/lib/locmare/dialog/body.rb b/lib/locmare/dialog/body.rb new file mode 100644 index 00000000..43aa832b --- /dev/null +++ b/lib/locmare/dialog/body.rb @@ -0,0 +1,17 @@ +require_dependency "locmare/dialog/body/file_header" +require_dependency "locmare/dialog/body/file_body" +module Locmare + module DialogModule + class Body < FilerModule::Body + + def file_header_class + DialogModule::BodyModule::FileHeader + end + + def file_body_class + DialogModule::BodyModule::FileBody + end + + end + end +end diff --git a/lib/locmare/dialog/body/file_body.rb b/lib/locmare/dialog/body/file_body.rb new file mode 100644 index 00000000..42771757 --- /dev/null +++ b/lib/locmare/dialog/body/file_body.rb @@ -0,0 +1,14 @@ +require_dependency "locmare/dialog/body/file_body/file_item" +module Locmare + module DialogModule + module BodyModule + class FileBody < FilerModule::BodyModule::FileBody + + def file_item_class + DialogModule::BodyModule::FileBodyModule::FileItem + end + + end + end + end +end diff --git a/lib/locmare/dialog/body/file_body/file_item.rb b/lib/locmare/dialog/body/file_body/file_item.rb new file mode 100644 index 00000000..0f000825 --- /dev/null +++ b/lib/locmare/dialog/body/file_body/file_item.rb @@ -0,0 +1,18 @@ +require_dependency "locmare/dialog/body/file_body/file_item/button" +module Locmare + module DialogModule + module BodyModule + module FileBodyModule + class FileItem < FilerModule::BodyModule::FileBodyModule::FileItem + include DialogModule::BodyModule::FileBodyModule::FileItemModule + + attr :button + def initialize file_body, item + super + @button = ButtonItemColumnFactory.factory self, self.filer.manifest.button, @item + end + end + end + end + end +end diff --git a/lib/locmare/dialog/body/file_body/file_item/button.rb b/lib/locmare/dialog/body/file_body/file_item/button.rb new file mode 100644 index 00000000..c63ceaac --- /dev/null +++ b/lib/locmare/dialog/body/file_body/file_item/button.rb @@ -0,0 +1,25 @@ +require_dependency "locmare/dialog/body/file_body/file_item/button/base" +module Locmare + module DialogModule + module BodyModule + module FileBodyModule + module FileItemModule + class ButtonItemColumnFactory + include ButtonItemColumnModule + @@types = { + 'default' => Default + } + def self.factory file_item, my_manifest, item + type = my_manifest.type + raise "undefined type for local view filers > #{file_item.item_name} > edit\n" unless type + my_class = @@types[type] + raise "undefined class for local view filers > #{file_item.item_name} > edit > #{type}\n" unless my_class + my_class.new(file_item, my_manifest, item) + end + + end + end + end + end + end +end diff --git a/lib/locmare/dialog/body/file_body/file_item/button/base.rb b/lib/locmare/dialog/body/file_body/file_item/button/base.rb new file mode 100644 index 00000000..a029da73 --- /dev/null +++ b/lib/locmare/dialog/body/file_body/file_item/button/base.rb @@ -0,0 +1,88 @@ +module Locmare + module DialogModule + module BodyModule + module FileBodyModule + module FileItemModule + module ButtonItemColumnModule + class Base + attr :file_item, :button_manifest, :item, :column_name + + def initialize file_item, button_manifest, item + @file_item = file_item + @button_manifest = button_manifest + @item = item + @column_name = 'button' + end + + def filer + @file_item.filer + end + + def manifest + self.filer.manifest + end + + def item_name + self.filer.item_name + end + + def image_dir + self.filer.image_dir + end + + def column_template_dir + self.filer.template_dir + 'item_column/' + end + + def column_template_file_name + raise "undefined column_template_file_name\n" + end + + def column_template_name + self.column_template_dir + self.column_template_file_name + end + + def item_template_dir + self.filer.template_dir + 'button/' + end + + def item_template_file_name + raise "undefined item_template_file_name\n" + end + + def item_template_name + self.item_template_dir + self.item_template_file_name + end + + end + + class Default < Base + def column_template_file_name + 'show' + end + + def item_template_file_name + 'default' + end + + def pickup_img_file_name + self.image_dir + 'pickup.png' + end + + def img_opt + {:width => Manifest.manifest.magic_numbers['thumbnail_width'] / 2, + :height => Manifest.manifest.magic_numbers['thumbnail_height'] / 2} + end + + def pickup_img_opt + img_opt.merge :src => self.pickup_img_file_name + end + + end + + end + end + end + end + end +end diff --git a/lib/locmare/dialog/body/file_header.rb b/lib/locmare/dialog/body/file_header.rb new file mode 100644 index 00000000..570a03af --- /dev/null +++ b/lib/locmare/dialog/body/file_header.rb @@ -0,0 +1,16 @@ +module Locmare + module DialogModule + module BodyModule + class FileHeader < FilerModule::BodyModule::FileHeader + attr :button + + def initialize body + super + c = self.filer.manifest.button.visible? ? Show : None + @button = c.new self, 'button' + end + + end + end + end +end diff --git a/lib/locmare/filer.rb b/lib/locmare/filer.rb index fb2a9c5a..0df34928 100644 --- a/lib/locmare/filer.rb +++ b/lib/locmare/filer.rb @@ -17,7 +17,7 @@ module Locmare @manifest = LocalManifest.manifest.filers[@item_name] @template_dir = 'templates/r/filer/' @header = Header.new self - @body = Body.new self + @body = self.mybody.new self self.init_pager end @@ -33,6 +33,11 @@ module Locmare ::Manifest::item_name_to_model @item_name end + # switch body class for dialog + def mybody + Body + end + def template_file_name "filer" end diff --git a/lib/locmare/filer/body.rb b/lib/locmare/filer/body.rb index 017e8245..56c1ff5b 100644 --- a/lib/locmare/filer/body.rb +++ b/lib/locmare/filer/body.rb @@ -8,8 +8,16 @@ module Locmare :file_header, :file_body def initialize filer @filer = filer - @file_header = FileHeader.new self - @file_body = FileBody.new self + @file_header = self.file_header_class.new self + @file_body = self.file_body_class.new self + end + + def file_header_class + FileHeader + end + + def file_body_class + FileBody end def manifest diff --git a/lib/locmare/filer/body/file_body.rb b/lib/locmare/filer/body/file_body.rb index 850c32b5..6df4bf46 100644 --- a/lib/locmare/filer/body/file_body.rb +++ b/lib/locmare/filer/body/file_body.rb @@ -8,10 +8,14 @@ module Locmare def initialize body @body = body @file_items = self.items.map {|item| - FileItem.new self, item + self.file_item_class.new self, item } end + def file_item_class + FileItem + end + def filer @body.filer end diff --git a/lib/locmare/locmare.rb b/lib/locmare/locmare.rb index 50b8c251..26c474d1 100644 --- a/lib/locmare/locmare.rb +++ b/lib/locmare/locmare.rb @@ -1,4 +1,5 @@ require_dependency "locmare/filer" +require_dependency "locmare/dialog" require_dependency "locmare/form" require_dependency "locmare/profiler" require_dependency "locmare/list_group" diff --git a/lib/peta/item.rb b/lib/peta/item.rb index 138b68a6..294c162f 100644 --- a/lib/peta/item.rb +++ b/lib/peta/item.rb @@ -87,6 +87,14 @@ module Peta self.plural.underscore end + def self.pickup_item_name + self.item_name + end + + def self.pickup_column_name + 'id' + end + def self.find_boost_name column_name self.my_peta.find_boost_name column_name end @@ -155,6 +163,18 @@ module Peta self.class.path_name(with_engine) end + def pickup_item_name + self.class.pickup_item_name + end + + def pickup_column_name + self.class.pickup_column_name + end + + def pickup_id + self.attributes[self.pickup_column_name] + end + def form_template with_engine = false self.path_name(with_engine) + '/form' end -- 2.11.0