From 4a8b5bd15837195e384246f231a4d3319dd6dbe7 Mon Sep 17 00:00:00 2001 From: Eric Schubert Date: Tue, 16 Nov 2021 13:52:24 +0100 Subject: [PATCH 1/5] [#39772] Moved wp-quqery-select to op-query-select --- .../work_packages/_menu_query_select.html.erb | 2 +- .../setup/global-dynamic-components.const.ts | 9 ++++--- .../openproject-work-packages.module.ts | 4 ---- .../partitioned-query-space-page.component.ts | 2 +- .../wp-view-base/work-packages-view.base.ts | 4 ++-- .../op-query-select.component.ts} | 24 +++++++++---------- .../op-query-select.template.html} | 2 +- .../op-static-queries.service.ts} | 2 +- frontend/src/app/shared/shared.module.ts | 6 +++++ .../work_packages/work_packages_table.rb | 2 +- 10 files changed, 29 insertions(+), 28 deletions(-) rename frontend/src/app/{features/work-packages/components/wp-query-select/wp-query-select-dropdown.component.ts => shared/components/op-query-select/op-query-select.component.ts} (87%) rename frontend/src/app/{features/work-packages/components/wp-query-select/wp-query-select.template.html => shared/components/op-query-select/op-query-select.template.html} (94%) rename frontend/src/app/{features/work-packages/components/wp-query-select/wp-static-queries.service.ts => shared/components/op-query-select/op-static-queries.service.ts} (99%) diff --git a/app/views/work_packages/_menu_query_select.html.erb b/app/views/work_packages/_menu_query_select.html.erb index 6b9025e494..4f99966bdc 100644 --- a/app/views/work_packages/_menu_query_select.html.erb +++ b/app/views/work_packages/_menu_query_select.html.erb @@ -1 +1 @@ - + diff --git a/frontend/src/app/core/setup/global-dynamic-components.const.ts b/frontend/src/app/core/setup/global-dynamic-components.const.ts index 9766218e88..ebcc94bd92 100644 --- a/frontend/src/app/core/setup/global-dynamic-components.const.ts +++ b/frontend/src/app/core/setup/global-dynamic-components.const.ts @@ -98,9 +98,9 @@ import { wpOverviewGraphSelector, } from 'core-app/shared/components/work-package-graphs/overview/wp-overview-graph.component'; import { - WorkPackageQuerySelectDropdownComponent, - wpQuerySelectSelector, -} from 'core-app/features/work-packages/components/wp-query-select/wp-query-select-dropdown.component'; + opQuerySelectSelector, + QuerySelectComponent, +} from 'core-app/shared/components/op-query-select/op-query-select.component'; import { GlobalSearchTitleComponent, globalSearchTitleSelector, @@ -184,7 +184,6 @@ import { ianMenuSelector, } from 'core-app/features/in-app-notifications/center/menu/menu.component'; - export const globalDynamicComponents:OptionalBootstrapDefinition[] = [ { selector: appBaseSelector, cls: ApplicationBaseComponent }, { selector: attributeHelpTextSelector, cls: AttributeHelpTextComponent }, @@ -224,7 +223,7 @@ export const globalDynamicComponents:OptionalBootstrapDefinition[] = [ { selector: projectMenuAutocompleteSelector, cls: ProjectMenuAutocompleteComponent }, { selector: remoteFieldUpdaterSelector, cls: RemoteFieldUpdaterComponent }, { selector: wpOverviewGraphSelector, cls: WorkPackageOverviewGraphComponent }, - { selector: wpQuerySelectSelector, cls: WorkPackageQuerySelectDropdownComponent }, + { selector: opQuerySelectSelector, cls: QuerySelectComponent }, { selector: triggerActionsEntryComponentSelector, cls: TriggerActionsEntryComponent, embeddable: true }, { selector: backlogsPageComponentSelector, cls: BacklogsPageComponent }, { selector: attributeValueMacro, cls: AttributeValueMacroComponent, embeddable: true }, diff --git a/frontend/src/app/features/work-packages/openproject-work-packages.module.ts b/frontend/src/app/features/work-packages/openproject-work-packages.module.ts index 0b49b5c00c..3ad070d341 100644 --- a/frontend/src/app/features/work-packages/openproject-work-packages.module.ts +++ b/frontend/src/app/features/work-packages/openproject-work-packages.module.ts @@ -42,7 +42,6 @@ import { OpSettingsMenuDirective } from 'core-app/shared/components/op-context-m import { WorkPackageStatusDropdownDirective } from 'core-app/shared/components/op-context-menu/handlers/wp-status-dropdown-menu.directive'; import { WorkPackageCreateSettingsMenuDirective } from 'core-app/shared/components/op-context-menu/handlers/wp-create-settings-menu.directive'; import { WorkPackageSingleContextMenuDirective } from 'core-app/shared/components/op-context-menu/wp-context-menu/wp-single-context-menu'; -import { WorkPackageQuerySelectDropdownComponent } from 'core-app/features/work-packages/components/wp-query-select/wp-query-select-dropdown.component'; import { WorkPackageTimelineHeaderController } from 'core-app/features/work-packages/components/wp-table/timeline/header/wp-timeline-header.directive'; import { WorkPackageTableTimelineRelations } from 'core-app/features/work-packages/components/wp-table/timeline/global-elements/wp-timeline-relations.directive'; import { WorkPackageTableTimelineStaticElements } from 'core-app/features/work-packages/components/wp-table/timeline/global-elements/wp-timeline-static-elements.directive'; @@ -85,7 +84,6 @@ import { ExternalQueryConfigurationComponent } from 'core-app/features/work-pack import { ExternalQueryConfigurationService } from 'core-app/features/work-packages/components/wp-table/external-configuration/external-query-configuration.service'; import { ExternalRelationQueryConfigurationComponent } from 'core-app/features/work-packages/components/wp-table/external-configuration/external-relation-query-configuration.component'; import { ExternalRelationQueryConfigurationService } from 'core-app/features/work-packages/components/wp-table/external-configuration/external-relation-query-configuration.service'; -import { WorkPackageStaticQueriesService } from 'core-app/features/work-packages/components/wp-query-select/wp-static-queries.service'; import { WorkPackagesListInvalidQueryService } from 'core-app/features/work-packages/components/wp-list/wp-list-invalid-query.service'; import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service'; import { WorkPackageWatchersService } from 'core-app/features/work-packages/components/wp-single-view-tabs/watchers-tab/wp-watchers.service'; @@ -213,7 +211,6 @@ import isNewResource from 'core-app/features/hal/helpers/is-new-resource'; // For any service that depends on the isolated query space, // they should be provided in wp-isolated-query-space.directive instead QueryFiltersService, - WorkPackageStaticQueriesService, WorkPackagesListInvalidQueryService, // Provide a separate service for creation events of WP Inline create @@ -298,7 +295,6 @@ import isNewResource from 'core-app/features/hal/helpers/is-new-resource'; WorkPackageStatusDropdownDirective, WorkPackageCreateSettingsMenuDirective, WorkPackageSingleContextMenuDirective, - WorkPackageQuerySelectDropdownComponent, WorkPackageViewDropdownMenuDirective, WorkPackageGroupToggleDropdownMenuDirective, diff --git a/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts b/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts index c8a3c655a4..d3c2ce3b7a 100644 --- a/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts +++ b/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts @@ -234,7 +234,7 @@ export class PartitionedQuerySpacePageComponent extends WorkPackagesViewBase imp if (isPersistedResource(query)) { this.selectedTitle = query.name; } else { - this.selectedTitle = this.wpStaticQueries.getStaticName(query); + this.selectedTitle = this.opStaticQueries.getStaticName(query); } this.titleEditingEnabled = this.authorisationService.can('query', 'updateImmediately'); diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/work-packages-view.base.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/work-packages-view.base.ts index 7fb5309d79..cd354c22dd 100644 --- a/frontend/src/app/features/work-packages/routing/wp-view-base/work-packages-view.base.ts +++ b/frontend/src/app/features/work-packages/routing/wp-view-base/work-packages-view.base.ts @@ -35,7 +35,7 @@ import { IsolatedQuerySpace } from 'core-app/features/work-packages/directives/q import { filter, take, withLatestFrom } from 'rxjs/operators'; import { LoadingIndicatorService } from 'core-app/core/loading-indicator/loading-indicator.service'; import { I18nService } from 'core-app/core/i18n/i18n.service'; -import { WorkPackageStaticQueriesService } from 'core-app/features/work-packages/components/wp-query-select/wp-static-queries.service'; +import { StaticQueriesService } from 'core-app/shared/components/op-query-select/op-static-queries.service'; import { WorkPackageViewHighlightingService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-highlighting.service'; import { States } from 'core-app/core/states/states.service'; import { WorkPackageViewColumnsService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-columns.service'; @@ -98,7 +98,7 @@ export abstract class WorkPackagesViewBase extends UntilDestroyedMixin implement @InjectField() I18n!:I18nService; - @InjectField() wpStaticQueries:WorkPackageStaticQueriesService; + @InjectField() opStaticQueries:StaticQueriesService; @InjectField() wpStatesInitialization:WorkPackageStatesInitializationService; diff --git a/frontend/src/app/features/work-packages/components/wp-query-select/wp-query-select-dropdown.component.ts b/frontend/src/app/shared/components/op-query-select/op-query-select.component.ts similarity index 87% rename from frontend/src/app/features/work-packages/components/wp-query-select/wp-query-select-dropdown.component.ts rename to frontend/src/app/shared/components/op-query-select/op-query-select.component.ts index 11af7a9478..9f8f1a3e8a 100644 --- a/frontend/src/app/features/work-packages/components/wp-query-select/wp-query-select-dropdown.component.ts +++ b/frontend/src/app/shared/components/op-query-select/op-query-select.component.ts @@ -42,16 +42,16 @@ import { MainMenuNavigationService } from 'core-app/core/main-menu/main-menu-nav import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin'; import { IOpSidemenuItem } from 'core-app/shared/components/sidemenu/sidemenu.component'; import { QueryResource } from 'core-app/features/hal/resources/query-resource'; -import { WorkPackageStaticQueriesService } from 'core-app/features/work-packages/components/wp-query-select/wp-static-queries.service'; +import { StaticQueriesService } from 'core-app/shared/components/op-query-select/op-static-queries.service'; -export const wpQuerySelectSelector = 'wp-query-select'; +export const opQuerySelectSelector = 'op-query-select'; @Component({ - selector: wpQuerySelectSelector, + selector: opQuerySelectSelector, changeDetection: ChangeDetectionStrategy.OnPush, - templateUrl: './wp-query-select.template.html', + templateUrl: './op-query-select.template.html', }) -export class WorkPackageQuerySelectDropdownComponent extends UntilDestroyedMixin implements OnInit { +export class QuerySelectComponent extends UntilDestroyedMixin implements OnInit { public text = { search: this.I18n.t('js.toolbar.search_query_label'), label: this.I18n.t('js.toolbar.search_query_label'), @@ -75,7 +75,7 @@ export class WorkPackageQuerySelectDropdownComponent extends UntilDestroyedMixin readonly I18n:I18nService, readonly states:States, readonly CurrentProject:CurrentProjectService, - readonly wpStaticQueries:WorkPackageStaticQueriesService, + readonly opStaticQueries:StaticQueriesService, readonly mainMenuService:MainMenuNavigationService, readonly cdRef:ChangeDetectorRef, ) { @@ -102,11 +102,12 @@ export class WorkPackageQuerySelectDropdownComponent extends UntilDestroyedMixin .pipe( map(([searchText, categories]) => categories .map((category) => { - if (this.matchesText(category.title, searchText)) { + if (QuerySelectComponent.matchesText(category.title, searchText)) { return category; } - const filteredChildren = category.children?.filter((query) => this.matchesText(query.title, searchText)); + const filteredChildren = category.children + ?.filter((query) => QuerySelectComponent.matchesText(query.title, searchText)); return { title: category.title, children: filteredChildren, collapsible: true }; }) .filter((category) => category.children && category.children.length > 0)), @@ -131,8 +132,7 @@ export class WorkPackageQuerySelectDropdownComponent extends UntilDestroyedMixin this.initialized = true; } - // noinspection JSMethodCanBeStatic - private matchesText(text:string, searchText:string):boolean { + private static matchesText(text:string, searchText:string):boolean { return text.toLowerCase().includes(searchText.toLowerCase()); } @@ -159,12 +159,12 @@ export class WorkPackageQuerySelectDropdownComponent extends UntilDestroyedMixin cat = 'starred'; } - categories[cat].push(WorkPackageQuerySelectDropdownComponent.toOpSideMenuItem(query)); + categories[cat].push(QuerySelectComponent.toOpSideMenuItem(query)); }); this.$queryCategories.next([ { title: this.text.scope_starred, children: categories.starred, collapsible: true }, - { title: this.text.scope_default, children: this.wpStaticQueries.all, collapsible: true }, + { title: this.text.scope_default, children: this.opStaticQueries.all, collapsible: true }, { title: this.text.scope_global, children: categories.public, collapsible: true }, { title: this.text.scope_private, children: categories.private, collapsible: true }, ]); diff --git a/frontend/src/app/features/work-packages/components/wp-query-select/wp-query-select.template.html b/frontend/src/app/shared/components/op-query-select/op-query-select.template.html similarity index 94% rename from frontend/src/app/features/work-packages/components/wp-query-select/wp-query-select.template.html rename to frontend/src/app/shared/components/op-query-select/op-query-select.template.html index 4231da272d..c9ed5dac4c 100644 --- a/frontend/src/app/features/work-packages/components/wp-query-select/wp-query-select.template.html +++ b/frontend/src/app/shared/components/op-query-select/op-query-select.template.html @@ -1,4 +1,4 @@ -
+