Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically set a matching tag when setting an item's read status #39

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ Under Edit -> Settings -> Reading List you can configure the following options
| Custom Read Statuses and Icons[^1] | Choose custom Read Status names and icons. Keyboard shortcuts will work up to Alt+9. Note: if you delete a read status, it will remain assigned to any items - you'll need to delete / change their statuses manually. |
| Automatically Change Status When Opening Item's Attachment[^1] | If enabled, you can choose a custom mapping for how Read Statuses are updated when you open an item's PDF and start reading it (eg. New -> In Progress). |
| Automatically Label New Items[^1] | When adding new items to your Zotero library, do you want them to automatically be labelled with a particular read status? |
| Tag and Read Status Synchronisation[^1] | If enabled, matching tags will automatically be applied to items when you change their read status, so you can also filter by and change item read statuses with the corresponding tags when using the Zotero app |
| Tag and Read Status Synchronisation Format[^1] | Whether to show read status emojis in their corresponding tags. This causes an emoji with the read status to appear before the item's title |

[^1]: Only supported in the Zotero 7 version of the extension
4 changes: 3 additions & 1 deletion addon/chrome/content/preferences.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* Normally need to restart Zotero for these to take effect */

/* Add, save, reset buttons */
table > button {
/* readstatus <-> tags buttons */
table > button,
hbox > button {
margin: 5px;
}

Expand Down
37 changes: 37 additions & 0 deletions addon/chrome/content/preferences.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,43 @@
<menupopup> </menupopup>
</menulist>
</groupbox>

<!-- Automatic Tagging -->
<groupbox>
<label>
<html:h2 data-l10n-id="pref-tag-synchronisation-title"></html:h2>
</label>
<checkbox
id="zotero-prefpane-__addonRef__-tag-synchronisation"
preference="extensions.zotero.__addonRef__.tag-synchronisation"
data-l10n-id="pref-tag-synchronisation"
onclick="Zotero.__addonInstance__.prefsMenu.tagSynchronisationToggled(window)"
/>
<radiogroup
preference="extensions.zotero.__addonRef__.tag-synchronisation-format"
>
<radio
value="0"
data-l10n-id="pref-tag-synchronisation-format-emoji"
/>
<radio
value="1"
data-l10n-id="pref-tag-synchronisation-format-noemoji"
/>
</radiogroup>
<hbox>
<html:button
id="tags-to-readstatus"
onclick="Zotero.__addonInstance__.data.zoteroReadingListOverlay.updateAllItemsReadStatusesToMatchTags()"
data-l10n-id="pref-tag-synchronisation-button-tags-to-readstatus"
/>
<html:button
id="readstatus-to-tags"
onclick="Zotero.__addonInstance__.data.zoteroReadingListOverlay.updateAllItemsTagsToMatchReadStatuses()"
data-l10n-id="pref-tag-synchronisation-button-readstatus-to-tags"
/>
</hbox>
</groupbox>
</vbox>
<vbox class="main-section">
<html:label
Expand Down
23 changes: 22 additions & 1 deletion addon/locale/en-US/addon.ftl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
addon-title = Zotero Reading List
menupopup-label = Read Status
read-status = Read Status
status-none = None
Expand All @@ -13,4 +14,24 @@ duplicate-status-names-description = Two or more custom reading status names are
invalid-status-names-title = Custom Reading Statuses Contains Invalid Characters
invalid-status-names-description = Custom reading statuses and icons cannot contain the characters ; or |. Please remove these characters.

autolabelnewitems-disabled = Disabled
autolabelnewitems-disabled = Disabled
enable-tag-synchronisation-title = Update tags to match read statuses?
enable-tag-synchronisation-prompt = You just enabled tag and read status synchronisation. Do you want to update all items' tags to match their read statuses?
tags-to-readstatus-message-progress = { $numItems ->
[one] Updating item read statuses to match tags for { $numItems } item in library
*[other] Updating item read statuses to match tags for { $numItems } items in library
}
readstatus-to-tags-message-progress = { $numItems ->
[one] Updating item tags to match read statuses for { $numItems } item in library
*[other] Updating item tags to match read statuses for { $numItems } items in library
}
tags-to-readstatus-message-done = { $numItems ->
[one] Updated item read statuses to match tags for { $numItems } item in library
*[other] Updated item read statuses to match tags for { $numItems } items in library
}
readstatus-to-tags-message-done = { $numItems ->
[one] Updated item tags to match read statuses for { $numItems } item in library
*[other] Updated item tags to match read statuses for { $numItems } items in library
}
tags-to-readstatus-message-error = Error updating read statuses to match tags
readstatus-to-tags-message-error = Error updating tags to match read statuses
10 changes: 10 additions & 0 deletions addon/locale/en-US/preferences.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pref-enable-keyboard-shortcuts =
.label = Enable keyboard shortcuts (Alt+0,1,2,3,4,5, ...). This disables Zotero's column sorting shortcuts!
pref-label-new-items =
.label = Automatically label items as "New" when you add them to Zotero
pref-tag-synchronisation =
.label = Automatically set a Zotero tag matching an item's read status
pref-label-items-when-opening-file =
.label = Automatically change the read status of items when opening an attached file
pref-help = { $name } Build { $version } { $time }
Expand All @@ -26,6 +28,14 @@ pref-statuslabeltable-button-add = Add New Status
pref-statuslabeltable-button-save = Save
pref-statuslabeltable-button-reset = Reset to Default

pref-tag-synchronisation-title = Tag and Read Status Synchronisation
pref-tag-synchronisation-button-tags-to-readstatus = Update Read Status to Match Tags
pref-tag-synchronisation-button-readstatus-to-tags = Update Tags to Match Read Status
pref-tag-synchronisation-format-emoji =
.label = Show emoji in tags
pref-tag-synchronisation-format-noemoji =
.label = Don't show emoji in tags

pref-openitemtable-title = Custom Status Changes When Opening Item
pref-openitemtable-header-statusfrom = Status From
pref-openitemtable-header-statusto = Status To
Expand Down
13 changes: 7 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zotero-reading-list",
"version": "1.5.7",
"version": "1.6.0-beta.2",
"description": "Keep track of whether you've read items in Zotero",
"config": {
"addonName": "Zotero Reading List",
Expand Down
2 changes: 2 additions & 0 deletions src/addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ColumnOptions } from "zotero-plugin-toolkit/dist/helpers/virtualizedTab
import { DialogHelper } from "zotero-plugin-toolkit/dist/helpers/dialog";
import hooks from "./hooks";
import prefsMenu from "./prefs-menu";
import ZoteroReadingList from "./modules/overlay";
import { createZToolkit } from "./utils/ztoolkit";

class Addon {
Expand All @@ -19,6 +20,7 @@ class Addon {
rows: Array<{ [dataKey: string]: string }>;
};
dialog?: DialogHelper;
zoteroReadingListOverlay?: ZoteroReadingList;
};
// Lifecycle hooks
public hooks: typeof hooks;
Expand Down
6 changes: 2 additions & 4 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { config } from "../package.json";
import { initLocale } from "./utils/locale";
import { createZToolkit } from "./utils/ztoolkit";

let zoteroReadingList: ZoteroReadingList;

async function onStartup() {
await Promise.all([
Zotero.initializationPromise,
Expand All @@ -28,12 +26,12 @@ async function onStartup() {
async function onMainWindowLoad(win: Window): Promise<void> {
// Create ztoolkit for every window
addon.data.ztoolkit = createZToolkit();
zoteroReadingList = new ZoteroReadingList();
addon.data.zoteroReadingListOverlay = new ZoteroReadingList();
}

// eslint-disable-next-line @typescript-eslint/require-await
async function onMainWindowUnload(win: Window): Promise<void> {
zoteroReadingList.unload();
addon.data.zoteroReadingListOverlay?.unload();
ztoolkit.unregisterAll();
addon.data.dialog?.window?.close();
}
Expand Down
Loading