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
Allow search to receive app_title as placeholder
Oliver Günther6da7132b3eb6
diff --git a/app/views/search/_mini_form.html.erb b/app/views/search/_mini_form.html.erbdeleted file mode 100644index fdbca3d30a7..00000000000--- a/app/views/search/_mini_form.html.erb+++ /dev/null@@ -1,31 +0,0 @@-<%#-- copyright-OpenProject is an open source project management software.-Copyright (C) 2012-2023 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.--++#%>-<div class="op-app-search">- <global-search-input></global-search-input>-</div>diff --git a/config/locales/en.yml b/config/locales/en.ymlindex a7f4dfe935b..96963dd924d 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -232,6 +232,7 @@ en:single: "or"global_search:+ placeholder: "Search in %{app_title}"overwritten_tabs:wiki_pages: "Wiki"messages: "Forum"diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex 7df08547718..c813937141a 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -1258,7 +1258,6 @@ en:current_project_and_all_descendants: "In this project + subprojects"current_project: "In this project"recently_viewed: "Recently viewed"- search: "Search"title:all_projects: "all projects"project_and_subprojects: "and all subprojects"diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.jsindex ee61c52ebdc..c9e146f26c0 100644--- a/frontend/.eslintrc.js+++ b/frontend/.eslintrc.js@@ -43,11 +43,11 @@ module.exports = {*/"@angular-eslint/directive-selector": ["error",- { "type": "attribute", "prefix": ["op", "spot"], "style": "camelCase" }+ {"type": "attribute", "prefix": ["op", "opce"], "style": "camelCase"},],"@angular-eslint/component-selector": ["error",- { "type": "element", "prefix": ["op", "spot"], "style": "kebab-case" }+ {"type": "element", "prefix": ["op", "opce"], "style": "kebab-case"},],"@angular-eslint/component-class-suffix": ["error", { "suffixes": ["Component", "Example"] }],diff --git a/frontend/src/app/core/global_search/input/global-search-input.component.html b/frontend/src/app/core/global_search/input/global-search-input.component.htmlindex d73d1eefbc9..d538f569d8d 100644--- a/frontend/src/app/core/global_search/input/global-search-input.component.html+++ b/frontend/src/app/core/global_search/input/global-search-input.component.html@@ -16,7 +16,7 @@[id]="'global-search-input'"[accesskey]="4"class="global-search"- [placeholder]="text.search_dots"+ [placeholder]="placeholder"[classes]="{'top-menu-search--input': true, '-markable': markable, '-expanded': expanded }"[inputAttrs]="{ 'class': 'global-search--input' }"[openOnEnter]="true"diff --git a/frontend/src/app/core/global_search/input/global-search-input.component.ts b/frontend/src/app/core/global_search/input/global-search-input.component.tsindex a9d9b75d4d0..db55ddf6db5 100644--- a/frontend/src/app/core/global_search/input/global-search-input.component.ts+++ b/frontend/src/app/core/global_search/input/global-search-input.component.ts@@ -33,33 +33,37 @@ import {Component,ElementRef,HostListener,+ Input,NgZone,OnDestroy,ViewChild,ViewEncapsulation,} from '@angular/core';import { BehaviorSubject, Observable, of } from 'rxjs';-import {- first, map, switchMap, tap,-} from 'rxjs/operators';+import { first, map, switchMap, tap } from 'rxjs/operators';import { GlobalSearchService } from 'core-app/core/global_search/services/global-search.service';import { isClickedWithModifier } from 'core-app/shared/helpers/link-handling/link-handling';-import { Highlighting } from 'core-app/features/work-packages/components/wp-fast-table/builders/highlighting/highlighting.functions';+import {+ Highlighting,+} from 'core-app/features/work-packages/components/wp-fast-table/builders/highlighting/highlighting.functions';import { DeviceService } from 'core-app/core/browser/device.service';import { insideOrSelf } from 'core-app/shared/directives/focus/contain-helpers';import { HalResourceNotificationService } from 'core-app/features/hal/services/hal-resource-notification.service';import { I18nService } from 'core-app/core/i18n/i18n.service';import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';-import { OpAutocompleterComponent } from 'core-app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component';+import {+ OpAutocompleterComponent,+} from 'core-app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component';import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';import { HalResourceService } from 'core-app/features/hal/services/hal-resource.service';import { HalResource } from 'core-app/features/hal/resources/hal-resource';import { ApiV3Service } from '../../apiv3/api-v3.service';-import { ApiV3WorkPackageCachedSubresource } from 'core-app/core/apiv3/endpoints/work_packages/api-v3-work-package-cached-subresource';+import {+ ApiV3WorkPackageCachedSubresource,+} from 'core-app/core/apiv3/endpoints/work_packages/api-v3-work-package-cached-subresource';import { RecentItemsService } from 'core-app/core/recent-items.service';--export const globalSearchSelector = 'global-search-input';+import { populateInputsFromDataset } from 'core-app/shared/components/dataset-inputs';interface SearchResultItem {id:string;@@ -82,7 +86,7 @@ interface SearchResultItems {}@Component({- selector: globalSearchSelector,+ selector: 'opce-global-search',changeDetection: ChangeDetectionStrategy.OnPush,templateUrl: './global-search-input.component.html',styleUrls: [@@ -94,6 +98,8 @@ interface SearchResultItems {encapsulation: ViewEncapsulation.None,})export class GlobalSearchInputComponent implements AfterViewInit, OnDestroy {+ @Input() public placeholder:string;+@ViewChild('btn', { static: true }) btn:ElementRef;@ViewChild(OpAutocompleterComponent, { static: true }) public ngSelectComponent:OpAutocompleterComponent;@@ -135,8 +141,6 @@ export class GlobalSearchInputComponent implements AfterViewInit, OnDestroy {current_project_and_all_descendants: this.I18n.t('js.global_search.current_project_and_all_descendants'),current_project: this.I18n.t('js.global_search.current_project'),recently_viewed: this.I18n.t('js.global_search.recently_viewed'),- search_dots: `${this.I18n.t('js.global_search.search')} ...`,- search: this.I18n.t('js.global_search.search'),};constructor(@@ -153,6 +157,7 @@ export class GlobalSearchInputComponent implements AfterViewInit, OnDestroy {readonly ngZone:NgZone,readonly recentItemsService:RecentItemsService,) {+ populateInputsFromDataset(this);}ngAfterViewInit():void {diff --git a/frontend/src/app/core/global_search/openproject-global-search.module.ts b/frontend/src/app/core/global_search/openproject-global-search.module.tsindex 5f4d534c6e4..745c77bd772 100644--- a/frontend/src/app/core/global_search/openproject-global-search.module.ts+++ b/frontend/src/app/core/global_search/openproject-global-search.module.ts@@ -26,17 +26,22 @@// See COPYRIGHT and LICENSE files for more details.//++-import { NgModule } from '@angular/core';+import { Injector, NgModule } from '@angular/core';import { OpenprojectWorkPackagesModule } from 'core-app/features/work-packages/openproject-work-packages.module';import { GlobalSearchInputComponent } from 'core-app/core/global_search/input/global-search-input.component';import { GlobalSearchWorkPackagesComponent } from 'core-app/core/global_search/global-search-work-packages.component';import { GlobalSearchTabsComponent } from 'core-app/core/global_search/tabs/global-search-tabs.component';import { GlobalSearchTitleComponent } from 'core-app/core/global_search/title/global-search-title.component';import { GlobalSearchService } from 'core-app/core/global_search/services/global-search.service';-import { GlobalSearchWorkPackagesEntryComponent } from 'core-app/core/global_search/global-search-work-packages-entry.component';-import { OpenprojectAutocompleterModule } from 'core-app/shared/components/autocompleter/openproject-autocompleter.module';+import {+ GlobalSearchWorkPackagesEntryComponent,+} from 'core-app/core/global_search/global-search-work-packages-entry.component';+import {+ OpenprojectAutocompleterModule,+} from 'core-app/shared/components/autocompleter/openproject-autocompleter.module';import { OpSharedModule } from 'core-app/shared/shared.module';import { RecentItemsService } from 'core-app/core/recent-items.service';+import { registerCustomElement } from 'core-app/shared/helpers/angular/custom-elements.helper';@NgModule({imports: [@@ -56,4 +61,8 @@ import { RecentItemsService } from 'core-app/core/recent-items.service';GlobalSearchTitleComponent,],})-export class OpenprojectGlobalSearchModule { }+export class OpenprojectGlobalSearchModule {+ constructor(readonly injector:Injector) {+ registerCustomElement('opce-global-search', GlobalSearchInputComponent, { injector });+ }+}diff --git a/frontend/src/app/core/setup/global-dynamic-components.const.ts b/frontend/src/app/core/setup/global-dynamic-components.const.tsindex 2afe03addc3..17d5cd5d452 100644--- a/frontend/src/app/core/setup/global-dynamic-components.const.ts+++ b/frontend/src/app/core/setup/global-dynamic-components.const.ts@@ -58,10 +58,6 @@ import {CopyToClipboardComponent,copyToClipboardSelector,} from 'core-app/shared/components/copy-to-clipboard/copy-to-clipboard.component';-import {- GlobalSearchInputComponent,- globalSearchSelector,-} from 'core-app/core/global_search/input/global-search-input.component';import {collapsibleSectionAugmentSelector,CollapsibleSectionComponent,@@ -214,7 +210,6 @@ export const globalDynamicComponents:OptionalBootstrapDefinition[] = [{ selector: copyToClipboardSelector, cls: CopyToClipboardComponent },{ selector: mainMenuResizerSelector, cls: MainMenuResizerComponent },{ selector: mainMenuToggleSelector, cls: MainMenuToggleComponent },- { selector: globalSearchSelector, cls: GlobalSearchInputComponent },{ selector: collapsibleSectionAugmentSelector, cls: CollapsibleSectionComponent },{ selector: enterpriseBannerSelector, cls: EnterpriseBannerComponent },{ selector: nonWorkingDaysListSelector, cls: OpNonWorkingDaysListComponent },diff --git a/lib/redmine/menu_manager/top_menu_helper.rb b/lib/redmine/menu_manager/top_menu_helper.rbindex 1d119595b81..28035e9d797 100644--- a/lib/redmine/menu_manager/top_menu_helper.rb+++ b/lib/redmine/menu_manager/top_menu_helper.rb@@ -50,7 +50,16 @@ module Redmine::MenuManager::TopMenuHelperenddef render_top_menu_search- render partial: 'search/mini_form'+ content_tag :div, class: 'op-app-search' do+ render_global_search_input+ end+ end++ def render_global_search_input+ angular_component_tag 'opce-global-search',+ inputs: {+ placeholder: I18n.t('global_search.placeholder', app_title: Setting.app_title)+ }enddef render_top_menu_right