Tweaks to trash functionality for collections and searches
- 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
6f53cf2f68
commit
c537d1ad28
6 changed files with 64 additions and 29 deletions
|
@ -222,19 +222,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;
|
||||||
|
|
|
@ -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
|
||||||
itemTypeAriaLabel = Zotero.getString(`pane.collections.deleted${item._ObjectType}Aria`) + '.';
|
if (item.isSearch()) {
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -509,3 +509,20 @@ item-pane-header-bibEntry =
|
||||||
.label = Bibliography Entry
|
.label = Bibliography Entry
|
||||||
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
|
||||||
|
}
|
||||||
|
|
|
@ -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…
|
||||||
|
|
|
@ -270,6 +270,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;
|
||||||
|
@ -320,5 +326,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");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue