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
create view on query creation - static
ulferts65f8f6adae6c
diff --git a/frontend/src/app/core/apiv3/api-v3.service.ts b/frontend/src/app/core/apiv3/api-v3.service.tsindex be455f65fe9..801b47cbee1 100644--- a/frontend/src/app/core/apiv3/api-v3.service.ts+++ b/frontend/src/app/core/apiv3/api-v3.service.ts@@ -53,6 +53,7 @@ import { Apiv3PlaceholderUsersPaths } from 'core-app/core/apiv3/endpoints/placehimport { Apiv3GroupsPaths } from 'core-app/core/apiv3/endpoints/groups/apiv3-groups-paths';import { HalResource } from 'core-app/features/hal/resources/hal-resource';import { Apiv3NotificationsPaths } from 'core-app/core/apiv3/endpoints/notifications/apiv3-notifications-paths';+import { APIv3ViewsPaths } from 'core-app/core/apiv3/endpoints/views/apiv3-views-paths';@Injectable({ providedIn: 'root' })export class APIV3Service {@@ -134,6 +135,9 @@ export class APIV3Service {// /api/v3/job_statusespublic readonly job_statuses = this.apiV3CollectionEndpoint('job_statuses');+ // /api/v3/views+ public readonly views = this.apiV3CustomEndpoint(APIv3ViewsPaths);+// VIRTUAL boards are /api/v3/grids + a scope filterpublic readonly boards = this.apiV3CustomEndpoint(Apiv3BoardsPaths);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.tsnew file mode 100644index 00000000000..8cf1a0619e2--- /dev/null+++ b/frontend/src/app/core/apiv3/endpoints/views/apiv3-views-paths.ts@@ -0,0 +1,50 @@+// -- 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 { APIv3GettableResource, APIv3ResourceCollection } from 'core-app/core/apiv3/paths/apiv3-resource';+import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';+import { Observable } from 'rxjs';+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');+ }++ /**+ * Create a new query resource+ *+ * @param payload Payload object or query HAL resource+ */+ public post(resource:ViewResource|Object):Observable<ViewResource> {+ return this+ .halResourceService+ .post<ViewResource>(this.path, resource);+ }+}diff --git a/frontend/src/app/features/hal/resources/views-resource.ts b/frontend/src/app/features/hal/resources/views-resource.tsnew file mode 100644index 00000000000..04200cc3d68--- /dev/null+++ b/frontend/src/app/features/hal/resources/views-resource.ts@@ -0,0 +1,41 @@+// -- 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 { HalResource } from 'core-app/features/hal/resources/hal-resource';++export interface ViewResourceLinks {+}++export interface ViewResourceEmbedded {+ query:HalResource;+}++export class ViewResource extends HalResource {+}++export interface ViewResource extends ViewResourceLinks, ViewResourceEmbedded {}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 5fe121a45e6..be8b46b6ba0 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@@ -38,7 +38,7 @@ import { I18nService } from 'core-app/core/i18n/i18n.service';import { from, Observable, of } from 'rxjs';import { input } from 'reactivestates';import {- catchError, mergeMap, share, switchMap, take,+ catchError, mapTo, mergeMap, share, switchMap, take} from 'rxjs/operators';import {WorkPackageViewPaginationService,@@ -232,21 +232,17 @@ export class WorkPackagesListService {query.name = name;const promise = this- .apiV3Service- .queries- .post(query, form)- .toPromise();-- void promise- .then((query) => {+ .createQueryAndView(query, form)+ .toPromise()+ .then((createdQuery) => {this.toastService.addSuccess(this.I18n.t('js.notice_successful_create'));// Reload the query, and then reload the menu- this.reloadQuery(query).subscribe(() => {- this.states.changes.queries.next(query.id!);+ this.reloadQuery(createdQuery).subscribe(() => {+ this.states.changes.queries.next(createdQuery.id!);});- return query;+ return createdQuery;});return promise;@@ -384,4 +380,26 @@ export class WorkPackagesListService {}return this.configuration.initialized;}++ private createQueryAndView(query:QueryResource, form:QueryFormResource|undefined) {+ return this+ .apiV3Service+ .queries+ .post(query, form)+ .pipe(+ switchMap((createdQuery) => this+ .apiV3Service+ .views+ .post({+ _links: {+ query: {+ href: createdQuery.href,+ },+ },+ })+ .pipe(+ mapTo(createdQuery),+ )),+ );+ }}