Fix attachment box bugs

This commit is contained in:
windingwind 2024-01-13 21:50:24 +08:00 committed by Dan Stillman
parent b34d0d2acc
commit 61a5704dd4
5 changed files with 47 additions and 42 deletions

View file

@ -244,7 +244,7 @@
}
}
render() {
async render() {
Zotero.debug('Refreshing attachment box');
if (this.usePreview) {
@ -259,13 +259,12 @@
let indexStatusRow = this._id('indexStatusRow');
let selectButton = this._id('select-button');
let fileExists = await IOUtils.exists(this._item.getFilePath());
let isImportedURL = this.item.attachmentLinkMode == Zotero.Attachments.LINK_MODE_IMPORTED_URL;
let isLinkedURL = this.item.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_URL;
// Metadata for URL's
if (isImportedURL || isLinkedURL) {
// URL
if (this.displayURL) {
if (this.displayURL && (isImportedURL || isLinkedURL)) {
let urlSpec = this.item.getField('url');
urlField.setAttribute('value', urlSpec);
urlField.setAttribute('tooltiptext', urlSpec);
@ -288,7 +287,7 @@
}
// Access date
if (this.displayAccessed) {
if (this.displayAccessed && isImportedURL) {
let itemAccessDate = this.item.getField('accessDate');
if (itemAccessDate) {
itemAccessDate = Zotero.Date.sqlToDate(itemAccessDate, true);
@ -302,12 +301,6 @@
else {
accessed.hidden = true;
}
}
// Metadata for files
else {
urlField.hidden = true;
accessed.hidden = true;
}
if (this.displayFileName && !isLinkedURL) {
let fileName = this.item.attachmentFilename;
@ -345,7 +338,7 @@
pagesRow.hidden = true;
}
if (this.displayDateModified && !this._item.isWebAttachment()) {
if (this.displayDateModified && fileExists && !this._item.isWebAttachment()) {
// Conflict resolution uses a modal window, so promises won't work, but
// the sync process passes in the file mod time as dateModified
if (this.synchronous) {
@ -371,7 +364,7 @@
}
// Full-text index information
if (this.displayIndexed) {
if (this.displayIndexed && fileExists && await Zotero.FullText.canIndex(this.item)) {
this.updateItemIndexedState()
.then(function () {
if (!this.item) return;
@ -429,7 +422,7 @@
str = 'general.yes';
break;
}
indexStatus.value = Zotero.getString(str);
indexStatus.textContent = Zotero.getString(str);
// Reindex button tooltip (string stored in zotero.properties)
str = Zotero.getString('pane.items.menu.reindexItem');

View file

@ -70,7 +70,7 @@
transparent="transparent"
src="resource://zotero/reader/reader.html"
flex="1"/>
<html:img id="image-preview"></html:img>
<html:img id="image-preview" class="media-preview"></html:img>
<html:span class="icon"></html:span>
<html:div class="btn-container">
<toolbarbutton id="prev" class="btn-prev" ondblclick="event.stopPropagation()"
@ -324,6 +324,7 @@
media = document.createElement("audio");
}
media.id = mediaID;
media.classList.add("media-preview");
this._id("next-preview").after(media);
}
media.onload = () => {

View file

@ -130,6 +130,10 @@
grid-template-columns: subgrid;
grid-column: span 2;
&[hidden] {
display: none;
}
// On hover of the meta-row, reveal all hidden icons
// unless there's .noHover class which keeps everything hidden
&:not(.noHover):hover .show-on-hover,

View file

@ -25,8 +25,10 @@ attachment-box {
#index-status {
margin-inline: 0;
margin-block: 0;
height: 22px;
padding: 2px 4px;
margin-top: 2px;
@include comfortable {
margin-top: 3px;
}
}
#reindex

View file

@ -49,6 +49,7 @@ attachment-preview {
pdf: "attachment-pdf",
snapshot: "attachment-snapshot",
epub: "attachment-epub",
image: "document",
);
@each $cls, $icon in $preview-icons {
@ -176,6 +177,10 @@ attachment-preview {
display: none;
}
.media-preview {
display: none !important;
}
.icon {
display: inline-block;
opacity: 1;