From c20d5cc0ae92e4996fbdf3f7246f65b503b6dae2 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 26 Dec 2024 17:48:47 +0300 Subject: [PATCH] [SSE] Auto update external links --- .../main/app/controller/DataTab.js | 11 ++++++--- .../main/app/view/ExternalLinksDlg.js | 23 +++++++++++++++---- apps/spreadsheeteditor/main/locale/en.json | 4 ++++ 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js index e99a4eb9ff..c7b3679712 100644 --- a/apps/spreadsheeteditor/main/app/controller/DataTab.js +++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js @@ -629,15 +629,17 @@ define([ }, onNeedUpdateExternalReferenceOnOpen: function() { + var value = this.api.asc_getUpdateLinks(); Common.UI.warning({ - msg: this.warnUpdateExternalData, - buttons: [{value: 'ok', caption: this.textUpdate, primary: true}, {value: 'cancel', caption: this.textDontUpdate}], + msg: value ? this.warnUpdateExternalAutoupdate : this.warnUpdateExternalData, + buttons: [{value: 'ok', caption: value ? this.textContinue : this.textUpdate, primary: true}, {value: 'cancel', caption: value ? this.textTurnOff : this.textDontUpdate}], maxwidth: 600, callback: _.bind(function(btn) { if (btn==='ok') { var links = this.api.asc_getExternalReferences(); links && (links.length>0) && this.api.asc_updateExternalReferences(links); } + value && this.api.asc_setUpdateLinks(btn==='ok', true); }, this) }); }, @@ -705,7 +707,10 @@ define([ warnUpdateExternalData: 'This workbook contains links to one or more external sources that could be unsafe.
If you trust the links, update them to get the latest data.', textUpdate: 'Update', textDontUpdate: 'Don\'t Update', - textAddExternalData: 'The link to an external source has been added. You can update such links in the Data tab.' + textAddExternalData: 'The link to an external source has been added. You can update such links in the Data tab.', + warnUpdateExternalAutoupdate: 'This workbook contains links that are updated automatically from external sources that could be unsafe.
If you trust the links, press \'Continue\' to update.', + textTurnOff: 'Turn off auto update', + textContinue: 'Continue' }, SSE.Controllers.DataTab || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js b/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js index c929ade71d..a4959b9273 100644 --- a/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js +++ b/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js @@ -63,7 +63,7 @@ define([ '
', '', '', - '', '', '', - '', '', + '', + '', + '', '
', + '', '', '', '', @@ -71,10 +71,15 @@ define([ '
', + '', '', '
', + '', + '
', '
' ].join(''))({scope: this}) @@ -181,6 +186,14 @@ define([ }); this.btnChange.on('click', _.bind(this.onChange, this)); + this.chUpdate = new Common.UI.CheckBox({ + el: $('#external-links-auto-update'), + labelText: this.textAutoUpdate + }); + this.chUpdate.on('change', _.bind(function(field, newValue, oldValue, eOpts){ + this.api && this.api.asc_setUpdateLinks(field.getValue()==='checked'); + }, this)); + this.afterRender(); }, @@ -191,7 +204,7 @@ define([ }, getFocusedComponents: function() { - return [ this.btnUpdate, this.btnChange, this.btnOpen, this.btnDelete, this.linksList ].concat(this.getFooterButtons()); + return [ this.btnUpdate, this.btnChange, this.btnOpen, this.btnDelete, this.linksList, this.chUpdate ].concat(this.getFooterButtons()); }, close: function () { @@ -206,6 +219,7 @@ define([ _setDefaults: function (props) { this.refreshList(); + this.api && this.api.asc_getExternalReferenceAutoUpdate && this.chUpdate.setValue(!!this.api.asc_getExternalReferenceAutoUpdate()); }, refreshList: function() { @@ -415,7 +429,8 @@ define([ textStatus: 'Status', textOk: 'OK', textUnknown: 'Unknown', - textUpdating: 'Updating...' + textUpdating: 'Updating...', + textAutoUpdate: 'Update automatically' }, SSE.Views.ExternalLinksDlg || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 555de3583b..879adf7ee0 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -798,6 +798,9 @@ "SSE.Controllers.DataTab.txtRemSelected": "Remove in selected", "SSE.Controllers.DataTab.txtUrlTitle": "Paste a data URL", "SSE.Controllers.DataTab.warnUpdateExternalData": "This workbook contains links to one or more external sources that could be unsafe.
If you trust the links, update them to get the latest data.", + "SSE.Controllers.DataTab.warnUpdateExternalAutoupdate": "This workbook contains links that are updated automatically from external sources that could be unsafe.
If you trust the links, press 'Continue' to update.", + "SSE.Controllers.DataTab.textTurnOff": "Turn off auto update", + "SSE.Controllers.DataTab.textContinue": "Continue", "SSE.Controllers.DocumentHolder.alignmentText": "Alignment", "SSE.Controllers.DocumentHolder.centerText": "Center", "SSE.Controllers.DocumentHolder.deleteColumnText": "Delete Column", @@ -2623,6 +2626,7 @@ "SSE.Views.ExternalLinksDlg.textUpdateAll": "Update all", "SSE.Views.ExternalLinksDlg.textUpdating": "Updating...", "SSE.Views.ExternalLinksDlg.txtTitle": "External links", + "SSE.Views.ExternalLinksDlg.textAutoUpdate": "Update automatically", "SSE.Views.FieldSettingsDialog.strLayout": "Layout", "SSE.Views.FieldSettingsDialog.strSubtotals": "Subtotals", "SSE.Views.FieldSettingsDialog.textNumFormat": "Number format",