Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix copying meetings between types, allow empty copy of structured meetings #14231

Merged
merged 2 commits into from Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -21,12 +21,21 @@
item.with_leading_visual_icon(icon: :pencil)
end if @meeting.editable?

menu.with_item(label: t(:button_copy),
href: copy_meeting_path(@meeting),
content_arguments: {
data: { turbo: false }
}) do |item|
item.with_leading_visual_icon(icon: :copy)
end

menu.with_item(label: t(:label_icalendar_download),
href: download_ics_meeting_path(@meeting)) do |item|
item.with_leading_visual_icon(icon: :download)
end

if User.current.allowed_to?(:send_meeting_agendas_notification, @meeting.project)
if User.current.allowed_in_project?(:send_meeting_agendas_notification, @meeting.project
)
menu.with_item(label: t('meeting.label_mail_all_participants'),
href: notify_meeting_path(@meeting),
form_arguments: { method: :post, data: { turbo: 'false' } }) do |item|
Expand Down
2 changes: 1 addition & 1 deletion modules/meeting/app/controllers/meetings_controller.rb
Expand Up @@ -102,7 +102,7 @@ def copy
params[:copied_from_meeting_id] = @meeting.id
params[:copied_meeting_agenda_text] = @meeting.agenda.text if @meeting.agenda.present?
@meeting = @meeting.copy(author: User.current)
render action: 'new', project_id: @project
render action: 'new', project_id: @project, locals: { copy: true }
end

def destroy
Expand Down
8 changes: 5 additions & 3 deletions modules/meeting/app/models/meeting.rb
Expand Up @@ -165,13 +165,15 @@ def all_changeable_participants
def copy(attrs)
copy = dup

# Called simply to initialize the value
copy.start_date
copy.start_time_hour
# Set a default to next week
copy.start_time = start_time + 1.week

copy.author = attrs.delete(:author)
copy.attributes = attrs
copy.set_initial_values
# Initialize virtual attributes
copy.start_date
copy.start_time_hour

copy.participants.clear
copy.participants_attributes = allowed_participants.collect(&:copy_attributes)
Expand Down
4 changes: 4 additions & 0 deletions modules/meeting/app/views/meetings/_form.html.erb
Expand Up @@ -55,6 +55,10 @@ See COPYRIGHT and LICENSE files for more details.
</span>
<p class="op-tile-block--description">
<%= t('meeting.types.structured_text') %>
<% if local_assigns[:copy] %>
<br/>
<strong><%= t('meeting.types.structured_text_copy') %></strong>
<% end %>
</p>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion modules/meeting/app/views/meetings/new.html.erb
Expand Up @@ -30,12 +30,13 @@ See COPYRIGHT and LICENSE files for more details.
<% html_title t(:label_meeting_new) %>
<%= toolbar title: t(:label_meeting_new) %>
<%= labelled_tabular_form_for @meeting,
as: :meeting,
url: {:controller => '/meetings', :action => 'create', :project_id => @project},
:html => {:id => 'meeting-form',
:data => { :controller => 'refresh-on-form-changes',
'refresh-on-form-changes-target': 'form',
'refresh-on-form-changes-turbo-stream-url-value': new_meeting_url }} do |f| -%>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= render :partial => 'form', :locals => { f:, copy: local_assigns[:copy] } %>
<%= styled_button_tag t(:button_create), class: '-highlight' %>
<%= link_to t(:button_cancel), { :action => 'index', :project_id => @project },
class: 'button' %>
Expand Down
1 change: 1 addition & 0 deletions modules/meeting/config/locales/en.yml
Expand Up @@ -125,6 +125,7 @@ en:
classic_text: 'Organize your meeting in a formattable text agenda and protocol.'
structured: 'Dynamic'
structured_text: 'Organize your meeting as a list of agenda items, optionally linking them to a work package.'
structured_text_copy: 'Copying a meeting will currently not copy the associated meeting agenda items, just the details'
copied: "Copied from Meeting #%{id}"

notice_successful_notification: "Notification sent successfully"
Expand Down
4 changes: 2 additions & 2 deletions modules/meeting/spec/features/meetings_copy_spec.rb
Expand Up @@ -62,7 +62,7 @@

shared_let(:twelve_hour_format) { "%I:%M %p" }
shared_let(:copied_meeting_time_heading) do
date = start_time.strftime("%m/%d/%Y")
date = start_time.next_week.strftime("%m/%d/%Y")
start_of_meeting = start_time.strftime(twelve_hour_format)
end_of_meeting = (start_time + meeting.duration.hours).strftime(twelve_hour_format)

Expand Down Expand Up @@ -90,7 +90,7 @@
expect(page)
.to have_field 'Duration', with: meeting.duration
expect(page)
.to have_field 'Start date', with: start_time.strftime("%Y-%m-%d")
.to have_field 'Start date', with: start_time.next_week.strftime("%Y-%m-%d")
expect(page)
.to have_field 'Time', with: start_time.strftime("%H:%M")

Expand Down
Expand Up @@ -62,7 +62,8 @@

let(:current_user) { user }
let(:new_page) { Pages::Meetings::New.new(project) }
let(:show_page) { Pages::StructuredMeeting::Show.new(StructuredMeeting.order(id: :asc).last) }
let(:meeting) { StructuredMeeting.order(id: :asc).last }
let(:show_page) { Pages::StructuredMeeting::Show.new(meeting) }

before do
login_as current_user
Expand Down Expand Up @@ -250,6 +251,30 @@
expect(page).to have_css('.flash', text: I18n.t('activerecord.errors.messages.error_conflict'))
end

it 'can copy the meeting (empty)' do
show_page.expect_toast(message: 'Successful creation')

# Can add and edit a single item
show_page.add_agenda_item do
fill_in 'Title', with: 'My agenda item'
fill_in 'Duration (min)', with: '25'
end

show_page.expect_agenda_item title: 'My agenda item'
show_page.cancel_add_form

click_button('op-meetings-header-action-trigger')
click_link 'Copy'

expect(page).to have_current_path "/meetings/#{meeting.id}/copy"

click_button 'Create'

expect(page).to have_text 'Your meeting is empty'
new_meeting = StructuredMeeting.reorder(id: :asc).last
expect(page).to have_current_path "/meetings/#{new_meeting.id}"
end

context 'with a work package reference to another' do
let!(:meeting) { create(:structured_meeting, project:, author: current_user) }
let!(:other_project) { create(:project) }
Expand Down