OSDN Git Service

t#31671:add elm copy
authoryasushiito <yas@pen-chan.jp>
Fri, 12 Jul 2013 01:47:38 +0000 (10:47 +0900)
committeryasushiito <yas@pen-chan.jp>
Fri, 12 Jul 2013 01:47:38 +0000 (10:47 +0900)
15 files changed:
app/models/balloon.rb
app/models/ground_color.rb
app/models/ground_picture.rb
app/models/panel_picture.rb
app/models/speech.rb
app/models/speech_balloon.rb
app/views/ground_colors/_copy.html.erb [new file with mode: 0644]
app/views/ground_colors/show.html.erb
app/views/ground_pictures/_copy.html.erb [new file with mode: 0644]
app/views/ground_pictures/show.html.erb
app/views/panel_pictures/_copy.html.erb [new file with mode: 0644]
app/views/panel_pictures/show.html.erb
app/views/speech_balloons/_copy.html.erb [new file with mode: 0644]
app/views/speech_balloons/show.html.erb
app/views/speeches/_form.html.erb

index 76cd5f7..7ca441c 100644 (file)
@@ -48,6 +48,14 @@ self.system_picture_id = 1
     self.speech_balloon
   end
   
+  def get_panel_id
+    if self.get_speech_balloon == nil or self.get_speech_balloon.panel == nil or self.get_speech_balloon.panel.new_record?
+      0
+    else
+      self.get_speech_balloon.panel.id
+    end
+  end
+  
   def tag_id c = nil
     'panel' + tag_panel_id + tag_element_type + tag_element_id + tag_element_part_type + tag_element_part_id + c.to_s
   end
@@ -57,11 +65,16 @@ self.system_picture_id = 1
   end
   
   def tag_panel_id
-    self.get_speech_balloon.panel.new_record? ? '0' : self.get_speech_balloon.panel.id.to_s
+    self.get_panel_id.to_s
   end
   
   def tag_element_id
-    self.get_speech_balloon.new_record? ? '0' : self.get_speech_balloon.id.to_s
+    r = if self.get_speech_balloon == nil or self.get_speech_balloon.new_record?
+      0
+    else
+      self.get_speech_balloon.panel.id
+    end
+    r.to_s
   end
   
   def tag_element_type
index 5d50f96..9a4a5e3 100644 (file)
@@ -167,6 +167,14 @@ class GroundColor < ActiveRecord::Base
     self.panel.remove_element(self, au)
   end
   
+  def copy from_panel
+    r = GroundColor.new self.attributes
+    r.panel_id = from_panel.id
+    r.t = r.panel.new_t 
+    r.z = r.panel.new_z 
+    r
+  end
+  
   def scenario
     if caption.blank?
       ''
index 4bcd683..f413ae7 100644 (file)
@@ -183,6 +183,14 @@ class GroundPicture < ActiveRecord::Base
     self.panel.remove_element(self, au)
   end
   
+  def copy from_panel
+    r = GroundPicture.new self.attributes
+    r.panel_id = from_panel.id
+    r.t = r.panel.new_t 
+    r.z = r.panel.new_z 
+    r
+  end
+  
   def scenario
     if caption.blank?
       ''
index cef80fe..73cbc03 100644 (file)
@@ -203,6 +203,14 @@ class PanelPicture < ActiveRecord::Base
     self.panel.remove_element(self, au)
   end
   
+  def copy from_panel
+    r = PanelPicture.new self.attributes
+    r.panel_id = from_panel.id
+    r.t = r.panel.new_t 
+    r.z = r.panel.new_z 
+    r
+  end
+  
   def scenario
     if caption.blank?
       ''
index 134c038..726f26d 100644 (file)
@@ -38,6 +38,14 @@ class Speech < ActiveRecord::Base
     self.speech_balloon
   end
   
+  def get_panel_id
+    if self.get_speech_balloon == nil or self.get_speech_balloon.panel == nil or self.get_speech_balloon.panel.new_record?
+      0
+    else
+      self.get_speech_balloon.panel.id
+    end
+  end
+  
   def tag_id c = nil
     'panel' + tag_panel_id + tag_element_type + tag_element_id + tag_element_part_type + tag_element_part_id + c.to_s
   end
