mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-18 13:38:24 -04:00
Merge pull request #4254 from Growstuff/feature/copy-activity
Add ability to copy/duplicate an activity
This commit is contained in:
@@ -33,6 +33,8 @@ class ActivitiesController < DataController
|
||||
due_date: Date.today
|
||||
)
|
||||
@activity.name = params[:name] if params[:name]
|
||||
@activity.description = params[:description] if params[:description]
|
||||
@activity.category = params[:category] if params[:category]
|
||||
@activity.due_date = params[:due_date] if params[:due_date]
|
||||
if params[:garden_id]
|
||||
@activity.garden = Garden.find_by(
|
||||
|
||||
@@ -88,6 +88,19 @@ module ButtonsHelper
|
||||
edit_button(edit_activity_path(activity), classes:)
|
||||
end
|
||||
|
||||
def activity_copy_button(activity, classes: 'btn')
|
||||
link_to new_activity_path(
|
||||
name: activity.name,
|
||||
description: activity.description,
|
||||
category: activity.category,
|
||||
garden_id: activity.garden_id,
|
||||
planting_id: activity.planting_id,
|
||||
due_date: activity.due_date
|
||||
), class: classes do
|
||||
copy_icon + ' ' + t('buttons.copy')
|
||||
end
|
||||
end
|
||||
|
||||
def activity_finish_button(activity, classes: 'btn btn-default btn-secondary')
|
||||
return unless can?(:edit, activity) || activity.finished
|
||||
|
||||
|
||||
@@ -59,6 +59,10 @@ module IconsHelper
|
||||
image_icon 'delete'
|
||||
end
|
||||
|
||||
def copy_icon
|
||||
icon('far', 'copy')
|
||||
end
|
||||
|
||||
def add_photo_icon
|
||||
image_icon 'add-photo'
|
||||
end
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
%a#activity-actions-button.btn.btn-info.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-bs-toggle" => "dropdown", type: "button", href: '#'} Actions
|
||||
.dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "planting-actions-button"}
|
||||
= activity_edit_button(activity, classes: 'dropdown-item')
|
||||
= activity_copy_button(activity, classes: 'dropdown-item')
|
||||
- if activity.active
|
||||
= activity_finish_button(activity, classes: 'dropdown-item')
|
||||
.dropdown-divider
|
||||
|
||||
@@ -72,6 +72,7 @@ en:
|
||||
add: Add
|
||||
add_photo: Add photo
|
||||
add_seed_to_stash: Add %{crop_name} seeds to stash
|
||||
copy: Copy
|
||||
delete: Delete
|
||||
edit: Edit
|
||||
harvest: Harvest
|
||||
|
||||
Reference in New Issue
Block a user