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

Fix autofocus directive

Benjamin Bädorf532f8b97799d
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.component.html b/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.component.html
new file mode 100644
index 00000000000..0376c85705c
--- /dev/null
+++ b/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.component.html
@@ -0,0 +1,199 @@
+<div
+ *ngIf="workPackage"
+ class="work-package--single-view"
+ [ngClass]="{'work-package--single-view_with-columns': showTwoColumnLayout()}"
+ data-selector="wp-single-view"
+>
+ <div
+ class="wp-new--subject-wrapper"
+ *ngIf="isNewResource"
+ >
+ <op-editable-attribute-field
+ [resource]="workPackage"
+ [wrapperClasses]="'-no-label'"
+ [fieldName]="'subject'"
+ ></op-editable-attribute-field>
+ </div>
+
+ <div class="wp-info-wrapper">
+ <wp-status-button
+ *ngIf="!isNewResource"
+ [workPackage]="workPackage"
+ ></wp-status-button>
+ <attribute-help-text
+ [attribute]="'status'"
+ [attributeScope]="'WorkPackage'"
+ *ngIf="!isNewResource"
+ ></attribute-help-text>
+
+ <div
+ class="work-packages--info-row"
+ *ngIf="!isNewResource"
+ >
+ <span [textContent]="idLabel"></span>:
+ <span [textContent]="text.infoRow.createdBy"></span>
+ <!-- The space has to be in an extra span
+ because otherwise the browser would add a second space after it -->
+ <span>&nbsp;</span>
+ <op-user-link
+ class="user-link"
+ [user]="workPackage.author"
+ ></op-user-link>
+ <span>.&nbsp;</span>
+ <span [textContent]="text.infoRow.lastUpdatedOn"></span>
+ <span>&nbsp;</span>
+ <op-date-time [dateTimeValue]="workPackage.updatedAt"></op-date-time>
+ <span>.</span>
+ </div>
+
+ <wp-custom-actions [workPackage]="workPackage" class="custom-actions"></wp-custom-actions>
+ </div>
+
+ <div
+ class="attributes-group -project-context __overflowing_element_container __overflowing_project_context"
+ *ngIf="projectContext && projectContext.field"
+ data-overflowing-identifier=".__overflowing_project_context"
+ >
+ <div>
+ <p class="wp-project-context--warning" [textContent]="text.project.required"></p>
+ <div
+ class="attributes-key-value"
+ [ngClass]="{'-span-all-columns': descriptor.spanAll }"
+ *ngFor="let descriptor of projectContext.field; trackBy:trackByName"
+ >
+ <div class="attributes-key-value--key">
+ <wp-replacement-label [fieldName]="descriptor.name">
+ {{ descriptor.label }}
+ <span
+ class="required"
+ *ngIf="descriptor.field.required && descriptor.field.writable"
+ >*</span>
+ </wp-replacement-label>
+ <attribute-help-text
+ [attribute]="descriptor.name"
+ [attributeScope]="'WorkPackage'"
+ ></attribute-help-text>
+ </div>
+ <div class="attributes-key-value--value-container">
+ <op-editable-attribute-field
+ [resource]="workPackage"
+ [fieldName]="descriptor.name"
+ ></op-editable-attribute-field>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div
+ class="attributes-group -project-context hide-when-print"
+ *ngIf="!isNewResource && projectContext && !projectContext.matches"
+ >
+ <div>
+ <p>
+ <span [innerHTML]="projectContextText"></span>
+ <br/>
+ <a
+ [attr.href]="projectContext.href"
+ class="project-context--switch-link"
+ [textContent]="text.project.switchTo"
+ ></a>
+ </p>
+ </div>
+ </div>
+
+ <ng-container *ngFor="let component of prependedAttributeGroupComponents()">
+ <ndc-dynamic
+ [ndcDynamicComponent]="component"
+ [ndcDynamicInputs]="{ workPackage: workPackage }"
+ ></ndc-dynamic>
+ </ng-container>
+
+ <div class="attributes-group description-group">
+ <div class="single-attribute work-packages--details--description">
+ <op-editable-attribute-field
+ [fieldName]="'description'"
+ [resource]="workPackage"
+ [isDropTarget]="true"
+ [wrapperClasses]="'-no-label'"
+ ></op-editable-attribute-field>
+ </div>
+ </div>
+
+ <div
+ *ngFor="let group of groupedFields; trackBy:trackByName"
+ [hidden]="shouldHideGroup(group)"
+ [attr.data-group-name]="group.name"
+ [ngClass]="'__overflowing_' + group.id"
+ [attr.data-overflowing-identifier]="'.__overflowing_' + group.id"
+ class="attributes-group __overflowing_element_container"
+ >
+ <ng-container wp-isolated-query-space *ngIf="group.isolated">
+ <ndc-dynamic
+ [ndcDynamicComponent]="attributeGroupComponent(group)"
+ [ndcDynamicInputs]="{
+ workPackage: workPackage,
+ group: group,
+ query: group.query
+ }"
+ ></ndc-dynamic>
+ </ng-container>
+
+ <ng-container *ngIf="!group.isolated">
+ <div class="attributes-group--header">
+ <div class="attributes-group--header-container">
+ <h3
+ class="attributes-group--header-text"
+ [textContent]="group.name"
+ ></h3>
+ </div>
+ </div>
+
+ <ndc-dynamic
+ [ndcDynamicComponent]="attributeGroupComponent(group)"
+ [ndcDynamicInjector]="injector"
+ [ndcDynamicInputs]="{ workPackage: workPackage, group: group }"
+ ></ndc-dynamic>
+ </ng-container>
+ </div>
+</div>
+
+<div class="work-packages--attachments attributes-group" *ngIf="isNewResource">
+ <div class="work-packages--attachments-container">
+ <div class="attributes-group--header">
+ <div class="attributes-group--header-container">
+ <h3 class="attributes-group--header-text" [textContent]="text.attachments.label"></h3>
+ </div>
+ </div>
+
+ <ndc-dynamic
+ [ndcDynamicComponent]="attachmentListComponent()"
+ [ndcDynamicInputs]="{ resource: workPackage }"
+ ></ndc-dynamic>
+
+ <ndc-dynamic
+ [ndcDynamicComponent]="attachmentUploadComponent()"
+ [ndcDynamicInputs]="{ resource: workPackage }"
+ *ngIf="workPackage.canAddAttachments"
+ ></ndc-dynamic>
+ </div>
+</div>
+
+<div class="work-packages--files attributes-group" *ngIf="!isNewResource">
+ <div class="work-packages--files-container">
+ <div class="attributes-group--header">
+ <div class="attributes-group--header-container">
+ <h3 class="attributes-group--header-text" [textContent]="text.files.label"></h3>
+ </div>
+ </div>
+
+ <div class="attributes-group--icon-indented-text">
+ <op-icon icon-classes="icon-info1"></op-icon>
+ <span [textContent]="text.files.migration_help"></span>
+ <a
+ [textContent]="text.files.label"
+ [uiSref]="uiSelfRef"
+ [uiParams]="{ workPackageId: workPackage.id, tabIdentifier: 'files' }"
+ ></a>
+ </div>
+ </div>
+</div>
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.component.ts b/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.component.ts
index 2b89dbfe932..1aed96634d8 100644
--- a/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.component.ts
@@ -86,7 +86,7 @@ export interface ResourceContextChange {
export const overflowingContainerAttribute = 'overflowingIdentifier';
@Component({
- templateUrl: './wp-single-view.html',
+ templateUrl: './wp-single-view.component.html',
selector: 'wp-single-view',
changeDetection: ChangeDetectionStrategy.OnPush,
})
@@ -142,7 +142,8 @@ export class WorkPackageSingleViewComponent extends UntilDestroyedMixin implemen
$element:JQuery;
- constructor(readonly I18n:I18nService,
+ constructor(
+ readonly I18n:I18nService,
protected currentProject:CurrentProjectService,
protected PathHelper:PathHelperService,
protected $state:StateService,
@@ -155,7 +156,8 @@ export class WorkPackageSingleViewComponent extends UntilDestroyedMixin implemen
protected injector:Injector,
protected cdRef:ChangeDetectorRef,
readonly elementRef:ElementRef,
- readonly browserDetector:BrowserDetector) {
+ readonly browserDetector:BrowserDetector,
+ ) {
super();
}
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.html b/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.html
deleted file mode 100644
index 3cc75d4ea3f..00000000000
--- a/frontend/src/app/features/work-packages/components/wp-single-view/wp-single-view.html
+++ /dev/null
@@ -1,165 +0,0 @@
-<div *ngIf="workPackage"
- class="work-package--single-view"
- [ngClass]="{'work-package--single-view_with-columns': showTwoColumnLayout()}"
- data-selector="wp-single-view">
- <div class="wp-new--subject-wrapper"
- *ngIf="isNewResource">
- <op-editable-attribute-field [resource]="workPackage"
- [wrapperClasses]="'-no-label'"
- [fieldName]="'subject'"></op-editable-attribute-field>
- </div>
-
- <div class="wp-info-wrapper">
- <wp-status-button *ngIf="!isNewResource"
- [workPackage]="workPackage">
- </wp-status-button>
- <attribute-help-text [attribute]="'status'"
- [attributeScope]="'WorkPackage'"
- *ngIf="!isNewResource"></attribute-help-text>
-
- <div class="work-packages--info-row"
- *ngIf="!isNewResource">
- <span [textContent]="idLabel"></span>:
- <span [textContent]="text.infoRow.createdBy"></span>
- <!-- The space has to be in an extra span
- because otherwise the browser would add a second space after it -->
- <span>&nbsp;</span>
- <op-user-link class="user-link"
- [user]="workPackage.author"></op-user-link>
- <span>.&nbsp;</span>
- <span [textContent]="text.infoRow.lastUpdatedOn"></span>
- <span>&nbsp;</span>
- <op-date-time [dateTimeValue]="workPackage.updatedAt"></op-date-time>
- <span>.</span>
- </div>
-
- <wp-custom-actions [workPackage]="workPackage" class="custom-actions"></wp-custom-actions>
- </div>
-
- <div class="attributes-group -project-context __overflowing_element_container __overflowing_project_context"
- *ngIf="projectContext && projectContext.field"
- data-overflowing-identifier=".__overflowing_project_context">
- <div>
- <p class="wp-project-context--warning" [textContent]="text.project.required"></p>
- <div class="attributes-key-value"
- [ngClass]="{'-span-all-columns': descriptor.spanAll }"
- *ngFor="let descriptor of projectContext.field; trackBy:trackByName">
- <div class="attributes-key-value--key">
- <wp-replacement-label [fieldName]="descriptor.name">
- {{ descriptor.label }}
- <span class="required"
- *ngIf="descriptor.field.required && descriptor.field.writable">*</span>
- </wp-replacement-label>
- <attribute-help-text [attribute]="descriptor.name"
- [attributeScope]="'WorkPackage'"></attribute-help-text>
- </div>
- <div class="attributes-key-value--value-container">
- <op-editable-attribute-field [resource]="workPackage"
- [fieldName]="descriptor.name"></op-editable-attribute-field>
- </div>
- </div>
- </div>
- </div>
-
- <div
- class="attributes-group -project-context hide-when-print"
- *ngIf="!isNewResource && projectContext && !projectContext.matches"
- >
- <div>
- <p>
- <span [innerHTML]="projectContextText"></span>
- <br/>
- <a [attr.href]="projectContext.href"
- class="project-context--switch-link"
- [textContent]="text.project.switchTo">
- </a>
- </p>
- </div>
- </div>
-
- <ng-container *ngFor="let component of prependedAttributeGroupComponents()">
- <ndc-dynamic [ndcDynamicComponent]="component"
- [ndcDynamicInputs]="{ workPackage: workPackage }">
- </ndc-dynamic>
- </ng-container>
-
- <div class="attributes-group description-group">
- <div class="single-attribute work-packages--details--description">
- <op-editable-attribute-field [fieldName]="'description'"
- [resource]="workPackage"
- [isDropTarget]="true"
- [wrapperClasses]="'-no-label'">
- </op-editable-attribute-field>
- </div>
- </div>
-
- <div
- *ngFor="let group of groupedFields; trackBy:trackByName"
- [hidden]="shouldHideGroup(group)"
- [attr.data-group-name]="group.name"
- [ngClass]="'__overflowing_' + group.id"
- [attr.data-overflowing-identifier]="'.__overflowing_' + group.id"
- class="attributes-group __overflowing_element_container"
- >
- <ng-container wp-isolated-query-space *ngIf="group.isolated">
- <ndc-dynamic [ndcDynamicComponent]="attributeGroupComponent(group)"
- [ndcDynamicInputs]="{ workPackage: workPackage,
- group: group,
- query: group.query }">
- </ndc-dynamic>
- </ng-container>
-
- <ng-container *ngIf="!group.isolated">
- <div class="attributes-group--header">
- <div class="attributes-group--header-container">
- <h3 class="attributes-group--header-text"
- [textContent]="group.name"></h3>
- </div>
- </div>
-
- <ndc-dynamic [ndcDynamicComponent]="attributeGroupComponent(group)"
- [ndcDynamicInjector]="injector"
- [ndcDynamicInputs]="{ workPackage: workPackage, group: group }">
- </ndc-dynamic>
- </ng-container>
- </div>
-</div>
-
-<div class="work-packages--attachments attributes-group" *ngIf="isNewResource">
- <div class="work-packages--attachments-container">
- <div class="attributes-group--header">
- <div class="attributes-group--header-container">
- <h3 class="attributes-group--header-text" [textContent]="text.attachments.label"></h3>
- </div>
- </div>
-
- <ndc-dynamic [ndcDynamicComponent]="attachmentListComponent()"
- [ndcDynamicInputs]="{ resource: workPackage }">
- </ndc-dynamic>
-
- <ndc-dynamic [ndcDynamicComponent]="attachmentUploadComponent()"
- [ndcDynamicInputs]="{ resource: workPackage }"
- *ngIf="workPackage.canAddAttachments">
- </ndc-dynamic>
- </div>
-</div>
-
-<div class="work-packages--files attributes-group" *ngIf="!isNewResource">
- <div class="work-packages--files-container">
- <div class="attributes-group--header">
- <div class="attributes-group--header-container">
- <h3 class="attributes-group--header-text" [textContent]="text.files.label"></h3>
- </div>
- </div>
-
- <div class="attributes-group--icon-indented-text">
- <op-icon icon-classes="icon-info1"></op-icon>
- <span [textContent]="text.files.migration_help"></span>
- <a
- [textContent]="text.files.label"
- [uiSref]="uiSelfRef"
- [uiParams]="{ workPackageId: workPackage.id, tabIdentifier: 'files' }"
- ></a>
- </div>
- </div>
-</div>
diff --git a/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.html b/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.html
index e6f18970641..8f9952644c5 100644
--- a/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.html
+++ b/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.html
@@ -105,9 +105,10 @@
</div>
<input
- id="flatpickr-input"
#flatpickrTarget
- hidden>
+ id="flatpickr-input"
+ hidden
+ />
</div>
<div class="spot-action-bar">
diff --git a/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.ts b/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.ts
index 9a5a9965acd..23e2c56438a 100644
--- a/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.ts
+++ b/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.ts
@@ -283,17 +283,14 @@ export class OpWpMultiDateFormComponent extends UntilDestroyedMixin implements A
}
ngAfterViewInit():void {
- console.log('ngAfterViewInit');
this
.dateModalRelations
.getMinimalDateFromPreceeding()
.subscribe((date) => {
- console.log('initialize date picker');
this.initializeDatepicker(date);
// Autofocus duration if that's what activated us
if (this.initialActivatedField === 'duration') {
- console.log('focus duration');
this.focusHelper.focus(this.durationField.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.ts
index 7de0e7e882f..e23909f343b 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
@@ -36,7 +36,7 @@ import { WorkPackageResource } from 'core-app/features/hal/resources/work-packag
export class CombinedDateEditFieldComponent extends DatePickerEditFieldComponent {
dates = '';
- opened = true;
+ opened = false;
text = {
placeholder: {
@@ -54,6 +54,10 @@ export class CombinedDateEditFieldComponent extends DatePickerEditFieldComponent
event.stopPropagation();
}
+ public showDatePickerModal():void {
+ this.opened = true;
+ }
+
public onModalClosed():void {
this.opened = false;
this.resetDates();
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/text-edit-field.component.html b/frontend/src/app/shared/components/fields/edit/field-types/text-edit-field.component.html
index 759be497e12..058614cc190 100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/text-edit-field.component.html
+++ b/frontend/src/app/shared/components/fields/edit/field-types/text-edit-field.component.html
@@ -1,10 +1,12 @@
-<input type="text"
- class="inline-edit--field op-input"
- [opAutofocus]="shouldFocus"
- [attr.aria-required]="required"
- [attr.required]="required"
- [disabled]="inFlight"
- [(ngModel)]="value"
- (keydown)="handler.handleUserKeydown($event)"
- (focusout)="handler.onFocusOut()"
- [id]="handler.htmlId" />
+<input
+ type="text"
+ class="inline-edit--field op-input some-class"
+ [opAutofocus]="shouldFocus"
+ [attr.aria-required]="required"
+ [attr.required]="required"
+ [disabled]="inFlight"
+ [(ngModel)]="value"
+ (keydown)="handler.handleUserKeydown($event)"
+ (focusout)="handler.onFocusOut()"
+ [id]="handler.htmlId"
+/>
diff --git a/frontend/src/app/shared/components/fields/edit/field/editable-attribute-field.component.html b/frontend/src/app/shared/components/fields/edit/field/editable-attribute-field.component.html
index 60cdcb8a94a..2dc27844382 100644
--- a/frontend/src/app/shared/components/fields/edit/field/editable-attribute-field.component.html
+++ b/frontend/src/app/shared/components/fields/edit/field/editable-attribute-field.component.html
@@ -1,18 +1,22 @@
-<div [ngClass]="[
- editFieldContainerClass,
- fieldName,
- active && '-active' || '',
- wrapperClasses || '-small'
- ]"
- (dragover)="startDragActivation($event)">
+<div
+ [ngClass]="[
+ editFieldContainerClass,
+ fieldName,
+ active && '-active' || '',
+ wrapperClasses || '-small'
+ ]"
+ (dragover)="startDragActivation($event)"
+>
+ <div
+ #editContainer
+ [hidden]="!active"
+ ></div>
- <div #editContainer
- [hidden]="!active">
- </div>
-
- <div (click)="activateIfEditable($event)"
- (keydown.enter)="activateIfEditable($event)"
- [hidden]="active"
- tabindex="-1"
- #displayContainer></div>
+ <div
+ (click)="activateIfEditable($event)"
+ (keydown.enter)="activateIfEditable($event)"
+ [hidden]="active"
+ tabindex="-1"
+ #displayContainer
+ ></div>
</div>
diff --git a/frontend/src/app/shared/components/fields/edit/field/editable-attribute-field.component.ts b/frontend/src/app/shared/components/fields/edit/field/editable-attribute-field.component.ts
index 0c8e48f8d38..2ff03def342 100644
--- a/frontend/src/app/shared/components/fields/edit/field/editable-attribute-field.component.ts
+++ b/frontend/src/app/shared/components/fields/edit/field/editable-attribute-field.component.ts
@@ -87,7 +87,8 @@ export class EditableAttributeFieldComponent extends UntilDestroyedMixin impleme
public destroyed = false;
- constructor(protected states:States,
+ constructor(
+ protected states:States,
protected injector:Injector,
protected elementRef:ElementRef,
protected opContextMenu:OPContextMenuService,
@@ -96,7 +97,8 @@ export class EditableAttributeFieldComponent extends UntilDestroyedMixin impleme
// Get parent field group from injector if we're in a form
@Optional() protected editForm:EditFormComponent,
protected cdRef:ChangeDetectorRef,
- protected I18n:I18nService) {
+ protected I18n:I18nService,
+ ) {
super();
}
diff --git a/frontend/src/app/shared/components/header-project-select/header-project-select.component.html b/frontend/src/app/shared/components/header-project-select/header-project-select.component.html
index eb81f8ccc4c..07bb8deb070 100644
--- a/frontend/src/app/shared/components/header-project-select/header-project-select.component.html
+++ b/frontend/src/app/shared/components/header-project-select/header-project-select.component.html
@@ -1,5 +1,6 @@
<spot-drop-modal
[open]="dropModalOpen"
+ [allowRepositioning]="false"
(closed)="close()"
alignment="bottom-left"
class="op-project-list-modal"
diff --git a/frontend/src/app/shared/directives/focus/autofocus.directive.ts b/frontend/src/app/shared/directives/focus/autofocus.directive.ts
index e6e411bf76e..9752ca4174f 100644
--- a/frontend/src/app/shared/directives/focus/autofocus.directive.ts
+++ b/frontend/src/app/shared/directives/focus/autofocus.directive.ts
@@ -28,6 +28,7 @@ export class AutofocusDirective implements AfterViewInit {
// <my-input opAutofocus />
//
if (this.condition || this.condition === '') {
+ console.log('focus', this.elementRef.nativeElement);
this.FocusHelper.focus(this.elementRef.nativeElement);
}
}
diff --git a/frontend/src/app/shared/directives/focus/focus-helper.ts b/frontend/src/app/shared/directives/focus/focus-helper.ts
index e0108d5e112..cc8d4f4c682 100644
--- a/frontend/src/app/shared/directives/focus/focus-helper.ts
+++ b/frontend/src/app/shared/directives/focus/focus-helper.ts
@@ -33,8 +33,7 @@ import { findAllFocusableElementsWithin } from 'core-app/shared/helpers/focus-he
export class FocusHelperService {
public focus(element:HTMLElement):void {
setTimeout(() => {
- const focusable = findAllFocusableElementsWithin(element)[0];
- console.log('focus', focusable);
+ const focusable = findAllFocusableElementsWithin(element)[0] || element;
focusable?.focus();
}, 20);
}