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
Please rubocop and eslint
Henriette Darge524347b4ff8e
diff --git a/app/contracts/work_packages/base_contract.rb b/app/contracts/work_packages/base_contract.rbindex df4b79bfe07..7acd4b431d4 100644--- a/app/contracts/work_packages/base_contract.rb+++ b/app/contracts/work_packages/base_contract.rb@@ -483,12 +483,22 @@ module WorkPackagesenddef validate_duration_integer- if (!model.duration_before_type_cast.is_a?(String) && model.duration_before_type_cast != model.duration) ||- (model.duration_before_type_cast.is_a?(String) && model.duration_before_type_cast.to_i.to_s != model.duration_before_type_cast)+ unless valid_duration?(model.duration_before_type_cast, model.duration)errors.add :duration, :not_an_integerendend+ def valid_duration?(value, duration)+ # the values don't match (e.g because a float was passed)+ return false if !value.is_a?(String) && value != duration++ # A string is passed, put the transformed value does not match+ return false if value.is_a?(String) && value.to_i.to_s != value++ # duration is valid+ true+ end+def validate_duration_matches_datesreturn unless calculated_duration && model.durationdiff --git a/app/controllers/work_packages/date_picker_controller.rb b/app/controllers/work_packages/date_picker_controller.rbindex 99d31a4cecc..bcc6f07fdc1 100644--- a/app/controllers/work_packages/date_picker_controller.rb+++ b/app/controllers/work_packages/date_picker_controller.rb@@ -130,13 +130,13 @@ class WorkPackages::DatePickerController < ApplicationControllerenddef schedule_manually- if params[:schedule_manually].present?- params[:schedule_manually]- elsif params[:work_package].present? && params[:work_package][:schedule_manually].present?- params[:work_package][:schedule_manually]- else+ find_if_present(params[:schedule_manually]) ||+ find_if_present(params.dig(:work_package, :schedule_manually)) ||work_package.schedule_manually- end+ end++ def find_if_present(value)+ value.presenceenddef work_package_datepicker_paramsdiff --git a/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.tsindex 5c4e17b587a..b3f23b08ee1 100644--- a/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.ts+++ b/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.ts@@ -101,6 +101,7 @@ export class OpWpModalDatePickerComponent extends UntilDestroyedMixin implementsdocument.addEventListener('date-picker:input-changed', this.changeListener.bind(this));}+ // eslint-disable-next-line @angular-eslint/use-lifecycle-interfacengOnDestroy():void {super.ngOnDestroy();@@ -108,15 +109,17 @@ export class OpWpModalDatePickerComponent extends UntilDestroyedMixin implements}changeListener(event:CustomEvent) {- switch (event.detail.field) {+ const details = (event.detail as { field:string, value:string });++ switch (details.field) {case 'work_package[start_date]':- this.startDate = event.detail.value;+ this.startDate = new Date(details.value);break;case 'work_package[due_date]':- this.dueDate = event.detail.value;+ this.dueDate = new Date(details.value);break;case 'work_package[ignore_non_working_days]':- this.ignoreNonWorkingDays = event.detail.value !== 'true';+ this.ignoreNonWorkingDays = details.value !== 'true';break;default:// Case fallthrough for eslint@@ -166,6 +169,7 @@ export class OpWpModalDatePickerComponent extends UntilDestroyedMixin implements);},},+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argumentthis.flatpickrTarget.nativeElement,);}diff --git a/frontend/src/app/shared/components/fields/edit/field-types/combined-date-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/combined-date-edit-field.component.tsindex 1060a96c101..a2e7e0ba82f 100644--- a/frontend/src/app/shared/components/fields/edit/field-types/combined-date-edit-field.component.ts+++ b/frontend/src/app/shared/components/fields/edit/field-types/combined-date-edit-field.component.ts@@ -27,26 +27,11 @@//++import {- ChangeDetectorRef,Component,- ElementRef,- Inject,- Injector,OnInit,} from '@angular/core';import { DatePickerEditFieldComponent } from 'core-app/shared/components/fields/edit/field-types/date-picker-edit-field.component';import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';-import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';-import { I18nService } from 'core-app/core/i18n/i18n.service';-import { ResourceChangeset } from 'core-app/shared/components/fields/changeset/resource-changeset';-import { HalResource } from 'core-app/features/hal/resources/hal-resource';-import { IFieldSchema } from 'core-app/shared/components/fields/field.base';-import { EditFieldHandler } from 'core-app/shared/components/fields/edit/editing-portal/edit-field-handler';-import {- OpEditingPortalChangesetToken,- OpEditingPortalHandlerToken,- OpEditingPortalSchemaToken,-} from 'core-app/shared/components/fields/edit/edit-field.component';@Component({templateUrl: './combined-date-edit-field.component.html',@@ -90,7 +75,7 @@ export class CombinedDateEditFieldComponent extends DatePickerEditFieldComponent}public save():void {- this.handler.handleUserSubmit();+ void this.handler.handleUserSubmit();}public cancel():void {diff --git a/frontend/src/app/shared/components/fields/edit/field-types/days-duration-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/days-duration-edit-field.component.tsindex d3ece812915..36a166bc074 100644--- a/frontend/src/app/shared/components/fields/edit/field-types/days-duration-edit-field.component.ts+++ b/frontend/src/app/shared/components/fields/edit/field-types/days-duration-edit-field.component.ts@@ -28,32 +28,17 @@import {ChangeDetectionStrategy,- ChangeDetectorRef,Component,- ElementRef,- Inject,- Injector,OnInit,} from '@angular/core';import { DatePickerEditFieldComponent } from 'core-app/shared/components/fields/edit/field-types/date-picker-edit-field.component';import * as moment from 'moment-timezone';-import { I18nService } from 'core-app/core/i18n/i18n.service';-import {- OpEditingPortalChangesetToken,- OpEditingPortalHandlerToken,- OpEditingPortalSchemaToken,-} from 'core-app/shared/components/fields/edit/edit-field.component';-import { ResourceChangeset } from 'core-app/shared/components/fields/changeset/resource-changeset';-import { HalResource } from 'core-app/features/hal/resources/hal-resource';-import { IFieldSchema } from 'core-app/shared/components/fields/field.base';-import { EditFieldHandler } from 'core-app/shared/components/fields/edit/editing-portal/edit-field-handler';-import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';@Component({templateUrl: './days-duration-edit-field.component.html',changeDetection: ChangeDetectionStrategy.OnPush,})-export class DaysDurationEditFieldComponent extends DatePickerEditFieldComponent implements OnInit{+export class DaysDurationEditFieldComponent extends DatePickerEditFieldComponent implements OnInit {opened = false;public get formattedValue():number {@@ -73,7 +58,7 @@ export class DaysDurationEditFieldComponent extends DatePickerEditFieldComponent}onModalClosed() {- this.handler.handleUserSubmit();+ void this.handler.handleUserSubmit();this.opened = false;}diff --git a/frontend/src/app/shared/components/fields/edit/modal-with-turbo-content/modal-with-turbo-content.directive.ts b/frontend/src/app/shared/components/fields/edit/modal-with-turbo-content/modal-with-turbo-content.directive.tsindex d1b051bc7e7..24a9e8acb68 100644--- a/frontend/src/app/shared/components/fields/edit/modal-with-turbo-content/modal-with-turbo-content.directive.ts+++ b/frontend/src/app/shared/components/fields/edit/modal-with-turbo-content/modal-with-turbo-content.directive.ts@@ -70,9 +70,7 @@ export class ModalWithTurboContentDirective implements AfterViewInit, OnDestroy}ngAfterViewInit() {- this- .elementRef- .nativeElement+ (this.elementRef.nativeElement as HTMLElement).addEventListener('turbo:submit-end', this.contextBasedListenerBound);document@@ -80,9 +78,7 @@ export class ModalWithTurboContentDirective implements AfterViewInit, OnDestroy}ngOnDestroy() {- this- .elementRef- .nativeElement+ (this.elementRef.nativeElement as HTMLElement).removeEventListener('turbo:submit-end', this.contextBasedListenerBound);documentdiff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/dialog/preview.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/dialog/preview.controller.tsindex f51d4964e7c..93c6368dc31 100644--- a/frontend/src/stimulus/controllers/dynamic/work-packages/dialog/preview.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/dialog/preview.controller.ts@@ -29,7 +29,10 @@*/import { Controller } from '@hotwired/stimulus';-import { debounce, DebouncedFunc } from 'lodash';+import {+ debounce,+ DebouncedFunc,+} from 'lodash';import Idiomorph from 'idiomorph/dist/idiomorph.cjs';interface TurboBeforeFrameRenderEventDetail {@@ -82,12 +85,12 @@ export abstract class DialogPreviewController extends Controller {Idiomorph.morph(currentElement, newElement, {ignoreActiveValue: true,callbacks: {- beforeNodeMorphed: (oldNode:Element, newNode:Element) => {+ beforeNodeMorphed: (oldNode:Element) => {// In case the element is an OpenProject custom dom element, morphing is prevented.return !oldNode.tagName?.startsWith('OPCE-');},afterNodeMorphed: (oldNode:Element, newNode:Element) => {- if (newNode.tagName === "INPUT" && (newNode as HTMLInputElement).name && (newNode as HTMLInputElement).name.startsWith('work_package[')) {+ if (newNode.tagName === 'INPUT' && (newNode as HTMLInputElement).name && (newNode as HTMLInputElement).name.startsWith('work_package[')) {this.dispatchChangeEvent((newNode as HTMLInputElement));}},