OSDN Git Service

fix model
authoryasushiito <yas@pen-chan.jp>
Sat, 8 Mar 2014 03:28:10 +0000 (12:28 +0900)
committeryasushiito <yas@pen-chan.jp>
Sat, 8 Mar 2014 03:28:10 +0000 (12:28 +0900)
17 files changed:
app/models/balloon.rb
app/models/ground_color.rb
app/models/ground_picture.rb
app/models/panel.rb
app/models/panel_picture.rb
app/models/scroll.rb
app/models/scroll_panel.rb
app/models/sheet.rb
app/models/sheet_panel.rb
app/models/speech.rb
app/models/speech_balloon.rb
app/models/story.rb
app/models/story_sheet.rb
app/views/panels/_body.html.erb
lib/peta/element.rb
lib/peta/item.rb
public/manifest.json

index b36a825..8f08c83 100644 (file)
@@ -1,6 +1,5 @@
 class Balloon < Peta::Content
   load_manifest
-  include Peta::ElementPart
   belongs_to :speech_balloon
   belongs_to :system_picture
   
@@ -14,14 +13,6 @@ class Balloon < Peta::Content
 #  validates :caption, :presence => true
   validates :settings, :extend_balloon => true
 
-  def self.colum_structures
-    @@colum_structures ||= {
-      :r => {
-        :helper => 'panels/tail_angle_helper'
-      }
-    }
-  end
-  
   def url
     '/system_pictures/' + self.system_picture.filename
   end
@@ -44,14 +35,6 @@ self.system_picture_id = 1
     self.get_parent.speech_balloon_template.symbol_option
   end
   
-  def get_parent
-    self.speech_balloon || @new_parent
-  end
-  
-  def tag_element_part_type
-    'balloon'
-  end
-  
   def self.list_where
     'panels.publish > 0'
   end
index cf78ded..f8036bd 100644 (file)
@@ -12,14 +12,6 @@ class GroundColor < Peta::Element
   validates :z, :presence => true, :numericality => {:greater_than => 0}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
