Skip to content

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

Some eslint and rubocop optimizations (no change in functionality)

Henriette Darge6d3df992f371
diff --git a/frontend/src/app/core/current-user/current-user.query.ts b/frontend/src/app/core/current-user/current-user.query.ts
index ea6a66d5744..35673134f46 100644
--- a/frontend/src/app/core/current-user/current-user.query.ts
+++ b/frontend/src/app/core/current-user/current-user.query.ts
@@ -1,8 +1,12 @@
import { Injectable } from '@angular/core';
-import { filterNilValue, Query } from '@datorama/akita';
-import { Observable } from 'rxjs';
-import { CapabilityResource } from 'core-app/features/hal/resources/capability-resource';
-import { CurrentUserState, CurrentUserStore } from './current-user.store';
+import {
+ filterNilValue,
+ Query,
+} from '@datorama/akita';
+import {
+ CurrentUserState,
+ CurrentUserStore,
+} from './current-user.store';
@Injectable()
export class CurrentUserQuery extends Query<CurrentUserState> {
@@ -14,5 +18,5 @@ export class CurrentUserQuery extends Query<CurrentUserState> {
user$ = this.select(({ id, name, mail }) => ({ id, name, mail }));
- capabilities$ = this.select('capabilities').pipe(filterNilValue()) as Observable<CapabilityResource[]>;
+ capabilities$ = this.select('capabilities').pipe(filterNilValue());
}
diff --git a/frontend/src/app/features/invite-user-modal/invite-user.component.ts b/frontend/src/app/features/invite-user-modal/invite-user.component.ts
index be6076e0e9a..529c98766a2 100644
--- a/frontend/src/app/features/invite-user-modal/invite-user.component.ts
+++ b/frontend/src/app/features/invite-user-modal/invite-user.component.ts
@@ -63,7 +63,7 @@ export class InviteUserModalComponent extends OpModalComponent implements OnInit
public createdNewPrincipal = false;
- public get loading() {
+ public get loading():boolean {
return this.locals.projectId && !this.project;
}
@@ -105,7 +105,7 @@ export class InviteUserModalComponent extends OpModalComponent implements OnInit
return this.closeWithPrincipal();
}
- this.goTo(Steps.Role);
+ return this.goTo(Steps.Role);
}
onRoleSave(role:RoleResource):void {
diff --git a/frontend/src/app/features/invite-user-modal/project-selection/project-allowed.validator.ts b/frontend/src/app/features/invite-user-modal/project-selection/project-allowed.validator.ts
index 03f46d3d336..48426abeb85 100644
--- a/frontend/src/app/features/invite-user-modal/project-selection/project-allowed.validator.ts
+++ b/frontend/src/app/features/invite-user-modal/project-selection/project-allowed.validator.ts
@@ -1,19 +1,21 @@
import { AbstractControl } from '@angular/forms';
-import { of } from 'rxjs';
+import {
+ Observable,
+ of,
+} from 'rxjs';
import { catchError, map, take } from 'rxjs/operators';
import { CurrentUserService } from 'core-app/core/current-user/current-user.service';
import idFromLink from 'core-app/features/hal/helpers/id-from-link';
-export const ProjectAllowedValidator = (currentUserService:CurrentUserService) =>
- (control:AbstractControl) => {
- const href = control.value?.href || control.value?.$links?.self.href;
- const id = href ? idFromLink(href) : control.value;
- return currentUserService.hasCapabilities$(
- 'memberships/create',
- id,
- ).pipe(
- take(1),
- map((isAllowed) => (isAllowed ? null : { lackingPermission: true })),
- catchError(() => of(null)),
- );
-}
+export const ProjectAllowedValidator = (currentUserService:CurrentUserService) => (control:AbstractControl):Observable<null|{ lackingPermission:boolean }> => {
+ const href = control.value?.href || control.value?.$links?.self.href;
+ const id = href ? idFromLink(href) : control.value;
+ return currentUserService.hasCapabilities$(
+ 'memberships/create',
+ id,
+ ).pipe(
+ take(1),
+ map((isAllowed) => (isAllowed ? null : { lackingPermission: true })),
+ catchError(() => of(null)),
+ );
+};
diff --git a/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts b/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts
index 1a33b7f10a3..7d4a6c10efc 100644
--- a/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts
+++ b/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts
@@ -7,6 +7,7 @@ import {
ElementRef,
} from '@angular/core';
import {
+ AbstractControl,
FormControl,
FormGroup,
Validators,
@@ -71,11 +72,11 @@ export class ProjectSelectionComponent implements OnInit {
project: new FormControl(null, [Validators.required], ProjectAllowedValidator(this.currentUserService)),
});
- get typeControl() {
+ get typeControl():AbstractControl {
return this.projectAndTypeForm.get('type')!;
}
- get projectControl() {
+ get projectControl():AbstractControl {
return this.projectAndTypeForm.get('project')!;
}
@@ -89,7 +90,7 @@ export class ProjectSelectionComponent implements OnInit {
readonly currentUserService:CurrentUserService,
) {}
- ngOnInit() {
+ ngOnInit():void {
this.typeControl.setValue(this.type);
if (this.project) {
diff --git a/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.ts b/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.ts
index 8a23b0a8424..0bf621171b9 100644
--- a/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.ts
+++ b/frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.ts
@@ -26,7 +26,12 @@
// See COPYRIGHT and LICENSE files for more details.
//++
-import { ChangeDetectionStrategy, Component, Input, Output } from '@angular/core';
+import {
+ ChangeDetectionStrategy,
+ Component,
+ Input,
+ Output,
+} from '@angular/core';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
import { DebouncedEventEmitter } from 'core-app/shared/helpers/rxjs/debounced-event-emitter';
@@ -35,7 +40,6 @@ import { componentDestroyed } from '@w11k/ngx-componentdestroyed';
import { QueryFilterInstanceResource } from 'core-app/features/hal/resources/query-filter-instance-resource';
import { IProjectAutocompleteItem } from 'core-app/shared/components/autocompleter/project-autocompleter/project-autocomplete-item';
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
-import { ID } from '@datorama/akita';
@Component({
selector: 'op-filter-project',
diff --git a/frontend/src/app/shared/components/autocompleter/project-autocompleter/insert-in-list.ts b/frontend/src/app/shared/components/autocompleter/project-autocompleter/insert-in-list.ts
index f3579617140..04400a7e4eb 100644
--- a/frontend/src/app/shared/components/autocompleter/project-autocompleter/insert-in-list.ts
+++ b/frontend/src/app/shared/components/autocompleter/project-autocompleter/insert-in-list.ts
@@ -40,7 +40,7 @@ const insertProjectWithAncestors = (
children: insertProjectWithAncestors([], project, ancestors.slice(1)),
},
];
-}
+};
export const buildTree = (
projects:IProjectAutocompleteItem[],
@@ -51,4 +51,3 @@ export const buildTree = (
(tree, project) => insertProjectWithAncestors(tree, project, project.ancestors),
[],
);
-
diff --git a/modules/reporting/lib/widget/filters/project.rb b/modules/reporting/lib/widget/filters/project.rb
index b449d35afb9..94232adfa19 100644
--- a/modules/reporting/lib/widget/filters/project.rb
+++ b/modules/reporting/lib/widget/filters/project.rb
@@ -31,32 +31,16 @@ class Widget::Filters::Project < Widget::Filters::Base
def render
write(content_tag(:div, id: "#{filter_class.underscore_name}_arg_1", class: 'advanced-filters--filter-value') do
- label = label_tag "#{filter_class.underscore_name}_arg_1_val",
- "#{h(filter_class.label)} #{I18n.t(:label_filter_value)}",
- class: 'hidden-for-sighted'
+ label = html_label
+ selected_values = map_filter_values
- selected_values = filter.values.each.map do |id|
- # When live testing, these IDs came out as integers.
- # However, when running the specs, they came out as strings.
- int_id = Integer(id)
- available_value = filter_class.available_values.detect { |val| Integer(val[1]) === int_id }
-
- if available_value != nil
- {
- id: int_id,
- name: available_value[0]
- }
- else
- nil
- end
- end
box = angular_component_tag 'op-project-autocompleter',
inputs: {
apiFilters: [],
name: "values[#{filter_class.underscore_name}][]",
multiple: true,
- value: selected_values.filter { |item| item != nil }
+ value: selected_values.filter { |item| !item.nil? }
},
id: "#{filter_class.underscore_name}_select_1",
class: 'filter-value'
@@ -66,4 +50,30 @@ class Widget::Filters::Project < Widget::Filters::Base
end
end)
end
+
+ private
+
+ def html_label
+ label_tag "#{filter_class.underscore_name}_arg_1_val",
+ "#{h(filter_class.label)} #{I18n.t(:label_filter_value)}",
+ class: 'hidden-for-sighted'
+ end
+
+ def map_filter_values
+ filter.values.each.map do |id|
+ # When live testing, these IDs came out as integers.
+ # However, when running the specs, they came out as strings.
+ int_id = Integer(id)
+ available_value = filter_class.available_values.detect { |val| Integer(val[1]) === int_id }
+
+ if available_value.nil?
+ nil
+ else
+ {
+ id: int_id,
+ name: available_value[0]
+ }
+ end
+ end
+ end
end