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
Add (empty) type filter options to the share modal
Henriette Darge9ec35b9c06c7
diff --git a/app/components/work_packages/share/modal_body_component.html.erb b/app/components/work_packages/share/modal_body_component.html.erbindex cdcffed9c38..95336057902 100644--- a/app/components/work_packages/share/modal_body_component.html.erb+++ b/app/components/work_packages/share/modal_body_component.html.erb@@ -44,10 +44,14 @@button.with_trailing_action_icon(icon: "triangle-down")I18n.t('work_package.sharing.filter.type')end- menu.with_item(label: I18n.t('work_package.sharing.filter.project_member'))- menu.with_item(label: I18n.t('work_package.sharing.filter.not_project_member'))- menu.with_item(label: I18n.t('work_package.sharing.filter.project_group'))- menu.with_item(label: I18n.t('work_package.sharing.filter.not_project_group'))+ type_filter_options.each do |option|+ menu.with_item(label: option[:label],+ href: filter_url(type_option: option),+ method: :get,+ tag: :a,+ active: type_filter_option_active?(option),+ role: "menuitem")+ endendenddiff --git a/app/components/work_packages/share/modal_body_component.rb b/app/components/work_packages/share/modal_body_component.rbindex 96d6fb173cd..1f6873b6dac 100644--- a/app/components/work_packages/share/modal_body_component.rb+++ b/app/components/work_packages/share/modal_body_component.rb@@ -76,6 +76,24 @@ module WorkPackageslist_container.instance_variable_set(:@list_arguments, new_list_arguments)end+ def type_filter_options+ [+ { label: I18n.t('work_package.sharing.filter.project_member'),+ value: { principal_type: 'User', project_member: true } },+ { label: I18n.t('work_package.sharing.filter.not_project_member'),+ value: { principal_type: 'User', project_member: false } },+ { label: I18n.t('work_package.sharing.filter.project_group'),+ value: { principal_type: 'Group', project_member: true } },+ { label: I18n.t('work_package.sharing.filter.not_project_group'),+ value: { principal_type: 'Group', project_member: false } }+ ]+ end++ def type_filter_option_active?(option)+ # Todo+ false+ end+def role_filter_option_active?(option)return false if params[:filters].nil?@@ -85,14 +103,30 @@ module WorkPackagesfind_role_ids(option[:value]).first == given_role_filter_value unless given_role_filter_value.nil?end- def filter_url(role_option:)+ def filter_url(type_option: nil, role_option: nil)args = {}filter = []- unless role_filter_option_active?(role_option)+ unless type_option.nil? || type_filter_option_active?(type_option)+ if type_option[:value][:project_member]+ # Todo+ # filter.push({ entity_and_project_member: { operator: "=", values: [params[:work_package_id]] } })+ else+ # Todo+ # filter.push({ entity_and_no_project_member: { operator: "=", values: [params[:work_package_id]] } })+ end++ end++ unless role_option.nil? || role_filter_option_active?(role_option)filter.push({ role_id: { operator: "=", values: find_role_ids(role_option[:value]) } })++ filter.push({ entity_type: { operator: "=", values: [WorkPackage.name] } })+ filter.push({ entity_id: { operator: "=", values: [params[:work_package_id]] } })end+ # Todo: Keep options of the other filter defined in params+args[:filters] = filter.to_json unless filter.empty?work_package_shares_path(args)diff --git a/app/controllers/work_packages/shares_controller.rb b/app/controllers/work_packages/shares_controller.rbindex 8a562e17678..282d52c4ff1 100644--- a/app/controllers/work_packages/shares_controller.rb+++ b/app/controllers/work_packages/shares_controller.rb@@ -170,8 +170,9 @@ class WorkPackages::SharesController < ApplicationController@query = ParamsToQueryService.new(Member, current_user).call(params)# Set default filter on the entity- @query.where('entity_id', '=', @work_package.id)- @query.where('entity_type', '=', WorkPackage.name)+ @query.where('entity_id', '=', @work_package.id) unless params[:filters]+ @query.where('entity_type', '=', WorkPackage.name) unless params[:filters]+ @query.where('project_id', '=', @project.id)@query.order(name: :asc) unless params[:sortBy]diff --git a/app/models/queries/members/filters/entity_type_filter.rb b/app/models/queries/members/filters/entity_type_filter.rbindex 8c3117104c5..7430f58b811 100644--- a/app/models/queries/members/filters/entity_type_filter.rb+++ b/app/models/queries/members/filters/entity_type_filter.rb@@ -28,7 +28,11 @@class Queries::Members::Filters::EntityTypeFilter < Queries::Members::Filters::MemberFilterdef type- :string+ :list_optional+ end++ def allowed_values+ [[WorkPackage.name, WorkPackage.name]]enddef self.key