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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#40228] added linkable work packages filter
Eric Schubert1d7049a4e2dd
diff --git a/app/models/work_package.rb b/app/models/work_package.rbindex 94579eb4bf8..e980f5bfc85 100644--- a/app/models/work_package.rb+++ b/app/models/work_package.rb@@ -61,6 +61,7 @@ class WorkPackage < ApplicationRecordhas_many :time_entries, dependent: :delete_allhas_many :file_links, dependent: :delete_all, class_name: 'Storages::FileLink', foreign_key: 'container_id'+ has_many :storages, through: :projecthas_and_belongs_to_many :changesets, -> {order("#{Changeset.table_name}.committed_on ASC, #{Changeset.table_name}.id ASC")diff --git a/modules/storages/app/models/queries/storages/work_packages/filter/file_link_origin_id_filter.rb b/modules/storages/app/models/queries/storages/work_packages/filter/file_link_origin_id_filter.rbindex 2ffa64a9bd3..707a0cfa552 100644--- a/modules/storages/app/models/queries/storages/work_packages/filter/file_link_origin_id_filter.rb+++ b/modules/storages/app/models/queries/storages/work_packages/filter/file_link_origin_id_filter.rb@@ -32,10 +32,6 @@ module Queries::Storages::WorkPackages::Filter:listend- def available_operators- [::Queries::Operators::Equals]- end-def allowed_values# Allow all input values that are given to the filter.# If no result is found, an empty collection is returned.diff --git a/modules/storages/app/models/queries/storages/work_packages/filter/linkable_to_storage_id_filter.rb b/modules/storages/app/models/queries/storages/work_packages/filter/linkable_to_storage_id_filter.rbnew file mode 100644index 00000000000..10f5f7bb71e--- /dev/null+++ b/modules/storages/app/models/queries/storages/work_packages/filter/linkable_to_storage_id_filter.rb@@ -0,0 +1,49 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2022 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.+#++++module Queries::Storages::WorkPackages::Filter+ class LinkableToStorageIdFilter < ::Queries::WorkPackages::Filter::WorkPackageFilter+ def type+ :list+ end++ def allowed_values+ # Allow all input values that are given to the filter.+ # If no result is found, an empty collection is returned.+ values.map { |value| [nil, value] }+ end++ def where+ ::Queries::Operators::Equals.sql_for_field(values, ::Storages::Storage.table_name, 'id')+ end++ def joins+ :storages+ end+ end+enddiff --git a/modules/storages/app/models/queries/storages/work_packages/filter/linkable_to_storage_url_filter.rb b/modules/storages/app/models/queries/storages/work_packages/filter/linkable_to_storage_url_filter.rbnew file mode 100644index 00000000000..2050cfd802c--- /dev/null+++ b/modules/storages/app/models/queries/storages/work_packages/filter/linkable_to_storage_url_filter.rb@@ -0,0 +1,50 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2022 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.+#++++module Queries::Storages::WorkPackages::Filter+ class LinkableToStorageUrlFilter < ::Queries::WorkPackages::Filter::WorkPackageFilter+ def type+ :list+ end++ def allowed_values+ # Allow all input values that are given to the filter.+ # If no result is found, an empty collection is returned.+ values.map { |value| [nil, value] }+ end++ def where+ canonical_url_values = values.map { |value| CGI.unescape(value).gsub(/\/+$/, '') }+ ::Queries::Operators::Equals.sql_for_field(canonical_url_values, ::Storages::Storage.table_name, 'host')+ end++ def joins+ :storages+ end+ end+enddiff --git a/modules/storages/lib/open_project/storages/engine.rb b/modules/storages/lib/open_project/storages/engine.rbindex b5517fa69fd..18feb38cfc9 100644--- a/modules/storages/lib/open_project/storages/engine.rb+++ b/modules/storages/lib/open_project/storages/engine.rb@@ -80,9 +80,12 @@ module OpenProject::Storagesconfig.to_prepare do::Queries::Register.filter ::Query, ::Queries::Storages::WorkPackages::Filter::FileLinkOriginIdFilter+ ::Queries::Register.filter ::Query, ::Queries::Storages::WorkPackages::Filter::LinkableToStorageIdFilter+ ::Queries::Register.filter ::Query, ::Queries::Storages::WorkPackages::Filter::LinkableToStorageUrlFilterend- # ToDo: Why is there |storage_id|? Is this a kind of manual routes.rb?+ # This helper methods adds a method on the `api_v3_paths` helper. It is created with one parameter (storage_id)+ # and the return value is a string.add_api_path :storage do |storage_id|"#{root}/storages/#{storage_id}"end