[28476] Acknowledge deletion of children

https://community.openproject.com/wp/28476
pull/6660/head
Oliver Günther 6 years ago
parent 543b0beffd
commit ef7459cd47
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 1
      config/locales/js-en.yml
  2. 25
      frontend/src/app/components/modals/wp-destroy-modal/wp-destroy.modal.html
  3. 20
      frontend/src/app/components/modals/wp-destroy-modal/wp-destroy.modal.ts
  4. 3
      spec/features/work_packages/table/delete_work_packages_spec.rb
  5. 6
      spec/support/components/work_packages/destroy_modal.rb
  6. 2
      spec/support/pages/split_work_package.rb

@ -697,6 +697,7 @@ en:
title: "Confirm deletion of %{label}" title: "Confirm deletion of %{label}"
text: "Are you sure you want to delete the following %{label} ?" text: "Are you sure you want to delete the following %{label} ?"
has_children: "The work package has %{childUnits}:" has_children: "The work package has %{childUnits}:"
confirm_deletion_children: "I acknowledge that ALL descendants of the listet work packages will be recursively removed."
deletes_children: "All child work packages and their descendants will also be recursively deleted." deletes_children: "All child work packages and their descendants will also be recursively deleted."
notice_successful_create: "Successful creation." notice_successful_create: "Successful creation."

@ -17,8 +17,8 @@
<section class="form--section -inner-scrolling"> <section class="form--section -inner-scrolling">
<h3 class="form--section-title" [textContent]="text.title"></h3> <h3 class="form--section-title" [textContent]="text.title"></h3>
<div *ngIf="singleWorkPackage" <div class="modal-inner-scrolling-container">
class="modal-inner-scrolling-container"> <ng-container *ngIf="singleWorkPackage">
<p> <p>
<span [textContent]="text.text"></span> <span [textContent]="text.text"></span>
<br/> <br/>
@ -44,9 +44,8 @@
<span [textContent]="text.deletesChildren"></span> <span [textContent]="text.deletesChildren"></span>
</p> </p>
</div> </div>
</div> </ng-container>
<ng-container *ngIf="workPackages.length > 1">
<div class="modal-inner-scrolling-container" *ngIf="workPackages.length > 1">
<p class="danger-zone--warning"> <p class="danger-zone--warning">
<span class="icon icon-error"></span> <span class="icon icon-error"></span>
<strong [textContent]="text.text"></strong> <strong [textContent]="text.text"></strong>
@ -54,19 +53,33 @@
<ul> <ul>
<li *ngFor="let wp of workPackages"> <li *ngFor="let wp of workPackages">
#<span [textContent]="wp.id"></span> #<span [textContent]="wp.id"></span>
&ngsp;
<span [textContent]="wp.subject"></span> <span [textContent]="wp.subject"></span>
<strong *ngIf="children(wp).length > 0"> <strong *ngIf="children(wp).length > 0">
(+ {{ text.childCount(wp) }}) (+ {{ text.childCount(wp) }})
</strong> </strong>
</li> </li>
</ul> </ul>
</ng-container>
<div *ngIf="mustConfirmChildren">
<label class="form--label-with-check-box">
<div class="form--check-box-container">
<input type="checkbox"
name="confirm-children-deletion"
id="confirm-children-deletion"
[(ngModel)]="childrenDeletionConfirmed"
class="form--check-box" />
</div>
{{ text.label_confirm_children_deletion }}
</label>
</div>
</div> </div>
</section> </section>
<div class="form--space -left-spacing"> <div class="form--space -left-spacing">
<button class="button -danger" <button class="button -danger"
[textContent]="text.confirm" [textContent]="text.confirm"
[attr.disabled]="busy || undefined" [attr.disabled]="busy || blockedDueToUnconfirmedChildren || undefined"
(click)="confirmDeletion($event)"> (click)="confirmDeletion($event)">
</button> </button>
<button class="button" <button class="button"

@ -53,6 +53,9 @@ export class WpDestroyModal extends OpModalComponent implements OnInit {
public singleWorkPackageChildren:WorkPackageResource[]; public singleWorkPackageChildren:WorkPackageResource[];
public busy = false; public busy = false;
// Need to confirm deletion when children are involved
public childrenDeletionConfirmed = false;
public text:any = { public text:any = {
label_visibility_settings: this.I18n.t('js.label_visibility_settings'), label_visibility_settings: this.I18n.t('js.label_visibility_settings'),
button_save: this.I18n.t('js.modals.button_save'), button_save: this.I18n.t('js.modals.button_save'),
@ -60,6 +63,7 @@ export class WpDestroyModal extends OpModalComponent implements OnInit {
warning: this.I18n.t('js.label_warning'), warning: this.I18n.t('js.label_warning'),
cancel: this.I18n.t('js.button_cancel'), cancel: this.I18n.t('js.button_cancel'),
close: this.I18n.t('js.close_popup_title'), close: this.I18n.t('js.close_popup_title'),
label_confirm_children_deletion: this.I18n.t('js.modals.destroy_work_package.confirm_deletion_children'),
}; };
constructor(readonly elementRef:ElementRef, constructor(readonly elementRef:ElementRef,
@ -105,9 +109,23 @@ export class WpDestroyModal extends OpModalComponent implements OnInit {
this.text.deletesChildren = this.I18n.t('js.modals.destroy_work_package.deletes_children'); this.text.deletesChildren = this.I18n.t('js.modals.destroy_work_package.deletes_children');
} }
public get blockedDueToUnconfirmedChildren() {
return this.mustConfirmChildren && !this.childrenDeletionConfirmed;
}
public get mustConfirmChildren() {
let result = false;
if (this.singleWorkPackage && this.singleWorkPackageChildren) {
let result = this.singleWorkPackageChildren.length > 0;
}
return result || !!_.find(this.workPackages, wp =>
wp.children && wp.children.length > 0);
}
public confirmDeletion($event:JQueryEventObject) { public confirmDeletion($event:JQueryEventObject) {
if (this.busy) { if (this.busy || this.blockedDueToUnconfirmedChildren) {
return false; return false;
} }

@ -72,7 +72,7 @@ describe 'Delete work package', js: true do
wp_table.visit! wp_table.visit!
wp_table.expect_work_package_listed wp1, wp2, wp_child wp_table.expect_work_package_listed wp1, wp2, wp_child
page.find('.work-package-table').send_keys [:control, 'a'] find('body').send_keys [:control, 'a']
context_menu.open_for(wp1) context_menu.open_for(wp1)
context_menu.choose('Bulk delete') context_menu.choose('Bulk delete')
@ -83,6 +83,7 @@ describe 'Delete work package', js: true do
context_menu.open_for(wp1) context_menu.open_for(wp1)
context_menu.choose('Bulk delete') context_menu.choose('Bulk delete')
destroy_modal.confirm_children_deletion
destroy_modal.confirm_deletion destroy_modal.confirm_deletion
loading_indicator_saveguard loading_indicator_saveguard

@ -50,6 +50,12 @@ module Components
end end
end end
def confirm_children_deletion
page.within(container) do
check 'confirm-children-deletion'
end
end
def confirm_deletion def confirm_deletion
page.within(container) do page.within(container) do
click_button 'Confirm' click_button 'Confirm'

@ -48,7 +48,7 @@ module Pages
end end
def closed? def closed?
expect(page).not_to have_selector(@selector) expect(page).to have_no_selector(@selector)
end end
def container def container

Loading…
Cancel
Save