Create a separate project edit helper for the work packages table

This commit is contained in:
Dombi Attila
2025-12-03 18:35:43 +02:00
parent 5a9f1c4c89
commit fc16f067f3
3 changed files with 72 additions and 10 deletions
@@ -0,0 +1,42 @@
# frozen_string_literal: true
# -- copyright
# OpenProject is an open source project management software.
# Copyright (C) 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.
# ++
require_relative "project_edit_field"
# For work package table inline editing
class InlineProjectEditField < ProjectEditField
def autocompleter
field_container.find("op-project-autocompleter")
end
def field_type
"op-project-autocompleter"
end
end
+29 -9
View File
@@ -1,16 +1,38 @@
# frozen_string_literal: true
# -- copyright
# OpenProject is an open source project management software.
# Copyright (C) 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.
# ++
require_relative "select_edit_field"
class ProjectEditField < SelectField
def autocompleter
if @selector&.start_with?("op")
# Direct autocompleter selector (for settings pages)
field_container
else
# Inline edit container (for work package tables)
field_container.find("op-project-autocompleter")
end
field_container
end
def search_for(query)
@@ -25,14 +47,12 @@ class ProjectEditField < SelectField
def expect_option(name, workspace_badge: false)
within(dropdown) do
# Find the option containing the name
option = page.find(".ng-option", text: name)
if workspace_badge
expect(option).to have_octicon
expect(option).to have_primer_text(workspace_badge, color: :muted)
else
# Expect no octicon SVG
expect(option).to have_no_octicon
expect(option).to have_no_primer_text(color: :muted)
end
@@ -391,7 +391,7 @@ module Pages
when :estimatedTime, :remainingTime
ProgressEditField.new container, key
when :project
ProjectEditField.new container, key
InlineProjectEditField.new container, key
else
EditField.new container, key
end