vpat 50: advanced settings - rework custom data directory section (#4048)
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 explorer pops up on button click.
This commit is contained in:
parent
8e87aa15e7
commit
28f3a29f35
4 changed files with 60 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',
|
||||
|
@ -354,64 +342,54 @@ 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 changeDataDir = document.getElementById("change-data-dir");
|
||||
changeDataDir.hidden = this._usingDefaultDataDir();
|
||||
|
||||
let customDataDir = document.getElementById("custom-data-dir");
|
||||
customDataDir.hidden = !this._usingDefaultDataDir();
|
||||
|
||||
let revertToDefaultDir = document.getElementById("reset-data-dir");
|
||||
let revertToDefaultDirLabel = document.getElementById("default-data-dir");
|
||||
revertToDefaultDir.hidden = this._usingDefaultDataDir();
|
||||
revertToDefaultDirLabel.hidden = this._usingDefaultDataDir();
|
||||
document.l10n.setArgs(revertToDefaultDirLabel, { directory: 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 = '';
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
readonly="true"
|
||||
flex="1"
|
||||
tabindex="0"
|
||||
class="directory-path"
|
||||
aria-labelledby="baseAttachmentPathLabel"/>
|
||||
<button id="baseAttachmentPathButton"
|
||||
label="&zotero.preferences.attachmentBaseDir.selectBasePath;"
|
||||
|
@ -94,7 +95,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()"
|
||||
|
@ -106,26 +107,29 @@
|
|||
<groupbox aria-label="&zotero.preferences.dataDir;">
|
||||
<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="custom-data-dir" data-l10n-id="preferences-advanced-custom-data-dir"
|
||||
oncommand="Zotero_Preferences.Advanced.dataDirUpdate(true)"/>
|
||||
<button id="reset-data-dir" data-l10n-id="preferences-advanced-reset-data-dir"
|
||||
oncommand="Zotero_Preferences.Advanced.dataDirUpdate(false)" aria-describedby="default-data-dir"/>
|
||||
<html:input id="default-data-dir" data-l10n-id="preferences-advanced-default-data-dir"
|
||||
data-l10n-attrs="value" readonly="true" class="directory-path"/>
|
||||
<button id="migrate-data-dir" label="&zotero.preferences.dataDir.migrate;"
|
||||
oncommand="Zotero_Preferences.Advanced.migrateDataDirectory()" hidden="true"/>
|
||||
</hbox>
|
||||
|
|
|
@ -82,3 +82,10 @@ preferences-advanced-server-enable-and-restart =
|
|||
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 = Revert to Default Location…
|
||||
preferences-advanced-custom-data-dir =
|
||||
.label = Use Custom Location…
|
||||
preferences-advanced-default-data-dir =
|
||||
.value = (Default: { $directory })
|
||||
.aria-label = Default location
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
align-items: center;
|
||||
}
|
||||
|
||||
#baseAttachmentPath {
|
||||
.directory-path {
|
||||
padding-inline-start: 24px;
|
||||
/* Background set in JS */
|
||||
background: none;
|
||||
|
@ -50,6 +50,18 @@
|
|||
border: none;
|
||||
}
|
||||
|
||||
#default-data-dir {
|
||||
padding-inline-start: 0;
|
||||
margin-inline-start: 0;
|
||||
margin-top: 2px;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.preferences-button-group {
|
||||
gap: 6px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
#zotero-prefpane-advanced-open-buttons {
|
||||
display: block;
|
||||
text-align: end;
|
||||
|
|
Loading…
Reference in a new issue