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

[#43663] Delete/Unlink modal

Eric Schubert4f0e2ad8726c
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index 32fb28a7f6c..3ee9a99de5a 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -34,10 +34,12 @@ en:
updating: "Updating…"
attachments:
+ delete: "Delete attachment"
+ delete_confirmation: |
+ Are you sure you want to delete this file? This action is not reversible.
draggable_hint: |
Drag on editor field to inline image or reference attachment. Closed editor fields will be opened while you keep dragging.
-
autocomplete_select:
placeholder:
multi: "Add \"%{name}\""
@@ -831,7 +833,6 @@ en:
text_work_packages_destroy_confirmation: "Are you sure you want to delete the selected work package(s)?"
text_query_destroy_confirmation: "Are you sure you want to delete the selected view?"
- text_attachment_destroy_confirmation: "Are you sure you want to delete the attachment?"
timelines:
quarter_label: 'Q%{quarter_number}'
gantt_chart: 'Gantt chart'
diff --git a/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.component.ts b/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.component.ts
index b48676a7caf..4d26d6cdac7 100644
--- a/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.component.ts
+++ b/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.component.ts
@@ -52,6 +52,8 @@ import { IFileIcon } from 'core-app/shared/components/file-links/file-link-icons
import {
getIconForMimeType,
} from 'core-app/shared/components/file-links/file-link-icons/file-link-list-item-icon.factory';
+import { ConfirmDialogService } from 'core-app/shared/components/modals/confirm-dialog/confirm-dialog.service';
+import { ConfirmDialogOptions } from 'core-app/shared/components/modals/confirm-dialog/confirm-dialog.modal';
@Component({
// eslint-disable-next-line @angular-eslint/component-selector
@@ -72,7 +74,8 @@ export class AttachmentListItemComponent extends UntilDestroyedMixin implements
public text = {
dragHint: this.I18n.t('js.attachments.draggable_hint'),
- destroyConfirmation: this.I18n.t('js.text_attachment_destroy_confirmation'),
+ deleteTitle: this.I18n.t('js.attachments.delete'),
+ deleteConfirmation: this.I18n.t('js.attachments.delete_confirmation'),
removeFile: (arg:unknown):string => this.I18n.t('js.label_remove_file', arg),
};
@@ -92,6 +95,7 @@ export class AttachmentListItemComponent extends UntilDestroyedMixin implements
private readonly I18n:I18nService,
private readonly pathHelper:PathHelperService,
private readonly timezoneService:TimezoneService,
+ private readonly confirmDialogService:ConfirmDialogService,
private readonly principalsResourceService:PrincipalsResourceService,
private readonly principalRendererService:PrincipalRendererService,
) {
@@ -174,14 +178,21 @@ export class AttachmentListItemComponent extends UntilDestroyedMixin implements
return AttachmentListItemComponent.imageFileExtensions.indexOf(ext.toLowerCase()) > -1;
}
- public confirmRemoveAttachment($event:JQuery.TriggeredEvent):boolean {
- if (!window.confirm(this.text.destroyConfirmation)) {
- $event.stopImmediatePropagation();
- $event.preventDefault();
- return false;
- }
-
- this.removeAttachment.emit();
- return false;
+ public confirmRemoveAttachment():void {
+ const options:ConfirmDialogOptions = {
+ text: {
+ text: this.text.deleteConfirmation,
+ title: this.text.deleteTitle,
+ button_continue: this.text.deleteTitle,
+ },
+ icon: {
+ continue: 'delete',
+ },
+ dangerHighlighting: true,
+ };
+ void this.confirmDialogService
+ .confirm(options)
+ .then(() => { this.removeAttachment.emit(); })
+ .catch(() => { /* confirmation rejected */ });
}
}
diff --git a/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.html b/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.html
index dd5f6370096..12e666221f2 100644
--- a/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.html
+++ b/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.html
@@ -33,7 +33,7 @@
<button
class="spot-link"
[title]="deleteIconTitle"
- (click)="confirmRemoveAttachment($event)"
+ (click)="confirmRemoveAttachment()"
>
<span class="spot-icon spot-icon_delete"></span>
</button>
diff --git a/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.component.ts b/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.component.ts
index 6a73a5aeae7..485652021e1 100644
--- a/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.component.ts
+++ b/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.component.ts
@@ -48,6 +48,8 @@ import {
getIconForMimeType,
} from 'core-app/shared/components/file-links/file-link-icons/file-link-list-item-icon.factory';
import SpotDropAlignmentOption from 'core-app/spot/drop-alignment-options';
+import { ConfirmDialogOptions } from 'core-app/shared/components/modals/confirm-dialog/confirm-dialog.modal';
+import { ConfirmDialogService } from 'core-app/shared/components/modals/confirm-dialog/confirm-dialog.service';
@Component({
// eslint-disable-next-line @angular-eslint/component-selector
@@ -86,6 +88,8 @@ export class FileLinkListItemComponent implements OnInit, AfterViewInit {
floatingText: {
noViewPermission: this.i18n.t('js.storages.file_links.no_permission'),
},
+ removalTitle: this.i18n.t('js.storages.file_links.remove'),
+ removalButtonLabel: this.i18n.t('js.storages.file_links.remove_short'),
removalConfirmation: this.i18n.t('js.storages.file_links.remove_confirmation'),
notAllowdTooltipText: this.i18n.t('js.storages.file_links.not_allowed_tooltip'),
};
@@ -93,6 +97,7 @@ export class FileLinkListItemComponent implements OnInit, AfterViewInit {
constructor(
private readonly i18n:I18nService,
private readonly timezoneService:TimezoneService,
+ private readonly confirmDialogService:ConfirmDialogService,
private readonly principalRendererService:PrincipalRendererService,
) {}
@@ -136,8 +141,19 @@ export class FileLinkListItemComponent implements OnInit, AfterViewInit {
}
public confirmRemoveFileLink():void {
- if (window.confirm(this.text.removalConfirmation)) {
- this.removeFileLink.emit();
- }
+ const options:ConfirmDialogOptions = {
+ text: {
+ text: this.text.removalConfirmation,
+ title: this.text.removalTitle,
+ button_continue: this.text.removalButtonLabel,
+ },
+ icon: {
+ continue: 'remove-link',
+ },
+ };
+ void this.confirmDialogService
+ .confirm(options)
+ .then(() => { this.removeFileLink.emit(); })
+ .catch(() => { /* confirmation rejected */ });
}
}
diff --git a/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.modal.html b/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.modal.html
index cdd1103824d..03edaddb283 100644
--- a/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.modal.html
+++ b/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.modal.html
@@ -1,34 +1,50 @@
<div
class="spot-modal confirm-form-submit--modal loading-indicator--location"
- [ngClass]="{'-highlight' : dangerHighlighting }"
data-indicator-name="modal"
>
<div class="spot-modal--header">{{text.title}}</div>
- <div class="spot-divider"></div>
-
<div class="spot-modal--body">
- <p>
- <span [textContent]="text.text"></span>
+ <span [textContent]="text.text"></span>
+ <span *ngFor="let data of passedData">
<br/>
- <span *ngFor="let data of passedData">
- <br/>
- <strong>{{data}}</strong>
- </span>
- </p>
+ <strong>{{data}}</strong>
+ </span>
</div>
<div class="spot-modal--footer spot-action-bar">
<div class="spot-action-bar--right">
- <button class="confirm-form-submit--continue button button_no-margin spot-action-bar--action"
+ <button class="button button_no-margin spot-action-bar--action"
+ (click)="closeMe($event)"
+ >
+ <op-icon
+ *ngIf="icon.cancel as clazz"
+ icon-classes="button--icon spot-icon spot-icon_{{clazz}}"
+ class="op-icon--wrapper">
+ <i
+ class="button--icon spot-icon spot-icon_{{clazz}}"
+ ></i>
+ </op-icon>
+ <span
+ class="button--text"
+ >{{text.button_cancel}}</span>
+ </button>
+ <button class="button button_no-margin spot-action-bar--action"
[ngClass]="dangerHighlighting ? '-danger': '-highlight'"
(click)="confirmAndClose($event)"
- [textContent]="text.button_continue"
- ></button>
- <button class="confirm-form-submit--cancel button button_no-margin spot-action-bar--action"
- (click)="closeMe($event)"
- [textContent]="text.button_cancel"
- ></button>
+ >
+ <op-icon
+ *ngIf="icon.continue as clazz"
+ icon-classes="button--icon spot-icon spot-icon_{{clazz}}"
+ class="op-icon--wrapper">
+ <i
+ class="button--icon spot-icon spot-icon_{{clazz}}"
+ ></i>
+ </op-icon>
+ <span
+ class="button--text"
+ >{{text.button_continue}}</span>
+ </button>
</div>
</div>
</div>
diff --git a/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.modal.ts b/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.modal.ts
index 5927060f22e..e0caf6ce832 100644
--- a/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.modal.ts
+++ b/frontend/src/app/shared/components/modals/confirm-dialog/confirm-dialog.modal.ts
@@ -27,8 +27,13 @@
//++
import {
- ChangeDetectorRef, Component, ElementRef, Inject,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ Inject,
} from '@angular/core';
+
import { OpModalComponent } from 'core-app/shared/components/modal/modal.component';
import { OpModalLocalsToken } from 'core-app/shared/components/modal/modal.service';
import { OpModalLocalsMap } from 'core-app/shared/components/modal/modal.types';
@@ -41,6 +46,10 @@ export interface ConfirmDialogOptions {
button_continue?:string;
button_cancel?:string;
};
+ icon?:{
+ continue?:string;
+ cancel?:string;
+ };
closeByEscape?:boolean;
showClose?:boolean;
closeByDocument?:boolean;
@@ -50,6 +59,7 @@ export interface ConfirmDialogOptions {
@Component({
templateUrl: './confirm-dialog.modal.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ConfirmDialogModalComponent extends OpModalComponent {
public showClose:boolean;
@@ -58,7 +68,7 @@ export class ConfirmDialogModalComponent extends OpModalComponent {
private options:ConfirmDialogOptions;
- public text:any = {
+ public text = {
title: this.I18n.t('js.modals.form_submit.title'),
text: this.I18n.t('js.modals.form_submit.text'),
button_continue: this.I18n.t('js.button_continue'),
@@ -66,6 +76,11 @@ export class ConfirmDialogModalComponent extends OpModalComponent {
close_popup: this.I18n.t('js.close_popup_title'),
};
+ public icon = {
+ continue: undefined,
+ cancel: undefined,
+ };
+
public passedData:string[];
public dangerHighlighting:boolean;
@@ -75,15 +90,16 @@ export class ConfirmDialogModalComponent extends OpModalComponent {
readonly cdRef:ChangeDetectorRef,
readonly I18n:I18nService) {
super(locals, cdRef, elementRef);
- this.options = locals.options || {};
+ this.options = (locals.options || {}) as ConfirmDialogOptions;
this.dangerHighlighting = _.defaultTo(this.options.dangerHighlighting, false);
this.passedData = _.defaultTo(this.options.passedData, []);
this.closeOnEscape = _.defaultTo(this.options.closeByEscape, true);
this.closeOnOutsideClick = _.defaultTo(this.options.closeByDocument, true);
this.showClose = _.defaultTo(this.options.showClose, true);
- // override default texts if any
+ // override default texts and icons if any
this.text = _.defaults(this.options.text, this.text);
+ this.icon = _.defaults(this.options.icon, this.icon);
}
public confirmAndClose(evt:Event):void {
diff --git a/frontend/src/app/shared/components/modals/request-for-confirmation/password-confirmation.modal.html b/frontend/src/app/shared/components/modals/request-for-confirmation/password-confirmation.modal.html
index b789c17a732..fdaf391b8cf 100644
--- a/frontend/src/app/shared/components/modals/request-for-confirmation/password-confirmation.modal.html
+++ b/frontend/src/app/shared/components/modals/request-for-confirmation/password-confirmation.modal.html
@@ -11,8 +11,8 @@
<div class="form--field -required">
<label class="form--label"
for="request_for_confirmation_password"
- [attr.aria-label]="text.field_description"
- [textContent]="text.password">
+ [attr.aria-label]="additionalText.field_description"
+ [textContent]="additionalText.password">
</label>
<div class="form--field-container">
<div class="form--text-field-container">
@@ -24,7 +24,7 @@
class="form--text-field">
</div>
</div>
- <div class="form--field-instructions" [textContent]="text.field_description"></div>
+ <div class="form--field-instructions" [textContent]="additionalText.field_description"></div>
</div>
</div>
@@ -32,7 +32,7 @@
<div class="spot-action-bar--right">
<button
class="confirm-form-submit--continue button button_no-margin -highlight spot-action-bar--action"
- [textContent]="text.confirm_button"
+ [textContent]="additionalText.confirm_button"
[disabled]="!passwordValuePresent()">
>
</button>
diff --git a/frontend/src/app/shared/components/modals/request-for-confirmation/password-confirmation.modal.ts b/frontend/src/app/shared/components/modals/request-for-confirmation/password-confirmation.modal.ts
index b5fa5588b4b..52e3e05c5a7 100644
--- a/frontend/src/app/shared/components/modals/request-for-confirmation/password-confirmation.modal.ts
+++ b/frontend/src/app/shared/components/modals/request-for-confirmation/password-confirmation.modal.ts
@@ -26,26 +26,35 @@
// See COPYRIGHT and LICENSE files for more details.
//++
-import { ConfirmDialogModalComponent } from 'core-app/shared/components/modals/confirm-dialog/confirm-dialog.modal';
import {
- Component, ElementRef, OnInit, ViewChild,
+ ChangeDetectionStrategy,
+ Component,
+ ElementRef,
+ OnInit,
+ ViewChild,
} from '@angular/core';
+import { ConfirmDialogModalComponent } from 'core-app/shared/components/modals/confirm-dialog/confirm-dialog.modal';
+
@Component({
templateUrl: './password-confirmation.modal.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
export class PasswordConfirmationModalComponent extends ConfirmDialogModalComponent implements OnInit {
public password_confirmation:string|null = null;
@ViewChild('passwordConfirmationField', { static: true }) passwordConfirmationField:ElementRef;
+ public additionalText = {
+ field_description: I18n.t('js.password_confirmation.field_description'),
+ confirm_button: I18n.t('js.button_confirm'),
+ password: I18n.t('js.label_password'),
+ };
+
public ngOnInit():void {
super.ngOnInit();
this.text.title = I18n.t('js.password_confirmation.title');
- this.text.field_description = I18n.t('js.password_confirmation.field_description');
- this.text.confirm_button = I18n.t('js.button_confirm');
- this.text.password = I18n.t('js.label_password');
this.closeOnEscape = false;
this.closeOnOutsideClick = false;
diff --git a/modules/storages/config/locales/js-en.yml b/modules/storages/config/locales/js-en.yml
index 0f09de0a5ee..33d2af365d1 100644
--- a/modules/storages/config/locales/js-en.yml
+++ b/modules/storages/config/locales/js-en.yml
@@ -28,5 +28,8 @@ en:
open: 'Open file on storage'
open_location: 'Open file in location'
remove: "Remove file link"
- remove_confirmation: "Are you sure you want to unlink the file from the work package?"
+ remove_confirmation: >
+ Are you sure you want to unlink the file from this work package? Unlinking does not affect the original file
+ and only removes the connection to this work package.
+ remove_short: "Remove link"
not_allowed_tooltip: "Please log in to Nextcloud to access this file"