diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index 3925e26..c2140f7 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -392,16 +392,17 @@ respond_to do |format| if @plan.save @plan.assign_creator(current_user) - format.html { redirect_to @plan, notice: _('Plan was successfully duplicated.') } - format.json { head :no_content } + flash[:notice] = 'Plan was successfully duplicated.' + format.js { render js: "window.location='#{plan_url(@plan)}?editing=true'" } + # format.html { redirect_to @plan, notice: _('Plan was successfully duplicated.') } + # format.json { head :no_content } else - flash[:notice] = failed_update_error(@plan, _('plan')) - format.html { render action: "edit" } + flash[:notice] = failed_create_error(@plan, 'Plan') + format.js {} end end end - private def plan_params diff --git a/app/views/plans/_plan_list_item.html.erb b/app/views/plans/_plan_list_item.html.erb index 5b445aa..05e6bcd 100644 --- a/app/views/plans/_plan_list_item.html.erb +++ b/app/views/plans/_plan_list_item.html.erb @@ -12,7 +12,7 @@ <%= link_to _('Export'), show_export_plan_path(plan), :class => "dmp_table_link"%> - <%= link_to _('Duplicate'), duplicate_plan_path(plan), method: :post, :class => "dmp_table_link"%> + <%= link_to _('Duplicate'), duplicate_plan_path(plan), method: :post, remote: true, :class => "dmp_table_link"%> <% if plan.owned_by?(current_user.id) then %> <%= link_to _('Delete'), plan_path(plan), :class => "dmp_table_link",