From 6a632a043b9cc052780bbe4a7fa8efbc248609ca Mon Sep 17 00:00:00 2001 From: yasushiito Date: Fri, 12 Jul 2013 10:47:38 +0900 Subject: [PATCH] t#31671:add elm copy --- app/models/balloon.rb | 17 +++++++++++++++-- app/models/ground_color.rb | 8 ++++++++ app/models/ground_picture.rb | 8 ++++++++ app/models/panel_picture.rb | 8 ++++++++ app/models/speech.rb | 17 +++++++++++++++-- app/models/speech_balloon.rb | 18 ++++++++++++++++++ app/views/ground_colors/_copy.html.erb | 8 ++++++++ app/views/ground_colors/show.html.erb | 10 +--------- app/views/ground_pictures/_copy.html.erb | 8 ++++++++ app/views/ground_pictures/show.html.erb | 2 ++ app/views/panel_pictures/_copy.html.erb | 8 ++++++++ app/views/panel_pictures/show.html.erb | 2 ++ app/views/speech_balloons/_copy.html.erb | 9 +++++++++ app/views/speech_balloons/show.html.erb | 2 ++ app/views/speeches/_form.html.erb | 2 +- 15 files changed, 113 insertions(+), 14 deletions(-) create mode 100644 app/views/ground_colors/_copy.html.erb create mode 100644 app/views/ground_pictures/_copy.html.erb create mode 100644 app/views/panel_pictures/_copy.html.erb create mode 100644 app/views/speech_balloons/_copy.html.erb diff --git a/app/models/balloon.rb b/app/models/balloon.rb index 76cd5f79..7ca441c7 100644 --- a/app/models/balloon.rb +++ b/app/models/balloon.rb @@ -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 diff --git a/app/models/ground_color.rb b/app/models/ground_color.rb index 5d50f96b..9a4a5e39 100644 --- a/app/models/ground_color.rb +++ b/app/models/ground_color.rb @@ -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? '' diff --git a/app/models/ground_picture.rb b/app/models/ground_picture.rb index 4bcd683b..f413ae71 100644 --- a/app/models/ground_picture.rb +++ b/app/models/ground_picture.rb @@ -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? '' diff --git a/app/models/panel_picture.rb b/app/models/panel_picture.rb index cef80fed..73cbc038 100644 --- a/app/models/panel_picture.rb +++ b/app/models/panel_picture.rb @@ -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? '' diff --git a/app/models/speech.rb b/app/models/speech.rb index 134c038b..726f26d6 100644 --- a/app/models/speech.rb +++ b/app/models/speech.rb @@ -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 diff --git a/app/models/speech_balloon.rb b/app/models/speech_balloon.rb index d8e6e310..19195ee9 100644 --- a/app/models/speech_balloon.rb +++ b/app/models/speech_balloon.rb @@ -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 index 00000000..ac02ed7d --- /dev/null +++ b/app/views/ground_colors/_copy.html.erb @@ -0,0 +1,8 @@ +<% if author and author.working? -%> +

<%= 'Copying my working panel' -%>

+

<%= t('home.index.catch') -%>

+ <%= 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 -%> diff --git a/app/views/ground_colors/show.html.erb b/app/views/ground_colors/show.html.erb index cf40b057..0adcbecf 100644 --- a/app/views/ground_colors/show.html.erb +++ b/app/views/ground_colors/show.html.erb @@ -36,12 +36,4 @@ <%= 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? -%> -

<%= t('home.index.catch') -%>

- <%= 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) %> - -

- <%= link_to t('resource_pictures.add_to_panel_for_ground_color'), main_app.new_ground_color_path(:code => @ground_color.code) %> -

-<% 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 index 00000000..ee15f626 --- /dev/null +++ b/app/views/ground_pictures/_copy.html.erb @@ -0,0 +1,8 @@ +<% if author and author.working? -%> +

<%= 'Copying my working panel' -%>

+

<%= t('home.index.catch') -%>

+ <%= 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 -%> diff --git a/app/views/ground_pictures/show.html.erb b/app/views/ground_pictures/show.html.erb index a48a4147..626da727 100644 --- a/app/views/ground_pictures/show.html.erb +++ b/app/views/ground_pictures/show.html.erb @@ -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 index 00000000..fa49fb50 --- /dev/null +++ b/app/views/panel_pictures/_copy.html.erb @@ -0,0 +1,8 @@ +<% if author and author.working? -%> +

<%= 'Copying my working panel' -%>

+

<%= t('home.index.catch') -%>

+ <%= 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 -%> diff --git a/app/views/panel_pictures/show.html.erb b/app/views/panel_pictures/show.html.erb index f558950c..933abc08 100644 --- a/app/views/panel_pictures/show.html.erb +++ b/app/views/panel_pictures/show.html.erb @@ -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 index 00000000..b0bff9f8 --- /dev/null +++ b/app/views/speech_balloons/_copy.html.erb @@ -0,0 +1,9 @@ +<% if author and author.working? -%> +

<%= 'Copying my working panel' -%>

+

<%= t('home.index.catch') -%>

+ <%= 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 -%> diff --git a/app/views/speech_balloons/show.html.erb b/app/views/speech_balloons/show.html.erb index 43300276..e9029626 100644 --- a/app/views/speech_balloons/show.html.erb +++ b/app/views/speech_balloons/show.html.erb @@ -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 %> diff --git a/app/views/speeches/_form.html.erb b/app/views/speeches/_form.html.erb index 522ec887..85afdee5 100644 --- a/app/views/speeches/_form.html.erb +++ b/app/views/speeches/_form.html.erb @@ -1,7 +1,7 @@
<%= f.label :content %>
- <%= 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) %>
<%= 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) %> -- 2.11.0