Skip to content

Commit ea34ef4

Browse files
authored
Merge pull request #23729 from opf/code-maintenance/OP-19546-migrate-lodash-es
[OP-19546] Migrate lodash helpers to lodash-es
2 parents 149e69d + 8c2d9b0 commit ea34ef4

54 files changed

Lines changed: 127 additions & 58 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

frontend/package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@types/jquery": "^4.0.1",
2424
"@types/jquery-migrate": "^3.3.3",
2525
"@types/lodash": "^4.17.24",
26+
"@types/lodash-es": "^4.17.12",
2627
"@types/mousetrap": "^1.6.3",
2728
"@types/node": "^25.9.3",
2829
"@types/pako": "^2.0.4",
@@ -141,6 +142,7 @@
141142
"json5": "^2.2.2",
142143
"lit-html": "^3.3.3",
143144
"lodash": "^4.18.1",
145+
"lodash-es": "^4.17.21",
144146
"luxon": "^3.7.2",
145147
"mdx-embed": "^1.1.2",
146148
"mime": "^4.1.0",

frontend/src/app/core/apiv3/endpoints/relations/apiv3-relations-paths.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
// See COPYRIGHT and LICENSE files for more details.
2727
//++
2828

29+
import { chunk } from 'lodash-es';
2930
import { ApiV3GettableResource, ApiV3ResourceCollection } from 'core-app/core/apiv3/paths/apiv3-resource';
3031
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
3132
import { forkJoin, from, Observable } from 'rxjs';
@@ -53,7 +54,7 @@ export class ApiV3RelationsPaths extends ApiV3ResourceCollection<RelationResourc
5354

5455
public loadInvolved(workPackageIds:string[]):Observable<RelationResource[]> {
5556
if (workPackageIds.length > MAGIC_RELATION_SIZE) {
56-
const chunks = _.chunk(workPackageIds, MAGIC_RELATION_SIZE);
57+
const chunks = chunk(workPackageIds, MAGIC_RELATION_SIZE);
5758
return forkJoin(chunks.map((chunk) => this.loadInvolved(chunk)))
5859
.pipe(
5960
map((results) => _.flatten(results)),

frontend/src/app/core/apiv3/virtual/apiv3-boards-paths.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,16 @@ export class ApiV3BoardsPaths extends ApiV3Collection<Board, ApiV3BoardPath> {
111111
}
112112

113113
private createGrid(type:BoardType, name:string, scope:string, actionAttribute?:string):Observable<GridResource> {
114-
const payload:any = _.set({ name }, '_links.scope.href', scope);
115-
payload.options = {
116-
type,
114+
const payload:{
115+
name:string;
116+
_links:{ scope:{ href:string } };
117+
options:{ type:BoardType; attribute?:string };
118+
} = {
119+
name,
120+
_links: {
121+
scope: { href: scope },
122+
},
123+
options: { type },
117124
};
118125

119126
if (actionAttribute) {

frontend/src/app/core/state/resource-store.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import {
4848
ResourceState,
4949
setResourceLoading,
5050
} from 'core-app/core/state/resource-store';
51-
import { omit } from 'lodash';
51+
import { omit } from 'lodash-es';
5252
import {
5353
ApiV3ListParameters,
5454
listParamsString,

frontend/src/app/core/states/states.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { camelCase } from 'lodash-es';
12
import {
23
InputState,
34
multiInput,
@@ -74,7 +75,7 @@ export class States extends StatesGroup {
7475
}
7576

7677
forResource<T extends HalResource = HalResource>(resource:T):InputState<T>|undefined {
77-
const stateName = `${_.camelCase(resource._type)}s`;
78+
const stateName = `${camelCase(resource._type)}s`;
7879
const state = this.forType<T>(stateName);
7980

8081
return state && state.get(resource.id!);

frontend/src/app/features/boards/board/board-list/board-list.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { pickBy } from 'lodash-es';
12
import {
23
ChangeDetectionStrategy,
34
ChangeDetectorRef,
@@ -199,7 +200,7 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
199200
this.untilDestroyed(),
200201
)
201202
.subscribe((selectionState) => {
202-
const selected = Object.keys(_.pickBy(selectionState.selected, (option, _) => option === true));
203+
const selected = Object.keys(pickBy(selectionState.selected, (option, _) => option === true));
203204

204205
const focused = this.wpViewFocusService.focusedWorkPackage;
205206

frontend/src/app/features/hal/resources/hal-resource.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
// See COPYRIGHT and LICENSE files for more details.
2727
//++
2828

29+
import { merge } from 'lodash-es';
2930
import { InputState } from '@openproject/reactivestates';
3031
import { Injector } from '@angular/core';
3132
import { States } from 'core-app/core/states/states.service';
@@ -171,7 +172,7 @@ export class HalResource {
171172
public $copy<T extends HalResource = HalResource>(source:object = {}):T {
172173
const clone:HalResourceClass<T> = this.constructor as any;
173174

174-
return new clone(this.injector, _.merge(this.$plain(), source), this.$loaded, this.halInitializer, this.$halType);
175+
return new clone(this.injector, merge(this.$plain(), source), this.$loaded, this.halInitializer, this.$halType);
175176
}
176177

177178
public $plain():any {

frontend/src/app/features/hal/resources/query-filter-instance-schema-resource.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
// See COPYRIGHT and LICENSE files for more details.
2727
//++
2828

29+
import { merge } from 'lodash-es';
2930
import { CollectionResource } from 'core-app/features/hal/resources/collection-resource';
3031
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
3132
import { HalLink } from 'core-app/features/hal/hal-link/hal-link';
@@ -112,7 +113,7 @@ export class QueryFilterInstanceSchemaResource extends SchemaResource {
112113
const dependentSchema = this.dependency.forValue(operator.href!.toString());
113114
const resultingSchema = {};
114115

115-
_.merge(resultingSchema, staticSchema, dependentSchema);
116+
merge(resultingSchema, staticSchema, dependentSchema);
116117

117118
return new QueryFilterInstanceSchemaResource(this.injector, resultingSchema, true, this.halInitializer, 'QueryFilterInstanceSchema');
118119
}

frontend/src/app/features/hal/resources/work-package-resource.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
// See COPYRIGHT and LICENSE files for more details.
2727
//++
2828

29+
import { truncate } from 'lodash-es';
2930
import { InputState } from '@openproject/reactivestates';
3031
import { I18nService } from 'core-app/core/i18n/i18n.service';
3132
import { States } from 'core-app/core/states/states.service';
@@ -225,7 +226,7 @@ export class WorkPackageBaseResource extends HalResource {
225226
}
226227

227228
public truncatedSubject(length = 40):string {
228-
return length <= 0 ? this.subject : _.truncate(this.subject, { length: length });
229+
return length <= 0 ? this.subject : truncate(this.subject, { length: length });
229230
}
230231

231232
public get isLeaf():boolean {

0 commit comments

Comments
 (0)