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
[#42552] added storage filter to file links endpoint
Eric Schubert402c52fedc3a
diff --git a/docs/api/apiv3/paths/work_package_file_links.yml b/docs/api/apiv3/paths/work_package_file_links.ymlindex a49e2bbbd10..b43226d7985 100644--- a/docs/api/apiv3/paths/work_package_file_links.yml+++ b/docs/api/apiv3/paths/work_package_file_links.yml@@ -129,6 +129,18 @@ get:schema:type: integerexample: 1337+ - name: filters+ in: query+ description: |-+ JSON specifying filter conditions.+ Accepts the same format as returned by the [queries](https://www.openproject.org/docs/api/endpoints/queries/)+ endpoint. The following filters are supported:++ - storage_id+ required: false+ example: '[{"storage_id":{"operator":"=","values":["42"]}}]'+ schema:+ type: stringresponses:'200':description: OKdiff --git a/modules/storages/app/models/queries/storages/file_links/filter/storage_id_filter.rb b/modules/storages/app/models/queries/storages/file_links/filter/storage_id_filter.rbnew file mode 100644index 00000000000..d34e4e8e176--- /dev/null+++ b/modules/storages/app/models/queries/storages/file_links/filter/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::FileLinks::Filter+ class StorageIdFilter < ::Queries::Filters::Base+ self.model = ::Storages::FileLink++ def human_name+ ::Storages::FileLink.human_attribute_name(name)+ end++ def type+ :list+ end++ def allowed_values+ ::Storages::Storage.pluck(:id).map { |id| [id, id.to_s] }+ end++ def where+ operator_strategy.sql_for_field(values, ::Storages::FileLink.table_name, 'storage_id')+ end+ end+enddiff --git a/modules/storages/lib/open_project/storages/engine.rb b/modules/storages/lib/open_project/storages/engine.rbindex fcc2bdd4b27..29ac7ec339e 100644--- a/modules/storages/lib/open_project/storages/engine.rb+++ b/modules/storages/lib/open_project/storages/engine.rb@@ -94,7 +94,8 @@ module OpenProject::Storages::Queries::Storages::WorkPackages::Filter::StorageIdFilter,::Queries::Storages::WorkPackages::Filter::StorageUrlFilter,::Queries::Storages::WorkPackages::Filter::LinkableToStorageIdFilter,- ::Queries::Storages::WorkPackages::Filter::LinkableToStorageUrlFilter+ ::Queries::Storages::WorkPackages::Filter::LinkableToStorageUrlFilter,+ ::Queries::Storages::FileLinks::Filter::StorageIdFilter].each do |filter|filter filterexclude filter