From 2bb7e6879208425b430353dc5c0eb5301b6f222d Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 30 Aug 2018 12:14:37 +0200 Subject: [PATCH] Remember previous values in the file upload modal --- www/common/sframe-common-file.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js index be9c320c5..5ad74d512 100644 --- a/www/common/sframe-common-file.js +++ b/www/common/sframe-common-file.js @@ -217,6 +217,10 @@ define([ }; // Get the upload options + var modalState = { + owned: true, + store: true + }; var fileUploadModal = function (file, cb) { var extIdx = file.name.lastIndexOf('.'); var name = extIdx !== -1 ? file.name.slice(0,extIdx) : file.name; @@ -235,9 +239,11 @@ define([ var privateData = common.getMetadataMgr().getPrivateData(); var autoStore = Util.find(privateData, ['settings', 'general', 'autostore']) || 0; + var initialState = modalState.owned || modalState.store; + var initialDisabled = modalState.owned ? { disabled: true } : {}; var manualStore = autoStore === 1 ? undefined : - UI.createCheckbox('cp-upload-store', Messages.autostore_forceSave, true, { - input: { disabled: true } + UI.createCheckbox('cp-upload-store', Messages.autostore_forceSave, initialState, { + input: initialDisabled }); // Ask for name, password and owner @@ -251,7 +257,7 @@ define([ h('span', { style: 'display:flex;align-items:center;justify-content:space-between' }, [ - UI.createCheckbox('cp-upload-owned', Messages.upload_modal_owner, true), + UI.createCheckbox('cp-upload-owned', Messages.upload_modal_owner, modalState.owned), createHelper('/faq.html#keywords-owned', Messages.creation_owned1) ]), manualStore @@ -275,6 +281,9 @@ define([ var owned = $(content).find('#cp-upload-owned').is(':checked'); var forceSave = owned || $(content).find('#cp-upload-store').is(':checked'); + modalState.owned = owned; + modalState.store = forceSave; + // Add extension to the name if needed if (!newName || !newName.trim()) { newName = file.name; } var newExtIdx = newName.lastIndexOf('.');