Skip to content

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

[#39772] Replace query select component

Eric Schubertbf67c648e28b
diff --git a/frontend/src/app/core/apiv3/endpoints/queries/apiv3-queries-paths.ts b/frontend/src/app/core/apiv3/endpoints/queries/apiv3-queries-paths.ts
index e397ac8b0b7..c0661924728 100644
--- a/frontend/src/app/core/apiv3/endpoints/queries/apiv3-queries-paths.ts
+++ b/frontend/src/app/core/apiv3/endpoints/queries/apiv3-queries-paths.ts
@@ -138,7 +138,7 @@ export class APIv3QueriesPaths extends APIv3ResourceCollection<QueryResource, AP
*
* @param projectIdentifier
*/
- public filterNonHidden(projectIdentifier?:string|null):Observable<CollectionResource<QueryResource>> {
+ public filterNonHidden(projectIdentifier:string|null):Observable<CollectionResource<QueryResource>> {
const listParams:Apiv3ListParameters = {
filters: [['hidden', '=', ['f']]],
};
diff --git a/frontend/src/app/core/main-menu/main-menu-toggle.service.ts b/frontend/src/app/core/main-menu/main-menu-toggle.service.ts
index 97b42b06123..6b720822e8a 100644
--- a/frontend/src/app/core/main-menu/main-menu-toggle.service.ts
+++ b/frontend/src/app/core/main-menu/main-menu-toggle.service.ts
@@ -128,7 +128,7 @@ export class MainMenuToggleService {
public closeMenu():void {
this.setWidth(0);
window.OpenProject.guardedLocalStorage(this.localStorageStateKey, 'true');
- jQuery('.collapsible-menu--search-input').blur();
+ jQuery('.searchable-menu--search-input').blur();
}
public closeWhenOnMobile():void {
diff --git a/frontend/src/app/features/in-app-notifications/center/menu/menu.component.ts b/frontend/src/app/features/in-app-notifications/center/menu/menu.component.ts
index 33677b28d2c..391020640bf 100644
--- a/frontend/src/app/features/in-app-notifications/center/menu/menu.component.ts
+++ b/frontend/src/app/features/in-app-notifications/center/menu/menu.component.ts
@@ -1,3 +1,31 @@
+// -- copyright
+// OpenProject is an open source project management software.
+// Copyright (C) 2012-2021 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.
+//++
+
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
diff --git a/frontend/src/app/features/work-packages/components/wp-query-select/wp-query-select-dropdown.component.ts b/frontend/src/app/features/work-packages/components/wp-query-select/wp-query-select-dropdown.component.ts
index ddf825231f1..11af7a9478d 100644
--- a/frontend/src/app/features/work-packages/components/wp-query-select/wp-query-select-dropdown.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-query-select/wp-query-select-dropdown.component.ts
@@ -26,47 +26,23 @@
// See COPYRIGHT and LICENSE files for more details.
//++
-import { States } from 'core-app/core/states/states.service';
-import { StateService, TransitionService } from '@uirouter/core';
import {
- ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, OnInit, ViewChild,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ OnInit,
} from '@angular/core';
-import { LoadingIndicatorService } from 'core-app/core/loading-indicator/loading-indicator.service';
+import { map } from 'rxjs/operators';
+import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
+import { States } from 'core-app/core/states/states.service';
import { I18nService } from 'core-app/core/i18n/i18n.service';
-import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
-import { WorkPackageStaticQueriesService } from 'core-app/features/work-packages/components/wp-query-select/wp-static-queries.service';
-import { QueryResource } from 'core-app/features/hal/resources/query-resource';
-import { isClickedWithModifier } from 'core-app/shared/helpers/link-handling/link-handling';
-import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
-import { KeyCodes } from 'core-app/shared/helpers/keyCodes.enum';
-import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';
+import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
import { MainMenuNavigationService } from 'core-app/core/main-menu/main-menu-navigation.service';
-import { MainMenuToggleService } from 'core-app/core/main-menu/main-menu-toggle.service';
-import { CollectionResource } from 'core-app/features/hal/resources/collection-resource';
-
-export type QueryCategory = 'starred'|'public'|'private'|'default';
-
-export interface IAutocompleteItem {
- // Some optional identifier
- identifier?:string;
- // Internal id for selecting items
- auto_id?:number;
- // The autocomplete item may be a static link (e.g., summary page)
- static_link?:string;
- // Label for the current locale
- label:string;
- // May be tied to a persisted query
- query?:QueryResource;
- // Or a loose map of query_props
- query_props?:any;
- // And is tied to a category
- category?:QueryCategory;
-}
-
-interface IQueryAutocompleteJQuery extends JQuery {
- querycomplete(...args:any[]):void;
-}
+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';
export const wpQuerySelectSelector = 'wp-query-select';
@@ -76,14 +52,6 @@ export const wpQuerySelectSelector = 'wp-query-select';
templateUrl: './wp-query-select.template.html',
})
export class WorkPackageQuerySelectDropdownComponent extends UntilDestroyedMixin implements OnInit {
- @ViewChild('wpQueryMenuSearchInput', { static: true }) _wpQueryMenuSearchInput:ElementRef;
-
- @ViewChild('queryResultsContainer', { static: true }) _queryResultsContainerElement:ElementRef;
-
- public loading = false;
-
- public noResults = false;
-
public text = {
search: this.I18n.t('js.toolbar.search_query_label'),
label: this.I18n.t('js.toolbar.search_query_label'),
@@ -94,444 +62,127 @@ export class WorkPackageQuerySelectDropdownComponent extends UntilDestroyedMixin
no_results: this.I18n.t('js.work_packages.query.text_no_results'),
};
- private unregisterTransitionListener:Function;
-
- private projectIdentifier:string|null;
-
- private hiddenCategories:any = [];
+ public $queries:Observable<IOpSidemenuItem[]>;
- private reportsBodySelector = '.controller-work_packages\\/reports';
+ private $queryCategories = new BehaviorSubject<IOpSidemenuItem[]>([]);
- private queryResultsContainer:JQuery;
-
- private buttonArrowLeft:JQuery;
-
- private searchInput:IQueryAutocompleteJQuery;
+ private $search = new BehaviorSubject<string>('');
private initialized = false;
- constructor(readonly ref:ChangeDetectorRef,
- readonly element:ElementRef,
+ constructor(
readonly apiV3Service:APIV3Service,
- readonly $state:StateService,
- readonly $transitions:TransitionService,
readonly I18n:I18nService,
readonly states:States,
readonly CurrentProject:CurrentProjectService,
- readonly loadingIndicator:LoadingIndicatorService,
- readonly pathHelper:PathHelperService,
readonly wpStaticQueries:WorkPackageStaticQueriesService,
readonly mainMenuService:MainMenuNavigationService,
- readonly toggleService:MainMenuToggleService,
- readonly cdRef:ChangeDetectorRef) {
+ readonly cdRef:ChangeDetectorRef,
+ ) {
super();
}
- public ngOnInit() {
- this.queryResultsContainer = jQuery(this._queryResultsContainerElement.nativeElement);
- this.projectIdentifier = this.element.nativeElement.getAttribute('data-project-identifier');
+ public set search(input:string) {
+ if (this.$search.value !== input) {
+ this.$search.next(input);
+ }
+ }
+ ngOnInit():void {
// When activating the work packages submenu,
// either initially or through click on the toggle, load the results
this.mainMenuService
.onActivate('work_packages', 'work_packages_query_select')
.subscribe(() => this.initializeAutocomplete());
- // Register click handler on results
- this.addClickHandler();
- this.cdRef.detach();
- }
+ this.$queries = combineLatest(
+ this.$search,
+ this.$queryCategories,
+ )
+ .pipe(
+ map(([searchText, categories]) => categories
+ .map((category) => {
+ if (this.matchesText(category.title, searchText)) {
+ return category;
+ }
- ngOnDestroy() {
- super.ngOnDestroy();
- this.unregisterTransitionListener();
+ const filteredChildren = category.children?.filter((query) => this.matchesText(query.title, searchText));
+ return { title: category.title, children: filteredChildren, collapsible: true };
+ })
+ .filter((category) => category.children && category.children.length > 0)),
+ );
}
- private initializeAutocomplete() {
+ private initializeAutocomplete():void {
if (this.initialized) {
return;
}
- this.searchInput = jQuery(this._wpQueryMenuSearchInput.nativeElement) as any;
- this.buttonArrowLeft = jQuery('.main-menu--arrow-left-to-project', jQuery('#main-menu-work-packages-wrapper').parent()) as any;
- this.initialized = true;
- this.buttonArrowLeft.focus();
- this.setupAutoCompletion(this.searchInput);
+ // Set focus on collapsible menu's back button.
+ // This improves accessibility for blind users to tell them their current location.
+ const buttonArrowLeft = document.getElementById('main-menu-work-packages-wrapper')?.parentElement
+ ?.getElementsByClassName('main-menu--arrow-left-to-project')[0] as HTMLElement;
+ if (buttonArrowLeft) {
+ buttonArrowLeft.focus();
+ }
+
this.updateMenuOnChanges();
- this.loadQueries();
+ this.initializeQueries();
+ this.initialized = true;
}
- private transformQueries(collection:CollectionResource<QueryResource>) {
- const loadedQueries:IAutocompleteItem[] = collection.elements
- .map((query) => ({ label: query.name, query, query_props: null }));
-
- // Add to the loaded set of queries the fixed set of queries for the current project context
- const combinedQueries = loadedQueries.concat(this.wpStaticQueries.all);
- return this.sortQueries(combinedQueries);
+ // noinspection JSMethodCanBeStatic
+ private matchesText(text:string, searchText:string):boolean {
+ return text.toLowerCase().includes(searchText.toLowerCase());
}
- // Filter the collection by categories, add the correct categories to every item of the filtered array
- // Sort every category array alphabetically, except the default queries
- private sortQueries(items:IAutocompleteItem[]):IAutocompleteItem[] {
- // Concat all categories in the right order
- const categorized:{ [category:string]:IAutocompleteItem[] } = {
- // Starred / favored
+ private initializeQueries():void {
+ const categories:{ [category:string]:IOpSidemenuItem[] } = {
starred: [],
- // default
default: [],
- // public
public: [],
- // private
private: [],
};
- let auto_id = 0;
- items.forEach((item):any => {
- item.auto_id = auto_id++;
-
- if (!item.query) {
- item.category = 'default';
- return categorized.default.push(item);
- }
-
- if (item.query.starred) {
- item.category = 'starred';
- return categorized.starred.push(item);
- }
-
- if (!item.query.starred && item.query.public) {
- item.category = 'public';
- return categorized.public.push(item);
- }
-
- if (!(item.query.starred || item.query.public)) {
- item.category = 'private';
- return categorized.private.push(item);
- }
- });
-
- return _.flatten(
- [categorized.starred, categorized.default, categorized.public, categorized.private]
- .map((items) => this.sortByLabel(items)),
- );
- }
-
- // Sort a given array of items by the value of their label attribute
- private sortByLabel(items:IAutocompleteItem[]):IAutocompleteItem[] {
- return items.sort((a, b) => a.label.toLowerCase().localeCompare(b.label.toLowerCase()));
- }
-
- private loadQueries() {
- return this.loadingPromise = this
- .apiV3Service
+ // TODO: use global query store
+ this.apiV3Service
.queries
.filterNonHidden(this.CurrentProject.identifier)
- .toPromise()
- .then((collection) => {
- // Update the complete collection
- this.searchInput.querycomplete('option', { source: this.transformQueries(collection) });
-
- // To visibly show the changes, we need to search again
- this.searchInput.querycomplete('search', this.searchInput.val());
-
- // To search an empty string would expand all categories again every time
- // Remember all previously hidden categories and set them again after updating the menu
- _.each(this.hiddenCategories, (category) => {
- const thisCategory:string = jQuery(category).attr('category')!;
- this.expandCollapseCategory(thisCategory);
- });
-
- // Update view
- this.ref.detectChanges();
- });
- }
-
- private set loadingPromise(promise:Promise<any>) {
- this.loading = true;
- promise
- .then(() => {
- this.loading = false;
- this.cdRef.detectChanges();
- })
- .catch(() => {
- this.loading = false;
- this.cdRef.detectChanges();
- });
- }
-
- private setupAutoCompletion(input:IQueryAutocompleteJQuery) {
- this.defineJQueryQueryComplete();
-
- input.querycomplete({
- delay: 100,
- // The values are added later by the listener also covering
- // the changes to queries (updateMenuOnChanges()).
- source: [],
- select: (ul:any, selected:{ item:IAutocompleteItem }) => false, // Don't show title of selected query in the input field
- response: (event:any, ui:any) => {
- // Show the noResults span if we don't have any matches
- this.noResults = (ui.content.length === 0);
- },
- close: (event:any, ui:any) => {
- const autocompleteUi = this.queryResultsContainer.find('ul.ui-autocomplete');
- if (!autocompleteUi.is(':visible') && !this.noResults) {
- autocompleteUi.show();
- }
- },
- focus: (_event:JQuery.TriggeredEvent, ui:{ item:IAutocompleteItem }) => {
- let sourceEvent:any|null = _event;
-
- while (sourceEvent && sourceEvent.originalEvent) {
- sourceEvent = sourceEvent.originalEvent;
- }
-
- // Focus the given item, but only when we're using the keyboard.
- // With the mouse, hover shall suffice to avoid weird focus/hover combinations
- // e.g., https://community.openproject.com/wp/28197
- if (sourceEvent && sourceEvent.type === 'keydown') {
- this.queryResultsContainer
- .find(`#collapsible-menu-item-${ui.item.auto_id} .collapsible-menu--item-link`)
- .focus();
- }
-
- return false;
- },
- appendTo: '.collapsible-menu--results-container',
- classes: {
- 'ui-autocomplete': 'collapsible-menu--search-ul -inplace',
- 'ui-menu-divider': 'collapsible-menu--category-icon',
- },
- opAutofocus: false, // Don't automatically select first entry since we 'open' the autocomplete on page load
- minLength: 0,
- });
- }
-
- private defineJQueryQueryComplete() {
- const thisComponent = this;
-
- jQuery.widget('custom.querycomplete', jQuery.ui.autocomplete, {
- _create(this:any) {
- this._super();
- this.widget().menu('option', 'items', '.collapsible-menu--item');
- this._search('');
- },
- _renderItem(this:{}, ul:any, item:IAutocompleteItem) {
- const link = jQuery('<a>')
- .addClass('collapsible-menu--item-link')
- .attr('href', thisComponent.buildQueryItemUrl(item))
- .text(item.label);
-
- const li = jQuery('<li>')
- .addClass('ui-menu-item collapsible-menu--item')
- .attr('id', `collapsible-menu-item-${item.auto_id}`)
- .attr('data-category', item.category || '')
- .data('ui-autocomplete-item', item) // Focus method of autocompleter needs this data for accessibility - if not set, it will throw errors
- .append(link)
- .appendTo(ul);
-
- thisComponent.setInitialHighlighting(li, item);
-
- return li;
- },
- _renderMenu(this:any, ul:any, items:IAutocompleteItem[]) {
- let currentCategory:QueryCategory;
-
- _.each(items, (option) => {
- // Check if item has same category as previous item and if not insert a new category label in the list
- if (option.category !== currentCategory) {
- currentCategory = option.category!;
- const label = thisComponent.labelFunction(currentCategory);
-
- ul.append(`<a tabindex="0" class="collapsible-menu--category-icon collapsible-menu--category-toggle" data-category="${currentCategory}" aria-hidden="true"></a>`);
- jQuery('<li>')
- .addClass('ui-autocomplete--category collapsible-menu--category-toggle ellipsis')
- .attr('title', label)
- .attr('data-category', currentCategory)
- .text(label)
- .appendTo(ul);
+ .pipe(this.untilDestroyed())
+ .subscribe((queryCollection) => {
+ queryCollection.elements.forEach((query) => {
+ let cat = 'private';
+ if (query.public) {
+ cat = 'public';
}
- this._renderItemData(ul, option);
- });
-
- // Scroll to selected element if search is empty
- if (thisComponent.searchInput.val() === '') {
- const selected = thisComponent.queryResultsContainer.find('.collapsible-menu--item.selected');
- if (selected.length > 0) {
- setTimeout(() => selected[0].scrollIntoView({ behavior: 'auto', block: 'center' }), 20);
+ if (query.starred) {
+ cat = 'starred';
}
- }
- },
- });
- }
-
- // Set class 'selected' on initial rendering of the menu
- // Case 1: Wp menu is opened from somewhere else in the project -> Compare query params with url params and highlight selected
- // Case 2: Click on menu item 'Work Packages' (query 'All open' is opened on default) -> highlight 'All open'
- private setInitialHighlighting(currentLi:JQuery, item:IAutocompleteItem) {
- const params = this.getQueryParams(item);
- const currentId = this.$state.params.query_id;
- const currentProps = this.$state.params.query_props;
- const onWorkPackagesPage:boolean = this.$state.includes('work-packages');
- const onWorkPackagesReportPage:boolean = jQuery('body').hasClass('controller-work_packages/reports');
-
- // When the current ID is selected
- const currentIdSelected = params.query_id && (currentId || '').toString() === params.query_id.toString();
-
- // Case1: Static query props
- const matchesStaticQueryProps = !item.query && item.query_props && item.query_props === currentProps;
- // Case2: We're on the All open menu item
- const allOpen = onWorkPackagesPage && !currentId && !currentProps && item.identifier === 'all_open';
-
- // Case3: We're on the static summary page
- const onSummary = onWorkPackagesReportPage && item.identifier === 'summary';
+ categories[cat].push(WorkPackageQuerySelectDropdownComponent.toOpSideMenuItem(query));
+ });
- if (currentIdSelected || matchesStaticQueryProps || allOpen || onSummary) {
- currentLi.addClass('selected');
- }
+ 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_global, children: categories.public, collapsible: true },
+ { title: this.text.scope_private, children: categories.private, collapsible: true },
+ ]);
+ });
}
- private labelFunction(category:QueryCategory):string {
- switch (category) {
- case 'starred':
- return this.text.scope_starred;
- case 'public':
- return this.text.scope_global;
- case 'private':
- return this.text.scope_private;
- case 'default':
- return this.text.scope_default;
- default:
- return '';
- }
+ private static toOpSideMenuItem(query:QueryResource):IOpSidemenuItem {
+ return {
+ title: query.name,
+ uiSref: 'work-packages',
+ uiParams: { query_id: query.id, query_props: '' },
+ };
}
// Listens on all changes of queries (via an observable in the service), e.g. delete, create, rename, toggle starred
- // Update collection in autocompleter
- // Search again for the current value in input field to update the menu without loosing the current search results
private updateMenuOnChanges() {
this.states.changes.queries
- .pipe(
- this.untilDestroyed(),
- )
- .subscribe(() => this.loadQueries());
- }
-
- private expandCollapseCategory(category:string) {
- jQuery(`[data-category="${category}"]`)
- // Don't hide the categories themselves (Regression #28584)
- .not('.ui-autocomplete--category')
- .toggleClass('-hidden');
- jQuery(`.collapsible-menu--category-icon[data-category="${category}"]`).toggleClass('-collapsed');
- }
-
- // On click of a menu item, load requested query
- private loadQuery(item:IAutocompleteItem) {
- const params = this.getQueryParams(item);
- const opts = { reload: true };
-
- this.$state.go(
- 'work-packages.partitioned.list',
- params,
- opts,
- );
-
- this.toggleService.closeWhenOnMobile();
- }
-
- private getQueryParams(item:IAutocompleteItem) {
- const val:{ query_id:string|null, query_props:string|null, projects?:string, projectPath?:string } = {
- query_id: item.query ? _.toString(item.query.id) : null,
- query_props: item.query ? null : item.query_props,
- };
-
- if (this.projectIdentifier) {
- val.projects = 'projects';
- val.projectPath = this.projectIdentifier;
- }
-
- return val;
- }
-
- private buildQueryItemUrl(item:IAutocompleteItem):string {
- // Static item (such as summary)
- if (item.static_link) {
- return item.static_link;
- }
-
- const params = this.getQueryParams(item);
- return this.$state.href('work-packages.partitioned.list', params);
- }
-
- private highlightSelected(item:IAutocompleteItem) {
- this.highlightBySelector(`#collapsible-menu-item-${item.auto_id}`);
- }
-
- private highlightBySelector(selector:string) {
- // Remove old selection
- this.queryResultsContainer.find('.ui-menu-item').removeClass('selected');
- // Find selected element in DOM and highlight it
- this.queryResultsContainer.find(selector).addClass('selected');
- }
-
- /**
- * When clicking an item with meta keys,
- * avoid its propagation.
- *
- */
- private addClickHandler() {
- this.queryResultsContainer
- .on('click keydown', '.ui-menu-item a', (evt:JQuery.TriggeredEvent) => {
- if (evt.type === 'keydown' && evt.which !== KeyCodes.ENTER) {
- return true;
- }
-
- // Find the item from the clicked element
- const target = jQuery(evt.target);
- const item:IAutocompleteItem = target
- .closest('.collapsible-menu--item')
- .data('ui-autocomplete-item');
-
- // Either the link is clicked with a modifier, then always cancel any propagation
- const clickedWithModifier = evt.type === 'click' && isClickedWithModifier(evt);
-
- // Or the item is only a static link, then cancel propagation
- const isStatic = !!item.static_link;
-
- if (clickedWithModifier || isStatic) {
- evt.stopImmediatePropagation();
-
- if (evt.type === 'keydown') {
- window.location.href = target.attr('href')!;
- }
- } else {
- // If neither clicked with modifier nor static
- // Then prevent the default link handling and load the query
- evt.preventDefault();
- this.loadQuery(item);
- this.highlightSelected(item);
- return false;
- }
-
- return true;
- })
- .on('click keydown', '.collapsible-menu--category-toggle', (evt:JQuery.TriggeredEvent) => {
- if (evt.type === 'keydown' && evt.which !== KeyCodes.ENTER) {
- return true;
- }
-
- const target = jQuery(evt.target);
- const clickedCategory = target.data('category');
-
- if (clickedCategory) {
- this.expandCollapseCategory(clickedCategory);
- }
-
- // Remember all hidden catagories
- this.hiddenCategories = this.queryResultsContainer.find('.ui-autocomplete--category.hidden');
-
- evt.preventDefault();
- return false;
- });
+ .pipe(this.untilDestroyed())
+ .subscribe(() => this.initializeQueries());
}
}
diff --git a/frontend/src/app/features/work-packages/components/wp-query-select/wp-query-select.template.html b/frontend/src/app/features/work-packages/components/wp-query-select/wp-query-select.template.html
index ac52fbecc3b..4231da272da 100644
--- a/frontend/src/app/features/work-packages/components/wp-query-select/wp-query-select.template.html
+++ b/frontend/src/app/features/work-packages/components/wp-query-select/wp-query-select.template.html
@@ -1,28 +1,28 @@
-<div id="querySelectDropdown" class="collapsible-menu--container">
- <div class="collapsible-menu--search-container">
- <div class="collapsible-menu--search-bar">
+<div id="querySelectDropdown" class="searchable-menu">
+ <div class="searchable-menu--search-container">
+ <div class="searchable-menu--search-bar">
<label for="query-title-filter"
class="hidden-for-sighted"
- [textContent]="text.label" ></label>
- <input #wpQueryMenuSearchInput
- type="text"
- class="collapsible-menu--search-input ui-autocomplete--input ellipsis"
+ [textContent]="text.label"></label>
+ <input type="text"
+ [(ngModel)]="search"
+ class="searchable-menu--search-input ellipsis"
name="query-title-filter"
id="query-title-filter"
- [attr.placeholder]="text.search" />
- <i class="icon-search collapsible-menu--search-icon"></i>
- </div>
- <div #queryResultsContainer class="collapsible-menu--results-container">
- <p class="collapsible-menu--no-results-container"
- [hidden]="!noResults || loading"
- [textContent]="text.no_results"></p>
- <div class="loading-indicator -compact" *ngIf="loading">
- <div class="block-1"></div>
- <div class="block-2"></div>
- <div class="block-3"></div>
- <div class="block-4"></div>
- <div class="block-5"></div>
- </div>
+ [attr.placeholder]="text.search"/>
+ <i class="icon-search searchable-menu--search-icon"></i>
</div>
+
+ <p class="searchable-menu--no-results-container"
+ [hidden]="($queries | async).length > 0"
+ [textContent]="text.no_results"></p>
+
+ <op-sidemenu
+ class="op-query-select--search-results"
+ [items]="$queries | async"
+ [collapsible]="true"
+ [searchable]="true"
+ >
+ </op-sidemenu>
</div>
</div>
diff --git a/frontend/src/app/features/work-packages/components/wp-query-select/wp-static-queries.service.ts b/frontend/src/app/features/work-packages/components/wp-query-select/wp-static-queries.service.ts
index 3e9f79b1b75..ab2fdc3539a 100644
--- a/frontend/src/app/features/work-packages/components/wp-query-select/wp-static-queries.service.ts
+++ b/frontend/src/app/features/work-packages/components/wp-query-select/wp-static-queries.service.ts
@@ -25,7 +25,7 @@
//
// See COPYRIGHT and LICENSE files for more details.
//++
-import { IAutocompleteItem } from 'core-app/features/work-packages/components/wp-query-select/wp-query-select-dropdown.component';
+
import { QueryResource } from 'core-app/features/hal/resources/query-resource';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { Injectable } from '@angular/core';
@@ -33,6 +33,7 @@ import { PathHelperService } from 'core-app/core/path-helper/path-helper.service
import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
import { StateService } from '@uirouter/core';
import { CurrentUserService } from 'core-app/core/current-user/current-user.service';
+import { IOpSidemenuItem } from 'core-app/shared/components/sidemenu/sidemenu.component';
@Injectable()
export class WorkPackageStaticQueriesService {
@@ -40,7 +41,7 @@ export class WorkPackageStaticQueriesService {
private readonly $state:StateService,
private readonly CurrentProject:CurrentProjectService,
private readonly PathHelper:PathHelperService,
- private readonly CurrentUserService:CurrentUserService) {
+ private readonly CurrentUser:CurrentUserService) {
}
public text = {
@@ -59,71 +60,86 @@ export class WorkPackageStaticQueriesService {
summary: this.I18n.t('js.work_packages.default_queries.summary'),
};
- // Create all static queries manually
- // The query_props configure default values of column names, sorting and applied filters
- // All queries are sorted by their update or creation time (so the latest is always the first)
- public get all():IAutocompleteItem[] {
- let items = [
+ public get all():IOpSidemenuItem[] {
+ let items:IOpSidemenuItem[] = [
{
- identifier: 'all_open',
- label: this.text.all_open,
- query_props: null,
+ title: this.text.all_open,
+ uiSref: 'work-packages',
+ uiParams: { query_id: '', query_props: '' },
},
{
- identifier: 'latest_activity',
- label: this.text.latest_activity,
- query_props: '{"c":["id","subject","type","status","assignee","updatedAt"],"hi":false,"g":"","t":"updatedAt:desc","f":[{"n":"status","o":"o","v":[]}]}',
+ title: this.text.latest_activity,
+ uiSref: 'work-packages',
+ uiParams: {
+ query_id: '',
+ query_props: '{"c":["id","subject","type","status","assignee","updatedAt"],"hi":false,"g":"","t":"updatedAt:desc","f":[{"n":"status","o":"o","v":[]}]}',
+ },
},
{
- identifier: 'gantt',
- label: this.text.gantt,
- query_props: '{"c":["id","type","subject","status","startDate","dueDate"],"tv":true,"tzl":"auto","tll":"{\\"left\\":\\"startDate\\",\\"right\\":\\"dueDate\\",\\"farRight\\":\\"subject\\"}","hi":true,"g":"","t":"startDate:asc","f":[{"n":"status","o":"o","v":[]}]}',
+ title: this.text.gantt,
+ uiSref: 'work-packages',
+ uiParams: {
+ query_id: '',
+ query_props: '{"c":["id","type","subject","status","startDate","dueDate"],"tv":true,"tzl":"auto","tll":"{\\"left\\":\\"startDate\\",\\"right\\":\\"dueDate\\",\\"farRight\\":\\"subject\\"}","hi":true,"g":"","t":"startDate:asc","f":[{"n":"status","o":"o","v":[]}]}',
+ },
},
{
- identifier: 'recently_created',
- label: this.text.recently_created,
- query_props: '{"c":["id","subject","type","status","assignee","createdAt"],"hi":false,"g":"","t":"createdAt:desc","f":[{"n":"status","o":"o","v":[]}]}',
+ title: this.text.recently_created,
+ uiSref: 'work-packages',
+ uiParams: {
+ query_id: '',
+ query_props: '{"c":["id","subject","type","status","assignee","createdAt"],"hi":false,"g":"","t":"createdAt:desc","f":[{"n":"status","o":"o","v":[]}]}',
+ },
},
- ] as IAutocompleteItem[];
+ ];
const projectIdentifier = this.CurrentProject.identifier;
if (projectIdentifier) {
items.push({
- identifier: 'summary',
- label: this.text.summary,
- static_link: `${this.PathHelper.projectWorkPackagesPath(projectIdentifier)}/report`,
+ title: this.text.summary,
+ href: `${this.PathHelper.projectWorkPackagesPath(projectIdentifier)}/report`,
});
}
- if (this.CurrentUserService.isLoggedIn) {
- items = items.concat([
+ if (this.CurrentUser.isLoggedIn) {
+ items = [
+ ...items,
{
- identifier: 'created_by_me',
- label: this.text.created_by_me,
- query_props: '{"c":["id","subject","type","status","assignee","updatedAt"],"hi":false,"g":"","t":"updatedAt:desc,id:asc","f":[{"n":"status","o":"o","v":[]},{"n":"author","o":"=","v":["me"]}]}',
+ title: this.text.created_by_me,
+ uiSref: 'work-packages',
+ uiParams: {
+ query_id: '',
+ query_props: '{"c":["id","subject","type","status","assignee","updatedAt"],"hi":false,"g":"","t":"updatedAt:desc,id:asc","f":[{"n":"status","o":"o","v":[]},{"n":"author","o":"=","v":["me"]}]}',
+ },
},
{
- identifier: 'assigned_to_me',
- label: this.text.assigned_to_me,
- query_props: '{"c":["id","subject","type","status","author","updatedAt"],"hi":false,"g":"","t":"updatedAt:desc,id:asc","f":[{"n":"status","o":"o","v":[]},{"n":"assigneeOrGroup","o":"=","v":["me"]}]}',
+ title: this.text.assigned_to_me,
+ uiSref: 'work-packages',
+ uiParams: {
+ query_id: '',
+ query_props: '{"c":["id","subject","type","status","author","updatedAt"],"hi":false,"g":"","t":"updatedAt:desc,id:asc","f":[{"n":"status","o":"o","v":[]},{"n":"assigneeOrGroup","o":"=","v":["me"]}]}',
+ },
},
- ]);
+ ];
}
return items;
}
- public getStaticName(query:QueryResource) {
+ public getStaticName(query:QueryResource):string {
if (this.$state.params.query_props) {
const queryProps = JSON.parse(this.$state.params.query_props);
delete queryProps.pp;
delete queryProps.pa;
const queryPropsString = JSON.stringify(queryProps);
- const matched = this.all.find((item) => item.query_props && item.query_props === queryPropsString);
+ const matched = this.all.find((item) => {
+ const uiParams = item.uiParams as { query_id:string, query_props:string };
+ return uiParams && uiParams.query_props === queryPropsString;
+ });
if (matched) {
- return matched.label;
+ return matched.title;
}
}
diff --git a/frontend/src/app/shared/components/sidemenu/sidemenu.component.html b/frontend/src/app/shared/components/sidemenu/sidemenu.component.html
index 9d4d4e3814c..b904d1fd045 100644
--- a/frontend/src/app/shared/components/sidemenu/sidemenu.component.html
+++ b/frontend/src/app/shared/components/sidemenu/sidemenu.component.html
@@ -20,7 +20,7 @@
<ul
class="op-sidemenu--items"
- [ngClass]="{'op-sidemenu--items_collapsed' : collapsed}"
+ [ngClass]="{'op-sidemenu--items_collapsed' : collapsed, 'searchable-menu--search-ul': searchable}"
>
<li
*ngFor="let item of items"
@@ -37,6 +37,7 @@
<a
*ngIf="!item.children && item.uiSref"
class="op-sidemenu--item-action"
+ [class]="{ 'op-sidemenu--item-action_with_icon': !!item.icon }"
uiSrefActive="op-sidemenu--item-action_active-child"
uiSrefActiveEq="op-sidemenu--item-action_active"
[attr.data-qa-selector]="'op-sidemenu--item-action--' + item.title.split(' ').join('')"
@@ -49,6 +50,7 @@
<a
*ngIf="!item.children && item.href"
class="op-sidemenu--item-action"
+ [class]="{ 'op-sidemenu--item-action_with_icon': !!item.icon }"
[attr.data-qa-selector]="'op-sidemenu--item-action--' + item.title.split(' ').join('')"
[href]="item.href"
>
diff --git a/frontend/src/app/shared/components/sidemenu/sidemenu.component.sass b/frontend/src/app/shared/components/sidemenu/sidemenu.component.sass
index 0a3b532fa83..bffe86bf486 100644
--- a/frontend/src/app/shared/components/sidemenu/sidemenu.component.sass
+++ b/frontend/src/app/shared/components/sidemenu/sidemenu.component.sass
@@ -9,7 +9,7 @@
color: var(--main-menu-fieldset-header-color)
border: 0
text-transform: uppercase
- padding: 8px 12px
+ padding: 8px 12px
margin-top: 12px
font-size: 12px
cursor: pointer
@@ -28,7 +28,7 @@
display: flex
align-items: center
color: var(--main-menu-font-color)
- padding: 8px 12px
+ padding: 8px 12px 8px 32px
&:hover
background: var(--main-menu-bg-hover-background)
@@ -42,6 +42,9 @@
background: var(--main-menu-bg-selected-background)
color: var(--main-menu-selected-font-color)
+ &_with_icon
+ padding-left: 12px
+
&--item-title
margin-right: auto
overflow: hidden
diff --git a/frontend/src/app/shared/components/sidemenu/sidemenu.component.ts b/frontend/src/app/shared/components/sidemenu/sidemenu.component.ts
index 1e99ffd34e9..f397184fcbd 100644
--- a/frontend/src/app/shared/components/sidemenu/sidemenu.component.ts
+++ b/frontend/src/app/shared/components/sidemenu/sidemenu.component.ts
@@ -33,6 +33,8 @@ export class OpSidemenuComponent {
@Input() collapsible = false;
+ @Input() searchable = false;
+
public collapsed = false;
constructor(
diff --git a/frontend/src/global_styles/layout/_collapsible_menu.sass b/frontend/src/global_styles/layout/_collapsible_menu.sass
deleted file mode 100644
index 734df2da07a..00000000000
--- a/frontend/src/global_styles/layout/_collapsible_menu.sass
+++ /dev/null
@@ -1,169 +0,0 @@
-
-$collapsible-menu-search-container-height: 35px
-
-.collapsible-menu--container
- .collapsible-menu--search-ul
- +allow-vertical-scrolling
- -ms-overflow-style: -ms-autohiding-scrollbar
- left: 0 !important
- top: 0 !important
- width: 100% !important
- padding-top: 10px !important
- max-height: 100%
- background: none
- z-index: 0 // Prevent overlapping with project select dropdown (https://community.openproject.com/wp/28175)
-
- @include styled-scroll-bar
-
-
- .collapsible-menu--results-container
- padding-top: 5px
- height: calc(100% - #{$collapsible-menu-search-container-height})
-
- // Firefox needs more left padding for whatever reason
- html.-browser-firefox &
- padding-left: 10px
-
- .collapsible-menu--no-results-container
- display: block
- padding: 15px 15px 0
- display: inline-block
- width: 100%
- white-space: normal
- font-size: var(--main-menu-font-size)
-
- .collapsible-menu--search-container
- padding-top: 10px
- overflow: hidden
- color: var(--main-menu-font-color)
-
- // Specific fix for Firefox
- body.-browser-firefox &
- padding-right: 14px
-
- .ui-state-active
- background: none !important
- color: inherit !important
-
- .ui-autocomplete--category
- width: auto
- padding-left: 33px
- line-height: $menu-item-line-height
- height: $menu-item-line-height
- font-weight: normal
- text-transform: uppercase
- // border-bottom: 1px solid $main-menu-border-color
- font-size: 0.8rem
- color: var(--main-menu-fieldset-header-color)
- cursor: pointer
-
- &:hover
- background: var(--main-menu-bg-hover-background) !important
-
- // The actual search input
- .collapsible-menu--search-bar
- height: $collapsible-menu-search-container-height
- position: relative
- margin: 0 10px
- min-width: 55px
-
- // Category collapsible links
- .collapsible-menu--category-icon
- @include icon-font-common
- // Overridden due to main menu :/
- padding: initial !important
- font-size: 0.6rem
- line-height: $menu-item-line-height
- height: $menu-item-line-height
- margin: 0px 12px
- position: absolute
- color: var(--main-menu-fieldset-header-color)
- z-index: 1
- border: none
- background: initial
-
- &::before
- @include icon-mixin-arrow-up1
-
- &.-collapsed
- &::before
- @include icon-mixin-arrow-down1
-
- // Add space above the category headings
- .collapsible-menu--category-toggle
- color: var(--main-menu-fieldset-header-color) !important
- margin-top: 10px
- &:nth-child(1), &:nth-child(2)
- margin-top: 0px
-
- // Single result element wrapper
- .collapsible-menu--item
- display: block !important
- height: 30px !important
- border-radius: 3px
-
- &.-hidden
- display: none !important
-
- &.selected
- .collapsible-menu--item-link
- background: var(--main-menu-bg-selected-background)
- color: var(--main-menu-selected-font-color)
-
- &:hover
- color: var(--main-menu-font-color)
-
- // Link within element wrapper
- .collapsible-menu--item-link
- @include text-shortener
- color: var(--main-menu-font-color) !important
- padding: 0px 2px 0px 33px !important
- margin: 0 !important
- line-height: 30px !important
- height: 30px !important
- text-decoration: none !important
-
- &:hover, &:focus, &:active
- background: var(--main-menu-bg-hover-background) !important
- color: var(--main-menu-hover-font-color) !important
-
- // Rule complexed for specificity issues
- input[type="text"].collapsible-menu--search-input
- color: var(--main-menu-font-color)
- width: 100%
- height: 35px
- border: 1px solid rgba(231, 231, 231, 0.15)
- border-radius: 3px
- box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.15)
- background-color: rgba(0, 0, 0, 0.15)
- padding: 0px 30px 0px 10px
-
- // Hide the little x to remove input where exists + supported
- &::-webkit-search-cancel-button
- display: none
- &::placeholder,
- &::-webkit-input-placeholder
- color: var(--main-menu-font-color)
- opacity: 0.5
- @include text-shortener
-
- .collapsible-menu--search-icon
- position: absolute
- top: 5px
- right: 10px
- color: var(--main-menu-font-color)
- opacity: 0.5
-
- .collapsible-menu--submenu
- margin-bottom: 10px
-
- .collapsible-menu--placeholder
- @include text-shortener
- color: var(--main-menu-font-color)
- font-size: var(--main-menu-font-size)
- padding: 0 10px
-
-#sidebar
- // Cancel out the sidebar padding
- .collapsible-menu--container
- margin: 0 -15px
\ No newline at end of file
diff --git a/frontend/src/global_styles/layout/_index.sass b/frontend/src/global_styles/layout/_index.sass
index a861e8c5fbe..71221f69e7c 100644
--- a/frontend/src/global_styles/layout/_index.sass
+++ b/frontend/src/global_styles/layout/_index.sass
@@ -36,7 +36,7 @@
@import breadcrumb
@import main_menu
@import main_menu_mobile
-@import collapsible_menu
+@import searchable_menu
@import colors
@import drop_down
@import drop_down_mobile
diff --git a/frontend/src/global_styles/layout/_main_menu.sass b/frontend/src/global_styles/layout/_main_menu.sass
index 6155e2c4c84..2ee800f5c50 100644
--- a/frontend/src/global_styles/layout/_main_menu.sass
+++ b/frontend/src/global_styles/layout/_main_menu.sass
@@ -27,6 +27,7 @@
//++
$menu-item-line-height: 30px
+$arrow-left-width: 40px
@mixin main-menu-hover
background: var(--main-menu-bg-hover-background)
@@ -55,8 +56,8 @@ $menu-item-line-height: 30px
.menu_root.closed,
.menu_root > li.open,
wp-query-select,
- .collapsible-menu--container,
- .collapsible-menu--search-container,
+ .searchable-menu,
+ .searchable-menu--search-container,
.main-menu--children > li.partial:only-child
height: 100%
@@ -70,7 +71,7 @@ $menu-item-line-height: 30px
a:focus
color: var(--main-menu-font-color)
-
+
ul
margin: 0
padding: 0
@@ -124,15 +125,10 @@ $menu-item-line-height: 30px
text-align: center
overflow: hidden
- .toggle-follow
- position: absolute
- width: 140px
.icon-time
background: none
padding: 0
-$arrow-left-width: 40px
-
.main-item-wrapper
display: flex
@@ -163,9 +159,7 @@ $arrow-left-width: 40px
// -------------------- CHILD menu items ---------------------------
.main-menu--children
display: none
- padding-top: 10px
- padding-bottom: 10px
- padding: 0
+ padding: 10px 0
width: 100%
&.unattached
border-top: 1px solid #ddd
@@ -173,15 +167,6 @@ $arrow-left-width: 40px
&.partial
padding-bottom: 10px
- // resetting styles in partials.
- background: initial
- &:hover,
- li,
- li:hover
- background: initial
- a:not(.main-menu--children-sub-item)
- padding: initial
-
&:hover
// simultaneously hover all menu item anchor tags
> a
@@ -204,13 +189,12 @@ $arrow-left-width: 40px
border-radius: 3px
padding-left: 14px
padding-right: 14px
- width: 40px
&:hover, &:focus, &:active
@include main-menu-hover
a.main-menu--parent-node
display: inline-block
- padding: 0px 11px 0 11px
+ padding: 0 11px 0 11px
font-size: var(--main-menu-font-size)
font-weight: 700
width: calc(100% - #{$arrow-left-width})
@@ -294,7 +278,7 @@ a.main-menu--parent-node
margin-top: 0
a, a:link
- &:not(.collapsible-menu--item-link):not(.collapsible-menu--category-icon)
+ &:not(.searchable-menu--item-link):not(.searchable-menu--category-icon)
color: var(--main-menu-sidebar-link-color)
display: inline
position: static
@@ -356,7 +340,7 @@ a.main-menu--parent-node
height: 100vh
width: 18px
position: fixed
- top: 0px
+ top: 0
border-left-width: 2px
border-left-style: solid
border-left-color: transparent
@@ -374,7 +358,7 @@ a.main-menu--parent-node
.resizer-toggle-container
margin-top: 50vh
margin-left: -12px
- display: inline-block
+ display: inline-block
.main-menu--navigation-toggler
cursor: pointer
&:before
@@ -410,6 +394,6 @@ $badge_offset: 4px
font-weight: bold
font-style: italic
-#main-menu-toggle
+#main-menu-toggle
.icon-close
display: none
diff --git a/frontend/src/global_styles/layout/_searchable_menu.sass b/frontend/src/global_styles/layout/_searchable_menu.sass
new file mode 100644
index 00000000000..58969a4ea29
--- /dev/null
+++ b/frontend/src/global_styles/layout/_searchable_menu.sass
@@ -0,0 +1,84 @@
+$searchable-menu--search-container-height: 35px
+
+.searchable-menu
+ &--search-ul
+ height: calc(100% - #{$searchable-menu--search-container-height})
+ +allow-vertical-scrolling
+ -ms-overflow-style: -ms-autohiding-scrollbar
+ left: 0 !important
+ top: 0 !important
+ width: 100% !important
+ padding-top: 10px !important
+ max-height: 100%
+ background: none
+ z-index: 0 // Prevent overlapping with project select dropdown (https://community.openproject.com/wp/28175)
+ @include styled-scroll-bar
+
+ &--results-container
+ padding-top: 5px
+ height: calc(100% - #{$searchable-menu--search-container-height})
+
+ // Firefox needs more left padding for whatever reason
+ html.-browser-firefox &
+ padding-left: 10px
+
+ &--no-results-container
+ padding: 15px 15px 0
+ display: inline-block
+ width: 100%
+ white-space: normal
+ font-size: var(--main-menu-font-size)
+
+ &--search-container
+ padding-top: 10px
+ overflow: hidden
+ color: var(--main-menu-font-color)
+
+ // Specific fix for Firefox
+ body.-browser-firefox &
+ padding-right: 14px
+
+ // The actual search input
+ &--search-bar
+ height: $searchable-menu--search-container-height
+ position: relative
+ margin: 0 10px
+ min-width: 55px
+
+ // Rule complexed for specificity issues
+ input[type="text"].searchable-menu--search-input
+ color: var(--main-menu-font-color)
+ width: 100%
+ height: 35px
+ border: 1px solid rgba(231, 231, 231, 0.15)
+ border-radius: 3px
+ box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.15)
+ background-color: rgba(0, 0, 0, 0.15)
+ padding: 0px 30px 0px 10px
+
+ // Hide the little x to remove input where exists + supported
+ &::-webkit-search-cancel-button
+ display: none
+ &::placeholder,
+ &::-webkit-input-placeholder
+ color: var(--main-menu-font-color)
+ opacity: 0.5
+ @include text-shortener
+
+ &--search-icon
+ position: absolute
+ top: 5px
+ right: 10px
+ color: var(--main-menu-font-color)
+ opacity: 0.5
+
+ &--placeholder
+ @include text-shortener
+ color: var(--main-menu-font-color)
+ font-size: var(--main-menu-font-size)
+ padding: 0 10px
+
+#sidebar
+ // Cancel out the sidebar padding
+ .searchable-menu
+ margin: 0 -15px
diff --git a/modules/reporting/app/views/cost_reports/_report_list.html.erb b/modules/reporting/app/views/cost_reports/_report_list.html.erb
index 8127a5d355d..e4c9be33a97 100644
--- a/modules/reporting/app/views/cost_reports/_report_list.html.erb
+++ b/modules/reporting/app/views/cost_reports/_report_list.html.erb
@@ -31,7 +31,7 @@ See COPYRIGHT and LICENSE files for more details.
<% if queries.any? %>
<% queries.each do |query| -%>
<ul class="pages-hierarchy -with-hierarchy">
- <li class="tree-menu--item ui-menu-item collapsible-menu--item" slug="<%= query.name %>">
+ <li class="tree-menu--item" slug="<%= query.name %>">
<%= link_to(h(query.name),
{:controller => '/cost_reports', :action => 'show', :id => query.id},
:class => 'tree-menu--title ellipsis') %>
@@ -40,6 +40,6 @@ See COPYRIGHT and LICENSE files for more details.
<% end -%>
<% else %>
<ul class="pages-hierarchy -with-hierarchy">
- <li class="collapsible-menu--placeholder"><%= t(:"label_no_reports") %></li>
+ <li><%= t(:"label_no_reports") %></li>
</ul>
<% end -%>
diff --git a/modules/reporting/app/views/cost_reports/_report_menu.html.erb b/modules/reporting/app/views/cost_reports/_report_menu.html.erb
index 75b606a518e..96088d67764 100644
--- a/modules/reporting/app/views/cost_reports/_report_menu.html.erb
+++ b/modules/reporting/app/views/cost_reports/_report_menu.html.erb
@@ -29,11 +29,11 @@ See COPYRIGHT and LICENSE files for more details.
<% [:private, :public].each do |report_type| %>
<div class="tree-menu--container" data-selected-page="<%= @query ? @query.name : '' %>">
- <ul class="pages-hierarchy -with-hierarchy collapsible-menu--container">
+ <ul class="pages-hierarchy -with-hierarchy">
<li class="-hierarchy-expanded">
<span class="tree-menu--item">
<span class="tree-menu--hierarchy-span">
- <a tabindex="0" role="button" class="tree-menu--hierarchy-indicator collapsible-menu--category-toggle">
+ <a tabindex="0" role="button" class="tree-menu--hierarchy-indicator">
<span aria-hidden="true" class="tree-menu--hierarchy-indicator-icon"></span>
<span class="tree-menu--hierarchy-indicator-expanded hidden-for-sighted">
<%= t("label_expanded_click_to_collapse") %></span>
@@ -42,7 +42,7 @@ See COPYRIGHT and LICENSE files for more details.
</a>
</span>
<a id='<%= "#{report_type}_sidebar_report_category" %>'
- class="tree-menu--title ellipsis ui-autocomplete--category collapsible-menu--category-toggle">
+ class="tree-menu--title ellipsis">
<%= t(:"label_#{report_type}_report_plural") %>
</a>
</span>
@@ -52,4 +52,3 @@ See COPYRIGHT and LICENSE files for more details.
</ul>
</div>
<% end %>
-
diff --git a/modules/reporting/spec/features/saving_spec.rb b/modules/reporting/spec/features/saving_spec.rb
index 4a3a86b9b5d..6b58a712096 100644
--- a/modules/reporting/spec/features/saving_spec.rb
+++ b/modules/reporting/spec/features/saving_spec.rb
@@ -21,7 +21,7 @@ describe 'Cost report saving', type: :feature, js: true do
report_page.save as: 'Testreport'
# Check if the category is displayed
- expect(page).to have_selector('#private_sidebar_report_category', text: I18n.t(:label_private_report_plural).upcase)
+ expect(page).to have_selector('#private_sidebar_report_category', text: I18n.t(:label_private_report_plural))
# Check if the new report is displayed
expect(page).to have_selector('.tree-menu--title', text: 'Testreport')
@@ -38,7 +38,7 @@ describe 'Cost report saving', type: :feature, js: true do
report_page.save as: 'Public report', public: true
# Check if the category is displayed
- expect(page).to have_selector('#public_sidebar_report_category', text: I18n.t(:label_public_report_plural).upcase)
+ expect(page).to have_selector('#public_sidebar_report_category', text: I18n.t(:label_public_report_plural))
# Check if the new report is displayed
expect(page).to have_selector('.tree-menu--title', text: 'Public report')
diff --git a/spec/features/menu_items/query_menu_item_spec.rb b/spec/features/menu_items/query_menu_item_spec.rb
index d43f6dd893e..fe8f6870851 100644
--- a/spec/features/menu_items/query_menu_item_spec.rb
+++ b/spec/features/menu_items/query_menu_item_spec.rb
@@ -77,7 +77,7 @@ RSpec.feature 'Query menu items', js: true do
click_on 'Save'
notification.expect_success('Successful update')
- expect(page).to have_selector('.collapsible-menu--item[data-category=starred]', text: query.name)
+ expect(page).to have_selector('.op-sidemenu--item', text: query.name)
end
after do
diff --git a/spec/features/support/components/ui_autocomplete.rb b/spec/features/support/components/ui_autocomplete.rb
index f2db089264d..dd75f031b46 100644
--- a/spec/features/support/components/ui_autocomplete.rb
+++ b/spec/features/support/components/ui_autocomplete.rb
@@ -48,7 +48,7 @@ module Components
list
end
- def select_autocomplete(element, query:, results_selector: nil, select_text: nil)
+ def select_autocomplete(element, query:, results_selector: nil, item_selector: nil, select_text: nil)
target_dropdown = search_autocomplete(element, results_selector: results_selector, query: query)
##
@@ -57,7 +57,12 @@ module Components
text = select_text.presence || query
# click the element to select it
- target_dropdown.find('.ui-menu-item', text: text).click
+ query_element = if item_selector
+ target_dropdown.find(item_selector, text: text)
+ else
+ target_dropdown.find('.ui-menu-item', text: text)
+ end
+ query_element.click
end
end
end
diff --git a/spec/features/work_packages/navigation_spec.rb b/spec/features/work_packages/navigation_spec.rb
index bfff3b19810..db988a2ab95 100644
--- a/spec/features/work_packages/navigation_spec.rb
+++ b/spec/features/work_packages/navigation_spec.rb
@@ -158,8 +158,8 @@ RSpec.feature 'Work package navigation', js: true, selenium: true do
visit project_path(project)
find('#main-menu-work-packages ~ .toggler').click
- expect(page).to have_selector('.collapsible-menu--search-ul')
- find('.collapsible-menu--item-link', text: query.name).click
+ expect(page).to have_selector('.op-query-select--search-results')
+ find('.op-sidemenu--item-action', text: query.name).click
expect(page).not_to have_selector('.title-container', text: 'Overview')
expect(page).to have_field('editable-toolbar-title', with: query.name)
@@ -200,7 +200,7 @@ RSpec.feature 'Work package navigation', js: true, selenium: true do
wp_display.expect_state 'Gantt'
# Click on All open
- find('.collapsible-menu--item-link', text: 'All open').click
+ find('.op-sidemenu--item-action', text: 'All open').click
if OpenProject::Configuration.bim?
wp_display.expect_state 'Cards'
diff --git a/spec/features/work_packages/select/select_query_spec.rb b/spec/features/work_packages/select/select_query_spec.rb
index 50dd8061ad1..8bb29bdc253 100644
--- a/spec/features/work_packages/select/select_query_spec.rb
+++ b/spec/features/work_packages/select/select_query_spec.rb
@@ -103,7 +103,7 @@ describe 'Query selection', type: :feature do
it 'updates the page upon query switching', js: true do
wp_page.expect_title query.name, editable: false
- find('.collapsible-menu--item-link', text: query2.name).click
+ find('.op-sidemenu--item-action', text: query2.name).click
end
end
end
diff --git a/spec/features/work_packages/table/queries/hidden_query_spec.rb b/spec/features/work_packages/table/queries/hidden_query_spec.rb
index 0d63571e5dd..c97b45dc3bf 100644
--- a/spec/features/work_packages/table/queries/hidden_query_spec.rb
+++ b/spec/features/work_packages/table/queries/hidden_query_spec.rb
@@ -16,11 +16,11 @@ describe 'Visiting a hidden query', js: true do
end
it 'does not render the hidden query' do
- expect(page).to have_selector('.collapsible-menu--search-ul')
- expect(page).to have_no_selector('.ui-menu-item', text: 'my hidden query')
+ expect(page).to have_selector('.op-query-select--search-results')
+ expect(page).to have_no_selector('.op-sidemenu--item-action', text: 'my hidden query')
query.update(name: 'my visible query', hidden: false)
wp_table.visit!
- expect(page).to have_selector('.ui-menu-item', text: 'my visible query')
+ expect(page).to have_selector('.op-sidemenu--item-action', text: 'my visible query')
end
end
diff --git a/spec/features/work_packages/table/queries/query_menu_refresh_spec.rb b/spec/features/work_packages/table/queries/query_menu_refresh_spec.rb
index 24d6bba47e5..f61395b6117 100644
--- a/spec/features/work_packages/table/queries/query_menu_refresh_spec.rb
+++ b/spec/features/work_packages/table/queries/query_menu_refresh_spec.rb
@@ -60,7 +60,7 @@ describe 'Refreshing query menu item', js: true do
expect(url).not_to match(/query_props=.+/)
# Locate query and refresh
- query_item = page.find(".collapsible-menu--item", text: last_query.name)
+ query_item = page.find(".op-sidemenu--item-action", text: last_query.name)
query_item.click
wp_table.expect_work_package_listed work_package, other_work_package
diff --git a/spec/features/work_packages/table/queries/query_menu_spec.rb b/spec/features/work_packages/table/queries/query_menu_spec.rb
index 99977df4956..ec8f3b4d989 100644
--- a/spec/features/work_packages/table/queries/query_menu_spec.rb
+++ b/spec/features/work_packages/table/queries/query_menu_spec.rb
@@ -43,8 +43,8 @@ describe 'Query menu item', js: true do
let(:wp_table) { ::Pages::WorkPackagesTable.new }
it 'should show the query menu (Regression #30082)' do
wp_table.visit!
- expect(page).to have_selector('.collapsible-menu--container')
- expect(page).to have_selector('.collapsible-menu--item', wait: 20, minimum: 1)
+ expect(page).to have_selector('.op-query-select--search-results')
+ expect(page).to have_selector('.op-sidemenu--item-action', wait: 20, minimum: 1)
end
end
@@ -70,7 +70,7 @@ describe 'Query menu item', js: true do
find('.button', text: 'Save').click
- expect(page).to have_selector('.ui-menu-item', text: 'Some query name', wait: 20)
+ expect(page).to have_selector('.op-sidemenu--item-action', text: 'Some query name', wait: 20)
last_query = Query.last
expect(last_query.is_public).to be_truthy
@@ -87,7 +87,7 @@ describe 'Query menu item', js: true do
query_title.rename 'My special query!123'
query_title.expect_title 'My special query!123'
- expect(page).to have_selector('.ui-menu-item', text: 'My special query!123', wait: 20, count: 1)
+ expect(page).to have_selector('.op-sidemenu--item-action', text: 'My special query!123', wait: 20, count: 1)
end
it 'allows filtering, saving, retrieving and altering the saved filter (Regression #25372)' do
@@ -123,7 +123,7 @@ describe 'Query menu item', js: true do
wp_table.expect_work_package_listed work_package_with_version, work_package_without_version
# Locate query
- query_item = page.find(".ui-menu-item", text: 'Some query name')
+ query_item = page.find(".op-sidemenu--item-action", text: 'Some query name')
query_item.click
# Overrides the query_props
@@ -144,7 +144,7 @@ describe 'Query menu item', js: true do
filters.expect_filter_count 1
expect(page.current_url).to include('query_props')
- query_item = page.find(".ui-menu-item", text: 'Some query name')
+ query_item = page.find(".op-sidemenu--item-action", text: 'Some query name')
query_item.click
retry_block do
diff --git a/spec/features/work_packages/table/queries/summary_spec.rb b/spec/features/work_packages/table/queries/summary_spec.rb
index 8e251a3882e..f2fd687e3bb 100644
--- a/spec/features/work_packages/table/queries/summary_spec.rb
+++ b/spec/features/work_packages/table/queries/summary_spec.rb
@@ -45,7 +45,7 @@ describe 'Work package query summary item', type: :feature, js: true do
end
it 'allows users to visit the summary page' do
- find('.ui-menu-item', text: 'Summary', wait: 10).click
+ find('.op-sidemenu--item-action', text: 'Summary', wait: 10).click
expect(page).to have_selector('h2', text: 'Summary')
expect(page).to have_selector('td', text: work_package.type.name)
end
diff --git a/spec/support/components/work_packages/query_menu.rb b/spec/support/components/work_packages/query_menu.rb
index 4636826be05..70367985715 100644
--- a/spec/support/components/work_packages/query_menu.rb
+++ b/spec/support/components/work_packages/query_menu.rb
@@ -38,6 +38,7 @@ module Components
def select(query)
select_autocomplete autocompleter,
results_selector: autocompleter_results_selector,
+ item_selector: autocompleter_item_selector,
query: query
end
@@ -46,7 +47,11 @@ module Components
end
def autocompleter_results_selector
- '.collapsible-menu--results-container'
+ '.op-query-select--search-results'
+ end
+
+ def autocompleter_item_selector
+ '.op-sidemenu--item-action'
end
def autocompleter_selector
diff --git a/spec/support/pages/work_packages/work_packages_table.rb b/spec/support/pages/work_packages/work_packages_table.rb
index 9ca11401ded..7140cf48fa0 100644
--- a/spec/support/pages/work_packages/work_packages_table.rb
+++ b/spec/support/pages/work_packages/work_packages_table.rb
@@ -124,7 +124,7 @@ module Pages
page.find('.title-container').click
page.within('#querySelectDropdown') do
- expect(page).to have_selector('.ui-menu-item', text: name)
+ expect(page).to have_selector('.op-sidemenu--item-action', text: name)
end
end