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
saving query on team_planner via title
ulfertsb71d41fcfe98
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 a62f73a4abd..81148dd1afe 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@@ -29,7 +29,7 @@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 { View } from 'core-app/core/state/views/view.model';+import { View, ViewCreatePayload } from 'core-app/core/state/views/view.model';import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';import { HttpClient } from '@angular/common/http';import { map } from 'rxjs/operators';@@ -49,12 +49,12 @@ export class APIv3ViewsPaths extends APIv3ResourceCollection<View, APIv3Gettable** @param TODO*/- post(resource:View|unknown, type:string):Observable<View> {+ post(resource:ViewCreatePayload, type:string):Observable<View> {return this.http.post(- `${this.path}/${type})}`,- { resource },+ `${this.path}/${type}`,+ resource,{withCredentials: true,responseType: 'json',diff --git a/frontend/src/app/core/state/views/view.model.ts b/frontend/src/app/core/state/views/view.model.tsindex 1eb575b7b41..5341e4c7ac1 100644--- a/frontend/src/app/core/state/views/view.model.ts+++ b/frontend/src/app/core/state/views/view.model.ts@@ -12,3 +12,11 @@ export interface View {id:ID;_links:ViewLinks;}++export interface ViewCreatePayload {+ _links:{+ [P in 'query']:{+ [Q in 'href']:string+ }+ }+}diff --git a/frontend/src/app/features/team-planner/team-planner/page/team-planner-page.component.ts b/frontend/src/app/features/team-planner/team-planner/page/team-planner-page.component.tsindex b9215392666..06330d57da6 100644--- a/frontend/src/app/features/team-planner/team-planner/page/team-planner-page.component.ts+++ b/frontend/src/app/features/team-planner/team-planner/page/team-planner-page.component.ts@@ -50,8 +50,8 @@ export class TeamPlannerPageComponent extends PartitionedQuerySpacePageComponent/** Toolbar is not editable */titleEditingEnabled = false;- /** Not savable */- showToolbarSaveButton = false;+ /** Savable */+ showToolbarSaveButton = true;/** Toolbar is always enabled */toolbarDisabled = false;@@ -89,21 +89,8 @@ export class TeamPlannerPageComponent extends PartitionedQuerySpacePageComponentthis.currentPartition = state.data?.partition || '-split';}- updateTitle(query?:QueryResource):void {- if (!query?.id) {- this.selectedTitle = this.text.unsaved_title;- } else {- super.updateTitle(query);- }- }-- // For shared template compliance- // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars- updateTitleName(val:string):void {- }-- // For shared template compliance- // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars- changeChangesFromTitle(val:string):void {+ // eslint-disable-next-line @typescript-eslint/no-unused-vars+ protected staticQueryName(query:QueryResource):string {+ return this.text.unsaved_title;}}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.tsindex a84bd61bb06..9ac41669059 100644--- 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.ts@@ -13,6 +13,10 @@ export class WorkPackagesQueryViewService {) { }create(query:QueryResource):Observable<View> {+ if (!query.href) {+ throw new Error('Expected only queries that are created since an href is required');+ }+return this.apiV3Service.viewsdiff --git a/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts b/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.tsindex e8b5beffd1e..b270b7e3837 100644--- a/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts+++ b/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts@@ -217,7 +217,7 @@ export class PartitionedQuerySpacePageComponent extends WorkPackagesViewBase impif (isPersistedResource(query)) {this.selectedTitle = query.name;} else {- this.selectedTitle = this.opStaticQueries.getStaticName(query);+ this.selectedTitle = this.staticQueryName(query);}this.titleEditingEnabled = this.authorisationService.can('query', 'updateImmediately');@@ -290,4 +290,8 @@ export class PartitionedQuerySpacePageComponent extends WorkPackagesViewBase impprotected shouldUpdateHtmlTitle():boolean {return true;}++ protected staticQueryName(query:QueryResource):string {+ return this.opStaticQueries.getStaticName(query);+ }}diff --git a/modules/team_planner/spec/features/query_handling_spec.rb b/modules/team_planner/spec/features/query_handling_spec.rbnew file mode 100644index 00000000000..1316f20f4af--- /dev/null+++ b/modules/team_planner/spec/features/query_handling_spec.rb@@ -0,0 +1,109 @@+#-- encoding: UTF-8++#-- 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.+#++++require 'spec_helper'+require_relative '../support/pages/team_planner'++describe 'Team planner query handling', type: :feature, js: true do+ shared_let(:type_task) { FactoryBot.create(:type_task) }+ shared_let(:type_bug) { FactoryBot.create(:type_bug) }+ shared_let(:project) do+ FactoryBot.create(:project,+ enabled_module_names: %w[work_package_tracking team_planner_view],+ types: [type_task, type_bug])+ end++ shared_let(:user) do+ FactoryBot.create :user,+ member_in_project: project,+ member_with_permissions: %w[+ view_work_packages+ edit_work_packages+ save_queries+ save_public_queries+ view_team_planner+ manage_team_planner+ ]+ end++ shared_let(:task) do+ FactoryBot.create :work_package,+ project: project,+ type: type_task,+ assigned_to: user,+ start_date: Time.zone.today - 1.day,+ due_date: Time.zone.today + 1.day,+ subject: 'A task for the user'+ end+ shared_let(:bug) do+ FactoryBot.create :work_package,+ project: project,+ type: type_bug,+ assigned_to: user,+ start_date: Time.zone.today - 1.day,+ due_date: Time.zone.today + 1.day,+ subject: 'A bug for the user'+ end++ let(:team_planner) { ::Pages::TeamPlanner.new project }+ let(:query_title) { ::Components::WorkPackages::QueryTitle.new }+ let(:filters) { team_planner.filters }++ current_user { user }++ it 'allows saving the team planner' do+ team_planner.visit!++ team_planner.expect_assignee user++ team_planner.within_lane(user) do+ team_planner.expect_event bug+ team_planner.expect_event task+ end++ filters.expect_filter_count("1")+ filters.open++ filters.add_filter_by('Type', 'is', [type_bug.name])++ filters.expect_filter_count("2")++ team_planner.within_lane(user) do+ team_planner.expect_event bug+ team_planner.expect_event task, present: false+ end++ query_title.expect_changed++ query_title.press_save_button++ team_planner.expect_and_dismiss_toaster(message: I18n.t('js.notice_successful_create'))+ end+end