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

Linting

Oliver Günther3a5645b74cff
diff --git a/frontend/src/app/core/schemas/schema-cache.service.ts b/frontend/src/app/core/schemas/schema-cache.service.ts
index 3a422a83455..aff84933cca 100644
--- a/frontend/src/app/core/schemas/schema-cache.service.ts
+++ b/frontend/src/app/core/schemas/schema-cache.service.ts
@@ -83,7 +83,7 @@ export class SchemaCacheService extends StateCacheService<SchemaResource> {
* @param resource The resource with a schema property or a string to the schema href.
* @return A promise with the loaded schema.
*/
- ensureLoaded(resource:HalResource|string):Promise<SchemaResource> {
+ ensureLoaded<T = SchemaResource>(resource:HalResource|string):Promise<T> {
const href = resource instanceof HalResource ? this.getSchemaHref(resource) : resource;
return this
@@ -91,7 +91,7 @@ export class SchemaCacheService extends StateCacheService<SchemaResource> {
.pipe(
take(1),
)
- .toPromise();
+ .toPromise() as unknown as Promise<T>;
}
/**
diff --git a/frontend/src/app/features/calendar/te-calendar/te-calendar.component.sass b/frontend/src/app/features/calendar/te-calendar/te-calendar.component.sass
index 992fdeeca9a..fb49f0e7adf 100644
--- a/frontend/src/app/features/calendar/te-calendar/te-calendar.component.sass
+++ b/frontend/src/app/features/calendar/te-calendar/te-calendar.component.sass
@@ -1,6 +1,6 @@
@import '../../app/spot/styles/sass/variables'
-te-calendar
+op-time-entries-calendar
// The two media queries below make sure the "Log time" button does not overlap
// with the dates on mobile. Instead, it will be shown above the full calendar toolbar.
// The media queries are the normal mobile/tablet breakpoints.
diff --git a/frontend/src/app/features/calendar/te-calendar/te-calendar.component.ts b/frontend/src/app/features/calendar/te-calendar/te-calendar.component.ts
index 804454681b4..c829109ed28 100644
--- a/frontend/src/app/features/calendar/te-calendar/te-calendar.component.ts
+++ b/frontend/src/app/features/calendar/te-calendar/te-calendar.component.ts
@@ -43,6 +43,18 @@ import { HalResourceNotificationService } from 'core-app/features/hal/services/h
import idFromLink from 'core-app/features/hal/helpers/id-from-link';
import { OpCalendarService } from 'core-app/features/calendar/op-calendar.service';
import { SchemaResource } from 'core-app/features/hal/resources/schema-resource';
+import { IFieldSchema } from 'core-app/shared/components/fields/field.base';
+import { VerboseFormattingArg } from '@fullcalendar/common';
+import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
+
+interface TimeEntrySchema extends SchemaResource {
+ activity:IFieldSchema;
+ workPackage:IFieldSchema;
+ project:IFieldSchema;
+ hours:IFieldSchema;
+ user:IFieldSchema;
+ comment:IFieldSchema;
+}
interface CalendarViewEvent {
el:HTMLElement;
@@ -69,7 +81,7 @@ const ADD_ENTRY_PROHIBITED_CLASS_NAME = '-prohibited';
@Component({
templateUrl: './te-calendar.template.html',
styleUrls: ['./te-calendar.component.sass'],
- selector: 'te-calendar',
+ selector: 'op-time-entries-calendar',
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
@@ -101,14 +113,10 @@ export class TimeEntryCalendarComponent {
public scaleRatio = 1;
- public calendarEvents:Function;
-
protected memoizedTimeEntries:{ start:Date, end:Date, entries:Promise<CollectionResource<TimeEntryResource>> };
public memoizedCreateAllowed = false;
- public hiddenDays:number[] = [];
-
public text = {
logTime: this.i18n.t('js.button_log_time'),
today: this.i18n.t('js.team_planner.today'),
@@ -131,17 +139,22 @@ export class TimeEntryCalendarComponent {
contentHeight: 550,
slotEventOverlap: false,
slotLabelInterval: `${this.labelIntervalHours}:00:00`,
- slotLabelFormat: (info:any) => ((this.maxHour - info.date.hour) / this.scaleRatio).toString(),
+ slotLabelFormat: (info:VerboseFormattingArg) => ((this.maxHour - info.date.hour) / this.scaleRatio).toString(),
allDaySlot: false,
displayEventTime: false,
slotMinTime: `${this.minHour - 1}:00:00`,
slotMaxTime: `${this.maxHour}:00:00`,
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
events: this.calendarEventsFunction.bind(this),
- eventOverlap: (stillEvent:any) => !stillEvent.classNames.includes(TIME_ENTRY_CLASS_NAME),
+ eventOverlap: (stillEvent:EventApi) => !stillEvent.classNames.includes(TIME_ENTRY_CLASS_NAME),
plugins: [timeGrid, interactionPlugin],
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
eventDidMount: this.alterEventEntry.bind(this),
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
eventWillUnmount: this.beforeEventRemove.bind(this),
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
eventClick: this.dispatchEventClick.bind(this),
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
eventDrop: this.moveEvent.bind(this),
dayHeaderClassNames: (data:DayHeaderMountArg) => this.calendar.applyNonWorkingDay(data),
dayCellClassNames: (data:DayCellMountArg) => this.calendar.applyNonWorkingDay(data),
@@ -166,15 +179,18 @@ export class TimeEntryCalendarComponent {
private calendar:OpCalendarService,
) {}
- public calendarEventsFunction(fetchInfo:{ start:Date, end:Date },
+ public calendarEventsFunction(
+ fetchInfo:{ start:Date, end:Date },
successCallback:(events:EventInput[]) => void,
- failureCallback:(error:unknown) => void):void|PromiseLike<EventInput[]> {
- this.fetchTimeEntries(fetchInfo.start, fetchInfo.end)
+ failureCallback:(error:unknown) => void,
+ ):void|PromiseLike<EventInput[]> {
+ void this.fetchTimeEntries(fetchInfo.start, fetchInfo.end)
.then((collection) => {
this.entries.emit(collection);
successCallback(this.buildEntries(collection.elements, fetchInfo));
- });
+ })
+ .catch(failureCallback);
}
protected fetchTimeEntries(start:Date, end:Date):Promise<CollectionResource<TimeEntryResource>> {
@@ -223,7 +239,7 @@ export class TimeEntryCalendarComponent {
// We already set the same function (different object) via angular.
// But it will trigger repainting the calendar.
// Weirdly, this.ucCalendar.getApi().rerender() does not.
- this.ucCalendar.getApi().setOption('slotLabelFormat', (info:any) => {
+ this.ucCalendar.getApi().setOption('slotLabelFormat', (info:VerboseFormattingArg) => {
const val = (this.maxHour - info.date.hour) / this.scaleRatio;
return val.toString();
});
@@ -237,19 +253,20 @@ export class TimeEntryCalendarComponent {
let start:Moment;
let end:Moment;
const hours = this.timezone.toHours(entry.hours) * this.scaleRatio;
+ const spentOn = entry.spentOn as string;
- if (hoursDistribution[entry.spentOn]) {
- start = hoursDistribution[entry.spentOn].clone().subtract(hours, 'h');
- end = hoursDistribution[entry.spentOn].clone();
+ if (hoursDistribution[spentOn]) {
+ start = hoursDistribution[spentOn].clone().subtract(hours, 'h');
+ end = hoursDistribution[spentOn].clone();
} else {
- start = moment(entry.spentOn).add(this.maxHour - hours, 'h');
- end = moment(entry.spentOn).add(this.maxHour, 'h');
+ start = moment(spentOn).add(this.maxHour - hours, 'h');
+ end = moment(spentOn).add(this.maxHour, 'h');
}
- hoursDistribution[entry.spentOn] = start;
+ hoursDistribution[spentOn] = start;
return this.timeEntry(entry, hours, start, end);
- }) as EventInput[];
+ });
}
private buildAuxEntries(entries:TimeEntryResource[], fetchInfo:{ start:Date, end:Date }):EventInput[] {
@@ -270,23 +287,24 @@ export class TimeEntryCalendarComponent {
return calendarEntries;
}
- private calculateDateSums(entries:TimeEntryResource[]):{ [p: string]: number } {
+ private calculateDateSums(entries:TimeEntryResource[]):{ [p:string]:number } {
const dateSums:{ [key:string]:number } = {};
entries.forEach((entry) => {
const hours = this.timezone.toHours(entry.hours);
+ const spentOn = entry.spentOn as string;
- if (dateSums[entry.spentOn]) {
- dateSums[entry.spentOn] += hours;
+ if (dateSums[spentOn]) {
+ dateSums[spentOn] += hours;
} else {
- dateSums[entry.spentOn] = hours;
+ dateSums[spentOn] = hours;
}
});
return dateSums;
}
- protected timeEntry(entry:TimeEntryResource, hours:number, start:Moment, end:Moment) {
+ protected timeEntry(entry:TimeEntryResource, hours:number, start:Moment, end:Moment):EventInput {
const color = this.colors.toHsl(this.entryName(entry));
const classNames = [TIME_ENTRY_CLASS_NAME];
@@ -309,18 +327,19 @@ export class TimeEntryCalendarComponent {
};
}
- protected sumEntry(date:Moment, duration:number) {
+ protected sumEntry(date:Moment, duration:number):EventInput {
return {
start: date.clone().add(this.maxHour - Math.min(duration * this.scaleRatio, this.maxHour - 0.5) - 0.5, 'h').format(),
end: date.clone().add(this.maxHour - Math.min(((duration + 0.05) * this.scaleRatio), this.maxHour - 0.5), 'h').format(),
classNames: DAY_SUM_CLASS_NAME,
rendering: 'background' as const,
startEditable: false,
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
sum: this.i18n.t('js.units.hour', { count: this.formatNumber(duration) }),
};
}
- protected addEntry(date:Moment, duration:number) {
+ protected addEntry(date:Moment, duration:number):EventInput {
const classNames = [ADD_ENTRY_CLASS_NAME];
if (duration >= 24) {
@@ -346,7 +365,7 @@ export class TimeEntryCalendarComponent {
if (event.event.extendedProps.entry) {
this.editEvent(event.event.extendedProps.entry);
} else if (event.el.classList.contains(ADD_ENTRY_CLASS_NAME) && !event.el.classList.contains(ADD_ENTRY_PROHIBITED_CLASS_NAME)) {
- this.addEvent(moment(event.event.start!));
+ this.addEvent(moment(event.event.start));
}
}
@@ -363,13 +382,13 @@ export class TimeEntryCalendarComponent {
}
private moveEvent(event:CalendarMoveEvent):void {
- const { entry } = event.event.extendedProps;
+ const entry = event.event.extendedProps.entry as TimeEntryResource;
// Use end instead of start as when dragging, the event might be too long and would thus be start
// on the day before by fullcalendar.
- entry.spentOn = moment(event.event.end!).format('YYYY-MM-DD');
+ entry.spentOn = moment(event.event.end).format('YYYY-MM-DD');
- this
+ void this
.schemaCache
.ensureLoaded(entry)
.then((schema) => {
@@ -379,7 +398,7 @@ export class TimeEntryCalendarComponent {
.id(entry)
.patch(entry, schema)
.subscribe(
- (event) => this.updateEventSet(event, 'update'),
+ (updated) => this.updateEventSet(updated, 'update'),
(e) => {
this.notifications.handleRawError(e);
event.revert();
@@ -409,7 +428,7 @@ export class TimeEntryCalendarComponent {
}
private updateEventSet(event:TimeEntryResource, action:'update'|'destroy'|'create'):void {
- this.memoizedTimeEntries.entries.then((collection) => {
+ void this.memoizedTimeEntries.entries.then((collection) => {
const foundIndex = collection.elements.findIndex((x) => x.id === event.id);
switch (action) {
@@ -420,7 +439,7 @@ export class TimeEntryCalendarComponent {
collection.elements.splice(foundIndex, 1);
break;
case 'create':
- this
+ void this
.apiV3Service
.time_entries
.cache
@@ -428,6 +447,8 @@ export class TimeEntryCalendarComponent {
collection.elements.push(event);
break;
+ default:
+ throw new Error('Invalid action');
}
this.ucCalendar.getApi().refetchEvents();
@@ -442,7 +463,7 @@ export class TimeEntryCalendarComponent {
return;
}
- this.addTooltip(event);
+ void this.addTooltip(event);
this.prependDuration(event);
this.appendFadeout(event);
}
@@ -460,7 +481,7 @@ export class TimeEntryCalendarComponent {
private appendSum(event:CalendarViewEvent):void {
if (event.event.extendedProps.sum) {
- event.el.innerHTML = event.event.extendedProps.sum;
+ event.el.innerHTML = event.event.extendedProps.sum as string;
}
}
@@ -471,7 +492,7 @@ export class TimeEntryCalendarComponent {
const { entry } = event.event.extendedProps;
- const schema = await this.schemaCache.ensureLoaded(entry);
+ const schema:TimeEntrySchema = await this.schemaCache.ensureLoaded(entry);
jQuery(event.el).tooltip({
content: this.tooltipContentString(event.event.extendedProps.entry, schema),
@@ -488,7 +509,7 @@ export class TimeEntryCalendarComponent {
}
private prependDuration(event:CalendarViewEvent):void {
- const timeEntry = event.event.extendedProps.entry;
+ const timeEntry = event.event.extendedProps.entry as TimeEntryResource;
if (this.timezone.toHours(timeEntry.hours) < 0.5) {
return;
@@ -511,7 +532,7 @@ export class TimeEntryCalendarComponent {
* need to deactivate the fc-fadeout.
*/
private appendFadeout(event:CalendarViewEvent):void {
- const timeEntry = event.event.extendedProps.entry;
+ const timeEntry = event.event.extendedProps.entry as TimeEntryResource;
if (this.timezone.toHours(timeEntry.hours) < 0.5) {
return;
@@ -551,10 +572,11 @@ export class TimeEntryCalendarComponent {
}
private workPackageName(entry:TimeEntryResource):string {
- return `#${idFromLink(entry.workPackage.href)}: ${entry.workPackage.name}`;
+ const workPackage = entry.workPackage as WorkPackageResource;
+ return `#${idFromLink(workPackage.href)}: ${workPackage.name}`;
}
- private tooltipContentString(entry:TimeEntryResource, schema:SchemaResource):string {
+ private tooltipContentString(entry:TimeEntryResource, schema:TimeEntrySchema):string {
return `
<ul class="tooltip--map">
<li class="tooltip--map--item">
@@ -580,8 +602,8 @@ export class TimeEntryCalendarComponent {
`;
}
- private sanitizedValue(value:string):string|null {
- return this.sanitizer.sanitize(SecurityContext.HTML, value);
+ private sanitizedValue(value:string):string {
+ return this.sanitizer.sanitize(SecurityContext.HTML, value) || '';
}
protected formatNumber(value:number):string {
diff --git a/frontend/src/app/features/hal/resources/time-entry-resource.ts b/frontend/src/app/features/hal/resources/time-entry-resource.ts
index eff332e41b4..9db075ba87e 100644
--- a/frontend/src/app/features/hal/resources/time-entry-resource.ts
+++ b/frontend/src/app/features/hal/resources/time-entry-resource.ts
@@ -27,8 +27,16 @@
//++
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
+import { ProjectResource } from 'core-app/features/hal/resources/project-resource';
+import Formattable = api.v3.Formattable;
export class TimeEntryResource extends HalResource {
+ project:ProjectResource;
+
+ activity:HalResource;
+
+ comment:Formattable;
+
public get state() {
return this.states.timeEntries.get(this.id!) as any;
}
diff --git a/frontend/src/app/shared/components/autocompleter/members-autocompleter/members-autocompleter.component.ts b/frontend/src/app/shared/components/autocompleter/members-autocompleter/members-autocompleter.component.ts
index 403f7ab3388..6493e82b330 100644
--- a/frontend/src/app/shared/components/autocompleter/members-autocompleter/members-autocompleter.component.ts
+++ b/frontend/src/app/shared/components/autocompleter/members-autocompleter/members-autocompleter.component.ts
@@ -20,7 +20,7 @@ export class MembersAutocompleterComponent extends UserAutocompleterComponent {
@InjectField() pathHelper:PathHelperService;
- public getAvailableUsers(searchTerm:any):Observable<IUserAutocompleteItem[]> {
+ public getAvailableUsers(searchTerm:string):Observable<IUserAutocompleteItem[]> {
return this.http
.get<IUserAutocompleteItem[]>(this.url,
{
diff --git a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.html b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.html
index 5805f6976a0..44b3770143e 100644
--- a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.html
+++ b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.html
@@ -52,8 +52,8 @@
[keyDownFn]="keyDownFn"
(change)="changed($event)"
- (open)="opened($event)"
- (close)="closed($event)"
+ (open)="opened()"
+ (close)="closed()"
(blur)="blured($event)"
(focus)="focused($event)"
(clear)="cleared($event)"
diff --git a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.ts b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.ts
index 5ff51fc49e2..170337183ef 100644
--- a/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.ts
+++ b/frontend/src/app/shared/components/autocompleter/op-autocompleter/op-autocompleter.component.ts
@@ -278,15 +278,16 @@ export class OpAutocompleterComponent extends UntilDestroyedMixin implements OnI
if (this.ngSelectInstance) {
setTimeout(() => {
this.cdRef.detectChanges();
- const component = (this.ngSelectInstance) as any;
+ const component = this.ngSelectInstance;
if (component && component.dropdownPanel) {
- component.dropdownPanel._updatePosition();
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-member-access,no-underscore-dangle
+ (component.dropdownPanel as any)._updatePosition();
}
}, 25);
}
}
- public opened(_:unknown) { // eslint-disable-line no-unused-vars
+ public opened():void { // eslint-disable-line no-unused-vars
// Re-search for empty value as search value gets removed
this.typeahead?.next('');
this.repositionDropdown();
@@ -297,15 +298,15 @@ export class OpAutocompleterComponent extends UntilDestroyedMixin implements OnI
return of((this.items as IOPAutocompleterOption[])?.filter((element) => element.name.includes(searchKey)));
}
- public closeSelect() {
- this.ngSelectInstance && this.ngSelectInstance.close();
+ public closeSelect():void {
+ this.ngSelectInstance?.close();
}
- public openSelect() {
- this.ngSelectInstance && this.ngSelectInstance.open();
+ public openSelect():void {
+ this.ngSelectInstance?.open();
}
- public focusSelect() {
+ public focusSelect():void {
this.ngZone.runOutsideAngular(() => {
setTimeout(() => {
this.ngSelectInstance.focus();
@@ -313,51 +314,51 @@ export class OpAutocompleterComponent extends UntilDestroyedMixin implements OnI
});
}
- public closed(_:unknown) { // eslint-disable-line no-unused-vars
+ public closed():void {
this.close.emit();
}
- public changed(val:any) {
+ public changed(val:unknown):void {
this.change.emit(val);
}
- public searched(val:any) {
+ public searched(val:{ term:string, items:unknown[] }):void {
this.search.emit(val);
}
- public blured(val:any) {
+ public blured(val:unknown):void {
this.blur.emit(val);
}
- public focused(val:any) {
+ public focused(val:unknown):void {
this.focus.emit(val);
}
- public cleared(val:any) {
+ public cleared(val:unknown):void {
this.clear.emit(val);
}
- public keydowned(val:any) {
+ public keydowned(val:unknown):void {
this.keydown.emit(val);
}
- public added(val:any) {
+ public added(val:unknown):void {
this.add.emit(val);
}
- public removed(val:any) {
+ public removed(val:unknown):void {
this.remove.emit(val);
}
- public scrolled(val:any) {
+ public scrolled(val:{ start:number; end:number }):void {
this.scroll.emit(val);
}
- public scrolledToEnd(val:any) {
+ public scrolledToEnd(val:unknown):void {
this.scrollToEnd.emit(val);
}
- public highlighting(property:string, id:string) {
+ public highlighting(property:string, id:string):string {
return Highlighting.inlineClass(property, id);
}
diff --git a/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter.component.ts b/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter.component.ts
index bffb702cf45..272def6d0f0 100644
--- a/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter.component.ts
+++ b/frontend/src/app/shared/components/autocompleter/user-autocompleter/user-autocompleter.component.ts
@@ -60,10 +60,11 @@ import {
} from '@angular/forms';
import { ID } from '@datorama/akita';
import { addFiltersToPath } from 'core-app/core/apiv3/helpers/add-filters-to-path';
-import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';
import { OpInviteUserModalService } from 'core-app/features/invite-user-modal/invite-user-modal.service';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
+import { CollectionResource } from 'core-app/features/hal/resources/collection-resource';
+import { UserResource } from 'core-app/features/hal/resources/user-resource';
export const usersAutocompleterSelector = 'op-user-autocompleter';
@@ -90,7 +91,7 @@ export interface IUserAutocompleteItem {
],
})
export class UserAutocompleterComponent extends UntilDestroyedMixin implements OnInit, ControlValueAccessor {
- userTracker = (item:any) => item.href || item.id;
+ userTracker = (item:{ href?:string, id:string }):string => item.href || item.id;
@ViewChild(NgSelectComponent, { static: true }) public ngSelectComponent:NgSelectComponent;
@@ -105,8 +106,6 @@ export class UserAutocompleterComponent extends UntilDestroyedMixin implements O
// <label> tags that have `for=""` set
@Input() public labelForId = '';
- @Input() public allowEmpty = false;
-
@Input() public appendTo = '';
@Input() public multiple = false;
@@ -115,6 +114,7 @@ export class UserAutocompleterComponent extends UntilDestroyedMixin implements O
@Input() public focusDirectly = false;
+ // eslint-disable-next-line @angular-eslint/no-input-rename
@Input('value') public _value:IUserAutocompleteItem|IUserAutocompleteItem[]|null = null;
@Input() public inviteUserToProject:string|undefined;
@@ -145,9 +145,9 @@ export class UserAutocompleterComponent extends UntilDestroyedMixin implements O
@Output() cancel = new EventEmitter();
- @Output() public onAddNew = new EventEmitter<HalResource>();
+ @Output() public userInvited = new EventEmitter<HalResource>();
- @ViewChild('hiddenInput') hiddenInput:ElementRef;
+ @ViewChild('hiddenInput') hiddenInput:ElementRef<HTMLElement>;
constructor(
public elementRef:ElementRef,
@@ -163,7 +163,8 @@ export class UserAutocompleterComponent extends UntilDestroyedMixin implements O
populateInputsFromDataset(this);
}
- ngOnInit() {
+ ngOnInit():void {
+ // eslint-disable-next-line @typescript-eslint/no-shadow
this.additionalFilters.forEach((filter) => this.inputFilters.add(filter.selector, filter.operator, filter.values));
this.opInviteUserModalService.close
@@ -172,35 +173,28 @@ export class UserAutocompleterComponent extends UntilDestroyedMixin implements O
filter((user) => !!user),
)
.subscribe((user:HalResource) => {
- this.onAddNew.emit(user);
+ this.userInvited.emit(user);
});
}
- public getAvailableUsers(searchTerm:any):Observable<IUserAutocompleteItem[]> {
+ public getAvailableUsers(searchTerm?:string):Observable<IUserAutocompleteItem[]> {
// Need to clone the filters to not add additional filters on every
// search term being processed.
const searchFilters = this.inputFilters.clone();
- if (searchTerm && searchTerm.length) {
+ if (searchTerm?.length) {
searchFilters.add('name', '~', [searchTerm]);
}
const filteredURL = addFiltersToPath(this.url, searchFilters);
- return this.halResourceService
- .get(filteredURL.toString())
+ return this
+ .halResourceService
+ .get<CollectionResource<UserResource>>(filteredURL.toString())
.pipe(
- map((res) => {
- const options = res.elements.map((el:any) => ({
- name: el.name, id: el.id, href: el.href, avatar: el.avatar,
- }));
-
- if (this.allowEmpty) {
- options.unshift({ name: this.I18n.t('js.timelines.filter.noneSelection'), href: null, id: null });
- }
-
- return options;
- }),
+ map((res) => res.elements.map((el) => ({
+ name: el.name, id: el.id, href: el.href, avatar: el.avatar,
+ })) as IUserAutocompleteItem[]),
);
}
@@ -208,8 +202,10 @@ export class UserAutocompleterComponent extends UntilDestroyedMixin implements O
this.value = value;
}
+ // eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars
onChange = (_:IUserAutocompleteItem|IUserAutocompleteItem[]|null):void => {};
+ // eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars
onTouched = (_:IUserAutocompleteItem|IUserAutocompleteItem[]|null):void => {};
registerOnChange(fn:(_:IUserAutocompleteItem|IUserAutocompleteItem[]|null) => void):void {
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/user-edit-field.component.html b/frontend/src/app/shared/components/fields/edit/field-types/user-edit-field.component.html
index 20c1e6495b0..2dabe748eec 100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/user-edit-field.component.html
+++ b/frontend/src/app/shared/components/fields/edit/field-types/user-edit-field.component.html
@@ -10,5 +10,5 @@
[value]="value"
(valueChange)="onModelChange($event)"
(cancel)="handler.handleUserCancel()"
- (onAddNew)="onModelChange($event)"
+ (userInvited)="onModelChange($event)"
></op-user-autocompleter>
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/user-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/user-edit-field.component.ts
index 9405aeb237d..a7da3dda759 100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/user-edit-field.component.ts
+++ b/frontend/src/app/shared/components/fields/edit/field-types/user-edit-field.component.ts
@@ -36,7 +36,6 @@ import {
OnInit,
} from '@angular/core';
import { HttpClient } from '@angular/common/http';
-import { from } from 'rxjs';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import {
EditFieldComponent,
@@ -51,17 +50,9 @@ import { ResourceChangeset } from '../../changeset/resource-changeset';
import { IFieldSchema } from '../../field.base';
import { EditFieldHandler } from '../editing-portal/edit-field-handler';
import { HalResourceService } from 'core-app/features/hal/services/hal-resource.service';
-import {
- take,
- tap,
-} from 'rxjs/operators';
import isNewResource from 'core-app/features/hal/helpers/is-new-resource';
-import idFromLink from 'core-app/features/hal/helpers/id-from-link';
import { IUserAutocompleteItem } from 'core-app/shared/components/autocompleter/user-autocompleter/user-autocompleter.component';
-import {
- CallableHalLink,
- HalLink,
-} from 'core-app/features/hal/hal-link/hal-link';
+import { CallableHalLink } from 'core-app/features/hal/hal-link/hal-link';
@Component({
templateUrl: './user-edit-field.component.html',
@@ -107,8 +98,8 @@ export class UserEditFieldComponent extends EditFieldComponent implements OnInit
// We fake a HalResource here because we're using a plain JS object, but the schema loading and editing
// is part of the older HalResource stack
const newUser = { ...user };
- const fakeUserHal = this.halResourceService.createHalResourceOfType('user', newUser);
- this.value = fakeUserHal;
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
+ this.value = this.halResourceService.createHalResourceOfType('user', newUser);
} else {
this.value = null;
}
diff --git a/frontend/src/app/shared/components/fields/field.base.ts b/frontend/src/app/shared/components/fields/field.base.ts
index 8afafc3a713..4fe2fefff5e 100644
--- a/frontend/src/app/shared/components/fields/field.base.ts
+++ b/frontend/src/app/shared/components/fields/field.base.ts
@@ -35,7 +35,7 @@ export interface IFieldSchema {
allowedValues?:any;
required?:boolean;
hasDefault:boolean;
- name?:string;
+ name:string;
options?:any;
}
diff --git a/frontend/src/app/shared/components/grids/widgets/time-entries/current-user/time-entries-current-user.component.html b/frontend/src/app/shared/components/grids/widgets/time-entries/current-user/time-entries-current-user.component.html
index 4efd33ecb78..a206a51a121 100644
--- a/frontend/src/app/shared/components/grids/widgets/time-entries/current-user/time-entries-current-user.component.html
+++ b/frontend/src/app/shared/components/grids/widgets/time-entries/current-user/time-entries-current-user.component.html
@@ -9,10 +9,10 @@
</widget-time-entries-current-user-menu>
</widget-header>
-<te-calendar
+<op-time-entries-calendar
(entries)="updateEntries($event)"
[displayedDays]="displayedDays"
-></te-calendar>
+></op-time-entries-calendar>
<ng-container>
<div class="total-hours">
diff --git a/lib/api/v3/work_packages/work_package_representer.rb b/lib/api/v3/work_packages/work_package_representer.rb
index 08e19a37789..5a717799a90 100644
--- a/lib/api/v3/work_packages/work_package_representer.rb
+++ b/lib/api/v3/work_packages/work_package_representer.rb
@@ -80,7 +80,10 @@ module API
end
link :logTime,
- cache_if: -> { current_user_allowed_to(:log_time, context: represented.project) || current_user_allowed_to(:log_own_time, context: represented.project) } do
+ cache_if: -> do
+ current_user_allowed_to(:log_time, context: represented.project) ||
+ current_user_allowed_to(:log_own_time, context: represented.project)
+ end do
next if represented.new_record?
{
diff --git a/modules/costs/app/contracts/time_entries/create_contract.rb b/modules/costs/app/contracts/time_entries/create_contract.rb
index 6703a2202d7..56be3186023 100644
--- a/modules/costs/app/contracts/time_entries/create_contract.rb
+++ b/modules/costs/app/contracts/time_entries/create_contract.rb
@@ -36,7 +36,7 @@ module TimeEntries
return unless model.project && model.user
return if allowed_to_log_for_others?
return if allowed_to_log_to_himself?
-
+
errors.add :base, :error_unauthorized
end
diff --git a/modules/costs/spec/requests/api/time_entries/create_form_resource_spec.rb b/modules/costs/spec/requests/api/time_entries/create_form_resource_spec.rb
index 8330df7a3fa..4de2275fdca 100644
--- a/modules/costs/spec/requests/api/time_entries/create_form_resource_spec.rb
+++ b/modules/costs/spec/requests/api/time_entries/create_form_resource_spec.rb
@@ -149,7 +149,7 @@ describe ::API::V3::TimeEntries::CreateFormAPI, content_type: :json do
expect(body)
.to be_json_eql(api_v3_paths.time_entries_activity(active_activity.id).to_json)
.at_path('_embedded/payload/_links/activity/href')
-
+
expect(body)
.to be_json_eql(api_v3_paths.user(user.id).to_json)
.at_path('_embedded/payload/_links/user/href')
diff --git a/modules/reporting/app/helpers/reporting_helper.rb b/modules/reporting/app/helpers/reporting_helper.rb
index 8bb835d0db6..5a0e8720f8c 100644
--- a/modules/reporting/app/helpers/reporting_helper.rb
+++ b/modules/reporting/app/helpers/reporting_helper.rb
@@ -106,7 +106,7 @@ module ReportingHelper
case key.to_sym
when :activity_id then mapped value, Enumeration, "<i>#{I18n.t(:caption_material_costs)}</i>"
when :project_id then link_to_project Project.find(value.to_i)
- when :user_id, :assigned_to_id, :author_id, :logged_by_id then link_to_user(User.find_by_id(value.to_i) || DeletedUser.first)
+ when :user_id, :assigned_to_id, :author_id, :logged_by_id then link_to_user(User.find_by(id: value.to_i) || DeletedUser.first)
when :tyear, :units then h(value.to_s)
when :tweek then "#{I18n.t(:label_week)} ##{h value}"
when :tmonth then month_name(value.to_i)
diff --git a/modules/reporting/app/models/cost_query/filter/logged_by_id.rb b/modules/reporting/app/models/cost_query/filter/logged_by_id.rb
index 396c0f6e5db..ebf3c7be066 100644
--- a/modules/reporting/app/models/cost_query/filter/logged_by_id.rb
+++ b/modules/reporting/app/models/cost_query/filter/logged_by_id.rb
@@ -50,6 +50,7 @@ class CostQuery::Filter::LoggedById < Report::Filter::Base
end
end
+ # rubocop:disable Metrics/AbcSize
def self.available_values(*)
# All users which are members in projects the user can see.
# Excludes the anonymous user
@@ -63,4 +64,5 @@ class CostQuery::Filter::LoggedById < Report::Filter::Base
values.unshift [::I18n.t(:label_me), me_value] if User.current.logged?
values
end
+ # rubocop:enable Metrics/AbcSize
end
diff --git a/modules/reporting/lib/widget/table/entry_table.rb b/modules/reporting/lib/widget/table/entry_table.rb
index f6f156967bc..46b285af024 100644
--- a/modules/reporting/lib/widget/table/entry_table.rb
+++ b/modules/reporting/lib/widget/table/entry_table.rb
@@ -27,7 +27,7 @@
#++
class ::Widget::Table::EntryTable < ::Widget::Table
- FIELDS = %i[spent_on user_id activity_id work_package_id comments logged_by_id project_id]
+ FIELDS = %i[spent_on user_id activity_id work_package_id comments logged_by_id project_id].freeze
def render
content = content_tag :div, class: 'generic-table--container -with-footer' do
diff --git a/spec/features/custom_fields/multi_user_custom_field_spec.rb b/spec/features/custom_fields/multi_user_custom_field_spec.rb
index 25c690be65e..b390e7186f7 100644
--- a/spec/features/custom_fields/multi_user_custom_field_spec.rb
+++ b/spec/features/custom_fields/multi_user_custom_field_spec.rb
@@ -81,7 +81,7 @@ describe "multi select custom values", js: true do
expect(cvs).to contain_exactly(group, user, placeholder)
cf_edit_field.activate!
- cf_edit_field.unset_value "Da Real", true
+ cf_edit_field.unset_value "Da Real", multi: true
cf_edit_field.submit_by_dashboard
wp_page.expect_and_dismiss_toaster(message: "Successful update.")
@@ -144,7 +144,7 @@ describe "multi select custom values", js: true do
page.find(".inline-edit--display-field", text: "Billy Nobbler").click
- cf_edit_field.unset_value "Anton Lupin", true
+ cf_edit_field.unset_value "Anton Lupin", multi: true
cf_edit_field.set_value "Cooper Quatermaine"
click_on "Reviewer: Save"
diff --git a/spec/features/custom_fields/multi_value_custom_field_spec.rb b/spec/features/custom_fields/multi_value_custom_field_spec.rb
index 33414b545fc..dedf641a679 100644
--- a/spec/features/custom_fields/multi_value_custom_field_spec.rb
+++ b/spec/features/custom_fields/multi_value_custom_field_spec.rb
@@ -82,7 +82,7 @@ describe "multi select custom values", js: true do
edit_field.activate!
- edit_field.unset_value "pineapple", true
+ edit_field.unset_value "pineapple", multi: true
edit_field.set_value "mushrooms"
edit_field.submit_by_dashboard
@@ -134,8 +134,8 @@ describe "multi select custom values", js: true do
wp1_field.activate!
- wp1_field.unset_value "pineapple", true
- wp1_field.unset_value "onions", true
+ wp1_field.unset_value "pineapple", multi: true
+ wp1_field.unset_value "onions", multi: true
wp1_field.submit_by_dashboard
@@ -150,7 +150,7 @@ describe "multi select custom values", js: true do
field = SelectField.new(split_view.container, "customField#{custom_field.id}")
field.activate!
- field.unset_value "ham", true
+ field.unset_value "ham", multi: true
field.submit_by_dashboard
wp_page.expect_and_dismiss_toaster message: 'Successful update'
diff --git a/spec/support/edit_fields/edit_field.rb b/spec/support/edit_fields/edit_field.rb
index af7d981d5e4..15ccf390ec9 100644
--- a/spec/support/edit_fields/edit_field.rb
+++ b/spec/support/edit_fields/edit_field.rb
@@ -15,6 +15,7 @@ class EditField
@property_name = property_name.to_s
@context = context
+ @field_type = derive_field_type
@selector = selector || ".inline-edit--container.#{property_name}"
end
@@ -164,7 +165,7 @@ class EditField
##
# Set or select the given value.
# For fields of type select, will check for an option with that value.
- def unset_value(content = nil, multi = false)
+ def unset_value(content = nil, multi: false)
activate!
scroll_to_element(input_element)
@@ -241,25 +242,25 @@ class EditField
field_container.find('.ng-input input')
end
- def field_type
- @field_type ||= case property_name.to_s
+ def derive_field_type
+ case property_name.to_s
when 'version'
'version-autocompleter'
when 'assignee',
- 'responsible'
+ 'responsible'
'op-user-autocompleter'
when 'priority',
- 'status',
- 'type',
- 'category',
- 'workPackage'
+ 'status',
+ 'type',
+ 'category',
+ 'workPackage'
'create-autocompleter'
when 'project'
'op-autocompleter'
when 'activity'
'activity-autocompleter'
else
- :input
- end.to_s
+ 'input'
+ end
end
end