@@ -47,11 +55,16 @@ class Speech < ActiveRecord::Base
   end
   
   def tag_panel_id
-    self.get_speech_balloon.panel.new_record? ? '0' : self.get_speech_balloon.panel.id.to_s
+    self.get_panel_id.to_s
   end
   
   def tag_element_id
-    self.get_speech_balloon.new_record? ? '0' : self.get_speech_balloon.id.to_s
+    r = if self.get_speech_balloon == nil or self.get_speech_balloon.new_record?
+      0
+    else
+      self.get_speech_balloon.panel.id
+    end
+    r.to_s
   end
   
   def tag_element_type
index d8e6e31..19195ee 100644 (file)
@@ -168,6 +168,24 @@ class SpeechBalloon < ActiveRecord::Base
     self.panel.remove_element(self, au)
   end
   
+  def copy from_panel
+    sb = SpeechBalloon.new self.attributes
+    sb.panel_id = from_panel.id
+    sb.t = sb.panel.new_t 
+    sb.z = sb.panel.new_z 
+    b = sb.build_balloon(self.balloon.attributes)
+    s = sb.build_speech(self.speech.attributes)
+    sb.extend self.speech_balloon_template.engine_speech_balloon_module
+    b.extend self.speech_balloon_template.engine_balloon_module
+    s.extend self.speech_balloon_template.engine_speech_module
+    b.new_speech_balloon = sb
+    s.new_speech_balloon = sb
+    sbe = sb.extend_speech_balloon
+    be = b.extend_balloon
+    se = s.extend_speech
+    {:speech_balloon => sb, :balloon => b, :speech => s, :speech_balloon_extend => sbe, :balloon_extend => be, :speech_extend => se }
+  end
+  
   def scenario
     ERB::Util.html_escape(self.caption.to_s) + self.balloon.scenario.to_s + 
     self.speech.scenario.to_s
diff --git a/app/views/ground_colors/_copy.html.erb b/app/views/ground_colors/_copy.html.erb
new file mode 100644 (file)
index 0000000..ac02ed7
--- /dev/null
@@ -0,0 +1,8 @@
+<% if author and author.working? -%>
+  <h2><%= 'Copying my working panel' -%></h2>
+  <h3><%= t('home.index.catch') -%></h3>
+  <%= link_to panel_icon(:object => author.working_panel, :size => 25), panel_path(author.working_panel) %>
+  <%= link_to author.working_panel.caption, main_app.panel_path(author.working_panel) %>
+
+  <%= render 'ground_colors/form', :ground_color => ground_color.copy(author.working_panel) %>
+<% end -%>
index cf40b05..0adcbec 100644 (file)
 <%= link_to t('link.edit'), edit_ground_color_path(@ground_color) %>
 <%= link_to t('link.destroy'), ground_color_path(@ground_color), :method => :delete %>
 
-<% if @author and @author.working? -%>
-  <h3><%= t('home.index.catch') -%></h3>
-  <%= link_to panel_icon(:object => @author.working_panel, :size => 25), panel_path(@author.working_panel) %>
-  <%= link_to @author.working_panel.caption, main_app.panel_path(@author.working_panel) %>
-
-  <p>
-    <%= link_to t('resource_pictures.add_to_panel_for_ground_color'), main_app.new_ground_color_path(:code => @ground_color.code) %>
-  </p>
-<% end -%>
+<%= render 'copy', :ground_color => @ground_color, :author => @author %>
diff --git a/app/views/ground_pictures/_copy.html.erb b/app/views/ground_pictures/_copy.html.erb
new file mode 100644 (file)
index 0000000..ee15f62
--- /dev/null
@@ -0,0 +1,8 @@
+<% if author and author.working? -%>
+  <h2><%= 'Copying my working panel' -%></h2>
+  <h3><%= t('home.index.catch') -%></h3>
+  <%= link_to panel_icon(:object => author.working_panel, :size => 25), panel_path(author.working_panel) %>
+  <%= link_to author.working_panel.caption, main_app.panel_path(author.working_panel) %>
+
+  <%= render 'ground_pictures/form', :ground_picture => ground_picture.copy(author.working_panel) %>
+<% end -%>
index a48a414..626da72 100644 (file)
@@ -40,3 +40,5 @@
 
 <%= link_to t('link.edit'), edit_ground_picture_path(@ground_picture) %>
 <%= link_to t('link.destroy'), ground_picture_path(@ground_picture), :method => :delete %>
