diff --git a/frontend/src/app/features/hal/resources/query-resource.ts b/frontend/src/app/features/hal/resources/query-resource.ts index d2f27eb4671..516ec1f6294 100644 --- a/frontend/src/app/features/hal/resources/query-resource.ts +++ b/frontend/src/app/features/hal/resources/query-resource.ts @@ -64,6 +64,10 @@ export class QueryResource extends HalResource { public sortBy:QuerySortByResource[]; + public setSortBy(newSortBy:QuerySortByResource[]):void { + this.sortBy = newSortBy; + } + public filters:QueryFilterInstanceResource[]; public starred:boolean; diff --git a/frontend/src/app/features/work-packages/components/wp-fast-table/handlers/state/drag-and-drop-transformer.ts b/frontend/src/app/features/work-packages/components/wp-fast-table/handlers/state/drag-and-drop-transformer.ts index 94b03d14708..02edf66dece 100644 --- a/frontend/src/app/features/work-packages/components/wp-fast-table/handlers/state/drag-and-drop-transformer.ts +++ b/frontend/src/app/features/work-packages/components/wp-fast-table/handlers/state/drag-and-drop-transformer.ts @@ -102,7 +102,7 @@ export class DragAndDropTransformer { // Save the query when switching to manual const query = this.querySpace.query.value; if (query && this.wpTableSortBy.switchToManualSorting(query)) { - await this.wpListService.save(query); + await this.wpListService.createOrSave(query); } } catch (e) { this.halNotification.handleRawError(e); diff --git a/frontend/src/app/features/work-packages/components/wp-grid/wp-grid.component.ts b/frontend/src/app/features/work-packages/components/wp-grid/wp-grid.component.ts index a8837c2d7dc..0706360a4bb 100644 --- a/frontend/src/app/features/work-packages/components/wp-grid/wp-grid.component.ts +++ b/frontend/src/app/features/work-packages/components/wp-grid/wp-grid.component.ts @@ -120,7 +120,7 @@ export class WorkPackagesGridComponent implements WorkPackageViewOutputs { public switchToManualSorting() { const query = this.querySpace.query.value; if (query && this.wpTableSortBy.switchToManualSorting(query)) { - this.wpList.save(query); + void this.wpList.createOrSave(query); } } } 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.ts index 0cc62bdded3..bce8b51328e 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 @@ -32,6 +32,7 @@ import { AuthorisationService } from 'core-app/core/model-auth/model-auth.servic import { StateService } from '@uirouter/core'; import { IsolatedQuerySpace } from 'core-app/features/work-packages/directives/query-space/isolated-query-space'; import { Injectable } from '@angular/core'; +import isPersistedResource from 'core-app/features/hal/helpers/is-persisted-resource'; import { UrlParamsHelperService } from 'core-app/features/work-packages/components/wp-query/url-params-helper'; import { ToastService } from 'core-app/shared/components/toaster/toast.service'; import { I18nService } from 'core-app/core/i18n/i18n.service'; @@ -333,6 +334,13 @@ export class WorkPackagesListService { return promise; } + public async createOrSave(query:QueryResource):Promise { + if (!isPersistedResource(query)) { + return this.create(query, 'New manually sorted query'); + } + return this.save(query); + } + public toggleStarred(query:QueryResource):Promise { const promise = this .apiV3Service diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-sort-by.service.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-sort-by.service.ts index b6ff24e7905..7b8c627900f 100644 --- a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-sort-by.service.ts +++ b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-sort-by.service.ts @@ -34,7 +34,6 @@ import { QueryResource } from 'core-app/features/hal/resources/query-resource'; import { IsolatedQuerySpace } from 'core-app/features/work-packages/directives/query-space/isolated-query-space'; import { States } from 'core-app/core/states/states.service'; import { QuerySortByResource } from 'core-app/features/hal/resources/query-sort-by-resource'; -import isPersistedResource from 'core-app/features/hal/helpers/is-persisted-resource'; import { PathHelperService } from 'core-app/core/path-helper/path-helper.service'; import { QueryColumn } from 'core-app/features/work-packages/components/wp-query/query-column'; import { WorkPackageQueryStateService } from './wp-view-base.service'; @@ -123,13 +122,8 @@ export class WorkPackageViewSortByService extends WorkPackageQueryStateService