Scaffold: Prompt to save before resetting

Now that Scaffold remembers and automatically loads the last edited translator
(65048fd624), it needs to be easier to create a
new translator without saving (and bumping the lastModified date on) the
translator you had open.
This commit is contained in:
Abe Jellinek 2023-07-31 09:44:20 -04:00
parent ef7916b320
commit 345bbcf50c

View file

@ -602,10 +602,23 @@ var Scaffold = new function () {
this.setFontSize(currentSize - 2);
};
this.newTranslator = async function (skipSave) {
if (!skipSave) {
_logOutput('Saving translator and resetting...');
await this.save();
this.newTranslator = async function (skipSavePrompt) {
if (!skipSavePrompt && _editors.code.getValue()) {
let ps = Services.prompt;
let buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_IS_STRING;
let label = document.getElementById('textbox-label').value;
let index = ps.confirmEx(null,
"Scaffold",
`Do you want to save the changes you made to ${label}?`,
buttonFlags,
Zotero.getString('general.no'),
Zotero.getString('general.yes'),
null, null, {}
);
if (index == 1 && !await this.save()) {
return;
}
}
this.generateTranslatorID();