Tweaks to trash functionality for collections and searches (#3307)

- Use SVG icons
- Show "[x] collection selected" or "[x] searches selected" in the item pane
- Show "[x] objects selected" if multiple types are selected, which I
  don't love, but I don't have a better idea
- Use existing strings for ARIA labels
This commit is contained in:
Dan Stillman 2024-05-13 07:07:12 -04:00
parent a532cfb475
commit e7e7e4d230
6 changed files with 65 additions and 29 deletions

View file

@ -224,19 +224,30 @@
// Display label in the middle of the item pane // Display label in the middle of the item pane
else { else {
if (count) { if (count) {
if (count == 1) { let key;
let item = this.data[0]; // In the trash, we have to check the object type
// If a collection or search is selected, it must be in the trash. if (this.collectionTreeRow.isTrash()) {
if (item.isCollection()) { let obj = this.data[0];
let subcollectionsCount = item.getDescendents(false, 'collection', true).length; if (this.data.every(x => x.isCollection())) {
msg = Zotero.getString('pane.collections.deletedCollection', subcollectionsCount); key = 'item-pane-message-collections-selected';
} }
else if (item.isSearch()) { else if (this.data.every(x => x.isSearch())) {
msg = Zotero.getString('pane.collections.deletedSearch'); key = 'item-pane-message-searches-selected';
}
else if (this.data.every(x => x.isItem())) {
key = 'item-pane-message-items-selected';
}
else {
key = 'item-pane-message-objects-selected';
} }
} }
else {
msg = Zotero.getString('pane.item.selected.multiple', count); key = 'item-pane-message-items-selected';
}
// TODO: Add mechanism for this to setItemPaneMessage()
let elem = document.createXULElement('description');
document.l10n.setAttributes(elem, key, { count });
msg = elem;
} }
else { else {
let rowCount = this.itemsView.rowCount; let rowCount = this.itemsView.rowCount;

View file

@ -2813,10 +2813,13 @@ var ItemTree = class ItemTree extends LibraryTree {
let itemTypeAriaLabel; let itemTypeAriaLabel;
try { try {
if (item.isSearch() || item.isCollection()) { // Special treatment for trashed collections or searches since they are not an actual
// Special treatment for trashed collections or searches since they are not an actual // item and do not have an item type
// item and do not have an item type if (item.isSearch()) {
itemTypeAriaLabel = Zotero.getString(`pane.collections.deleted${item._ObjectType}Aria`) + '.'; itemTypeAriaLabel = Zotero.getString('searchConditions.collection') + '.';
}
else if (item.isCollection()) {
itemTypeAriaLabel = Zotero.getString('searchConditions.savedSearch') + '.';
} }
else { else {
var itemType = Zotero.ItemTypes.getName(item.itemTypeID); var itemType = Zotero.ItemTypes.getName(item.itemTypeID);
@ -3823,20 +3826,16 @@ var ItemTree = class ItemTree extends LibraryTree {
_getIcon(index) { _getIcon(index) {
var item = this.getRow(index).ref; var item = this.getRow(index).ref;
// TEMP // Non-item objects that can be appear in the trash
if (item.isCollection() || item.isSearch()) { if (item.isCollection() || item.isSearch()) {
let iconClsName; let icon;
if (item.isCollection()) { if (item.isCollection()) {
iconClsName = "IconTreeitemCollection"; icon = getCSSIcon('collection');
} }
if (item.isSearch()) { else if (item.isSearch()) {
iconClsName = "IconTreeitemSearch"; icon = getCSSIcon('search');
}
var icon = getDOMElement(iconClsName);
if (!icon) {
Zotero.debug('Could not find tree icon for "' + itemType + '"');
return document.createElement('span');
} }
icon.classList.add('icon-item-type');
return icon; return icon;
} }

View file

@ -691,7 +691,7 @@ Zotero.Collection.prototype.trash = Zotero.Promise.coroutine(function* (env) {
}); });
/** /**
* Completely erases the collection and it's descendants. * Completely erase the collection and its descendants.
**/ **/
Zotero.Collection.prototype._eraseData = Zotero.Promise.coroutine(function* (env) { Zotero.Collection.prototype._eraseData = Zotero.Promise.coroutine(function* (env) {
Zotero.DB.requireTransaction(); Zotero.DB.requireTransaction();

View file

@ -535,6 +535,24 @@ item-pane-header-bibEntry =
item-pane-header-more-options = item-pane-header-more-options =
.label = More Options .label = More Options
item-pane-message-items-selected = { $count ->
[one] { $count } item selected
*[other] { $count } items selected
}
item-pane-message-collections-selected = { $count ->
[one] { $count } collection selected
*[other] { $count } collections selected
}
item-pane-message-searches-selected = { $count ->
[one] { $count } search selected
*[other] { $count } searches selected
}
item-pane-message-objects-selected = { $count ->
[one] { $count } object selected
*[other] { $count } objects selected
}
locate-library-lookup-no-resolver = You must choose a resolver from the { $pane } pane of the { -app-name } settings. locate-library-lookup-no-resolver = You must choose a resolver from the { $pane } pane of the { -app-name } settings.
architecture-win32-warning-message = { -app-name } is running in 32-bit mode on a 64-bit version of Windows. { -app-name } will run more efficiently in 64-bit mode. architecture-win32-warning-message = { -app-name } is running in 32-bit mode on a 64-bit version of Windows. { -app-name } will run more efficiently in 64-bit mode.

View file

@ -276,10 +276,6 @@ pane.collections.retracted = Retracted Items
pane.collections.duplicate = Duplicate Items pane.collections.duplicate = Duplicate Items
pane.collections.removeLibrary = Remove Library pane.collections.removeLibrary = Remove Library
pane.collections.removeLibrary.text = Are you sure you want to permanently remove “%S” from this computer? pane.collections.removeLibrary.text = Are you sure you want to permanently remove “%S” from this computer?
pane.collections.deletedCollection = Deleted collection with %1$S subcollections
pane.collections.deletedCollectionAria = Deleted collection
pane.collections.deletedSearch = Deleted search
pane.collections.deletedSearchAria = Deleted search
pane.collections.menu.duplicate.savedSearch = Duplicate Saved Search pane.collections.menu.duplicate.savedSearch = Duplicate Saved Search
pane.collections.menu.remove.library = Remove Library… pane.collections.menu.remove.library = Remove Library…

View file

@ -274,6 +274,12 @@ $-attachmentIcons: (
attachment-video attachment-video
); );
// Non-item objects that can appear in the trash
$-trashableObjectIcons: (
"collection",
"search"
);
.icon-item-type { .icon-item-type {
width: 16px; width: 16px;
height: 16px; height: 16px;
@ -324,5 +330,11 @@ $-attachmentIcons: (
background-origin: content-box; background-origin: content-box;
} }
} }
@each $icon in $-trashableObjectIcons {
.icon-css.icon-#{$icon} {
@include svgicon($icon, $color, "16", "collection-tree");
}
}
} }
} }