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

Remove `op-view-select` component as it was not completely replaced by the Rails SubmenuComponent. Further the static-queries.service was reduced as the static queries are now also build by the Rails SubmenuComponent

Henriette Dargeb3cdcec8da64
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 a309bca94de..eeaa5c73953 100644
--- a/frontend/src/app/core/setup/global-dynamic-components.const.ts
+++ b/frontend/src/app/core/setup/global-dynamic-components.const.ts
@@ -69,10 +69,6 @@ import {
WorkPackageOverviewGraphComponent,
wpOverviewGraphSelector,
} from 'core-app/shared/components/work-package-graphs/overview/wp-overview-graph.component';
-import {
- opViewSelectSelector,
- ViewSelectComponent,
-} from 'core-app/shared/components/op-view-select/op-view-select.component';
import {
GlobalSearchTitleComponent,
globalSearchTitleSelector,
@@ -201,7 +197,6 @@ export const globalDynamicComponents:OptionalBootstrapDefinition[] = [
{ selector: enterpriseActiveSavedTrialSelector, cls: EEActiveSavedTrialComponent },
{ selector: headerProjectSelectSelector, cls: OpHeaderProjectSelectComponent },
{ selector: wpOverviewGraphSelector, cls: WorkPackageOverviewGraphComponent },
- { selector: opViewSelectSelector, cls: ViewSelectComponent },
{ selector: triggerActionsEntryComponentSelector, cls: TriggerActionsEntryComponent, embeddable: true },
{ selector: editableQueryPropsSelector, cls: EditableQueryPropsComponent },
{ selector: backupSelector, cls: BackupComponent },
diff --git a/frontend/src/app/shared/components/op-view-select/op-static-queries.service.ts b/frontend/src/app/shared/components/op-view-select/op-static-queries.service.ts
index 51566ed8c9d..49a88d2e29a 100644
--- a/frontend/src/app/shared/components/op-view-select/op-static-queries.service.ts
+++ b/frontend/src/app/shared/components/op-view-select/op-static-queries.service.ts
@@ -29,70 +29,25 @@
import { QueryResource } from 'core-app/features/hal/resources/query-resource';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { Injectable } from '@angular/core';
-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';
-import { ViewType } from 'core-app/shared/components/op-view-select/op-view-select.component';
-import { BannersService } from 'core-app/core/enterprise/banners.service';
-
-interface IStaticQuery extends IOpSidemenuItem {
- view:ViewType;
-}
@Injectable()
export class StaticQueriesService {
- private staticQueries:IStaticQuery[] = [];
-
constructor(
private readonly I18n:I18nService,
private readonly $state:StateService,
- private readonly CurrentProject:CurrentProjectService,
- private readonly PathHelper:PathHelperService,
- private readonly CurrentUser:CurrentUserService,
- private readonly bannersService:BannersService,
) {
- this.staticQueries = this.buildQueries();
}
public text = {
- assignee: this.I18n.t('js.work_packages.properties.assignee'),
- author: this.I18n.t('js.work_packages.properties.author'),
- created_at: this.I18n.t('js.work_packages.properties.createdAt'),
- updated_at: this.I18n.t('js.work_packages.properties.updatedAt'),
- status: this.I18n.t('js.work_packages.properties.status'),
work_packages: this.I18n.t('js.label_work_package_plural'),
- gantt: this.I18n.t('js.gantt_chart.label'),
- latest_activity: this.I18n.t('js.work_packages.default_queries.latest_activity'),
- created_by_me: this.I18n.t('js.work_packages.default_queries.created_by_me'),
- assigned_to_me: this.I18n.t('js.work_packages.default_queries.assigned_to_me'),
- recently_created: this.I18n.t('js.work_packages.default_queries.recently_created'),
all_open: this.I18n.t('js.work_packages.default_queries.all_open'),
- shared_with_users: this.I18n.t('js.work_packages.default_queries.shared_with_users'),
- shared_with_me: this.I18n.t('js.work_packages.default_queries.shared_with_me'),
- summary: this.I18n.t('js.work_packages.default_queries.summary'),
- overdue: this.I18n.t('js.notifications.date_alerts.overdue'),
};
public getStaticName(query:QueryResource):string {
if (this.$state.params.query_props) {
- const queryProps = JSON.parse(this.$state.params.query_props) as { pa:unknown, pp:unknown }&unknown;
- delete queryProps.pp;
- delete queryProps.pa;
- const queryPropsString = JSON.stringify(queryProps);
-
- const matched = this.staticQueries.find((item) => {
- const uiParams = item.uiParams as { query_id:string, query_props:string };
- return uiParams && uiParams.query_props === queryPropsString;
- });
-
- if (matched) {
- return matched.title;
- }
-
- if (this.$state.params.name) {
- const nameKey = this.$state.params.name as string;
+ const nameKey = this.$state.params.name as string;
+ if (nameKey) {
return this.I18n.t(`js.work_packages.default_queries.${nameKey}`);
}
}
@@ -107,137 +62,4 @@ export class StaticQueriesService {
// Otherwise, fall back to work packages
return this.text.work_packages;
}
-
- public buildQueries():IStaticQuery[] {
- let items:IStaticQuery[] = [
- {
- title: this.text.all_open,
- uiSref: 'work-packages',
- uiParams: { query_id: undefined, query_props: undefined },
- view: 'WorkPackagesTable',
- },
- {
- title: this.text.latest_activity,
- uiSref: 'work-packages',
- uiParams: {
- query_id: undefined,
- query_props: '{"c":["id","subject","type","status","assignee","updatedAt"],"hi":false,"g":"","t":"updatedAt:desc","f":[{"n":"status","o":"*","v":[]}]}',
- },
- view: 'WorkPackagesTable',
- },
- {
- title: this.text.recently_created,
- uiSref: 'work-packages',
- uiParams: {
- query_id: undefined,
- query_props: '{"c":["id","subject","type","status","assignee","createdAt"],"hi":false,"g":"","t":"createdAt:desc","f":[{"n":"status","o":"o","v":[]}]}',
- },
- view: 'WorkPackagesTable',
- },
- {
- title: this.text.overdue,
- uiSref: 'work-packages',
- uiParams: {
- query_id: undefined,
- query_props: '{"c":["id","type","subject","status","startDate","dueDate","duration"],"hi":false,"g":"","t":"createdAt:desc","f":[{"n":"dueDate","o":"<t-","v":["1"]},{"n":"status","o":"o","v":[]}]}',
- },
- view: 'WorkPackagesTable',
- },
- ];
-
- const projectIdentifier = this.CurrentProject.identifier;
- if (projectIdentifier) {
- items = [
- ...items,
- ...this.projectDependentQueries(projectIdentifier),
- ];
- }
-
- if (this.CurrentUser.isLoggedIn) {
- items = [
- ...items,
- ...this.userDependentQueries(),
- ];
- }
-
- return items;
- }
-
- public getStaticQueriesForView(view:ViewType):IOpSidemenuItem[] {
- return this.staticQueries
- .filter((query) => query.view === view);
- }
-
- private projectDependentQueries(projectIdentifier:string):IStaticQuery[] {
- return [
- {
- title: this.text.summary,
- href: `${this.PathHelper.projectWorkPackagesPath(projectIdentifier)}/report`,
- view: 'WorkPackagesTable',
- },
- ];
- }
-
- private userDependentQueries():IStaticQuery[] {
- return [
- {
- title: this.text.created_by_me,
- uiSref: 'work-packages',
- uiParams: {
- query_id: undefined,
- 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"]}]}',
- },
- view: 'WorkPackagesTable',
- },
- {
- title: this.text.assigned_to_me,
- uiSref: 'work-packages',
- uiParams: {
- query_id: undefined,
- 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"]}]}',
- },
- view: 'WorkPackagesTable',
- },
- {
- title: this.text.shared_with_users,
- view: 'WorkPackagesTable',
- isEnterprise: true,
- ...this.eeGuardedShareRoute,
- },
- {
- title: this.text.shared_with_me,
- view: 'WorkPackagesTable',
- isEnterprise: true,
- ...this.eeGuardedShareWithMeRoute,
- },
- ];
- }
-
- private get eeGuardedShareWithMeRoute() {
- if (this.bannersService.eeShowBanners) {
- return { uiSref: 'work-packages.share_upsale', uiParams: null, uiOptions: { inherit: false } };
- }
-
- return {
- uiSref: 'work-packages',
- uiParams: {
- query_id: undefined,
- query_props: '{"c":["id","subject","type","project"],"hi":false,"g":"","t":"updatedAt:desc,id:asc","f":[{"n":"sharedWithMe","o":"=","v":"t"}]}',
- },
- };
- }
-
- private get eeGuardedShareRoute() {
- if (this.bannersService.eeShowBanners) {
- return { uiSref: 'work-packages.share_upsale', uiParams: null, uiOptions: { inherit: false } };
- }
-
- return {
- uiSref: 'work-packages',
- uiParams: {
- query_id: undefined,
- query_props: '{"c":["id","subject","type","project","sharedWithUsers"],"hi":false,"g":"","t":"updatedAt:desc,id:asc","f":[{"n":"sharedWithUser","o":"*","v":[]}]}',
- },
- };
- }
}
diff --git a/frontend/src/app/shared/components/op-view-select/op-view-select.component.ts b/frontend/src/app/shared/components/op-view-select/op-view-select.component.ts
deleted file mode 100644
index 1225fb10014..00000000000
--- a/frontend/src/app/shared/components/op-view-select/op-view-select.component.ts
+++ /dev/null
@@ -1,244 +0,0 @@
-// -- copyright
-// OpenProject is an open source project management software.
-// Copyright (C) 2012-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.
-//++
-
-import {
- ChangeDetectionStrategy,
- ChangeDetectorRef,
- Component,
- ElementRef,
- Input,
- OnInit,
-} from '@angular/core';
-import { map } from 'rxjs/operators';
-import {
- BehaviorSubject,
- combineLatest,
-} from 'rxjs';
-import { States } from 'core-app/core/states/states.service';
-import { I18nService } from 'core-app/core/i18n/i18n.service';
-import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
-import { populateInputsFromDataset } from 'core-app/shared/components/dataset-inputs';
-import { MainMenuNavigationService } from 'core-app/core/main-menu/main-menu-navigation.service';
-import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
-import { IOpSidemenuItem } from 'core-app/shared/components/sidemenu/sidemenu.component';
-import { StaticQueriesService } from 'core-app/shared/components/op-view-select/op-static-queries.service';
-import { ViewsResourceService } from 'core-app/core/state/views/views.service';
-import { IView } from 'core-app/core/state/views/view.model';
-import idFromLink from 'core-app/features/hal/helpers/id-from-link';
-import { ApiV3ListParameters } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';
-import { MAGIC_PAGE_NUMBER } from 'core-app/core/apiv3/helpers/get-paginated-results';
-
-export type ViewType = 'WorkPackagesTable'|'Bim'|'TeamPlanner'|'WorkPackagesCalendar'|'Gantt';
-
-export const opViewSelectSelector = 'op-view-select';
-
-@Component({
- selector: opViewSelectSelector,
- changeDetection: ChangeDetectionStrategy.OnPush,
- templateUrl: './op-view-select.template.html',
-})
-export class ViewSelectComponent extends UntilDestroyedMixin implements OnInit {
- public text = {
- search: this.I18n.t('js.global_search.search'),
- label: this.I18n.t('js.toolbar.search_query_label'),
- scope_default: this.I18n.t('js.label_default_queries'),
- scope_starred: this.I18n.t('js.label_starred_queries'),
- scope_global: this.I18n.t('js.label_global_queries'),
- scope_private: this.I18n.t('js.label_custom_queries'),
- no_results: this.I18n.t('js.autocompleter.notFoundText'),
- };
-
- @Input() menuItems:string[] = [];
-
- @Input() projectId:string|undefined;
-
- @Input() baseRoute:string;
-
- @Input() viewType:ViewType;
-
- public items:IOpSidemenuItem[] = [];
-
- private apiViewType:string;
-
- private viewCategories$ = new BehaviorSubject<IOpSidemenuItem[]>([]);
-
- private search$ = new BehaviorSubject<string>('');
-
- private initialized = false;
-
- constructor(
- readonly elementRef:ElementRef,
- readonly apiV3Service:ApiV3Service,
- readonly I18n:I18nService,
- readonly states:States,
- readonly opStaticQueries:StaticQueriesService,
- readonly mainMenuService:MainMenuNavigationService,
- readonly cdRef:ChangeDetectorRef,
- readonly viewsService:ViewsResourceService,
- ) {
- super();
-
- populateInputsFromDataset(this);
- }
-
- public set search(input:string) {
- if (this.search$.value !== input) {
- this.search$.next(input);
- }
- }
-
- ngOnInit():void {
- this.apiViewType = `Views::${this.viewType}`;
-
- // When activating the work packages submenu,
- // either initially or through click on the toggle, load the results
- this.mainMenuService
- .onActivate(...this.menuItems)
- .subscribe(() => this.initializeAutocomplete());
-
- combineLatest([
- this.search$,
- this.viewCategories$,
- ]).pipe(
- map(([searchText, categories]) => {
- // We go the way of assigning the variable instead of using the observable directly with the async pipe.
- // For whatever the reason Angular's change detection does not catch the changes made here.
- // Thus, the sidemenu items were only updated with the next global change event (e.g. notifications push or some user interaction).
- this.items = categories
- .map((category) => {
- if (ViewSelectComponent.matchesText(category.title, searchText)) {
- return category;
- }
- const filteredChildren = category.children
- ?.filter((query) => ViewSelectComponent.matchesText(query.title, searchText));
-
- return { title: category.title, children: filteredChildren, collapsible: true };
- })
- .filter((category) => category.children && category.children.length > 0);
-
- this.cdRef.detectChanges();
-
- return this.items;
- }),
- ).subscribe();
- }
-
- private initializeAutocomplete():void {
- if (this.initialized) {
- return;
- }
-
- // 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.initializeViews();
- this.initialized = true;
- }
-
- private static matchesText(text:string, searchText:string):boolean {
- return text.toLowerCase().includes(searchText.toLowerCase());
- }
-
- private initializeViews():void {
- const categories:{ [category:string]:IOpSidemenuItem[] } = {
- starred: [],
- default: [],
- public: [],
- private: [],
- createNew: [],
- };
-
- const params:ApiV3ListParameters = {
- filters: [
- ['type', '=', [this.apiViewType]],
- ],
- pageSize: MAGIC_PAGE_NUMBER,
- };
-
- if (this.projectId) {
- params.filters?.push(
- ['project', '=', [this.projectId]],
- );
- } else {
- params.filters?.push(
- ['project', '!*', []],
- );
- }
-
- this.viewsService.fetchResults(params)
- .pipe(this.untilDestroyed())
- .subscribe((views) => {
- views
- .sort((a, b) => a._links.query.title.localeCompare(b._links.query.title))
- .forEach((view) => {
- let cat = 'private';
- if (view.public) {
- cat = 'public';
- }
- if (view.starred) {
- cat = 'starred';
- }
-
- categories[cat].push(this.toOpSideMenuItem(view));
- });
-
- const staticQueries = this.opStaticQueries.getStaticQueriesForView(this.viewType);
- const viewCategories = [
- { title: this.text.scope_starred, children: categories.starred, collapsible: true },
- { title: this.text.scope_default, children: staticQueries, collapsible: true },
- { title: this.text.scope_global, children: categories.public, collapsible: true },
- { title: this.text.scope_private, children: categories.private, collapsible: true },
- ];
-
- this.viewCategories$.next(viewCategories);
- });
- }
-
- private toOpSideMenuItem(view:IView):IOpSidemenuItem {
- const { query } = view._links;
- return {
- title: query.title,
- uiSref: this.baseRoute,
- uiParams: { query_id: idFromLink(query.href), query_props: undefined },
- uiOptions: { reload: true },
- };
- }
-
- // Listens on all changes of queries (via an observable in the service), e.g. delete, create, rename, toggle starred
- private updateMenuOnChanges() {
- this.states.changes.queries
- .pipe(this.untilDestroyed())
- .subscribe(() => this.initializeViews());
- }
-}
diff --git a/frontend/src/app/shared/components/op-view-select/op-view-select.template.html b/frontend/src/app/shared/components/op-view-select/op-view-select.template.html
deleted file mode 100644
index f7c4cb93c79..00000000000
--- a/frontend/src/app/shared/components/op-view-select/op-view-select.template.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<div id="viewSelect" 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 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 searchable-menu--search-icon"></i>
- </div>
-
- <p class="searchable-menu--no-results-container"
- [hidden]="items.length > 0"
- [textContent]="text.no_results"></p>
-
- <op-sidemenu
- class="op-view-select--search-results"
- [items]="items"
- [collapsible]="true"
- [searchable]="true"
- >
- </op-sidemenu>
- </div>
-</div>
diff --git a/frontend/src/app/shared/shared.module.ts b/frontend/src/app/shared/shared.module.ts
index c16f1726f3e..678d3c53f40 100644
--- a/frontend/src/app/shared/shared.module.ts
+++ b/frontend/src/app/shared/shared.module.ts
@@ -58,7 +58,6 @@ import { FreeTrialButtonComponent } from 'core-app/features/enterprise/free-tria
import { HomescreenNewFeaturesBlockComponent } from 'core-app/features/homescreen/blocks/new-features.component';
import { TablePaginationComponent } from 'core-app/shared/components/table-pagination/table-pagination.component';
import { HookService } from 'core-app/features/plugins/hook-service';
-import { ViewSelectComponent } from 'core-app/shared/components/op-view-select/op-view-select.component';
import { StaticQueriesService } from 'core-app/shared/components/op-view-select/op-static-queries.service';
import {
highlightColSelector,
@@ -207,8 +206,6 @@ export function bootstrapModule(injector:Injector):void {
OpProjectIncludeListComponent,
OpLoadingProjectListComponent,
- ViewSelectComponent,
-
// Old datepickers
OpMultiDatePickerComponent,
@@ -220,8 +217,6 @@ export function bootstrapModule(injector:Injector):void {
ViewsResourceService,
],
declarations: [
- ViewSelectComponent,
-
ToastsContainerComponent,
ToastComponent,
UploadProgressComponent,