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
add duration edit field
ulfertsa9ec036a268c
diff --git a/frontend/src/app/shared/components/fields/edit/edit-field.initializer.ts b/frontend/src/app/shared/components/fields/edit/edit-field.initializer.tsindex e7eb90fbd73..6047cb15911 100644--- a/frontend/src/app/shared/components/fields/edit/edit-field.initializer.ts+++ b/frontend/src/app/shared/components/fields/edit/edit-field.initializer.ts@@ -47,9 +47,10 @@ import { WorkPackageCommentFieldComponent } from 'core-app/features/work-packageimport { ProjectEditFieldComponent } from './field-types/project-edit-field.component';import { HoursDurationEditFieldComponent } from 'core-app/shared/components/fields/edit/field-types/hours-duration-edit-field.component';import { UserEditFieldComponent } from './field-types/user-edit-field.component';+import { DaysDurationEditFieldComponent } from 'core-app/shared/components/fields/edit/field-types/days-duration-edit-field.compontent';export function initializeCoreEditFields(editFieldService:EditFieldService, selectAutocompleterRegisterService:SelectAutocompleterRegisterService) {- return () => {+ return ():void => {editFieldService.defaultFieldType = 'text';editFieldService.addFieldType(TextEditFieldComponent, 'text', ['String'])@@ -81,6 +82,9 @@ export function initializeCoreEditFields(editFieldService:EditFieldService, sele.addSpecificFieldType('WorkPackage', CombinedDateEditFieldComponent,'date',['combinedDate', 'startDate', 'dueDate', 'date'])+ .addSpecificFieldType('WorkPackage', DaysDurationEditFieldComponent,+ 'duration',+ ['duration']).addSpecificFieldType('Project', ProjectStatusEditFieldComponent, 'status', ['status']).addSpecificFieldType('TimeEntry', PlainFormattableEditFieldComponent, 'comment', ['comment']).addSpecificFieldType('TimeEntry', TimeEntryWorkPackageEditFieldComponent, 'workPackage', ['WorkPackage'])diff --git a/frontend/src/app/shared/components/fields/edit/field-types/days-duration-edit-field.compontent.ts b/frontend/src/app/shared/components/fields/edit/field-types/days-duration-edit-field.compontent.tsnew file mode 100644index 00000000000..99e22025783--- /dev/null+++ b/frontend/src/app/shared/components/fields/edit/field-types/days-duration-edit-field.compontent.ts@@ -0,0 +1,101 @@+/*+ * OpenProject is an open source project management software.+ * Copyright (C) 2010-2022 the OpenProject GmbH+ *+ * This program is free software; you can redistribute it and/or+ * modify it under the terms of the GNU General Public License version 3.+ *+ * OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+ * Copyright (C) 2006-2013 Jean-Philippe Lang+ * Copyright (C) 2010-2013 the ChiliProject Team+ *+ * This program is free software; you can redistribute it and/or+ * modify it under the terms of the GNU General Public License+ * as published by the Free Software Foundation; either version 2+ * of the License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with this program; if not, write to the Free Software+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+ *+ * See COPYRIGHT and LICENSE files for more details.+ */++import {+ ChangeDetectionStrategy,+ Component,+ OnDestroy,+ OnInit,+} from '@angular/core';+import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';+import { OpModalService } from 'core-app/shared/components/modal/modal.service';+import { take } from 'rxjs/operators';+import { DatePickerModalComponent } from 'core-app/shared/components/datepicker/datepicker.modal';+import { TimezoneService } from 'core-app/core/datetime/timezone.service';+import { EditFieldComponent } from 'core-app/shared/components/fields/edit/edit-field.component';++@Component({+ template: `+ <input type="number"+ class="inline-edit--field op-input"+ [ngModel]="formattedValue"+ [disabled]="true"+ [id]="handler.htmlId" />+ `,+ changeDetection: ChangeDetectionStrategy.OnPush,+})+export class DaysDurationEditFieldComponent extends EditFieldComponent implements OnInit, OnDestroy {+ @InjectField() readonly timezoneService:TimezoneService;++ @InjectField() opModalService:OpModalService;++ private modal:DatePickerModalComponent;++ public get formattedValue():number {+ return Number(moment.duration(this.value).asDays().toFixed(0));+ }++ ngOnInit():void {+ super.ngOnInit();++ this.handler+ .$onUserActivate+ .pipe(+ this.untilDestroyed(),+ )+ .subscribe(() => {+ this.showDatePickerModal();+ });+ }++ ngOnDestroy():void {+ super.ngOnDestroy();+ this.modal?.closeMe();+ }++ public showDatePickerModal():void {+ this.modal = this+ .opModalService+ .show(DatePickerModalComponent, this.injector, { changeset: this.change, fieldName: this.name }, true);++ const { modal } = this;++ setTimeout(() => {+ const modalElement = jQuery(modal.elementRef.nativeElement).find('.op-datepicker-modal');+ const field = jQuery(this.elementRef.nativeElement);+ modal.reposition(modalElement, field);+ });++ modal+ .closingEvent+ .pipe(take(1))+ .subscribe(() => {+ void this.handler.handleUserSubmit();+ });+ }+}diff --git a/frontend/src/app/shared/components/fields/openproject-fields.module.ts b/frontend/src/app/shared/components/fields/openproject-fields.module.tsindex b96c687c61a..33b18445cb7 100644--- a/frontend/src/app/shared/components/fields/openproject-fields.module.ts+++ b/frontend/src/app/shared/components/fields/openproject-fields.module.ts@@ -62,6 +62,7 @@ import { EditFieldControlsModule } from 'core-app/shared/components/fields/edit/import { ProjectEditFieldComponent } from './edit/field-types/project-edit-field.component';import { HoursDurationEditFieldComponent } from 'core-app/shared/components/fields/edit/field-types/hours-duration-edit-field.component';import { UserEditFieldComponent } from './edit/field-types/user-edit-field.component';+import { DaysDurationEditFieldComponent } from 'core-app/shared/components/fields/edit/field-types/days-duration-edit-field.compontent';@NgModule({imports: [@@ -103,6 +104,7 @@ import { UserEditFieldComponent } from './edit/field-types/user-edit-field.compodeclarations: [EditFormPortalComponent,HoursDurationEditFieldComponent,+ DaysDurationEditFieldComponent,FloatEditFieldComponent,PlainFormattableEditFieldComponent,MultiSelectEditFieldComponent,