-  def self.colum_structures
-    @@colum_structures ||= {
-      :code => {
-        :helper => 'panels/color_helper'
-      }
-    }
-  end
-  
   def self.list_opt_for_panel
     {
       :ground_colors => {
@@ -111,13 +103,6 @@ class GroundColor < Peta::Element
     r
   end
   
-  def boost
-  end
-  
-  def tag_element_type
-    'ground_color'
-  end
-  
   def self.list_where
     'panels.publish > 0'
   end
index 779848d..fe67caa 100644 (file)
@@ -79,13 +79,6 @@ class GroundPicture < Peta::Element
     self.tmb_opt_img_tag
   end
   
-  def boost
-  end
-  
-  def tag_element_type
-    'ground_picture'
-  end
-  
   def repeat_text
     @@repeat_texts[self.repeat]
   end
index 1c81e69..c2e0b60 100644 (file)
@@ -19,10 +19,6 @@ class Panel < Peta::Content
   validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :publish, :presence => true, :numericality => true
   
-  def self.valid_encode_columns
-    super + ['caption']
-  end
-  
   def self.each_element_class_names
     Manifest.manifest.system_resources.elements.each do |k, n|
       yield k
@@ -68,60 +64,21 @@ class Panel < Peta::Content
     self.publish > 0
   end
   
-  # ground_picture element template 
-  def style_wh
+  def style
     {
-      'width' => self.width.to_s + 'px', 'height' => self.height.to_s + 'px'
+      'width' => self.width.to_s + 'px', 'height' => self.height.to_s + 'px', 
+      'border-style' => 'solid', 'border-width' => self.border.to_s + 'px', 
+      'border-color' => 'black', 'background-color' => 'white'
     }
   end
   
-  def tag_id c = nil
-    'panel' + self.tag_panel_id + c.to_s
-  end
-  
-  def tag_panel_id
-    self.new_record? ? '0' : self.id.to_s
-  end
-  
-  def field_tag_id f
-    self.tag_id + f.to_s
-  end
-  
-  def tag_attributes column = nil, opt = {}
+  # ground_picture element template 
+  def style_wh
     {
-      :id => self.field_tag_id(column), :panel_id => self.tag_panel_id
-    }.merge(opt)
-  end
-  
-  def select_tag_attributes(selected, column, opt = {})
-    [
-      {:html => {:selected => selected}}, 
-      self.field_tag_attributes(column, opt)
-    ]
-  end
-  
-  def field_tag_attributes column, no_attr, opt = {}
-    self.tag_attributes(column).merge(
-      {:column => column}
-    ).merge(opt)
-  end
-  
-  def tag_attr column = nil, opt = {}
-    self.tag_attributes(column, opt).to_attr
-  end
-  
-  def field_tag_attr column, no_attr, opt = {}
-    self.field_tag_attributes(column, no_attr, opt).to_attr
+      'width' => self.width.to_s + 'px', 'height' => self.height.to_s + 'px'
+    }
   end
   
-    def render_count
-      @render_count ||= 1
-    end
-    
-    def rendered
-      @render_count = render_count + 1
-    end
-    
   def self.list_where
     'panels.publish > 0'
   end
@@ -268,16 +225,6 @@ class Panel < Peta::Content
     Panel.validate_elements_serial validate_serial_list
   end
   
-  def boost
-    @new_element_index = 0
-    self.panel_elements.each do |elm|
-      if elm.new_record?
-        elm.new_index = @new_element_index
-        @new_element_index += 1
-      end
-    end
-  end 
-  
   def store attr, operators
     if attr == false
       self.errors.add :base, I18n.t('errors.invalid_json')
index 4c463d9..e79836a 100644 (file)
@@ -14,17 +14,6 @@ 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.colum_structures
-    @@colum_structures ||= {
-      :width => {
-        :helper => 'panels/size_helper'
-      }, 
-      :height => {
-        :helper => 'panels/size_helper'
-      }
-    }
-  end
-  
   def self.list_opt_for_panel
     {
       :panel_pictures => {
@@ -109,13 +98,6 @@ class PanelPicture < Peta::Element
     self.picture.symbol_option
   end
   
-  def boost
-  end
-  
-  def tag_element_type
-    'panel_picture'
-  end
-  
   def self.list_where
     'panels.publish > 0'
   end
index a569013..4c1d21a 100644 (file)
@@ -6,6 +6,7 @@ class Scroll < Peta::Content
   validates :title, :presence => true, :length => {:maximum => 100}
   validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
   validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
+  
   def supply_default
     self.visible = 0 if self.visible.blank?
   end
index 356efd0..ea41ed2 100644 (file)
@@ -9,11 +9,6 @@ class ScrollPanel < Peta::Element
   validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
-  def tag_attributes column = nil, opt = {}
-    {
-    }
-  end
-  
   def supply_default
     self.scroll_id = nil
     self.panel_id = nil
index ee85e6f..b36a3b1 100644 (file)
@@ -53,18 +53,6 @@ class Sheet < Peta::Content
   def symbol_filename
   end
   
-  def tag_id
-    'sheet' + self.tag_sheet_id
-  end
-  
-  def tag_sheet_id
-    self.new_record? ? '0' : self.id.to_s
-  end
-  
-  def field_tag_id f
-    self.tag_id + f.to_s
-  end
-  
   def self.list_where
     'sheets.visible > 0'
   end
@@ -173,16 +161,6 @@ class Sheet < Peta::Content
     Sheet.validate_elements_serial validate_serial_list
   end
   
-  def boost
-    @new_element_index = 0
-    self.panel_elements.each do |elm|
-      if elm.new_record?
-        elm.new_index = @new_element_index
-        @new_element_index += 1
-      end
-    end
-  end 
-  
   def store attr, operators
     if attr == false
       self.errors.add :base, I18n.t('errors.invalid_json')
index 300980c..2894484 100644 (file)
@@ -155,16 +155,6 @@ class SheetPanel < Peta::Element
     end
   end
   
-  def boost operators
-    if self.panel
-      self.panel.author_id = operators.author.id
-      self.panel.panel_elements.each do |elm|
-        elm.new_panel = self
-        elm.boost
-      end
-    end
-  end
-  
   def panel_attributes
     if self.panel
       {'panel_attributes' => self.panel.copy}
@@ -279,120 +269,4 @@ class SheetPanel < Peta::Element
     res
   end
   
-    # element.rb
-    def self.colum_structures
-      @@colum_structures ||= {
-      }
-    end
-    
-    def self.path_name with_engine = false
-      self.to_s.tableize
-    end
-    
-    def new_index
-      @new_index
-    end
-    
-    def new_index= v
-      @new_index = v
-    end
-    
-    def new_sheet
-      @new_sheet
-    end
-    
-    def new_sheet= v
-      @new_sheet = v
-    end
-    
-    def get_sheet
-      self.sheet || @new_sheet
-    end
-    
-    def tag_id c = nil
-      'sheet' + self.tag_sheet_id + self.tag_element_type + self.tag_element_id + c.to_s
-    end
-    
-    def field_tag_id f
-      self.tag_id + f.to_s
-    end
-    
-    def tag_sheet_id
-      (self.get_sheet == nil or self.get_sheet.new_record?) ? '0' : self.get_sheet.id.to_s
-    end
-    
-    def tag_element_id
-      self.new_record? ? '0' : self.id.to_s
-    end
-    
-    def tag_element_type
-      'sheet_panel'
-    end
-    
-    def tag_new_index
-      self.new_index.to_s
-    end
-    
-    def path_name with_engine = false
-      self.class.path_name(with_engine)
-    end
-    
-    def form_template with_engine = false
-      self.path_name(with_engine) + '/form'
-    end
-    
-    def scenario_template with_engine = false
-      self.path_name(with_engine) + '/scenario'
-    end
-    
-    def element_face_template with_engine = false
-      self.path_name(with_engine) + '/element_face'
-    end
-    
-    def form_helper_template(colum_name)
-      self.class.colum_structures[colum_name][:helper]
-    end
-    
-    def tag_attributes column = nil, opt = {}
-      {
-        :id => self.field_tag_id(column), :sheet_id => self.tag_sheet_id, 
-        :element_id => self.tag_element_id, :element_type => self.tag_element_type
-      }.merge(opt)
-    end
-    
-    def field_tag_attributes column, no_attr, opt = {}
-      self.tag_attributes(column).merge(
-        {:column => column, :new_index => self.tag_new_index, :no_attr => no_attr}
-      ).merge(opt)
-    end
-    
-    #render element by body
-    def any_tag_attributes name = nil, opt = {}
-      r = self.tag_attributes(name)
-      r.merge!(
-        {:new_index => self.tag_new_index}
-      ) if self.new_index
-      r.merge(opt)
-    end
-    
-    def select_tag_attributes(selected, column, no_attr)
-      [
-        :last, :first, 
-        {:html => {:selected => selected}}, 
-        self.field_tag_attributes(column, no_attr)
-      ]
-    end
-    
-    def tag_attr column = nil, opt = {}
-      self.tag_attributes(column, opt).to_attr
-    end
-    
-    def field_tag_attr column, no_attr, opt = {}
-      self.field_tag_attributes(column, no_attr, opt).to_attr
-    end
-    
-    def any_tag_attr name = nil, opt = {}
-      self.any_tag_attributes(name, opt).to_attr
-    end
-    
 end
index 506671c..f42b2a7 100644 (file)
@@ -1,6 +1,5 @@
 class Speech < Peta::Content
   load_manifest
-  include Peta::ElementPart
   belongs_to :speech_balloon
   belongs_to :writing_format
   
@@ -18,14 +17,6 @@ class Speech < Peta::Content
   
   @@text_align_texts = ['left', 'left', 'right', 'center']
   
-  def self.colum_structures
-    @@colum_structures ||= {
-      :fore_color => {
-        :helper => 'panels/color_helper'
-      }
-    }
-  end
-  
   def supply_default
     self.x = 0
     self.y = 0
@@ -42,14 +33,6 @@ class Speech < Peta::Content
     self.get_parent.speech_balloon_template.symbol_option
   end
   
-  def get_parent
-    self.speech_balloon || @new_parent
-  end
-  
-  def tag_element_part_type
-    'speech'
-  end
-  
   def outer_style
     {
       'top' => self.y, 'left' => self.x, 
index 5077550..f9d9cec 100644 (file)
@@ -58,30 +58,6 @@ class SpeechBalloon < Peta::Element
     self.speech_balloon_template.symbol_option
   end
   
-  def new_balloon
-    @new_balloon
-  end
-  
-  def new_balloon= v
-    @new_balloon = v
-  end
-  
-  def get_balloon
-    self.balloon || @new_balloon
-  end
-  
-  def new_speech
-    @new_speech
-  end
-  
-  def new_speech= v
-    @new_speech = v
-  end
-  
-  def get_speech
-    self.speech || @new_speech
-  end
-  
   def boost
     self.extend self.speech_balloon_template.engine_extend_module
     if self.balloon
@@ -137,10 +113,6 @@ class SpeechBalloon < Peta::Element
     'speech_balloons.updated_at desc'
   end
   
-  def self.list_opt
-    {:panel => {:author => {}}, :balloon => {}, :speech => {}, :speech_balloon_template => {} }
-  end
-  
   def self.list_json_opt
     {:include => {:panel => {:include => {:author => {} }}, :balloon => {}, :speech => {}, :speech_balloon_template => {} }}
   end
index 9153230..2cb5ab4 100644 (file)
@@ -9,11 +9,6 @@ class Story < Peta::Content
   validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
-  def tag_attributes column = nil, opt = {}
-    {
-    }
-  end
-  
   def supply_default
     self.comic_id = nil
     self.visible = 0 if self.visible.blank?
index 3650fe5..140fa75 100644 (file)
@@ -9,11 +9,6 @@ class StorySheet < Peta::Element
   validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
-  def tag_attributes column = nil, opt = {}
-    {
-    }
-  end
-  
   def supply_default
     self.story_id = nil
     self.sheet_id = nil
index bdfa554..f7bc737 100644 (file)
@@ -1,4 +1,4 @@
-<%= content_tag :div, :id => panel.tag_id, :panel_id => panel.tag_panel_id, :class => "pettanr-comic-panel", :style => "width: #{panel.width}px; height: #{panel.height}px; border-style: solid; border-width: #{panel.border}px; border-color: black; background-color: white;" do %>
+<%= content_tag :div, panel.tag_attributes(nil, {:panel_id => panel.id, :class => "pettanr-comic-panel", :style => raw(panel.style.to_style)}) do %>
   <% if panel.visible? operators -%>
     <% panel.panel_elements.each do |element| %>
       <%= render element.path_name + '/element', :element => element, :root => panel, :spot => spot %>
@@ -7,4 +7,3 @@
     <h2><%= t('panels.hidden') %></h2>
   <% end %>
 <% end %>
-<% panel.rendered %>
index 3587186..3ce72c2 100644 (file)
@@ -47,7 +47,7 @@ module Peta
     
     def tag_attributes column = nil, opt = {}
       r = super
-      r.merge({'data-parent_dom_id' => self.parent.dom_item_id}) if self.editor
+      r.merge({'data-parent_dom_id' => self.parent.dom_item_id}) if self.editize?
       r
     end
     
index 2d9604b..9f84df3 100644 (file)
@@ -165,6 +165,7 @@ module Peta
     end
     
     def engine?
+      return false unless self.my_engine_resource
       self.my_engine_resource.resource_items.include? self.attributes[self.extend_column_name]
     end
     
index 2fe139d..742b311 100644 (file)
       }\r
     },\r
     "speech_balloon": {\r
-      "extend": "classname",\r
+      "extend_column_name": "classname",\r
       "associations": {\r
         "belongs_to": {\r
           "panel": {}\r
       }\r
     },\r
     "speech_balloon_template": {\r
+      "extend_column_name": "classname",\r
       "associations": {\r
         "belongs_to": {\r
           "system_picture": {}\r
       }\r
     },\r
     "writing_format": {\r
+      "extend_column_name": "classname",\r
       "associations": {\r
         "belongs_to": {\r
           "system_picture": {}\r
       }\r
     },\r
     "license_group": {\r
+      "extend_column_name": "classname",\r
       "associations": {\r
         "belongs_to": {},\r
         "has_many": {\r
           "SquareSpeechBalloon": "square_speech_balloon"\r
         }\r
       },\r
+      "speech_balloons": {\r
+        "resource_items": {\r
+          "CircleSpeechBalloon": "circle_speech_balloon",\r
+          "PlainSpeechBalloon": "plain_speech_balloon",\r
+          "SquareSpeechBalloon": "square_speech_balloon"\r
+        }\r
+      },\r
       "writing_formats": {\r
         "has_route": 0,\r
         "resource_items": {\r
                   "size": {\r
                     "type": "size",\r
                     "args": {\r
-                      "path": "panels/size_helper",\r
-                      "class": "panel_picture_width_tool"\r
+                      "dom_class": "panel_picture_width_tool"\r
                     }\r
                   }\r
                 },\r
                   "size": {\r
                     "type": "size",\r
                     "args": {\r
-                      "path": "panels/size_helper",\r
-                      "class": "panel_picture_height_tool"\r
+                      "dom_class": "panel_picture_height_tool"\r
                     }\r
                   }\r
                 },\r
                 },\r
                 "helpers": {\r
                   "popup": {\r
-                    "type": "size",\r
+                    "type": "popup",\r
                     "args": {\r
-                      "path": "panels/popup_helper",\r
                       "source": "pictures"\r
                     }\r
                   }\r
                 "helpers": {\r
                   "tail_angle": {\r
                     "type": "size",\r
-                    "args": {\r
-                      "path": "panels/tail_angle_helper"\r
-                    }\r
+                    "args": {}\r
                   }\r
                 },\r
                 "row_break": true\r
                 },\r
                 "helpers": {\r
                   "color": {\r
-                    "type": "size",\r
+                    "type": "color",\r
                     "args": {\r
-                      "path": "panels/color_helper",\r
                       "wrapper": "speech-fore_color-wrap"\r
                     }\r
                   }\r
                 },\r
                 "helpers": {\r
                   "color": {\r
-                    "type": "size",\r
+                    "type": "color",\r
                     "args": {\r
-                      "path": "panels/color_helper",\r
                       "wrapper": "ground_color-code-wrap"\r
                     }\r
                   }\r