diff --git a/core/app/assets/stylesheets/refinery/components/_icons.scss b/core/app/assets/stylesheets/refinery/components/_icons.scss index 41eb7536f7..9d0284e334 100644 --- a/core/app/assets/stylesheets/refinery/components/_icons.scss +++ b/core/app/assets/stylesheets/refinery/components/_icons.scss @@ -10,6 +10,7 @@ .delete_section_icon {@include icon('minus-circle', $icon_delete_colour);} .download_icon {@include icon('download');} +.duplicate_icon {@include icon('copy');} .edit_email_icon {@include icon('envelope-o');} .edit_icon {@include icon('edit', $icon_edit_colour);} .email_icon {@include icon('envelope-o');} diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml index 3ba67fa260..ed851e9562 100644 --- a/core/config/locales/en.yml +++ b/core/config/locales/en.yml @@ -17,6 +17,8 @@ en: updated: '%{what} was successfully updated.' destroyed: '%{what} was successfully removed.' not_destroyed: '%{what} was not removed.' + duplicated: '%{what} was duplicated.' + duplicate_suffix: ' Copy' site_bar: log_out: Log out switch_to_your_website: Switch to your website diff --git a/core/lib/refinery/crud.rb b/core/lib/refinery/crud.rb index a94b86ecda..4ae5451e23 100644 --- a/core/lib/refinery/crud.rb +++ b/core/lib/refinery/crud.rb @@ -59,7 +59,7 @@ def self.crudify_options end prepend_before_action :find_#{singular_name}, - :only => [:update, :destroy, :edit, :show] + :only => [:update, :destroy, :edit, :show, :duplicate] prepend_before_action :merge_position_into_params!, :only => :create def new @@ -83,6 +83,17 @@ def create def edit # object gets found by find_#{singular_name} function end + + def duplicate + original = @#{singular_name} + @#{singular_name} = original.dup + @#{singular_name}.title << duplicate_suffix + render 'edit' + end + + def duplicate_suffix + t('refinery.crudify.duplicate_suffix') + end def update if @#{singular_name}.update(#{singular_name}_params)