+
+<%= render 'copy', :ground_picture => @ground_picture, :author => @author %>
diff --git a/app/views/panel_pictures/_copy.html.erb b/app/views/panel_pictures/_copy.html.erb
new file mode 100644 (file)
index 0000000..fa49fb5
--- /dev/null
@@ -0,0 +1,8 @@
+<% if author and author.working? -%>
+  <h2><%= 'Copying my working panel' -%></h2>
+  <h3><%= t('home.index.catch') -%></h3>
+  <%= link_to panel_icon(:object => author.working_panel, :size => 25), panel_path(author.working_panel) %>
+  <%= link_to author.working_panel.caption, main_app.panel_path(author.working_panel) %>
+
+  <%= render 'panel_pictures/form', :panel_picture => panel_picture.copy(author.working_panel) %>
+<% end -%>
index f558950..933abc0 100644 (file)
@@ -55,3 +55,5 @@
 
 <%= link_to t('link.edit'), edit_panel_picture_path(@panel_picture) %>
 <%= link_to t('link.destroy'), panel_picture_path(@panel_picture), :method => :delete %>
+
+<%= render 'copy', :panel_picture => @panel_picture, :author => @author %>
diff --git a/app/views/speech_balloons/_copy.html.erb b/app/views/speech_balloons/_copy.html.erb
new file mode 100644 (file)
index 0000000..b0bff9f
--- /dev/null
@@ -0,0 +1,9 @@
+<% if author and author.working? -%>
+  <h2><%= 'Copying my working panel' -%></h2>
+  <h3><%= t('home.index.catch') -%></h3>
+  <%= link_to panel_icon(:object => author.working_panel, :size => 25), panel_path(author.working_panel) %>
+  <%= link_to author.working_panel.caption, main_app.panel_path(author.working_panel) %>
+  <% sbset = speech_balloon.copy(author.working_panel) -%>
+
+  <%= render speech_balloon.speech_balloon_template.engine_name + '/speech_balloons/form', :speech_balloon => sbset[:speech_balloon], :balloon => sbset[:balloon], :speech => sbset[:speech], :speech_balloon_extend => sbset[:speech_balloon_extend], :balloon_extend => sbset[:balloon_extend], :speech_extend => sbset[:speech_extend] %>
+<% end -%>
index 4330027..e902962 100644 (file)
@@ -90,3 +90,5 @@
 
 <%= link_to t('link.edit'), edit_speech_balloon_path(@speech_balloon) %>
 <%= link_to t('link.destroy'), speech_balloon_path(@speech_balloon), :method => :delete %>
+
+<%= render 'copy', :speech_balloon => @speech_balloon, :author => @author %>
index 522ec88..85afdee 100644 (file)
@@ -1,7 +1,7 @@
 
   <div class="field">
     <%= f.label :content %><br />
-    <%= f.number_field :content, :id => speech.field_tag_id(:content), :panel_id => speech.tag_panel_id, :element_part_id => speech.tag_element_part_id, :element_part_type => speech.tag_element_part_type, :column => :content, :tree => speech.field_tree(:content) %>
+    <%= f.texxt_area :content, :id => speech.field_tag_id(:content), :panel_id => speech.tag_panel_id, :element_part_id => speech.tag_element_part_id, :element_part_type => speech.tag_element_part_type, :column => :content, :tree => speech.field_tree(:content) %>
   </div>
   
   <%= f.hidden_field :x, :id => speech.field_tag_id(:x), :panel_id => speech.tag_panel_id, :element_id => speech.tag_element_id, :element_type => speech.tag_element_type, :element_part_id => speech.tag_element_part_id, :element_part_type => speech.tag_element_part_type, :column => :x, :tree => speech.field_tree(:x) %>