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
Revert "Revert "Merge pull request #11505 from opf/feat/44344-modal-trap-focus""
Oliver Güntherafb732f9360b
diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erbindex 8694ab0dd47..2550240cb0c 100644--- a/app/views/layouts/base.html.erb+++ b/app/views/layouts/base.html.erb@@ -59,6 +59,7 @@ See COPYRIGHT and LICENSE files for more details.</div></noscript><op-toasts-container></op-toasts-container>+<op-modal-overlay></op-modal-overlay><% main_menu = render_main_menu(local_assigns.fetch(:menu_name, nil), @project) %><% side_displayed = content_for?(:sidebar) || content_for?(:main_menu) || !main_menu.blank? %><% initial_classes = initial_menu_classes(side_displayed, show_decoration) %>diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.tsindex c978f2bd0ec..dd1c4f27837 100644--- a/frontend/src/app/app.module.ts+++ b/frontend/src/app/app.module.ts@@ -93,6 +93,7 @@ import { OpenProjectDirectFileUploadService } from './core/file-upload/op-directimport { OpenProjectStateModule } from 'core-app/core/state/openproject-state.module';import { OpenprojectContentLoaderModule } from 'core-app/shared/components/op-content-loader/openproject-content-loader.module';import { OpenProjectHeaderInterceptor } from 'core-app/features/hal/http/openproject-header-interceptor';+import { A11yModule } from '@angular/cdk/a11y';export function initializeServices(injector:Injector) {return () => {@@ -114,6 +115,8 @@ export function initializeServices(injector:Injector) {imports: [// The BrowserModule must only be loaded here!BrowserModule,+ A11yModule,+// CommonsOPSharedModule,// Design Systemdiff --git a/frontend/src/app/core/setup/global-dynamic-components.const.ts b/frontend/src/app/core/setup/global-dynamic-components.const.tsindex 3c02c6cc893..93893c28527 100644--- a/frontend/src/app/core/setup/global-dynamic-components.const.ts+++ b/frontend/src/app/core/setup/global-dynamic-components.const.ts@@ -199,6 +199,7 @@ import {CalendarSidemenuComponent,opCalendarSidemenuSelector,} from 'core-app/features/calendar/sidemenu/calendar-sidemenu.component';+import { OpModalOverlayComponent, opModalOverlaySelector } from 'core-app/shared/components/modal/modal-overlay.component';export const globalDynamicComponents:OptionalBootstrapDefinition[] = [{ selector: appBaseSelector, cls: ApplicationBaseComponent },@@ -254,4 +255,5 @@ export const globalDynamicComponents:OptionalBootstrapDefinition[] = [{ selector: backupSelector, cls: BackupComponent },{ selector: opInAppNotificationBellSelector, cls: InAppNotificationBellComponent },{ selector: ianMenuSelector, cls: IanMenuComponent },+ { selector: opModalOverlaySelector, cls: OpModalOverlayComponent },];diff --git a/frontend/src/app/core/setup/globals/global-listeners/preview-trigger.service.ts b/frontend/src/app/core/setup/globals/global-listeners/preview-trigger.service.tsindex 735c73006c5..3b6d7c5191e 100644--- a/frontend/src/app/core/setup/globals/global-listeners/preview-trigger.service.ts+++ b/frontend/src/app/core/setup/globals/global-listeners/preview-trigger.service.ts@@ -32,8 +32,6 @@ import { WpPreviewModalComponent } from 'core-app/shared/components/modals/previ@Injectable({ providedIn: 'root' })export class PreviewTriggerService {- private previewModal:WpPreviewModalComponent;-private modalElement:HTMLElement;private mouseInModal = false;@@ -54,14 +52,15 @@ export class PreviewTriggerService {return;}- this.previewModal = this.opModalService.show(+ this.opModalService.show(WpPreviewModalComponent,this.injector,{ workPackageLink: href, event: e },true,- );- this.modalElement = this.previewModal.elementRef.nativeElement;- this.previewModal.reposition(jQuery(this.modalElement), el);+ ).subscribe((previewModal) => {+ this.modalElement = previewModal.elementRef.nativeElement as HTMLElement;+ previewModal.reposition(jQuery(this.modalElement), el);+ });});jQuery(document.body).on('mouseleave', '.preview-trigger', () => {diff --git a/frontend/src/app/core/setup/globals/global-listeners/request-for-confirmation.ts b/frontend/src/app/core/setup/globals/global-listeners/request-for-confirmation.tsindex e830fa46b96..5386c79cea5 100644--- a/frontend/src/app/core/setup/globals/global-listeners/request-for-confirmation.ts+++ b/frontend/src/app/core/setup/globals/global-listeners/request-for-confirmation.ts@@ -33,7 +33,7 @@ function registerListener(form:JQuery,$event:JQuery.TriggeredEvent,opModalService:OpModalService,- modal:typeof PasswordConfirmationModalComponent,+ passwordModal:typeof PasswordConfirmationModalComponent,) {const passwordConfirm = form.find('_password_confirmation');@@ -42,20 +42,22 @@ function registerListener(}$event.preventDefault();- const modalComponent = opModalService.show(modal, 'global');- modalComponent.closingEvent.subscribe((confirmModal:any) => {- if (confirmModal.confirmed) {+ opModalService.show(passwordModal, 'global')+ .subscribe((modal) => modal.closingEvent.subscribe(() => {+ if (!modal.confirmed) {+ return;+ }+jQuery('<input>').attr({type: 'hidden',name: '_password_confirmation',- value: confirmModal.password_confirmation,+ value: modal.password_confirmation,}).appendTo(form);form.trigger('submit');- }- });+ }));return false;}diff --git a/frontend/src/app/features/boards/board/configuration-modal/board-configuration.modal.ts b/frontend/src/app/features/boards/board/configuration-modal/board-configuration.modal.tsindex bcd4e4f9b84..a3b42f8960b 100644--- a/frontend/src/app/features/boards/board/configuration-modal/board-configuration.modal.ts+++ b/frontend/src/app/features/boards/board/configuration-modal/board-configuration.modal.ts@@ -61,7 +61,7 @@ export class BoardConfigurationModalComponent extends OpModalComponent implement}ngOnInit() {- this.$element = jQuery(this.elementRef.nativeElement);+ this.$element = this.elementRef.nativeElement as HTMLElement;this.tabPortalHost = new TabPortalOutlet(this.boardConfigurationService.tabs,@@ -116,7 +116,7 @@ export class BoardConfigurationModalComponent extends OpModalComponent implementreturn true;}- protected get afterFocusOn():JQuery {+ protected get afterFocusOn():HTMLElement {return this.$element;}}diff --git a/frontend/src/app/features/invite-user-modal/invite-user-modal-augment.service.ts b/frontend/src/app/features/invite-user-modal/invite-user-modal-augment.service.tsindex 986edd490e4..452b675f1bd 100644--- a/frontend/src/app/features/invite-user-modal/invite-user-modal-augment.service.ts+++ b/frontend/src/app/features/invite-user-modal/invite-user-modal-augment.service.ts@@ -61,19 +61,17 @@ export class OpInviteUserModalAugmentService {private spawnModal(event:ClickEvent) {event.preventDefault();- const modal = this.opModalService.show(+ this.opModalService.show(InviteUserModalComponent,'global',{ projectId: this.currentProjectService.id },- );-- modal+ ).subscribe((modal) => modal.closingEvent.subscribe((modal:InviteUserModalComponent) => {// Just reload the page for now if we saved anythingif (modal.data) {window.location.reload();}- });+ }));}}diff --git a/frontend/src/app/features/invite-user-modal/invite-user-modal.service.ts b/frontend/src/app/features/invite-user-modal/invite-user-modal.service.tsindex d454838610a..f3c4d73fe5e 100644--- a/frontend/src/app/features/invite-user-modal/invite-user-modal.service.ts+++ b/frontend/src/app/features/invite-user-modal/invite-user-modal.service.ts@@ -47,16 +47,14 @@ export class OpInviteUserModalService {}public open(projectId:string|null = this.currentProjectService.id) {- const modal = this.opModalService.show(+ this.opModalService.show(InviteUserModalComponent,'global',{ projectId },- );-- modal+ ).subscribe((modal) => modal.closingEvent.subscribe((modal:InviteUserModalComponent) => {this.close.emit(modal.data);- });+ }));}}diff --git a/frontend/src/app/features/job-status/display-job-page/display-job-page.component.ts b/frontend/src/app/features/job-status/display-job-page/display-job-page.component.tsindex e685d23eb4c..795838f5410 100644--- a/frontend/src/app/features/job-status/display-job-page/display-job-page.component.ts+++ b/frontend/src/app/features/job-status/display-job-page/display-job-page.component.ts@@ -3,7 +3,6 @@ import {} from '@angular/core';import { StateService } from '@uirouter/core';import { OpModalService } from 'core-app/shared/components/modal/modal.service';-import { OpModalComponent } from 'core-app/shared/components/modal/modal.component';import { JobStatusModalComponent } from 'core-app/features/job-status/job-status-modal/job-status.modal';import { take } from 'rxjs/operators';@@ -11,25 +10,23 @@ import { take } from 'rxjs/operators';template: '',})export class DisplayJobPageComponent implements AfterViewInit, OnDestroy {- private modal?:OpModalComponent;-constructor(private $state:StateService,private modalService:OpModalService) {}ngAfterViewInit() {- this.modal = this.modalService.show(JobStatusModalComponent, 'global', { jobId: this.$state.params.jobId });- this.modal- .closingEvent- .pipe(- take(1),- ).subscribe(() => {- // Go back in history- window.history.back();- });+ this.modalService.show(JobStatusModalComponent, 'global', { jobId: this.$state.params.jobId })+ .subscribe((modal) => modal+ .closingEvent+ .pipe(+ take(1),+ ).subscribe(() => {+ // Go back in history+ window.history.back();+ }));}ngOnDestroy() {- this.modal?.closeMe();+ this.modalService.close();}}diff --git a/frontend/src/app/features/work-packages/components/wp-table/config-menu/config-menu.component.ts b/frontend/src/app/features/work-packages/components/wp-table/config-menu/config-menu.component.tsindex a53930376cd..801308c8b5d 100644--- a/frontend/src/app/features/work-packages/components/wp-table/config-menu/config-menu.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-table/config-menu/config-menu.component.ts@@ -1,5 +1,5 @@import { I18nService } from 'core-app/core/i18n/i18n.service';-import { Component, OnInit, Injector } from '@angular/core';+import { Component, Injector } from '@angular/core';import { OpModalService } from 'core-app/shared/components/modal/modal.service';import { OPContextMenuService } from 'core-app/shared/components/op-context-menu/op-context-menu.service';import { WpTableConfigurationModalComponent } from 'core-app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.modal';@@ -8,20 +8,17 @@ import { WpTableConfigurationModalComponent } from 'core-app/features/work-packatemplateUrl: './config-menu.template.html',selector: 'wp-table-config-menu',})-export class WorkPackagesTableConfigMenuComponent implements OnInit {- public text:any;+export class WorkPackagesTableConfigMenuComponent {+ public text = {+ configureTable: this.I18n.t('js.toolbar.settings.configure_view'),+ };- constructor(readonly I18n:I18nService,+ constructor(+ readonly I18n:I18nService,readonly injector:Injector,readonly opModalService:OpModalService,- readonly opContextMenu:OPContextMenuService) {- }-- ngOnInit():void {- this.text = {- configureTable: I18n.t('js.toolbar.settings.configure_view'),- };- }+ readonly opContextMenu:OPContextMenuService,+ ) { }public openTableConfigurationModal() {this.opContextMenu.close();diff --git a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.modal.ts b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.modal.tsindex c688f3d0e18..acd11707d5b 100644--- a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.modal.ts+++ b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.modal.ts@@ -45,8 +45,6 @@ export class WpTableConfigurationModalComponent extends OpModalComponent impleme/* Close on outside click */public closeOnOutsideClick = false;- public $element:JQuery;-public text = {title: this.I18n.t('js.work_packages.table_configuration.modal_title'),closePopup: this.I18n.t('js.close_popup_title'),@@ -94,7 +92,7 @@ export class WpTableConfigurationModalComponent extends OpModalComponent impleme}ngOnInit() {- this.$element = jQuery(this.elementRef.nativeElement);+ this.$element = this.elementRef.nativeElement as HTMLElement;this.tabPortalHost = new TabPortalOutlet(this.wpTableConfigurationService.tabs,@@ -148,7 +146,7 @@ export class WpTableConfigurationModalComponent extends OpModalComponent implemereturn true;}- protected get afterFocusOn():JQuery {+ protected get afterFocusOn():HTMLElement {return this.$element;}diff --git a/frontend/src/app/features/work-packages/components/wp-table/embedded/wp-embedded-table.component.ts b/frontend/src/app/features/work-packages/components/wp-table/embedded/wp-embedded-table.component.tsindex 7cca4bc3e72..91abe2b09dd 100644--- a/frontend/src/app/features/work-packages/components/wp-table/embedded/wp-embedded-table.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-table/embedded/wp-embedded-table.component.ts@@ -88,16 +88,13 @@ export class WorkPackageEmbeddedTableComponent extends WorkPackageEmbeddedBaseCo});}- public openConfigurationModal(onUpdated:() => void) {- this.querySpace.query- .valuesPromise()- .then(() => {- const modal = this.opModalService- .show(WpTableConfigurationModalComponent, this.injector);-- // Detach this component when the modal closes and pass along the query data- modal.onDataUpdated.subscribe(onUpdated);- });+ public async openConfigurationModal(onUpdated:() => void):Promise<void> {+ await this.querySpace.query.valuesPromise();++ this.opModalService+ .show(WpTableConfigurationModalComponent, this.injector)+ // Detach this component when the modal closes and pass along the query data+ .subscribe((modal) => modal.onDataUpdated.subscribe(onUpdated));}protected initializeStates(query:QueryResource) {diff --git a/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts b/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.tsindex c13882a4212..90e51747cb6 100644--- a/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts+++ b/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts@@ -257,10 +257,7 @@ export class PartitionedQuerySpacePageComponent extends WorkPackagesViewBase impprotected inviteModal = InviteUserModalComponent;openInviteUserModal():void {- const inviteModal = this.opModalService.show(this.inviteModal, 'global');- inviteModal.closingEvent.subscribe((modal:any) => {- console.log('Modal closed!', modal);- });+ this.opModalService.show(this.inviteModal, 'global');}protected loadQuery(firstPage = false):Promise<QueryResource> {diff --git a/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.modal.ts b/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.modal.tsindex b0833126183..0245e99d05c 100644--- a/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.modal.ts+++ b/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.modal.ts@@ -53,10 +53,12 @@ export class AttributeHelpTextModalComponent extends OpModalComponent implementspublic helpText:HelpTextResource = this.locals.helpText!;- constructor(@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,+ constructor(+ @Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,readonly I18n:I18nService,readonly cdRef:ChangeDetectorRef,- readonly elementRef:ElementRef) {+ readonly elementRef:ElementRef,+ ) {super(locals, cdRef, elementRef);}diff --git a/frontend/src/app/shared/components/attribute-help-texts/help-text.modal.html b/frontend/src/app/shared/components/attribute-help-texts/help-text.modal.htmlindex a0251f605b0..cf960dc6651 100644--- a/frontend/src/app/shared/components/attribute-help-texts/help-text.modal.html+++ b/frontend/src/app/shared/components/attribute-help-texts/help-text.modal.html@@ -28,20 +28,21 @@<div class="spot-action-bar--right"><buttontype="button"- class="button button_no-margin spot-action-bar--action spot-modal--cancel-button"+ class="button spot-action-bar--action spot-modal--cancel-button"(click)="closeMe()">{{ text.close }}</button>- <a- class="help-text--edit-button button button_no-margin spot-action-bar--action"+ <button+ class="help-text--edit-button button spot-action-bar--action"*ngIf="helpText.editText"[attr.href]="helpTextLink"[attr.title]="text.edit"+ type="button"><op-icon icon-classes="button--icon icon-edit"></op-icon><span class="button--text" [textContent]="text.edit"></span>- </a>+ </button></div></div></div>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 1b02baeea93..d2cd8ee08d6 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@@ -50,7 +50,7 @@ export class CombinedDateEditFieldComponent extends DatePickerEditFieldComponentthis.modal- .onDataUpdated+ ?.onDataUpdated.subscribe((dates:string) => {this.dates = dates;this.cdRef.detectChanges();diff --git a/frontend/src/app/shared/components/fields/edit/field-types/date-picker-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/date-picker-edit-field.component.tsindex 28a2d840af9..cff71a024c0 100644--- a/frontend/src/app/shared/components/fields/edit/field-types/date-picker-edit-field.component.ts+++ b/frontend/src/app/shared/components/fields/edit/field-types/date-picker-edit-field.component.ts@@ -49,7 +49,7 @@ export abstract class DatePickerEditFieldComponent extends EditFieldComponent im@InjectField() deviceService:DeviceService;- protected modal:SingleDateModalComponent|MultiDateModalComponent;+ protected modal:SingleDateModalComponent|MultiDateModalComponent|null = null;ngOnInit():void {super.ngOnInit();@@ -71,29 +71,28 @@ export abstract class DatePickerEditFieldComponent extends EditFieldComponent impublic showDatePickerModal():void {const component = this.change.schema.isMilestone ? SingleDateModalComponent : MultiDateModalComponent;- this.modal = this- .opModalService- .show<SingleDateModalComponent|MultiDateModalComponent>(- component,- this.injector,- { changeset: this.change, fieldName: this.name },- !this.deviceService.isMobile,- );+ this.opModalService.show<SingleDateModalComponent|MultiDateModalComponent>(+ component,+ this.injector,+ { changeset: this.change, fieldName: this.name },+ !this.deviceService.isMobile,+ ).subscribe((modal) => {+ this.modal = modal;- const { modal } = this;+ setTimeout(() => {+ const modalElement = jQuery(modal.elementRef.nativeElement).find('.op-datepicker-modal');+ const field = jQuery(this.elementRef.nativeElement);+ modal.reposition(modalElement, field);+ });- setTimeout(() => {- const modalElement = jQuery(modal.elementRef.nativeElement).find('.op-datepicker-modal');- const field = jQuery(this.elementRef.nativeElement);- modal.reposition(modalElement, field);+ (modal as OpModalComponent)+ .closingEvent+ .pipe(take(1))+ .subscribe(() => {+ this.modal = null;+ this.onModalClosed();+ });});-- (modal as OpModalComponent)- .closingEvent- .pipe(take(1))- .subscribe(() => {- this.onModalClosed();- });}protected onModalClosed():void {diff --git a/frontend/src/app/shared/components/grids/grid/add-widget.service.ts b/frontend/src/app/shared/components/grids/grid/add-widget.service.tsindex b6d84713deb..ac5cd60a7e1 100644--- a/frontend/src/app/shared/components/grids/grid/add-widget.service.ts+++ b/frontend/src/app/shared/components/grids/grid/add-widget.service.ts@@ -58,30 +58,35 @@ export class GridAddWidgetService {private select(area:GridArea) {return new Promise<GridWidgetResource>((resolve, reject) => {- const modal = this.opModalService.show(AddGridWidgetModalComponent, this.injector, { schema: this.layout.schema });- modal.closingEvent.subscribe((modal:AddGridWidgetModalComponent) => {- const registered = modal.chosenWidget;-- if (!registered) {- reject();- return;- }-- const source = {- _type: 'GridWidget',- identifier: registered.identifier,- startRow: area.startRow,- endRow: area.endRow,- startColumn: area.startColumn,- endColumn: area.endColumn,- options: registered.properties || {},- };-- const resource:GridWidgetResource = this.halResource.createHalResource(source);-- resource.grid = this.layout.gridResource;-- resolve(resource);+ this.opModalService.show(+ AddGridWidgetModalComponent,+ this.injector,+ { schema: this.layout.schema },+ ).subscribe((modal) => {+ modal.closingEvent.subscribe(() => {+ const registered = modal.chosenWidget;++ if (!registered) {+ reject();+ return;+ }++ const source = {+ _type: 'GridWidget',+ identifier: registered.identifier,+ startRow: area.startRow,+ endRow: area.endRow,+ startColumn: area.startColumn,+ endColumn: area.endColumn,+ options: registered.properties || {},+ };++ const resource:GridWidgetResource = this.halResource.createHalResource(source);++ resource.grid = this.layout.gridResource;++ resolve(resource);+ });});});}diff --git a/frontend/src/app/shared/components/grids/grid/grid.component.ts b/frontend/src/app/shared/components/grids/grid/grid.component.tsindex dbfc198fe6d..bd2ff29c2ac 100644--- a/frontend/src/app/shared/components/grids/grid/grid.component.ts+++ b/frontend/src/app/shared/components/grids/grid/grid.component.ts@@ -20,7 +20,7 @@ export interface WidgetRegistration {identifier:string;title:string;component:{ new (...args:any[]):AbstractWidgetComponent };- properties?:any;+ properties?:Record<string, unknown>;}export const GRID_PROVIDERS = [diff --git a/frontend/src/app/shared/components/grids/widgets/add/add.modal.html b/frontend/src/app/shared/components/grids/widgets/add/add.modal.htmlindex 6f7848e3d60..1273f255313 100644--- a/frontend/src/app/shared/components/grids/widgets/add/add.modal.html+++ b/frontend/src/app/shared/components/grids/widgets/add/add.modal.html@@ -1,9 +1,5 @@<divclass="spot-modal loading-indicator--location"- tabindex="0"- cdkFocusInitial- cdkTrapFocus- [cdkTrapFocusAutoCapture]="true"data-indicator-name="modal"><div class="spot-modal--header">{{text.title}}</div>diff --git a/frontend/src/app/shared/components/grids/widgets/menu/wp-set-menu.component.ts b/frontend/src/app/shared/components/grids/widgets/menu/wp-set-menu.component.tsindex a958042e554..04a3bcc6803 100644--- a/frontend/src/app/shared/components/grids/widgets/menu/wp-set-menu.component.ts+++ b/frontend/src/app/shared/components/grids/widgets/menu/wp-set-menu.component.ts@@ -31,16 +31,16 @@ import {} from '@angular/core';import { I18nService } from 'core-app/core/i18n/i18n.service';import { OpModalService } from 'core-app/shared/components/modal/modal.service';-import { OpModalComponent } from 'core-app/shared/components/modal/modal.component';import { GridRemoveWidgetService } from 'core-app/shared/components/grids/grid/remove-widget.service';import { ComponentType } from '@angular/cdk/portal';import { WidgetAbstractMenuComponent } from 'core-app/shared/components/grids/widgets/menu/widget-abstract-menu.component';import { WpGraphConfigurationModalComponent } from 'core-app/shared/components/work-package-graphs/configuration-modal/wp-graph-configuration.modal';import { GridAreaService } from 'core-app/shared/components/grids/grid/area.service';+import { WpTableConfigurationModalComponent } from 'core-app/features/work-packages/components/wp-table/configuration-modal/wp-table-configuration.modal';@Directive()export abstract class WidgetWpSetMenuComponent extends WidgetAbstractMenuComponent {- protected configurationComponent:ComponentType<OpModalComponent>;+ protected configurationComponent:ComponentType<WpGraphConfigurationModalComponent|WpTableConfigurationModalComponent>;@Output()onConfigured:EventEmitter<any> = new EventEmitter();@@ -64,10 +64,13 @@ export abstract class WidgetWpSetMenuComponent extends WidgetAbstractMenuComponereturn {linkText: this.i18n.t('js.toolbar.settings.configure_view'),onClick: () => {- this.opModalService.show(this.configurationComponent, this.injector, this.locals)- .closingEvent.subscribe((modal:WpGraphConfigurationModalComponent) => {- this.onConfigured.emit(modal.configuration);- });+ this.opModalService+ .show(this.configurationComponent, this.injector, this.locals)+ .subscribe((modal) => modal.closingEvent.subscribe(() => {+ if (modal instanceof WpGraphConfigurationModalComponent) {+ this.onConfigured.emit(modal.configuration);+ }+ }));return true;},};diff --git a/frontend/src/app/shared/components/grids/widgets/time-entries/current-user/configuration-modal/configuration.modal.ts b/frontend/src/app/shared/components/grids/widgets/time-entries/current-user/configuration-modal/configuration.modal.tsindex 9af4d6a40e6..3117d4c3e96 100644--- a/frontend/src/app/shared/components/grids/widgets/time-entries/current-user/configuration-modal/configuration.modal.ts+++ b/frontend/src/app/shared/components/grids/widgets/time-entries/current-user/configuration-modal/configuration.modal.ts@@ -21,8 +21,6 @@ export class TimeEntriesCurrentUserConfigurationModalComponent extends OpModalCo/* Close on outside click */public closeOnOutsideClick = true;- public $element:JQuery;-public text = {displayedDays: this.I18n.t('js.grid.widgets.time_entries_current_user.displayed_days'),closePopup: this.I18n.t('js.close_popup_title'),diff --git a/frontend/src/app/shared/components/grids/widgets/time-entries/current-user/time-entries-current-user-menu.component.ts b/frontend/src/app/shared/components/grids/widgets/time-entries/current-user/time-entries-current-user-menu.component.tsindex 8534cae1192..ec52f4bf841 100644--- a/frontend/src/app/shared/components/grids/widgets/time-entries/current-user/time-entries-current-user-menu.component.ts+++ b/frontend/src/app/shared/components/grids/widgets/time-entries/current-user/time-entries-current-user-menu.component.ts@@ -64,11 +64,13 @@ export class WidgetTimeEntriesCurrentUserMenuComponent extends WidgetAbstractMenlinkText: this.i18n.t('js.grid.configure'),onClick: () => {this.opModalService.show(TimeEntriesCurrentUserConfigurationModalComponent, this.injector, this.locals)- .closingEvent.subscribe((modal:TimeEntriesCurrentUserConfigurationModalComponent) => {- if (modal.options) {- this.onConfigured.emit(modal.options);- }- });+ .subscribe(+ (modal) => modal.closingEvent.subscribe(() => {+ if (modal.options) {+ this.onConfigured.emit(modal.options);+ }+ }),+ );return true;},};diff --git a/frontend/src/app/shared/components/modal/modal-overlay.component.html b/frontend/src/app/shared/components/modal/modal-overlay.component.htmlnew file mode 100644index 00000000000..70fd959d7c5--- /dev/null+++ b/frontend/src/app/shared/components/modal/modal-overlay.component.html@@ -0,0 +1,21 @@+<div+ class="spot-modal-overlay"+ [ngClass]="{+ 'spot-modal-overlay_active': (activeModalRef$ | async) !== null,+ 'spot-modal-overlay_not-full-screen': notFullscreen+ }"+ #overlay+ tabindex="0"+ cdkFocusInitial+ cdkTrapFocus+ (click)="close()"+>+ <button+ type="button"+ class="spot-button spot-modal-overlay--close-button"+ (click)="close()"+ >+ <span class="spot-icon spot-icon_close"></span>+ </button>+ <ng-template cdkPortalOutlet></ng-template>+</div>diff --git a/frontend/src/app/shared/components/modal/modal-overlay.component.ts b/frontend/src/app/shared/components/modal/modal-overlay.component.tsnew file mode 100644index 00000000000..089ff215a7a--- /dev/null+++ b/frontend/src/app/shared/components/modal/modal-overlay.component.ts@@ -0,0 +1,121 @@+// -- copyright+// OpenProject is an open source project management software.+// Copyright (C) 2012-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,+ ComponentRef,+ ElementRef,+ OnInit,+ ViewChild,+} from '@angular/core';+import {+ CdkPortalOutlet,+ ComponentPortal,+} from '@angular/cdk/portal';+import { I18nService } from 'core-app/core/i18n/i18n.service';+import { OpModalService } from 'core-app/shared/components/modal/modal.service';+import { OpModalComponent } from './modal.component';+import { ReplaySubject } from 'rxjs';++export const opModalOverlaySelector = 'op-modal-overlay';++@Component({+ selector: opModalOverlaySelector,+ templateUrl: './modal-overlay.component.html',+ changeDetection: ChangeDetectionStrategy.OnPush,+})+export class OpModalOverlayComponent implements OnInit {+ public notFullscreen = false;++ @ViewChild(CdkPortalOutlet) portalOutlet:CdkPortalOutlet;++ @ViewChild('overlay') overlay:ElementRef;++ activeModalData$ = this.modalService.activeModalData$;++ activeModalInstance$ = this.modalService.activeModalInstance$;++ activeModalRef$ = new ReplaySubject<OpModalComponent|null>();++ constructor(+ readonly modalService:OpModalService,+ readonly I18n:I18nService,+ ) { }++ ngOnInit():void {+ this.activeModalData$+ .subscribe((modalData) => {+ this.notFullscreen = false;++ if (modalData === null) {+ const ref = (this.portalOutlet.attachedRef as ComponentRef<OpModalComponent>);+ if (!ref) {+ return;+ }++ if (!ref.instance.onClose()) {+ return;+ }++ ref.instance.closingEvent.emit(ref.instance);+ this.activeModalRef$.next(null);+ this.activeModalInstance$.next(null);++ this.portalOutlet.detach();++ return;+ }++ const {+ modal,+ injector,+ notFullscreen,+ } = modalData;+ this.notFullscreen = notFullscreen;+ const portal = new ComponentPortal(modal, null, injector);+ const ref = this.portalOutlet.attach(portal);+ const instance = ref.instance;+ this.activeModalRef$.next(instance);++ this.activeModalInstance$.next(instance);+ setTimeout(() => {+ (this.overlay.nativeElement as HTMLElement).focus();+ // Focus on the first element+ instance && instance.onOpen();++ // Trigger another round of change detection in the modal+ ref.changeDetectorRef.detectChanges();+ }, 0);+ });+ }++ public close():void {+ this.modalService.close();+ }+}diff --git a/frontend/src/app/shared/components/modal/modal-wrapper-augment.service.ts b/frontend/src/app/shared/components/modal/modal-wrapper-augment.service.tsindex e6cea7faaba..6861f6eda60 100644--- a/frontend/src/app/shared/components/modal/modal-wrapper-augment.service.ts+++ b/frontend/src/app/shared/components/modal/modal-wrapper-augment.service.ts@@ -39,10 +39,11 @@ const iframeSelector = '.iframe-target-wrapper';*/@Injectable({ providedIn: 'root' })export class OpModalWrapperAugmentService {- constructor(@Inject(DOCUMENT) protected documentElement:Document,+ constructor(+ @Inject(DOCUMENT) protected documentElement:Document,protected injector:Injector,- protected opModalService:OpModalService) {- }+ protected opModalService:OpModalService,+ ) {}/*** Create initial listeners for Rails-rendered modalsdiff --git a/frontend/src/app/shared/components/modal/modal.component.ts b/frontend/src/app/shared/components/modal/modal.component.tsindex 921003ef866..6e41e6103ec 100644--- a/frontend/src/app/shared/components/modal/modal.component.ts+++ b/frontend/src/app/shared/components/modal/modal.component.ts@@ -18,7 +18,7 @@ export abstract class OpModalComponent extends UntilDestroyedMixin implements On/* Reference to service */protected service:OpModalService = this.locals.service;- public $element:JQuery;+ public $element:HTMLElement;/** Closing event called from the service when closing this modal */public closingEvent = new EventEmitter<this>();@@ -28,14 +28,16 @@ export abstract class OpModalComponent extends UntilDestroyedMixin implements On/* Data to be return from this modal instance */public data:unknown;- protected constructor(public locals:OpModalLocalsMap,+ protected constructor(+ public locals:OpModalLocalsMap,readonly cdRef:ChangeDetectorRef,- readonly elementRef:ElementRef) {+ readonly elementRef:ElementRef,+ ) {super();}ngOnInit() {- this.$element = jQuery(this.elementRef.nativeElement);+ this.$element = this.elementRef.nativeElement as HTMLElement;}ngOnDestroy() {@@ -67,7 +69,7 @@ export abstract class OpModalComponent extends UntilDestroyedMixin implements Onthis.cdRef.detectChanges();}- protected get afterFocusOn():JQuery {+ protected get afterFocusOn():HTMLElement {return this.$element;}}diff --git a/frontend/src/app/shared/components/modal/modal.module.ts b/frontend/src/app/shared/components/modal/modal.module.tsindex 839d21c0f66..1936f283fa4 100644--- a/frontend/src/app/shared/components/modal/modal.module.ts+++ b/frontend/src/app/shared/components/modal/modal.module.ts@@ -1,18 +1,24 @@import { NgModule } from '@angular/core';import { CommonModule } from '@angular/common';+import { PortalModule } from '@angular/cdk/portal';+import { A11yModule } from '@angular/cdk/a11y';import { FocusModule } from 'core-app/shared/directives/focus/focus.module';import { IconModule } from 'core-app/shared/components/icon/icon.module';import { OpModalService } from './modal.service';import { OpModalWrapperAugmentService } from './modal-wrapper-augment.service';import { OpModalBannerComponent } from 'core-app/shared/components/modal/modal-banner/modal-banner.component';+import { OpModalOverlayComponent } from 'core-app/shared/components/modal/modal-overlay.component';@NgModule({imports: [CommonModule,FocusModule,IconModule,+ PortalModule,+ A11yModule,],exports: [+ OpModalOverlayComponent,OpModalBannerComponent,],providers: [@@ -21,6 +27,7 @@ import { OpModalBannerComponent } from 'core-app/shared/components/modal/modal-b],declarations: [OpModalBannerComponent,+ OpModalOverlayComponent,],})export class OpenprojectModalModule { }diff --git a/frontend/src/app/shared/components/modal/modal.service.ts b/frontend/src/app/shared/components/modal/modal.service.tsindex 843fab968ce..070fc4034c8 100644--- a/frontend/src/app/shared/components/modal/modal.service.ts+++ b/frontend/src/app/shared/components/modal/modal.service.ts@@ -27,84 +27,39 @@//++import {- ApplicationRef,- ComponentFactoryResolver,- ComponentRef,Injectable,InjectionToken,Injector,} from '@angular/core';-import {- ComponentPortal,- ComponentType,- DomPortalOutlet,- PortalInjector,-} from '@angular/cdk/portal';-import { TransitionService } from '@uirouter/core';+import { ComponentType, PortalInjector } from '@angular/cdk/portal';import { OpModalComponent } from 'core-app/shared/components/modal/modal.component';+import { Observable, ReplaySubject } from 'rxjs';+import { filter, take } from 'rxjs/operators';export const OpModalLocalsToken = new InjectionToken<any>('OP_MODAL_LOCALS');@Injectable({ providedIn: 'root' })export class OpModalService {- public active:OpModalComponent|null = null;-- // Hold a reference to the DOM node we're using as a host- private readonly portalHostElement:HTMLElement;-- // And a reference to the actual portal host interface on top of the element- private bodyPortalHost:DomPortalOutlet;+ public activeModalInstance$ = new ReplaySubject<OpModalComponent|null>(1);- // Remember when we're opening a new modal to avoid the outside click bubbling up.- private opening = false;+ public activeModalData$ = new ReplaySubject<{+ modal:ComponentType<OpModalComponent>,+ injector:Injector,+ notFullscreen:boolean,+ }|null>(1);constructor(- private readonly componentFactoryResolver:ComponentFactoryResolver,- private readonly appRef:ApplicationRef,- private readonly $transitions:TransitionService,private readonly injector:Injector,) {- const hostElement = document.createElement('div');- hostElement.classList.add('spot-modal-overlay');- document.body.appendChild(hostElement);-- const closeButton = document.createElement('button');- closeButton.classList.add('spot-button', 'spot-modal-close-button');- closeButton.innerHTML = '<span class="spot-icon spot-icon_close"></span>';- hostElement.appendChild(closeButton);-// Listen to keystrokes on window to close context menuswindow.addEventListener('keydown', (evt:KeyboardEvent) => {- if (this.active && this.active.closeOnEscape && evt.key === 'Escape') {- this.active.closeOnEscapeFunction();+ if (evt.key !== 'Escape') {+ return;}- return true;- });- // Listen to any click on the modal overlay (backdrop click)- hostElement.addEventListener('click', (evt:MouseEvent) => {- if (this.active- && !this.opening- && this.portalHostElement === evt.target as Element) {- this.close();- }+ this.close();});-- closeButton.addEventListener('click', () => {- if (this.active && !this.opening) {- this.close();- }- });-- this.bodyPortalHost = new DomPortalOutlet(- hostElement,- this.componentFactoryResolver,- this.appRef,- this.injector,- );-- this.portalHostElement = hostElement;}/**@@ -114,63 +69,38 @@ export class OpModalService {* @param injector The injector to pass into the component. Ensure this is the hierarchical injector if needed.* Can be passed 'global' to take the default (global!) injector of this service.* @param locals A map to be injected via token into the component.- * @param notFullScreen Whether the modal is treated as non-overlay*/public show<T extends OpModalComponent>(modal:ComponentType<T>,injector:Injector|'global',locals:Record<string, unknown> = {},- notFullScreen = false,- ):T {+ notFullscreen = false,+ ):Observable<T> {this.close();- // Prevent closing events during the opening time frame.- this.opening = true;-// Allow users to pass the global injector when deliberately requested.if (injector === 'global') {injector = this.injector;}- // Create a portal for the given component class and render it- const portal = new ComponentPortal(modal, null, this.injectorFor(injector, locals));- const ref:ComponentRef<OpModalComponent> = this.bodyPortalHost.attach(portal) as ComponentRef<OpModalComponent>;- this.active = ref.instance as T;- this.portalHostElement.classList.add('spot-modal-overlay_active');- if (notFullScreen) {- this.portalHostElement.classList.add('spot-modal-overlay_not-full-screen');- }-- setTimeout(() => {- // Focus on the first element- this.active && this.active.onOpen();-- // Mark that we've opened the modal now- this.opening = false;-- // Trigger another round of change detection in the modal- ref.changeDetectorRef.detectChanges();- }, 20);-- return this.active as T;- }+ this.activeModalData$.next({+ modal,+ injector: this.injectorFor(injector, locals),+ notFullscreen,+ });- public isActive(modal:OpModalComponent):boolean {- return this.active !== null && this.active === modal;+ return this.activeModalInstance$+ .pipe(+ filter((m) => m !== null),+ take(1),+ ) as Observable<T>;}/*** Closes currently open modal window*/public close():void {- // Detach any component currently in the portal- if (this.active && this.active.onClose()) {- this.active.closingEvent.emit(this.active);- this.bodyPortalHost.detach();- this.portalHostElement.classList.remove('spot-modal-overlay_active');- this.portalHostElement.classList.remove('spot-modal-overlay_not-full-screen');- this.active = null;- }+ this.activeModalData$.next(null);}/**diff --git a/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.service.ts b/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.service.tsindex df7e9764c5b..e7e6b857dd0 100644--- a/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.service.ts+++ b/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.service.ts@@ -61,14 +61,17 @@ export class ConfirmDialogService {*/public confirm(options:ConfirmDialogOptions):Promise<void> {return new Promise<void>((resolve, reject) => {- const confirmModal = this.opModalService.show(ConfirmDialogModalComponent, this.injector, { options });- confirmModal.closingEvent.subscribe((modal:ConfirmDialogModalComponent) => {+ this.opModalService.show(+ ConfirmDialogModalComponent,+ this.injector,+ { options },+ ).subscribe((modal) => modal.closingEvent.subscribe(() => {if (modal.confirmed) {resolve();} else {reject();}- });+ }));});}diff --git a/frontend/src/app/shared/components/modals/editor/editor-macros.service.ts b/frontend/src/app/shared/components/modals/editor/editor-macros.service.tsindex aec476eede8..e7a42044256 100644--- a/frontend/src/app/shared/components/modals/editor/editor-macros.service.ts+++ b/frontend/src/app/shared/components/modals/editor/editor-macros.service.ts@@ -45,12 +45,15 @@ export class EditorMacrosService {*/public configureWorkPackageButton(typeName?:string, classes?:string):Promise<{ type:string, classes:string }> {return new Promise<{ type:string, classes:string }>((resolve, reject) => {- const modal = this.opModalService.show(WpButtonMacroModalComponent, this.injector, { type: typeName, classes });- modal.closingEvent.subscribe((modal:WpButtonMacroModalComponent) => {+ this.opModalService.show(+ WpButtonMacroModalComponent,+ this.injector,+ { type: typeName, classes },+ ).subscribe((modal) => modal.closingEvent.subscribe(() => {if (modal.changed) {resolve({ type: modal.type, classes: modal.classes });}- });+ }));});}@@ -61,12 +64,15 @@ export class EditorMacrosService {public configureWikiPageInclude(page:string):Promise<string> {return new Promise<string>((resolve, _) => {const pageValue = page || '';- const modal = this.opModalService.show(WikiIncludePageMacroModalComponent, this.injector, { page: pageValue });- modal.closingEvent.subscribe((modal:WikiIncludePageMacroModalComponent) => {+ this.opModalService.show(+ WikiIncludePageMacroModalComponent,+ this.injector,+ { page: pageValue },+ ).subscribe((modal) => modal.closingEvent.subscribe(() => {if (modal.changed) {resolve(modal.page);}- });+ }));});}@@ -76,12 +82,15 @@ export class EditorMacrosService {*/public editCodeBlock(content:string, languageClass:string):Promise<{ content:string, languageClass:string }> {return new Promise<{ content:string, languageClass:string }>((resolve, _) => {- const modal = this.opModalService.show(CodeBlockMacroModalComponent, this.injector, { content, languageClass });- modal.closingEvent.subscribe((modal:CodeBlockMacroModalComponent) => {+ this.opModalService.show(+ CodeBlockMacroModalComponent,+ this.injector,+ { content, languageClass },+ ).subscribe((modal) => modal.closingEvent.subscribe(() => {if (modal.changed) {resolve({ languageClass: modal.languageClass, content: modal.content });}- });+ }));});}@@ -91,15 +100,18 @@ export class EditorMacrosService {*/public configureChildPages(page:string, includeParent:string):Promise<object> {return new Promise<object>((resolve, _) => {- const modal = this.opModalService.show(ChildPagesMacroModalComponent, this.injector, { page, includeParent });- modal.closingEvent.subscribe((modal:ChildPagesMacroModalComponent) => {+ this.opModalService.show(+ ChildPagesMacroModalComponent,+ this.injector,+ { page, includeParent },+ ).subscribe((modal) => modal.closingEvent.subscribe(() => {if (modal.changed) {resolve({page: modal.page,includeParent: modal.includeParent,});}- });+ }));});}}diff --git a/frontend/src/app/shared/components/modals/export-modal/wp-table-export.modal.ts b/frontend/src/app/shared/components/modals/export-modal/wp-table-export.modal.tsindex aa985790bde..dcbfc444e4d 100644--- a/frontend/src/app/shared/components/modals/export-modal/wp-table-export.modal.ts+++ b/frontend/src/app/shared/components/modals/export-modal/wp-table-export.modal.ts@@ -35,7 +35,7 @@ export class WpTableExportModalComponent extends OpModalComponent implements OnI/* Close on outside click */public closeOnOutsideClick = true;- public $element:JQuery;+ public $element:HTMLElement;public exportOptions:{ identifier:string, label:string, url:string }[];@@ -46,7 +46,8 @@ export class WpTableExportModalComponent extends OpModalComponent implements OnIcancelButton: this.I18n.t('js.button_cancel'),};- constructor(@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,+ constructor(+ @Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,readonly I18n:I18nService,readonly elementRef:ElementRef,readonly querySpace:IsolatedQuerySpace,@@ -54,7 +55,8 @@ export class WpTableExportModalComponent extends OpModalComponent implements OnIreadonly httpClient:HttpClient,readonly wpTableColumns:WorkPackageViewColumnsService,readonly loadingIndicator:LoadingIndicatorService,- readonly toastService:ToastService) {+ readonly toastService:ToastService,+ ) {super(locals, cdRef, elementRef);}@@ -136,7 +138,7 @@ export class WpTableExportModalComponent extends OpModalComponent implements OnIreturn url.toString();}- protected get afterFocusOn():JQuery {- return jQuery('#work-packages-settings-button');+ protected get afterFocusOn():HTMLElement {+ return document.getElementById('work-packages-settings-button')!;}}diff --git a/frontend/src/app/shared/components/modals/modal-wrapper/dynamic-content.modal.html b/frontend/src/app/shared/components/modals/modal-wrapper/dynamic-content.modal.htmlindex 0841ea9e823..1589434941d 100644--- a/frontend/src/app/shared/components/modals/modal-wrapper/dynamic-content.modal.html+++ b/frontend/src/app/shared/components/modals/modal-wrapper/dynamic-content.modal.html@@ -1,4 +1,5 @@<divclass="spot-modal dynamic-content-modal--wrapper loading-indicator--location"+ #wrapperdata-indicator-name="modal"></div>diff --git a/frontend/src/app/shared/components/modals/modal-wrapper/dynamic-content.modal.ts b/frontend/src/app/shared/components/modals/modal-wrapper/dynamic-content.modal.tsindex cdf9a4360ba..78b96d67f16 100644--- a/frontend/src/app/shared/components/modals/modal-wrapper/dynamic-content.modal.ts+++ b/frontend/src/app/shared/components/modals/modal-wrapper/dynamic-content.modal.ts@@ -28,7 +28,7 @@import {ChangeDetectionStrategy,- ChangeDetectorRef, Component, ElementRef, Inject, OnDestroy, OnInit,+ ChangeDetectorRef, Component, ElementRef, Inject, OnDestroy, OnInit, ViewChild,} from '@angular/core';import { OpModalLocalsToken } from 'core-app/shared/components/modal/modal.service';import { OpModalLocalsMap } from 'core-app/shared/components/modal/modal.types';@@ -45,10 +45,14 @@ export class DynamicContentModalComponent extends OpModalComponent implements On// the modal when removing error messages or clicking on labels e.g. in the registration modal.public closeOnOutsideClick = false;- constructor(readonly elementRef:ElementRef,+ @ViewChild('wrapper') wrapper:HTMLElement;++ constructor(+ readonly elementRef:ElementRef,@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,readonly cdRef:ChangeDetectorRef,- readonly I18n:I18nService) {+ readonly I18n:I18nService,+ ) {super(locals, cdRef, elementRef);}@@ -56,13 +60,11 @@ export class DynamicContentModalComponent extends OpModalComponent implements Onsuper.ngOnInit();// Append the dynamic body- this.$element- .find('.dynamic-content-modal--wrapper')- .addClass(this.locals.modalClassName)- .append(this.locals.modalBody);+ this.wrapper.classList.add(this.locals.modalClassName);+ this.wrapper.appendChild(this.locals.modalBody);const modal = document.querySelector('.spot-modal') as HTMLElement;- const closeButton = modal.querySelector('[dynamic-content-modal-close-button]') as HTMLMetaElement;+ const closeButton = modal.querySelector('[dynamic-content-modal-close-button]') as HTMLButtonElement;closeButton.addEventListener('click', () => this.closeMe());}diff --git a/frontend/src/app/shared/components/modals/save-modal/save-query.modal.ts b/frontend/src/app/shared/components/modals/save-modal/save-query.modal.tsindex 5475f6f87bf..85bbafdae25 100644--- a/frontend/src/app/shared/components/modals/save-modal/save-query.modal.ts+++ b/frontend/src/app/shared/components/modals/save-modal/save-query.modal.ts@@ -66,7 +66,8 @@ export class SaveQueryModalComponent extends OpModalComponent {close_popup: this.I18n.t('js.close_popup_title'),};- constructor(readonly elementRef:ElementRef,+ constructor(+ readonly elementRef:ElementRef,@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,readonly I18n:I18nService,readonly states:States,@@ -74,7 +75,8 @@ export class SaveQueryModalComponent extends OpModalComponent {readonly wpListService:WorkPackagesListService,readonly halNotification:HalResourceNotificationService,readonly cdRef:ChangeDetectorRef,- readonly toastService:ToastService) {+ readonly toastService:ToastService,+ ) {super(locals, cdRef, elementRef);}@@ -88,7 +90,7 @@ export class SaveQueryModalComponent extends OpModalComponent {}public get afterFocusOn() {- return jQuery('#work-packages-settings-button');+ return document.getElementById('work-packages-settings-button')!;}public saveQueryAs($event:Event):void {diff --git a/frontend/src/app/shared/components/modals/share-modal/query-sharing.modal.ts b/frontend/src/app/shared/components/modals/share-modal/query-sharing.modal.tsindex 4609d7b089b..88e0d94f498 100644--- a/frontend/src/app/shared/components/modals/share-modal/query-sharing.modal.ts+++ b/frontend/src/app/shared/components/modals/share-modal/query-sharing.modal.ts@@ -64,7 +64,8 @@ export class QuerySharingModalComponent extends OpModalComponent implements OnInclose_popup: this.I18n.t('js.close_popup_title'),};- constructor(readonly elementRef:ElementRef,+ constructor(+ readonly elementRef:ElementRef,@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,readonly I18n:I18nService,readonly states:States,@@ -72,7 +73,8 @@ export class QuerySharingModalComponent extends OpModalComponent implements OnInreadonly cdRef:ChangeDetectorRef,readonly wpListService:WorkPackagesListService,readonly halNotification:HalResourceNotificationService,- readonly toastService:ToastService) {+ readonly toastService:ToastService,+ ) {super(locals, cdRef, elementRef);}@@ -91,7 +93,7 @@ export class QuerySharingModalComponent extends OpModalComponent implements OnIn}public get afterFocusOn() {- return jQuery('#work-packages-settings-button');+ return document.getElementById('work-packages-settings-button')!;}public saveQuery($event:Event):void {diff --git a/frontend/src/app/shared/components/time_entries/create/create.service.ts b/frontend/src/app/shared/components/time_entries/create/create.service.tsindex 26aa1774bfb..d4f6544f829 100644--- a/frontend/src/app/shared/components/time_entries/create/create.service.ts+++ b/frontend/src/app/shared/components/time_entries/create/create.service.ts@@ -38,21 +38,21 @@ export class TimeEntryCreateService {void this.createNewTimeEntry(date, wp).then((changeset) => {- const modal = this.opModalService.show(+ this.opModalService.show(TimeEntryCreateModalComponent,this.injector,{ ...options, changeset },- );-- modal- .closingEvent- .pipe(take(1))- .subscribe(() => {- if (modal.createdEntry) {- resolve({ entry: modal.createdEntry, action: 'create' });- } else {- reject();- }+ ).subscribe((modal) => {+ modal+ .closingEvent+ .pipe(take(1))+ .subscribe(() => {+ if (modal.createdEntry) {+ resolve({ entry: modal.createdEntry, action: 'create' });+ } else {+ reject();+ }+ });});});});diff --git a/frontend/src/app/shared/components/time_entries/edit/edit.service.ts b/frontend/src/app/shared/components/time_entries/edit/edit.service.tsindex 90b7f8c0f6e..cdc0417a4e2 100644--- a/frontend/src/app/shared/components/time_entries/edit/edit.service.ts+++ b/frontend/src/app/shared/components/time_entries/edit/edit.service.ts@@ -31,29 +31,25 @@ export class TimeEntryEditService {return new Promise<{ entry:TimeEntryResource, action:'update'|'destroy' }>((resolve, reject) => {void this.createChangeset(entry)- .then((changeset) => {- const modal = this.opModalService.show(- TimeEntryEditModalComponent,- this.injector,- { ...options, changeset },- );-- modal- .closingEvent- .pipe(take(1))- .subscribe(() => {- if (modal.destroyedEntry) {- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access- modal.destroyedEntry.delete().then(() => {- resolve({ entry: modal.destroyedEntry, action: 'destroy' });- });- } else if (modal.modifiedEntry) {- resolve({ entry: modal.modifiedEntry, action: 'update' });- } else {- reject();- }- });- });+ .then((changeset) => this.opModalService.show(+ TimeEntryEditModalComponent,+ this.injector,+ { ...options, changeset },+ ).subscribe((modal) => modal+ .closingEvent+ .pipe(take(1))+ .subscribe(() => {+ if (modal.destroyedEntry) {+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access+ void modal.destroyedEntry.delete().then(() => {+ resolve({ entry: modal.destroyedEntry, action: 'destroy' });+ });+ } else if (modal.modifiedEntry) {+ resolve({ entry: modal.modifiedEntry, action: 'update' });+ } else {+ reject();+ }+ })));});}diff --git a/frontend/src/app/shared/components/work-package-graphs/configuration-modal/wp-graph-configuration.modal.ts b/frontend/src/app/shared/components/work-package-graphs/configuration-modal/wp-graph-configuration.modal.tsindex 0ee311944ee..30af5cc521a 100644--- a/frontend/src/app/shared/components/work-package-graphs/configuration-modal/wp-graph-configuration.modal.ts+++ b/frontend/src/app/shared/components/work-package-graphs/configuration-modal/wp-graph-configuration.modal.ts@@ -43,7 +43,7 @@ export class WpGraphConfigurationModalComponent extends OpModalComponent impleme/* Close on outside click */public closeOnOutsideClick = false;- public $element:JQuery;+ public $element:HTMLElement;public text = {title: this.I18n.t('js.chart.modal_title'),@@ -79,7 +79,7 @@ export class WpGraphConfigurationModalComponent extends OpModalComponent impleme}ngOnInit():void {- this.$element = jQuery(this.elementRef.nativeElement);+ this.$element = this.elementRef.nativeElement as HTMLElement;this.loadingIndicator.indicator('modal').promise = this.graphConfiguration.loadForms().then(() => {@@ -134,7 +134,7 @@ export class WpGraphConfigurationModalComponent extends OpModalComponent implemereturn true;}- protected get afterFocusOn():JQuery {+ protected get afterFocusOn():HTMLElement {return this.$element;}}diff --git a/frontend/src/app/spot/components/drop-modal/drop-modal.component.html b/frontend/src/app/spot/components/drop-modal/drop-modal.component.htmlindex b9d622d49a2..8bd238a9cae 100644--- a/frontend/src/app/spot/components/drop-modal/drop-modal.component.html+++ b/frontend/src/app/spot/components/drop-modal/drop-modal.component.html@@ -1,9 +1,12 @@<ng-content select="[slot=trigger]"></ng-content><div+ *ngIf="open"[ngClass]="['spot-drop-modal--body', 'spot-container', alignmentClass]"+(click)="onBodyClick($event)"+cdkTrapFocus- *ngIf="open"+ tabindex="0"><ng-content select="[slot=body]"></ng-content>diff --git a/frontend/src/app/spot/spot.module.ts b/frontend/src/app/spot/spot.module.tsindex b7ec798807e..8ab5413d3db 100644--- a/frontend/src/app/spot/spot.module.ts+++ b/frontend/src/app/spot/spot.module.ts@@ -4,6 +4,7 @@ import {ReactiveFormsModule,} from '@angular/forms';import { CommonModule } from '@angular/common';+import { A11yModule } from '@angular/cdk/a11y';import { I18nService } from 'core-app/core/i18n/i18n.service';import { SpotCheckboxComponent } from './components/checkbox/checkbox.component';@@ -23,6 +24,7 @@ import { SpotSelectorFieldComponent } from './components/selector-field/selectorFormsModule,ReactiveFormsModule,CommonModule,+ A11yModule,],providers: [diff --git a/frontend/src/app/spot/styles/sass/components/modal-overlay.sass b/frontend/src/app/spot/styles/sass/components/modal-overlay.sassindex aff8382a2e0..e8d8010d134 100644--- a/frontend/src/app/spot/styles/sass/components/modal-overlay.sass+++ b/frontend/src/app/spot/styles/sass/components/modal-overlay.sass@@ -26,3 +26,13 @@right: unsetbottom: unsettop: initial++ &--close-button+ display: block+ margin: 1rem++ @media (min-width: 680px)+ display: none++ @media (max-height: 480px)+ align-self: end