class PanelsController < ApplicationController
if Manifest.manifest.magic_numbers['run_mode'] == 0
- before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy, :catch]
- before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy, :catch]
+ before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+ before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
else
before_filter :authenticate_reader, :only => [
:index, :show, :by_scroll, :by_sheet, :by_author, :by_speech_balloon_template
]
- before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy, :catch]
- before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy, :catch]
+ before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+ before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
end
private
end
end
+=begin
def new
set_new
respond_to do |format|
format.json { render json: @item.to_json }
end
end
+=end
+
+ def new
+ form_new
+ end
+
+ def edit
+ form_edit
+ end
def create
set_model
created_html_format format
created_json_format format
else
- format.html {
- flash[:notice] = I18n.t('flash.notice.not_created', :model => @my_model_class.model_name.human)
- @editor = Editor::PanelEditor.new @item, @operators
- render :template => @editor.template_name, :locals => {
- :editor => @editor
- }
- }
+ not_created_html_format format
not_created_json_format format
end
end
updated_html_format format
updated_json_format format
else
- format.html {
- flash[:notice] = I18n.t('flash.notice.not_updated', :model => @my_model_class.model_name.human)
- @editor = Editor::PanelEditor.new @item, @operators
- render :template => @editor.template_name, :locals => {
- :editor => @editor
- }
- }
+ not_updated_html_format format
not_updated_json_format format
end
end
end
end
- def catch
- @item = Panel.edit(params[:id], @operators)
-
- respond_to do |format|
- @operators.author.working_panel_id = @item.id
- if @operators.author.save
- format.html { redirect_to @item }
- else
- end
- end
- end
-
end
respond_to do |format|
format.html {
if @operators.author
- @new_panel_items = assist_items('panel', 'private')
+ @new_panel_items = assist_items('home', 'panels')
end
}
list_json_format @list, format
end
end
+=begin
def new
set_new
respond_to do |format|
end
end
+=end
+
+ def new
+ form_new
+ end
+
+ def edit
+ form_edit
+ end
+
def create
- @sheet = Sheet.new
- @sheet.supply_default
+ set_model
+ @item = @my_model_class.new
+ @item.supply_default
jsn = nil
if params[:json]
jsn = JSON.parse_no_except(params[:json])
@prm = params[:sheet] || jsn
respond_to do |format|
- if @sheet.store @prm, @operators
+ if @item.store @prm, @operators
created_html_format format
created_json_format format
else
- format.html {
- flash[:notice] = I18n.t('flash.notice.not_created', :model => @my_model_class.model_name.human)
- @editor = Editor::PanelEditor.new @item, @operators
- render :template => @editor.template_name, :locals => {
- :editor => @editor
- }
- }
+ not_created_html_format format
not_created_json_format format
end
end
end
def update
- @sheet = Sheet.edit(params[:id], @operators)
+ set_edit
jsn = nil
if params[:json]
jsn = JSON.parse(params[:json])
end
@prm = params[:sheet] || jsn
respond_to do |format|
- if @sheet.store @prm, @operators
+ if @item.store @prm, @operators
updated_html_format format
updated_json_format format
else
- format.html {
- flash[:notice] = I18n.t('flash.notice.not_updated', :model => @my_model_class.model_name.human)
- @editor = Editor::PanelEditor.new @item, @operators
- render :template => @editor.template_name, :locals => {
- :editor => @editor
- }
- }
+ not_updated_html_format format
not_updated_json_format format
end
end
has_many :comics
has_many :sheets
has_many :panels
- belongs_to :working_panel, :class_name => "Panel"
validates :name, :presence => true, :length => {:maximum => 30}
- validates :working_panel_id, :numericality => {:allow_nil => true}
validates :user_id, :numericality => true, :existence => {:both => false}
def supply_default
self.user_id = nil
end
- def working?
- self.working_panel_id and self.working_panel
- end
-
def self.show_opt
{:include => {:user => {:artist => {}}} }
end
}
end
- def self.panelize balloon_attributes
- {'balloon_attributes' => balloon_attributes}
- end
-
def scenario
end
def copyable?
r = true
- Sheet.each_element_class_names do |n|
- self.elements_by_class_name(n).each do |elm|
- next if elm.copyable?
- r = false
- break
- end
- break unless r
+ self.elements_items.each do |elm|
+ next if elm.copyable?
+ r = false
+ break
end
r
end
- def copy
- attr = self.copy_attributes
- Sheet.each_element_class_names do |n|
- element_attr = Sheet.class_name_to_class(n).panelize(
- self.elements_by_class_name(n).map {|elm|
- elm.copy_attributes.merge elm.panel_attributes
- }
- )
- attr.merge! element_attr
- end
- attr
- end
-
end
end
end
- def self.panelize elements_attributes
- elements_attributes = [elements_attributes] unless elements_attributes.is_a?(Array)
- hash = {}
- index = 0
- elements_attributes.each do |element_attributes|
- hash[self.to_s.tableize + '_attributes'] ||= {}
- n = if element_attributes['id']
- element_attributes['id'].to_s
- else
- index += 1
- 'new' + index.to_s
- end
- hash[self.to_s.tableize + '_attributes'][n] = element_attributes
- end
- hash
- end
-
- def copy_attributes
- r = self.attributes
- r.delete 'id'
- r.delete 'sheet_id'
- r.delete 'panel_id' # create panel
- r.delete 'created_at'
- r.delete 'updated_at'
- r
- end
-
def copyable?
- if self.panel and self.panel.publish? == false
- false
- else
+ if self.panel and self.panel.publish?
true
- end
- end
-
- def panel_attributes
- if self.panel
- {'panel_attributes' => self.panel.copy}
else
- {}
+ false
end
end
{:include => {:speech_balloon => {:panel => {:author => {}}, :balloon => {}, :speech_balloon_template => {} }}}
end
- def self.panelize speech_attributes
- {'speech_attributes' => speech_attributes}
- end
-
def scenario
self.boosts 'read'
self.render
end
def plain_scenario
- self.content + "\n"
+ self.content.to_s + "\n"
end
def feed
<%= link_to t('link.edit'), edit_ground_color_path(@ground_color) %>
<%= link_to t('link.destroy'), ground_color_path(@ground_color), :method => :delete %>
-
-<%= render 'panels/element_copy', :element => @ground_color, :operators => @operators %>
<%= link_to t('link.edit'), edit_ground_picture_path(@ground_picture) %>
<%= link_to t('link.destroy'), ground_picture_path(@ground_picture), :method => :delete %>
-
-<%= render 'panels/element_copy', :element => @ground_picture, :operators => @operators %>
<%= link_to t('*'), main_app.new_original_picture_path %>\r
<%= link_to t('tab.creator.resource_picture'), '/home/resource_pictures' %>\r
<% end %>\r
- <% if @operators.author and @operators.author.working? -%>\r
- <%= link_to t('tab.creator..catch'), main_app.panel_path(@operators.author.working_panel) %>\r
- <% end %>\r
</div>\r
<%= yield %>\r
<div width="100%" style="background-color: #faddfa; padding: 5px;">\r
<%= link_to t('link.edit'), edit_panel_picture_path(@panel_picture) %>
<%= link_to t('link.destroy'), panel_picture_path(@panel_picture), :method => :delete %>
-
-<%= render 'panels/element_copy', :element => @panel_picture, :operators => @operators %>
+++ /dev/null
-<% if operators.author and operators.author.working? -%>
- <h2><%= t('panels.element_copy') -%></h2>
- <h3><%= t('home.index.catch') -%></h3>
- <%= link_to panel_icon(:object => operators.author.working_panel, :size => 25), panel_path(operators.author.working_panel) %>
- <%= link_to operators.author.working_panel.caption, main_app.panel_path(operators.author.working_panel) %>
-
- <%= form_for(operators.author.working_panel) do |f| %>
- <%= hidden_field_tag "json", element.copy(operators.author.working_panel).to_json %>
- <div>
- <%= submit_tag t('panels.inspire') -%>
- </div>
- <% end %>
-<% end -%>
<td>
<% if panel.own? operators %>
<%= link_to t('link.edit'), main_app.edit_panel_path(panel) %>
- <%= link_to t('link.catch'), main_app.catch_panel_path(panel) %>
<% end %>
</td>
</tr>
<% @page_caption = @item.caption %>
<p id="notice"><%= notice %></p>
-<% if @item.sheet_elements.empty? -%>
+<% if @item.sheet_panels.empty? -%>
<h2><%= t('sheet_panels.sheet.empty') %></h2>
<% else %>
<div id=" @item.tag_id wrapper" sheet_id=" @item.tag_sheet_id " class="pettanr-sheet-wrapper" editable="true">
<h2><%= t('sheets.show.copy') -%></h2>
<%= form_for(Sheet.new, :html => {:jqform => 'pettanr-sheet-form'}) do |f| %>
- <%= hidden_field_tag "json", @item.copy().to_json %>
+ <%= hidden_field_tag "json", @item.post_attributes(:all => true).to_json %>
<div>
<%= submit_tag t('sheets.show.inspire') -%>
</div>
get :by_sheet
get :by_author
get :by_speech_balloon_template
- get :catch
get :edit
put :update
delete :destroy
{}
end
- def self.panelize elements_attributes
- elements_attributes = [elements_attributes] unless elements_attributes.is_a?(Array)
- hash = {}
- index = 0
- elements_attributes.each do |element_attributes|
- hash[self.to_s.tableize + '_attributes'] ||= {}
- n = if element_attributes['id']
- element_attributes['id'].to_s
- else
- index += 1
- 'new' + index.to_s
- end
- hash[self.to_s.tableize + '_attributes'][n] = element_attributes
- end
- hash
- end
-
def has_picture?
false
end
res
end
- def self.panelize panel
- attr = panel.attributes
- attr.delete 'id'
- attr
- end
-
end
end