OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
deduce view to create from current uistate
ulfertsaad2bac1acc9
diff --git a/frontend/src/app/core/apiv3/endpoints/views/apiv3-views-paths.ts b/frontend/src/app/core/apiv3/endpoints/views/apiv3-views-paths.tsindex 8cf1a0619e2..d1a31082b64 100644--- a/frontend/src/app/core/apiv3/endpoints/views/apiv3-views-paths.ts+++ b/frontend/src/app/core/apiv3/endpoints/views/apiv3-views-paths.ts@@ -34,17 +34,17 @@ import { ViewResource } from 'core-app/features/hal/resources/views-resource';export class APIv3ViewsPaths extends APIv3ResourceCollection<ViewResource, APIv3GettableResource<ViewResource>> {constructor(protected apiRoot:APIV3Service,protected basePath:string) {- super(apiRoot, basePath, 'views/work_packages_table');+ super(apiRoot, basePath, 'views');}/**- * Create a new query resource+ * Create a new view resource*- * @param payload Payload object or query HAL resource+ * @param payload Payload object or view HAL resource*/- public post(resource:ViewResource|Object):Observable<ViewResource> {+ public post(resource:ViewResource|unknown, type:string):Observable<ViewResource> {return this.halResourceService- .post<ViewResource>(this.path, resource);+ .post<ViewResource>(`${this.path}/${type}`, resource);}}diff --git a/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.ts b/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.tsindex be8b46b6ba0..acdd0b277b7 100644--- a/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.ts+++ b/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.ts@@ -52,6 +52,7 @@ import { ErrorResource } from 'core-app/features/hal/resources/error-resource';import { QueryFormResource } from 'core-app/features/hal/resources/query-form-resource';import { WorkPackageStatesInitializationService } from './wp-states-initialization.service';import { WorkPackagesListInvalidQueryService } from './wp-list-invalid-query.service';+import { WorkPackagesQueryViewService } from 'core-app/features/work-packages/components/wp-list/wp-query-view.service';export interface QueryDefinition {queryParams:{ query_id?:string, query_props?:string };@@ -98,6 +99,7 @@ export class WorkPackagesListService {protected wpTablePagination:WorkPackageViewPaginationService,protected wpStatesInitialization:WorkPackageStatesInitializationService,protected wpListInvalidQueryService:WorkPackagesListInvalidQueryService,+ protected wpQueryView:WorkPackagesQueryViewService,) { }/**@@ -388,15 +390,8 @@ export class WorkPackagesListService {.post(query, form).pipe(switchMap((createdQuery) => this- .apiV3Service- .views- .post({- _links: {- query: {- href: createdQuery.href,- },- },- })+ .wpQueryView+ .create(createdQuery).pipe(mapTo(createdQuery),)),diff --git a/frontend/src/app/features/work-packages/components/wp-list/wp-query-view.service.ts b/frontend/src/app/features/work-packages/components/wp-list/wp-query-view.service.tsnew file mode 100644index 00000000000..e7f85416893--- /dev/null+++ b/frontend/src/app/features/work-packages/components/wp-list/wp-query-view.service.ts@@ -0,0 +1,41 @@+import { Injectable } from '@angular/core';+import { StateService } from '@uirouter/core';+import { QueryResource } from 'core-app/features/hal/resources/query-resource';+import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';+import { ViewResource } from 'core-app/features/hal/resources/views-resource';+import { Observable } from 'rxjs';++@Injectable()+export class WorkPackagesQueryViewService {+ constructor(+ protected $state:StateService,+ protected apiV3Service:APIV3Service,+ ) { }++ create(query:QueryResource):Observable<ViewResource> {+ return this+ .apiV3Service+ .views+ .post(+ {+ _links: {+ query: {+ href: query.href,+ },+ },+ },+ this.viewType,+ );+ }++ private get viewType() {+ if (this.$state.includes('work-packages')) {+ return 'work_packages_table';+ }+ if (this.$state.includes('team_planner')) {+ return 'team_planner';+ }++ throw new Error('Not on a path defined for query views');+ }+}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.tsindex 3ad070d341e..18fc9e9bc98 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@@ -171,6 +171,7 @@ import { WorkPackageFilterContainerComponent } from 'core-app/features/work-packimport { FilterBooleanValueComponent } from 'core-app/features/work-packages/components/filters/filter-boolean-value/filter-boolean-value.component';import { WorkPackageMarkNotificationButtonComponent } from 'core-app/features/work-packages/components/wp-buttons/wp-mark-notification-button/work-package-mark-notification-button.component';import isNewResource from 'core-app/features/hal/helpers/is-new-resource';+import { WorkPackagesQueryViewService } from 'core-app/features/work-packages/components/wp-list/wp-query-view.service';@NgModule({imports: [@@ -221,6 +222,8 @@ import isNewResource from 'core-app/features/hal/helpers/is-new-resource';WorkPackageRelationsService,WorkPackageWatchersService,+ WorkPackagesQueryViewService,+HalEventsService,],declarations: [