X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fstory_sheets_controller.rb;fp=app%2Fcontrollers%2Fstory_sheets_controller.rb;h=b3b076e244c38904cc0bb86fa75299f3b28b8e49;hb=e9239d853f803c86df3a230e4d113c66833ecc71;hp=07083899b7b632e4b1868b7adefc8dcef0cdc936;hpb=03f41cad6ca10529eca98a34dcda6a69964390e3;p=pettanr%2Fpettanr.git diff --git a/app/controllers/story_sheets_controller.rb b/app/controllers/story_sheets_controller.rb index 07083899..b3b076e2 100644 --- a/app/controllers/story_sheets_controller.rb +++ b/app/controllers/story_sheets_controller.rb @@ -63,45 +63,31 @@ class StorySheetsController < ApplicationController end def create - @story_sheet = StorySheet.new - @story_sheet.supply_default - @story_sheet.attributes = params[:story_sheet] - @story_sheet.overwrite @operators - @story = Story.edit(@story_sheet.story_id, @operators) if @story_sheet.story_id - @sheet = Sheet.show(@story_sheet.sheet_id, @operators) if @story_sheet.sheet_id + @my_model_class = self.class.model + @item = @my_model_class.new + @item.supply_default + @item.attributes = params[@item.item_name] + @item.overwrite @operators + @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id + @panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id - respond_to do |format| - if @story_sheet.store @operators - flash[:notice] = I18n.t('flash.notice.created', :model => StorySheet.model_name.human) - format.html { redirect_to play_story_path(@story) } - format.json { render json: @story_sheet.to_json(StorySheet.show_json_opt) } - else - flash[:notice] = I18n.t('flash.notice.not_created', :model => StorySheet.model_name.human) - format.html { render action: "new" } - format.json { render json: @story_sheet.errors, status: :unprocessable_entity } - end - end + leaf_render_create play_scroll_path(@binder) end def update - @story_sheet = StorySheet.edit(params[:id], @operators) - ot = @story_sheet.t - @story_sheet.attributes = params[:story_sheet] - @story_sheet.overwrite @operators - @story = Story.edit(@story_sheet.story_id, @operators) if @story_sheet.story_id - respond_to do |format| - if @story_sheet.store @operators, ot - flash[:notice] = I18n.t('flash.notice.updated', :model => StorySheet.model_name.human) - format.html { redirect_to play_story_path(@story) } - format.json { head :ok } - else - flash[:notice] = I18n.t('flash.notice.not_updated', :model => StorySheet.model_name.human) - format.html { render action: "edit" } - format.json { render json: @story_sheet.errors, status: :unprocessable_entity } - end - end + @my_model_class = self.class.model + @item = @my_model_class.edit(params[:id], @operators) + ot = @item.t + @item.attributes = params[@item.item_name] + @item.overwrite @operators + @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id + # no check permission for destination + # swapable hidden panel + #@panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id + + leaf_render_update ot, play_scroll_path(@binder) end - + def destroy @story_sheet = StorySheet.edit(params[:id], @operators) @story = Story.edit(@story_sheet.story_id, @operators) if @story_sheet.story_id