Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14718 from opf/feature/52119-make-renamed-attribu…
…tes-searchable-with-old-names [#52119] Make renamed progress attributes searchable with old names
- Loading branch information
Showing
9 changed files
with
178 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
frontend/src/app/shared/components/work-packages/alternative-search.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { I18nService } from 'core-app/core/i18n/i18n.service'; | ||
import { QueryFilterResource } from 'core-app/features/hal/resources/query-filter-resource'; | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
|
||
export class AlternativeSearchService { | ||
constructor( | ||
readonly I18n:I18nService, | ||
) { } | ||
|
||
private specialSearchStrings = { | ||
percentComplete: this.I18n.t('js.work_packages.properties.percentComplete'), | ||
percentCompleteAlternative: this.I18n.t('js.work_packages.properties.percentCompleteAlternative'), | ||
work: this.I18n.t('js.work_packages.properties.work'), | ||
workAlternative: this.I18n.t('js.work_packages.properties.workAlternative'), | ||
remainingWork: this.I18n.t('js.work_packages.properties.remainingWork'), | ||
remainingWorkAlternative: this.I18n.t('js.work_packages.properties.remainingWorkAlternative'), | ||
}; | ||
|
||
private alternativeNames:{ [index:string]:string } = { | ||
[this.specialSearchStrings.percentCompleteAlternative]: this.specialSearchStrings.percentComplete, | ||
[this.specialSearchStrings.workAlternative]: this.specialSearchStrings.work, | ||
[this.specialSearchStrings.remainingWorkAlternative]: this.specialSearchStrings.remainingWork, | ||
}; | ||
|
||
public searchFunction = (term:string, currentItem:QueryFilterResource):boolean => { | ||
const lowercaseSearchTerm = term.toLowerCase(); | ||
const lowercaseCurrentItemName = currentItem.name.toLowerCase(); | ||
|
||
const alternativeMatch = Object | ||
.keys(this.alternativeNames) | ||
.some((alternativeName) => { | ||
return alternativeName.toLowerCase().includes(lowercaseSearchTerm) | ||
&& currentItem.name === this.alternativeNames[alternativeName]; | ||
}); | ||
|
||
return lowercaseCurrentItemName.includes(lowercaseSearchTerm) | ||
|| alternativeMatch; | ||
}; | ||
} |
84 changes: 84 additions & 0 deletions
84
spec/features/a11y/work_packages/alternative_name_autcompleting_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# frozen_string_literal: true | ||
|
||
# -- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2024 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 'spec_helper' | ||
|
||
RSpec.describe "Alternative name autocompleting", | ||
:js, | ||
:with_cuprite do | ||
let!(:project) { create(:project_with_types) } | ||
let!(:work_package) { create(:work_package, project:) } | ||
let!(:user) { create(:admin) } | ||
|
||
let(:work_packages_page) { Pages::WorkPackagesTable.new(project) } | ||
let(:filters) { Components::WorkPackages::Filters.new } | ||
let(:columns) { Components::WorkPackages::Columns.new } | ||
|
||
before { login_as(user) } | ||
|
||
describe 'Work package filter autocompleter' do | ||
it 'allows discovering attributes by alternative names' do | ||
work_packages_page.visit! | ||
work_packages_page.expect_work_package_listed(work_package) | ||
|
||
filters.open! | ||
|
||
# Exact alternative match | ||
filters.expect_alternative_available_filter('Progress', '% Complete') | ||
# Partial alternative match | ||
filters.expect_alternative_available_filter('ime', 'Work') | ||
# Exact "real" match | ||
filters.expect_alternative_available_filter('% Complete', '% Complete') | ||
# Partial "real" match | ||
filters.expect_alternative_available_filter('ork', 'Work') | ||
# Indifferent to casing | ||
filters.expect_alternative_available_filter('% comp', '% Complete') | ||
end | ||
end | ||
|
||
describe 'Work package view configuration form' do | ||
it 'allows discovering attributes by alternative names' do | ||
work_packages_page.visit! | ||
work_packages_page.expect_work_package_listed(work_package) | ||
|
||
columns.open_modal | ||
# Exact alternative match | ||
columns.expect_alternative_available_column('Progress', '% Complete') | ||
# Partial alternative match | ||
columns.expect_alternative_available_column('ime', 'Work') | ||
# Exact "real" match | ||
columns.expect_alternative_available_column('% Complete', '% Complete') | ||
# Partial "real" match | ||
columns.expect_alternative_available_column('hours', 'Remaining work') | ||
# Indifferent to casing | ||
columns.expect_alternative_available_column('% comp', '% Complete') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters