Skip to content

Commit e155f60

Browse files
GulomovCreativetheboxeropengeek
authored
Big trash refactor (#16600)
### What does it do? 1. Adds new "Trash" menu item to the top menu 2. Fixes #14190 3. Fixes trash button icon color change when its inactive 4. Removes unnecessary styles 5. Adds a purge button to the edit resource page 6. The resource tree and trash button state are now updates when a resource is deleted/undeleted on the resource update page 7. Fixes trash button tooltip information when purging resources on the trash page 8. Now when a resource have been delete/undelete in the resource tree, the state of the resource update form (checkbox and buttons) updates 9. Fixes undefined text of the trash button tooltip 10. Adds purge resource menu item to the context menu in the resource tree ### Why is it needed? There are many errors when deleting/restoring/purging resources ### How to test 1. — 2. Click by the middle mouse button on the trash button on the toolbar 3. Hover over the trash button when its inactive, before the icon changed color, now when inactive it does not 4. — 5. Open the edit resource page, delete it and you will see a new purging button 6. If you delete or restore a resource on the edit page, the resource tree and the trash button in the toolbar remain unchanged. Now the resource tree and the trash button will change their state 7. On the trash page when purging resources, the state of the trash button in the toolbar was not updated, now it will be 8. Create a resource, open its edit page and delete the resource **in the resource tree**, the state of the checkbox and buttons in the edit form will not change. Now everything works as it should. 9. If you delete a resource and when you hover the trash button, it will be undefined in the tooltip. Now the information will be correct 10. Open the context menu of resource tree, delete the resource and open again ### Related issue(s)/PR(s) #14190 --------- Co-authored-by: Jan Peca <[email protected]> Co-authored-by: Jason Coward <[email protected]>
1 parent c1f2213 commit e155f60

File tree

26 files changed

+294
-157
lines changed

26 files changed

+294
-157
lines changed

_build/data/transport.core.menus.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,14 @@
7979
'action' => 'system/contenttype',
8080
],
8181
// endregion
82-
82+
// region: Trash
83+
[
84+
'text' => 'trash',
85+
'description' => 'trash_desc',
86+
'permissions' => 'menu_trash',
87+
'action' => 'resource/trash',
88+
],
89+
// endregion
8390
],
8491
],
8592
// endregion

_build/templates/default/sass/_buttons.scss

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -672,12 +672,6 @@ html.ext-strict body #modx-container .x-small-editor .x-form-text {
672672
font-weight: 400;
673673
}
674674

675-
.tree-trash > em > button:before {
676-
@extend %pseudo-font;
677-
content: fa-content($fa-var-trash-alt);
678-
font-weight: 400;
679-
}
680-
681675
/* alignment overrides */
682676
#modx-leftbar .x-toolbar-ct .x-btn .tree-new-symlink > em > button {
683677
top: 4px;

_build/templates/default/sass/_tree.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -989,14 +989,15 @@
989989
#modx-leftbar-tabpanel__modx-trash-link {
990990
.icon {
991991
opacity: .5;
992-
&:hover {
993-
color: $red;
994-
}
995992
}
996993

997994
&.active {
998995
.icon {
999996
opacity: 1;
1000997
}
998+
999+
&:hover .icon {
1000+
color: $red;
1001+
}
10011002
}
10021003
}

_build/templates/default/sass/index.scss

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ a.x-grid-link:focus {
663663
background: scale-color($color: $red, $saturation: -10%, $lightness: 94%);
664664
font-weight: 400;
665665
}
666-
// The "Call Stack" header row
666+
// The "Call Stack" header row
667667
&[bgcolor^="#e9b"] {
668668
background: $colorSplash;
669669
color: $white !important;
@@ -1685,6 +1685,15 @@ iframe[classname="x-hidden"] {
16851685
color: $green;
16861686
}
16871687

1688+
#modx-abtn-purge {
1689+
background-color: $red;
1690+
color: $white;
1691+
1692+
&:hover {
1693+
background-color: darken($red, 10%);
1694+
}
1695+
}
1696+
16881697
#modx-abtn-help {
16891698
color: $colorSplash;
16901699
}

