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
Remove duplicate method idFromHref from the UrlParamsHelperService and use idFromLink instead.
Dombi Attilac3ee40c58488
diff --git a/frontend/src/app/features/hal/helpers/id-from-link.ts b/frontend/src/app/features/hal/helpers/id-from-link.tsindex a96a5f62305..c92e89fcfa8 100644--- a/frontend/src/app/features/hal/helpers/id-from-link.ts+++ b/frontend/src/app/features/hal/helpers/id-from-link.ts@@ -1,4 +1,4 @@export default function idFromLink(href:string|null):string {- const idPart = (href || '').split('/').pop()!;+ const idPart = (href || '').split('/').pop()!.split('?')[0];return decodeURIComponent(idPart);}diff --git a/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.spec.ts b/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.spec.tsindex 749337eb70b..ec2d09e8069 100644--- a/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.spec.ts+++ b/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.spec.ts@@ -113,7 +113,7 @@ describe('UrlParamsHelper', () => {it('should encode query to params JSON', () => {const encodedJSON = UrlParamsHelper.encodeQueryJsonParams(query, additional);- const expectedJSON = '{"c":["type","status","soße"],"hi":true,"g":"status","s":true,"tv":true,"tzl":"days","hl":"inline","hla":["a","b"],"t":"type:desc","f":[{"n":"soße","o":"=","v":["knoblauch"]},{"n":"created_at","o":"<t-","v":["5"]}],"pa":10,"pp":100}'+ const expectedJSON = '{"c":["type","status","soße"],"hi":true,"g":"status","s":true,"tv":true,"tzl":"days","hl":"inline","hla":["a","b"],"t":"type:desc","f":[{"n":"soße","o":"=","v":["knoblauch"]},{"n":"created_at","o":"<t-","v":["5"]}],"pa":10,"pp":100}';expect(encodedJSON).toEqual(expectedJSON);});diff --git a/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.ts b/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.tsindex 5d23464f5ed..0f1d0c53d55 100644--- a/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.ts+++ b/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.ts@@ -159,7 +159,7 @@ export class UrlParamsHelperService {private encodeHighlightedAttributes(query:QueryResource):Partial<QueryProps> {if (query.highlightingMode === 'inline') {if (Array.isArray(query.highlightedAttributes) && query.highlightedAttributes.length > 0) {- return { hla: query.highlightedAttributes.map((el) => this.idFromHref(el.href as string)) };+ return { hla: query.highlightedAttributes.map((el) => idFromLink(el.href)) };}}@@ -362,11 +362,7 @@ export class UrlParamsHelperService {return query.columns.map((column:any) => column.id || idFromLink(column.href));}if (query._links.columns) {- return query._links.columns.map((column:HalLink) => {- const id = column.href!;-- return this.idFromHref(id);- });+ return query._links.columns.map((column:HalLink) => idFromLink(column.href as string));}}@@ -397,7 +393,7 @@ export class UrlParamsHelperService {filters.forEach((filter:QueryFilterInstanceResource) => {const id = this.buildV3GetFilterIdFromFilter(filter);const operator = this.buildV3GetOperatorIdFromFilter(filter) as FilterOperator;- const values = this.buildV3GetValuesFromFilter(filter)+ const values = this.buildV3GetValuesFromFilter(filter);builder.add(id, operator, values);});@@ -412,14 +408,14 @@ export class UrlParamsHelperService {public buildV3GetFilterIdFromFilter(filter:QueryFilterInstanceResource) {const href = filter.filter ? filter.filter.href : filter._links.filter.href;- return this.idFromHref(href);+ return idFromLink(href as string);}public buildV3GetValuesFromFilter(filter:QueryFilterInstanceResource|QueryFilterResource) {if (filter.values) {return _.map(filter.values, (v:any) => this.queryFilterValueToParam(v));}- return _.map(filter._links.values, (v:any) => this.idFromHref(v.href));+ return _.map(filter._links.values, (v:any) => idFromLink(v.href as string));}private buildV3GetOperatorIdFromFilter(filter:QueryFilterInstanceResource) {@@ -428,7 +424,7 @@ export class UrlParamsHelperService {}const { href } = filter._links.operator;- return this.idFromHref(href);+ return idFromLink(href as string);}private buildV3GetSortByFromQuery(query:QueryResource) {@@ -437,19 +433,9 @@ export class UrlParamsHelperService {if (sort.id) {return sort.id;}- const href = sort.href!;-- const id = this.idFromHref(href);-- return id;+ return idFromLink(sort.href);});return JSON.stringify(sortByIds.map((id:string) => id.split('-')));}-- private idFromHref(href:string) {- const id = href.substring(href.lastIndexOf('/') + 1, href.length);-- return decodeURIComponent(id);- }}