Skip to content

Commit

Permalink
chore[Op#57515]: Redefine filter as `Filters::AvailableCustomFieldsPr…
Browse files Browse the repository at this point in the history
…ojectsFilter`

clarify that we're querying against `CustomFieldsProject` which is the join table for all custom field types, except "ProjectCustomField" aka "Project Attributes" which uses a special join table `ProjectCustomFieldsProjectMapping`
  • Loading branch information
akabiru committed Sep 4, 2024
1 parent d0b68e1 commit f240ef7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class Admin::CustomFields::CustomFieldProjectsController < ApplicationController
menu_item :custom_fields

def index
@available_project_custom_fields_query = ProjectQuery.new(
@available_custom_fields_projects_query = ProjectQuery.new(
name: "custom-fields-projects-#{@custom_field.id}"
) do |query|
query.where(:available_project_custom_fields, "=", [@custom_field.id])
query.where(:available_custom_fields_projects, "=", [@custom_field.id])
query.select(:name)
query.order("lft" => "asc")
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/queries/projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module Queries::Projects
::Queries::Register.register(ProjectQuery) do
filter Filters::AncestorFilter
filter Filters::AvailableProjectAttributesFilter
filter Filters::AvailableProjectCustomFieldsFilter
filter Filters::AvailableCustomFieldsProjectsFilter
filter Filters::TypeFilter
filter Filters::ActiveFilter
filter Filters::TemplatedFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
# ++
#

class Queries::Projects::Filters::AvailableProjectCustomFieldsFilter < Queries::Projects::Filters::Base
class Queries::Projects::Filters::AvailableCustomFieldsProjectsFilter < Queries::Projects::Filters::Base
def self.key
:available_project_custom_fields
:available_custom_fields_projects
end

def type
Expand Down Expand Up @@ -65,6 +65,6 @@ def where
end

def human_name
I18n.t(:label_available_project_custom_fields)
I18n.t(:label_available_custom_fields_projects)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ See COPYRIGHT and LICENSE files for more details.
end
else
render(Admin::CustomFields::CustomFieldProjects::TableComponent.new(
query: @available_project_custom_fields_query,
query: @available_custom_fields_projects_query,
params: params.merge({ custom_field: @custom_field }))
)
end
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2070,9 +2070,9 @@ en:
label_attribute_expand_text: "The complete text for '%{attribute}'"
label_authentication: "Authentication"
label_authentication_settings: "Authentication settings"
label_available_custom_fields_projects: "Available custom fields projects"
label_available_global_roles: "Available global roles"
label_available_project_attributes: "Available project attributes"
label_available_project_custom_fields: "Available project custom fields"
label_available_project_forums: "Available forums"
label_available_project_repositories: "Available repositories"
label_available_project_versions: "Available versions"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@

require "spec_helper"

RSpec.describe Queries::Projects::Filters::AvailableProjectCustomFieldsFilter do
RSpec.describe Queries::Projects::Filters::AvailableCustomFieldsProjectsFilter do
it_behaves_like "basic query filter" do
let(:class_key) { :available_project_custom_fields }
let(:class_key) { :available_custom_fields_projects }
let(:type) { :list }
let(:human_name) { "Available project custom fields" }
let(:human_name) { "Available custom fields projects" }
end

it_behaves_like "list query filter", scope: false do
Expand All @@ -44,7 +44,7 @@
let(:valid_values) do
[custom_field_project1.custom_field_id.to_s, custom_field_project2.custom_field_id.to_s]
end
let(:name) { "Available project attributes" }
let(:name) { "Available custom fields projects" }

describe "#apply_to" do
let(:values) { valid_values }
Expand Down

0 comments on commit f240ef7

Please sign in to comment.