vpat 50: rework data dir setting interface
Selecting custom data directory radio button in advanced settings opens up a modal to select the directory. It is not a typical behavior for radio button, so it conflicts with 3.2.2 success criteria. This is a rework of the data directory setting interface to be similar to LABD. It does not have radio buttons and the directory exporer pops up on button click
This commit is contained in:
parent
1d5971c48f
commit
fb7569a06e
4 changed files with 37 additions and 59 deletions
|
@ -50,18 +50,6 @@ Zotero_Preferences.Advanced = {
|
|||
document.getElementById('baseAttachmentPath').addEventListener('syncfrompreference',
|
||||
() => Zotero_Preferences.Attachment_Base_Directory.updateUI());
|
||||
|
||||
document.getElementById('data-dir').addEventListener('syncfrompreference', (event) => {
|
||||
event.target.value = this.onDataDirLoad();
|
||||
});
|
||||
|
||||
document.getElementById('data-dir').addEventListener('synctopreference', () => {
|
||||
this.onDataDirUpdate();
|
||||
});
|
||||
|
||||
document.getElementById('data-dir-path').addEventListener('syncfrompreference', (event) => {
|
||||
event.target.value = this.getDataDirPath();
|
||||
});
|
||||
|
||||
this.onDataDirLoad();
|
||||
|
||||
document.getElementById('fulltext-rebuildIndex').setAttribute('label',
|
||||
|
@ -350,64 +338,46 @@ Zotero_Preferences.Advanced = {
|
|||
|
||||
|
||||
onDataDirLoad: function () {
|
||||
var useDataDir = Zotero.Prefs.get('useDataDir');
|
||||
var dataDir = Zotero.Prefs.get('lastDataDir') || Zotero.Prefs.get('dataDir');
|
||||
var currentDir = Zotero.DataDirectory.dir;
|
||||
var defaultDataDir = Zotero.DataDirectory.defaultDir;
|
||||
|
||||
if (Zotero.forceDataDir) {
|
||||
document.getElementById('command-line-data-dir-path').textContent = currentDir;
|
||||
document.getElementById('command-line-data-dir').hidden = false;
|
||||
document.getElementById('data-dir').hidden = true;
|
||||
}
|
||||
|
||||
// Change "Use profile directory" label to home directory location unless using profile dir
|
||||
if (useDataDir || currentDir == defaultDataDir) {
|
||||
document.getElementById('default-data-dir').setAttribute(
|
||||
'label', Zotero.getString('dataDir.default', Zotero.DataDirectory.defaultDir)
|
||||
);
|
||||
}
|
||||
|
||||
// Don't show custom data dir as in-use if set to the default
|
||||
if (dataDir == defaultDataDir) {
|
||||
useDataDir = false;
|
||||
}
|
||||
|
||||
document.getElementById('data-dir-path').setAttribute('disabled', !useDataDir);
|
||||
document.getElementById('migrate-data-dir').setAttribute(
|
||||
'hidden', !Zotero.DataDirectory.canMigrate()
|
||||
);
|
||||
|
||||
return useDataDir;
|
||||
|
||||
let revertToDefaultDir = document.getElementById("reset-data-dir");
|
||||
revertToDefaultDir.hidden = this._usingDefaultDataDir();
|
||||
revertToDefaultDir.setAttribute('data-l10n-args', `{"tooltiptext": "${Zotero.DataDirectory.defaultDir}"}`);
|
||||
this.setDataDirInput();
|
||||
},
|
||||
|
||||
|
||||
onDataDirUpdate: Zotero.Promise.coroutine(function* (forceNew) {
|
||||
var radiogroup = document.getElementById('data-dir');
|
||||
var newUseDataDir = radiogroup.selectedIndex == 1;
|
||||
|
||||
if (!forceNew && newUseDataDir && !this._usingDefaultDataDir()) {
|
||||
return;
|
||||
}
|
||||
dataDirUpdate: Zotero.Promise.coroutine(function* (isCustomSelection) {
|
||||
if (!isCustomSelection && this._usingDefaultDataDir()) return;
|
||||
|
||||
// This call shows a filepicker if needed, forces a restart if required, and does nothing if
|
||||
// cancel was pressed or value hasn't changed
|
||||
yield Zotero.DataDirectory.choose(
|
||||
true,
|
||||
!newUseDataDir,
|
||||
!isCustomSelection,
|
||||
() => Zotero.launchURL('https://www.zotero.org/support/zotero_data')
|
||||
);
|
||||
radiogroup.selectedIndex = this._usingDefaultDataDir() ? 0 : 1;
|
||||
}),
|
||||
|
||||
|
||||
chooseDataDir: function() {
|
||||
let radiogroup = document.getElementById('data-dir');
|
||||
if (radiogroup.selectedIndex == 0) {
|
||||
radiogroup.selectedIndex = 1;
|
||||
setDataDirInput: async function () {
|
||||
var filefield = document.getElementById('data-dir-path');
|
||||
var path = Zotero.Prefs.get('dataDir');
|
||||
if (path && await IOUtils.exists(path)) {
|
||||
filefield.style.backgroundImage = 'url(moz-icon://' + Zotero.File.pathToFileURI(path) + '?size=16)';
|
||||
filefield.value = path;
|
||||
}
|
||||
else {
|
||||
this.onDataDirUpdate(true);
|
||||
filefield.value = '';
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
readonly="true"
|
||||
flex="1"
|
||||
tabindex="0"
|
||||
class="directory-path"
|
||||
aria-labelledby="baseAttachmentPathLabel"/>
|
||||
<button id="baseAttachmentPathButton"
|
||||
label="&zotero.preferences.attachmentBaseDir.selectBasePath;"
|
||||
|
@ -74,7 +75,7 @@
|
|||
aria-describedby="baseAttachmentPathLabel"/>
|
||||
</hbox>
|
||||
|
||||
<hbox>
|
||||
<hbox class="preferences-button-group">
|
||||
<button id="resetBasePath"
|
||||
label="&zotero.preferences.attachmentBaseDir.resetBasePath;"
|
||||
oncommand="Zotero_Preferences.Attachment_Base_Directory.clearPath()"
|
||||
|
@ -86,26 +87,25 @@
|
|||
<groupbox>
|
||||
<label><html:h2>&zotero.preferences.dataDir;</html:h2></label>
|
||||
|
||||
<radiogroup id="data-dir"
|
||||
preference="extensions.zotero.useDataDir">
|
||||
<radio id="default-data-dir" label="&zotero.preferences.dataDir.useProfile;" value="false"/>
|
||||
<hbox align="center">
|
||||
<radio label="&zotero.preferences.dataDir.custom;" value="true"/>
|
||||
<html:input type="text" id="data-dir-path" preference="extensions.zotero.dataDir"
|
||||
readonly="true" style="flex: 1"/>
|
||||
<button label="&zotero.preferences.dataDir.choose;"
|
||||
oncommand="return Zotero_Preferences.Advanced.chooseDataDir()"/>
|
||||
</hbox>
|
||||
</radiogroup>
|
||||
<hbox align="center">
|
||||
<label id="dara-dir-label" value="Data directory:" control="data-dir-path"></label>
|
||||
<html:input type="text" id="data-dir-path" preference="extensions.zotero.dataDir"
|
||||
readonly="true" class="directory-path"/>
|
||||
<button id="change-data-dir" label="&zotero.preferences.attachmentBaseDir.selectBasePath;"
|
||||
aria-describedby="dara-dir-label"
|
||||
oncommand="Zotero_Preferences.Advanced.dataDirUpdate(true)"/>
|
||||
</hbox>
|
||||
|
||||
<vbox id="command-line-data-dir" hidden="true">
|
||||
<description id="command-line-data-dir-path"/>
|
||||
<label value="&zotero.preferences.dataDir.viaCommandLine;"/>
|
||||
</vbox>
|
||||
|
||||
<hbox>
|
||||
<hbox class="preferences-button-group">
|
||||
<button label="&zotero.preferences.dataDir.reveal;"
|
||||
oncommand="Zotero.DataDirectory.reveal()"/>
|
||||
<button id="reset-data-dir" data-l10n-id="preferences-advanced-reset-data-dir"
|
||||
oncommand="Zotero_Preferences.Advanced.dataDirUpdate(false)"/>
|
||||
<button id="migrate-data-dir" label="&zotero.preferences.dataDir.migrate;"
|
||||
oncommand="Zotero_Preferences.Advanced.migrateDataDirectory()" hidden="true"/>
|
||||
</hbox>
|
||||
|
|
|
@ -74,3 +74,6 @@ preferences-advanced-enable-local-api =
|
|||
preferences-advanced-language-and-region-title = Language and Region
|
||||
preferences-advanced-enable-bidi-ui =
|
||||
.label = Enable bidirectional text editing utilities
|
||||
preferences-advanced-reset-data-dir =
|
||||
.label = Restore to default location
|
||||
.tooltiptext = { $tooltiptext }
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
align-items: center;
|
||||
}
|
||||
|
||||
#baseAttachmentPath {
|
||||
.directory-path {
|
||||
padding-inline-start: 24px;
|
||||
/* Background set in JS */
|
||||
background: none;
|
||||
|
@ -50,6 +50,11 @@
|
|||
border: none;
|
||||
}
|
||||
|
||||
.preferences-button-group {
|
||||
gap: 6px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
#zotero-prefpane-advanced-open-buttons {
|
||||
display: block;
|
||||
text-align: end;
|
||||
|
|
Loading…
Reference in a new issue