core/lexicon/en/resource.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
$_lang['resource_createdon'] = 'Created On';
4646
$_lang['resource_delete'] = 'Delete';
4747
$_lang['resource_delete_confirm'] = 'Are you sure you want to delete the resource: "[[+resource]]"?<br />NOTE: Any child resources will also be deleted!';
48+
$_lang['resource_purge'] = 'Erase resource';
49+
$_lang['resource_purge_confirm'] = 'Do you really want to finally erase the following resource: "[[+resource]]"?<br />WARNING: This cannot be undone.';
4850
$_lang['resource_description'] = 'Description';
4951
$_lang['resource_description_help'] = 'This is an optional description of the resource.';
5052
$_lang['resource_duplicate'] = 'Duplicate';

core/lexicon/en/topmenu.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@
119119
$_lang['tools_desc'] = 'Utilities to keep your site sorted';
120120
$_lang['topnav'] = 'Main Navigation';
121121
$_lang['topnav_desc'] = '';
122+
$_lang['trash'] = 'Trash';
123+
$_lang['trash_desc'] = 'Manage deleted resources.';
122124
$_lang['user'] = 'User';
123125
$_lang['usernav'] = 'User Navigation';
124126
$_lang['usernav_desc'] = '';

core/lexicon/en/trash.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
$_lang['trash.restore_all'] = 'Restore all';
2222
$_lang['trash.selected_purge'] = 'Erase selected resources';
2323
$_lang['trash.selected_restore'] = 'Restore selected resources';
24-
$_lang['trash.purge'] = 'Erase resource';
24+
$_lang['trash.purge'] = 'Erase';
2525
$_lang['trash.purge_confirm_title'] = 'Erase resource(s)?';
2626
$_lang['trash.purge_confirm_message'] = 'Do you really want to finally erase the following resource(s)? This cannot be undone.<hr>[[+list]]';
2727
$_lang['trash.purge_all_confirm_message'] = 'Do you really want to finally erase the listed [[+count]] resource(s)?<br><br><strong>This cannot be undone, and it affects all currently trashed resources in the grid.</strong><hr>[[+list]]';

core/src/Revolution/Processors/Resource/GetNodes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public function prepare()
109109
'edit_document' => $this->modx->hasPermission('edit_document') ? 'pedit' : '',
110110
'delete_document' => $this->modx->hasPermission('delete_document') ? 'pdelete' : '',
111111
'undelete_document' => $this->modx->hasPermission('undelete_document') ? 'pundelete' : '',
112+
'purge_deleted' => $this->modx->hasPermission('purge_deleted') ? 'ppurge' : '',
112113
'publish_document' => $this->modx->hasPermission('publish_document') ? 'ppublish' : '',
113114
'unpublish_document' => $this->modx->hasPermission('unpublish_document') ? 'punpublish' : '',
114115
'resource_duplicate' => $this->modx->hasPermission('resource_duplicate') ? 'pduplicate' : '',

core/src/Revolution/Processors/Resource/GetToolbar.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,10 @@ public function process()
9191

9292
$items[] = [
9393
'id' => 'emptifier',
94-
'cls' => 'tree-trash',
9594
'tooltip' => $this->modx->lexicon('trash.manage_recycle_bin_tooltip', [
9695
'count' => $deletedResources
9796
]),
98-
'disabled' => ($deletedResources == 0) ? true : false,
99-
'handler' => 'new Function("this.redirect(\"?a=resource/trash\");");'
97+
'disabled' => $deletedResources === 0
10098
];
10199
}
102100

core/src/Revolution/Processors/Resource/Trash/Purge.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,12 @@ public function process()
198198
}
199199
}
200200

201+
$deletedCount = $this->modx->getCount(modResource::class, ['deleted' => 1]);
202+
201203
return $this->success($msg, [
202204
'count_success' => count($success),
203-
'count_failures' => count($this->failures)
205+
'count_failures' => count($this->failures),
206+
'deletedCount' => $deletedCount,
204207
]);
205208
}
206209
}

0 commit comments

Comments
 (0)