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

Address Jens's PR feedback

Aaron Contreras2fc089ea41e7
diff --git a/frontend/src/global_styles/content/_forms.sass b/frontend/src/global_styles/content/_forms.sass
index db7197587aa..fd1463595c9 100644
--- a/frontend/src/global_styles/content/_forms.sass
+++ b/frontend/src/global_styles/content/_forms.sass
@@ -630,10 +630,6 @@ input[readonly].-clickable
line-height: normal
padding: 3px 24px 3px 3px
- &.-prompt-visible
- font-style: italic
- color: $spot-color-basic-gray-3
-
&[multiple]
background-image: none
padding-right: $form-padding
diff --git a/frontend/src/stimulus/controllers/dynamic/select-field-with-prompt.controller.ts b/frontend/src/stimulus/controllers/dynamic/select-field-with-prompt.controller.ts
deleted file mode 100644
index 63d959fd611..00000000000
--- a/frontend/src/stimulus/controllers/dynamic/select-field-with-prompt.controller.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * -- copyright
- * OpenProject is an open source project management software.
- * Copyright (C) 2023 the OpenProject GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version 3.
- *
- * OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
- * Copyright (C) 2006-2013 Jean-Philippe Lang
- * Copyright (C) 2010-2013 the ChiliProject Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * See COPYRIGHT and LICENSE files for more details.
- * ++
- */
-
-import { Controller } from '@hotwired/stimulus';
-
-export default class SelectFieldWithPromptController extends Controller<HTMLSelectElement> {
- connect() {
- this.togglePromptStyling();
- }
-
- togglePromptStyling() {
- if (this.promptSelected()) {
- this.element.classList.add('-prompt-visible');
- } else {
- this.element.classList.remove('-prompt-visible');
- }
- }
-
- private promptSelected() {
- const options = Array.from(this.element.options);
-
- return options.find((option) => option.value === '' && option.selected);
- }
-}
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index d5039829952..4b94c4b2f8a 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -138,19 +138,6 @@ class MeetingsController < ApplicationController
@meeting.author = User.current
end
- def project_id
- params[:project_id] || params.dig(:meeting, :project_id)
- end
-
- def find_optional_project
- return true if project_id.blank?
-
- @project = Project.find(project_id)
- authorize
- rescue ActiveRecord::RecordNotFound
- render_404
- end
-
def global_upcoming_meetings
projects = Project.allowed_to(User.current, :view_meetings)
diff --git a/modules/meeting/app/helpers/meetings_helper.rb b/modules/meeting/app/helpers/meetings_helper.rb
index 69a7f88ca28..844b7ca7327 100644
--- a/modules/meeting/app/helpers/meetings_helper.rb
+++ b/modules/meeting/app/helpers/meetings_helper.rb
@@ -77,8 +77,18 @@ module MeetingsHelper
request.path == new_meeting_path
end
- def new_form_refresh_url
- participants_section_meetings_path
+ def participants_section_refresh_url
+ if global_create_context?
+ participants_section_meetings_path
+ else
+ participants_section_meetings_path(project_id: @project.id)
+ end
+ end
+
+ def participants_section_attributes
+ attributes = { data: { refresh_on_form_changes_target: 'turboFrame' } }
+ attributes = attributes.merge({ src: participants_section_refresh_url }) unless global_create_context?
+ attributes
end
def options_for_project_selection
@@ -86,8 +96,4 @@ module MeetingsHelper
.filter { _1.module_enabled?('meetings') }
.map { [_1.name, _1.id] }
end
-
- def project_select_initial_class_list
- params.dig(:meeting, :project_id).blank? ? '-prompt-visible' : ''
- end
end
diff --git a/modules/meeting/app/views/meetings/_form.html.erb b/modules/meeting/app/views/meetings/_form.html.erb
index 9d949387a88..53b89352acc 100644
--- a/modules/meeting/app/views/meetings/_form.html.erb
+++ b/modules/meeting/app/views/meetings/_form.html.erb
@@ -37,18 +37,23 @@ See COPYRIGHT and LICENSE files for more details.
<% if global_create_context? %>
<div class="form--field -required">
- <%= f.select :project_id,
- options_for_project_selection,
- {prompt: t(:project_selection_placeholder),
- container_class: '-wide'},
- class: project_select_initial_class_list,
- required: true,
- data: {
- 'application-target': 'dynamic',
- controller: 'select-field-with-prompt',
- action: 'change->select-field-with-prompt#togglePromptStyling ' \
- 'change->refresh-on-form-changes#triggerTurboReload'
- } %>
+ <label class="form--label" for="project_id"><%= Meeting.human_attribute_name(:project) %>:</label>
+ <div class="form--field-container">
+ <%= angular_component_tag 'op-project-autocompleter',
+ inputs: {
+ apiFilters: [['user_action', '=', ['meetings/create']]],
+ name: 'project_id',
+ value: @project,
+ appendTo: 'body',
+ hiddenFieldAction: 'change->refresh-on-form-changes#triggerTurboReload',
+ },
+ id: 'project_id',
+ class: 'form--select-container -wide remote-field--input',
+ data: {
+ 'qa-selector': 'project_id'
+ }
+ %>
+ </div>
</div>
<% end %>
@@ -103,10 +108,7 @@ See COPYRIGHT and LICENSE files for more details.
</div>
</div>
- <%= turbo_frame_tag "participants_section",
- src: new_form_refresh_url,
- data: { refresh_on_form_changes_target: 'turboFrame' },
- loading: :lazy do %>
+ <%= turbo_frame_tag "participants_section", **participants_section_attributes do %>
<% end %>
<%= hidden_field_tag "copied_from_meeting_id", params[:copied_from_meeting_id] if params[:copied_from_meeting_id].present? %>
diff --git a/modules/meeting/app/views/meetings/new.html.erb b/modules/meeting/app/views/meetings/new.html.erb
index 48403b36920..6343a49db75 100644
--- a/modules/meeting/app/views/meetings/new.html.erb
+++ b/modules/meeting/app/views/meetings/new.html.erb
@@ -34,7 +34,7 @@ See COPYRIGHT and LICENSE files for more details.
:html => {:id => 'meeting-form',
:data => { :controller => 'refresh-on-form-changes',
'refresh-on-form-changes-target': 'form',
- 'refresh-on-form-changes-turbo-refresh-url-value': new_form_refresh_url }} do |f| -%>
+ 'refresh-on-form-changes-turbo-refresh-url-value': participants_section_refresh_url }} do |f| -%>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= styled_button_tag t(:button_create), class: '-highlight' %>
<%= link_to t(:button_cancel), { :action => 'index', :project_id => @project },
diff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rb
index c2135c721b0..30d5a5f19dd 100644
--- a/modules/meeting/lib/open_project/meeting/engine.rb
+++ b/modules/meeting/lib/open_project/meeting/engine.rb
@@ -40,7 +40,10 @@ module OpenProject::Meeting
project_module :meetings do
permission :view_meetings, meetings: %i[index show], meeting_agendas: %i[history show diff],
meeting_minutes: %i[history show diff]
- permission :create_meetings, { meetings: %i[new participants_section create copy] }, require: :member
+ permission :create_meetings,
+ { meetings: %i[new participants_section create copy] },
+ require: :member,
+ contract_actions: { meetings: %i[create] }
permission :edit_meetings, { meetings: %i[edit update] }, require: :member
permission :delete_meetings, { meetings: [:destroy] }, require: :member
permission :meetings_send_invite, { meetings: [:icalendar] }, require: :member
diff --git a/modules/meeting/spec/controllers/meetings_controller_spec.rb b/modules/meeting/spec/controllers/meetings_controller_spec.rb
index 8173a5a4896..7d8e462aa0c 100644
--- a/modules/meeting/spec/controllers/meetings_controller_spec.rb
+++ b/modules/meeting/spec/controllers/meetings_controller_spec.rb
@@ -127,14 +127,40 @@ RSpec.describe MeetingsController do
allow(Meeting).to receive(:new).and_return(meeting)
end
- describe 'html' do
+ context 'with a project id' do
before do
- get :participants_section, params: { project_id: project.id }
+ allow(Project).to receive(:find).and_return(project)
end
- it { expect(response).to be_successful }
- it { expect(response).to render_template :participants_section }
- it { expect(assigns(:meeting)).to eql meeting }
+ describe 'html' do
+ before do
+ get :participants_section, params: { project_id: project.id }
+ end
+
+ it { expect(response).to be_successful }
+ it { expect(response).to render_template :participants_section }
+ it { expect(assigns(:meeting)).to eql meeting }
+ it { expect(assigns(:project)).to eql project }
+ end
+ end
+
+ context 'without a project id' do
+ context 'with a project id' do
+ before do
+ allow(Project).to receive(:find).and_return(nil)
+ end
+
+ describe 'html' do
+ before do
+ get :participants_section
+ end
+
+ it { expect(response).to be_successful }
+ it { expect(response).to render_template :participants_section }
+ it { expect(assigns(:meeting)).to eql meeting }
+ it { expect(assigns(:project)).to be_nil }
+ end
+ end
end
end
diff --git a/modules/meeting/spec/features/meetings_new_spec.rb b/modules/meeting/spec/features/meetings_new_spec.rb
index 2b477414da0..0993f4a61e9 100644
--- a/modules/meeting/spec/features/meetings_new_spec.rb
+++ b/modules/meeting/spec/features/meetings_new_spec.rb
@@ -81,11 +81,6 @@ RSpec.describe 'Meetings new', :js do
new_page.set_title 'Some title'
new_page.set_project project
- # Setting the project reloads the page
- # causing a StaleElementReferenceError
- # if the execution is too quick.
- SeleniumHubWaiter.wait
-
new_page.set_start_date '2013-03-28'
new_page.set_start_time '13:30'
new_page.set_duration '1.5'
diff --git a/modules/meeting/spec/support/pages/meetings/new.rb b/modules/meeting/spec/support/pages/meetings/new.rb
index a632914888c..042828e2989 100644
--- a/modules/meeting/spec/support/pages/meetings/new.rb
+++ b/modules/meeting/spec/support/pages/meetings/new.rb
@@ -31,6 +31,8 @@ require_relative './show'
module Pages::Meetings
class New < Base
+ include Components::Autocompleter::NgSelectAutocompleteHelpers
+
def click_create
click_button 'Create'
@@ -48,7 +50,9 @@ module Pages::Meetings
end
def set_project(project)
- select project.name, from: 'Project'
+ select_autocomplete find("[data-qa-selector='project_id'"),
+ query: project.name,
+ results_selector: 'body'
end
def set_start_date(date)