Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add copying attachment as a checkbox

Oliver Güntherefb4e735a8cb
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index afc0b5a8f74..f928fd9abf3 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -75,7 +75,7 @@ class MeetingsController < ApplicationController
if @copy_from
::Meetings::CopyService
.new(user: current_user, model: @copy_from)
- .call(attributes: @converted_params, copy_agenda: params[:copy_agenda] == '1')
+ .call(attributes: @converted_params, **copy_attributes)
else
::Meetings::CreateService
.new(user: current_user)
@@ -335,4 +335,11 @@ class MeetingsController < ApplicationController
rescue ActiveRecord::RecordNotFound
render_404
end
+
+ def copy_attributes
+ {
+ copy_agenda: params[:copy_agenda] == '1',
+ copy_attachments: params[:copy_attachments] == '1',
+ }
+ end
end
diff --git a/modules/meeting/app/services/meetings/copy_service.rb b/modules/meeting/app/services/meetings/copy_service.rb
index 686421add8c..1e40c87ea05 100644
--- a/modules/meeting/app/services/meetings/copy_service.rb
+++ b/modules/meeting/app/services/meetings/copy_service.rb
@@ -42,7 +42,7 @@ module Meetings
self.contract_class = contract_class
end
- def call(send_notifications: nil, save: true, copy_agenda: true, copy_attachments: true, attributes: {})
+ def call(send_notifications: nil, save: true, copy_agenda: true, copy_attachments: false, attributes: {})
if save
create(meeting, attributes, send_notifications:, copy_agenda:, copy_attachments:)
else
diff --git a/modules/meeting/app/views/meetings/_form.html.erb b/modules/meeting/app/views/meetings/_form.html.erb
index 90aaa6ca245..cf74a6c7837 100644
--- a/modules/meeting/app/views/meetings/_form.html.erb
+++ b/modules/meeting/app/views/meetings/_form.html.erb
@@ -39,7 +39,7 @@ See COPYRIGHT and LICENSE files for more details.
<% if copy_from.present? %>
<%= f.hidden_field :type, value: copy_from.type %>
<%= hidden_field_tag "copied_from_meeting_id", copy_from.id %>
- <div class="form--field -required">
+ <div class="form--field">
<%= styled_label_tag 'copy_agenda', t('meeting.copy.agenda') %>
<div class="form--field-container">
<%= styled_check_box_tag 'copy_agenda',
@@ -52,6 +52,19 @@ See COPYRIGHT and LICENSE files for more details.
<%= t('meeting.copy.agenda_text') %>
</div>
</div>
+ <div class="form--field">
+ <%= styled_label_tag 'copy_attachments', t('meeting.copy.attachments') %>
+ <div class="form--field-container">
+ <%= styled_check_box_tag 'copy_attachments',
+ 1,
+ false,
+ no_label: true,
+ class: 'radio-button' %>
+ </div>
+ <div class="form--field-instructions">
+ <%= t('meeting.copy.attachments_text') %>
+ </div>
+ </div>
<% elsif @meeting.new_record? %>
<div class="form--field -required -align-start">
<label class="form--label" for="meeting_type"><%= Meeting.human_attribute_name(:type) %></label>
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index ec4288efb3f..0ad6eab92f3 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -115,6 +115,8 @@ en:
meeting:
copy:
title: "Copy meeting %{title}"
+ attachments: "Copy attachments"
+ attachments_text: "Copy over all attached files to the new meeting"
agenda: "Copy agenda"
agenda_text: "Copy the agenda of the old meeting"
email:
diff --git a/modules/meeting/spec/services/meetings/copy_service_integration_spec.rb b/modules/meeting/spec/services/meetings/copy_service_integration_spec.rb
index 7f855ea018b..f0fcd27170b 100644
--- a/modules/meeting/spec/services/meetings/copy_service_integration_spec.rb
+++ b/modules/meeting/spec/services/meetings/copy_service_integration_spec.rb
@@ -119,15 +119,18 @@ RSpec.describe Meetings::CopyService, "integration", type: :model do
notes: "![](/api/v3/attachments/#{attachment.id}/content")
end
- it "copies the attachment" do
- expect(copy.attachments.length)
- .to eq 1
+ context "when asking to copy attachments" do
+ let(:params) { { copy_attachments: true } }
+ it "copies the attachment" do
+ expect(copy.attachments.length)
+ .to eq 1
- expect(copy.attachments.first.id)
- .not_to eq attachment.id
+ expect(copy.attachments.first.id)
+ .not_to eq attachment.id
- expect(copy.agenda_items.count).to eq(1)
- expect(copy.agenda_items.first.notes).to include "attachments/#{copy.attachments.first.id}/content"
+ expect(copy.agenda_items.count).to eq(1)
+ expect(copy.agenda_items.first.notes).to include "attachments/#{copy.attachments.first.id}/content"
+ end
end
context "when asking not to copy attachments" do