-
- def new
- raise Pettanr::NotWork unless @author.working_panel
- @speech_balloon_template = SpeechBalloonTemplate.show params[:speech_balloon_template_id], @author
-
- @panel = Panel.edit(@author.working_panel, @author)
- @speech_balloon = SpeechBalloon.new :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
- @speech_balloon.boost
- @speech_balloon.supply_default
- @speech_balloon.get_balloon.supply_default
- @speech_balloon.get_speech.supply_default
-
- respond_to do |format|
- format.html {
- render @speech_balloon_template.engine_name + '/speech_balloons/new'
- }
- format.json { render :json => @speech_balloon.to_json(SpeechBalloon.show_json_opt) }
- end
- end
-
- def edit
- @speech_balloon = SpeechBalloon.show(params[:id], @author)
- @speech_balloon_template = @speech_balloon.speech_balloon_template
- @panel = Panel.edit(@speech_balloon.panel.id, @author)
-
- @speech_balloon.boost
-
- respond_to do |format|
- format.html {
- render @speech_balloon_template.engine_name + '/speech_balloons/edit'
- }
- end
- end
-
- def create
- raise Pettanr::NotWork unless @author.working_panel
- SpeechBalloon.fold_extend_settings params
- @panel = Panel.edit(@author.working_panel, @author)
- @speech_balloon = SpeechBalloon.new
- @speech_balloon.attributes = params[:speech_balloon]
-
- @speech_balloon_template = @speech_balloon.speech_balloon_template
- @speech_balloon.boost
-
- params[:speech_balloon][:balloon_attributes][:system_picture_id] = @speech_balloon.get_balloon.select_system_picture
-
- @speech_balloon.overwrite @panel.id
-
- respond_to do |format|
- if @speech_balloon.valid? and @speech_balloon.store(@author, params[:speech_balloon])
- flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
- format.html { redirect_to @panel }
- format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
- else
- flash[:notice] = I18n.t('flash.notice.not_created', :model => SpeechBalloon.model_name.human)
- format.html {
- render @speech_balloon_template.engine_name + '/speech_balloons/new'
- }
- format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
- end
- end