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:
parent
a532cfb475
commit
e7e7e4d230
6 changed files with 65 additions and 29 deletions
|
@ -224,19 +224,30 @@
|
|||
// Display label in the middle of the item pane
|
||||
else {
|
||||
if (count) {
|
||||
if (count == 1) {
|
||||
let item = this.data[0];
|
||||
// If a collection or search is selected, it must be in the trash.
|
||||
if (item.isCollection()) {
|
||||
let subcollectionsCount = item.getDescendents(false, 'collection', true).length;
|
||||
msg = Zotero.getString('pane.collections.deletedCollection', subcollectionsCount);
|
||||
let key;
|
||||
// In the trash, we have to check the object type
|
||||
if (this.collectionTreeRow.isTrash()) {
|
||||
let obj = this.data[0];
|
||||
if (this.data.every(x => x.isCollection())) {
|
||||
key = 'item-pane-message-collections-selected';
|
||||
}
|
||||
else if (item.isSearch()) {
|
||||
msg = Zotero.getString('pane.collections.deletedSearch');
|
||||
else if (this.data.every(x => x.isSearch())) {
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
msg = Zotero.getString('pane.item.selected.multiple', count);
|
||||
else {
|
||||
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 {
|
||||
let rowCount = this.itemsView.rowCount;
|
||||
|
|
|
@ -2813,10 +2813,13 @@ var ItemTree = class ItemTree extends LibraryTree {
|
|||
|
||||
let itemTypeAriaLabel;
|
||||
try {
|
||||
if (item.isSearch() || item.isCollection()) {
|
||||
// Special treatment for trashed collections or searches since they are not an actual
|
||||
// item and do not have an item type
|
||||
itemTypeAriaLabel = Zotero.getString(`pane.collections.deleted${item._ObjectType}Aria`) + '.';
|
||||
// Special treatment for trashed collections or searches since they are not an actual
|
||||
// item and do not have an item type
|
||||
if (item.isSearch()) {
|
||||
itemTypeAriaLabel = Zotero.getString('searchConditions.collection') + '.';
|
||||
}
|
||||
else if (item.isCollection()) {
|
||||
itemTypeAriaLabel = Zotero.getString('searchConditions.savedSearch') + '.';
|
||||
}
|
||||
else {
|
||||
var itemType = Zotero.ItemTypes.getName(item.itemTypeID);
|
||||
|
@ -3823,20 +3826,16 @@ var ItemTree = class ItemTree extends LibraryTree {
|
|||
_getIcon(index) {
|
||||
var item = this.getRow(index).ref;
|
||||
|
||||
// TEMP
|
||||
// Non-item objects that can be appear in the trash
|
||||
if (item.isCollection() || item.isSearch()) {
|
||||
let iconClsName;
|
||||
let icon;
|
||||
if (item.isCollection()) {
|
||||
iconClsName = "IconTreeitemCollection";
|
||||
icon = getCSSIcon('collection');
|
||||
}
|
||||
if (item.isSearch()) {
|
||||
iconClsName = "IconTreeitemSearch";
|
||||
}
|
||||
var icon = getDOMElement(iconClsName);
|
||||
if (!icon) {
|
||||
Zotero.debug('Could not find tree icon for "' + itemType + '"');
|
||||
return document.createElement('span');
|
||||
else if (item.isSearch()) {
|
||||
icon = getCSSIcon('search');
|
||||
}
|
||||
icon.classList.add('icon-item-type');
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.DB.requireTransaction();
|
||||
|
|
|
@ -535,6 +535,24 @@ item-pane-header-bibEntry =
|
|||
item-pane-header-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.
|
||||
|
||||
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.
|
||||
|
|
|
@ -276,10 +276,6 @@ pane.collections.retracted = Retracted Items
|
|||
pane.collections.duplicate = Duplicate Items
|
||||
pane.collections.removeLibrary = Remove Library
|
||||
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.remove.library = Remove Library…
|
||||
|
|
|
@ -274,6 +274,12 @@ $-attachmentIcons: (
|
|||
attachment-video
|
||||
);
|
||||
|
||||
// Non-item objects that can appear in the trash
|
||||
$-trashableObjectIcons: (
|
||||
"collection",
|
||||
"search"
|
||||
);
|
||||
|
||||
.icon-item-type {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
|
@ -324,5 +330,11 @@ $-attachmentIcons: (
|
|||
background-origin: content-box;
|
||||
}
|
||||
}
|
||||
|
||||
@each $icon in $-trashableObjectIcons {
|
||||
.icon-css.icon-#{$icon} {
|
||||
@include svgicon($icon, $color, "16", "collection-tree");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue