diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js
index d1b023d43..de4eaeaed 100644
--- a/apps/spreadsheeteditor/main/app/controller/DataTab.js
+++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js
@@ -63,6 +63,13 @@ define([
this._state = {
CSVOptions: new Asc.asc_CTextOptions(0, 4, '')
};
+ this.externalData = {
+ stackRequests: [],
+ stackResponse: [],
+ callback: undefined,
+ isUpdating: false,
+ linkStatus: {}
+ };
},
onLaunch: function () {
},
@@ -106,6 +113,13 @@ define([
});
Common.NotificationCenter.on('data:remduplicates', _.bind(this.onRemoveDuplicates, this));
Common.NotificationCenter.on('data:sortcustom', _.bind(this.onCustomSort, this));
+ if (this.toolbar.mode.canRequestReferenceData && this.api) {
+ // this.api.asc_registerCallback('asc_onNeedUpdateExternalReferenceOnOpen', _.bind(this.onNeedUpdateExternalReferenceOnOpen, this));
+ this.api.asc_registerCallback('asc_onStartUpdateExternalReference', _.bind(this.onStartUpdateExternalReference, this));
+ this.api.asc_registerCallback('asc_onUpdateExternalReference', _.bind(this.onUpdateExternalReference, this));
+ this.api.asc_registerCallback('asc_onErrorUpdateExternalReference', _.bind(this.onErrorUpdateExternalReference, this));
+ Common.Gateway.on('setreferencedata', _.bind(this.setReferenceData, this));
+ }
},
SetDisabled: function(state) {
@@ -432,12 +446,90 @@ define([
},
onExternalLinks: function() {
- (new SSE.Views.ExternalLinksDlg({
+ var me = this;
+ this.externalLinksDlg = (new SSE.Views.ExternalLinksDlg({
api: this.api,
+ isUpdating: this.externalData.isUpdating,
handler: function(result) {
Common.NotificationCenter.trigger('edit:complete');
}
- })).show();
+ }));
+ this.externalLinksDlg.on('close', function(win){
+ me.externalLinksDlg = null;
+ })
+ this.externalLinksDlg.show()
+ },
+
+ onUpdateExternalReference: function(arr, callback) {
+ if (this.toolbar.mode.isEdit && this.toolbar.editMode) {
+ var me = this;
+ me.externalData = {
+ stackRequests: [],
+ stackResponse: [],
+ callback: undefined,
+ isUpdating: false,
+ linkStatus: {}
+ };
+ arr && arr.length>0 && arr.forEach(function(item) {
+ var data;
+ switch (item.asc_getType()) {
+ case Asc.c_oAscExternalReferenceType.link:
+ data = {link: item.asc_getData()};
+ break;
+ case Asc.c_oAscExternalReferenceType.path:
+ data = {path: item.asc_getData()};
+ break;
+ case Asc.c_oAscExternalReferenceType.referenceData:
+ data = {referenceData: item.asc_getData()};
+ break;
+ }
+ data && me.externalData.stackRequests.push({data: data, id: item.asc_getId()});
+ });
+ me.externalData.callback = callback;
+ me.requestReferenceData();
+ }
+ },
+
+ requestReferenceData: function() {
+ if (this.externalData.stackRequests.length>0) {
+ var item = this.externalData.stackRequests.shift();
+ this.externalData.linkStatus.id = item.id;
+ Common.Gateway.requestReferenceData(item.data);
+ }
+ },
+
+ setReferenceData: function(data) {
+ if (this.toolbar.mode.isEdit && this.toolbar.editMode) {
+ if (data) {
+ this.externalData.stackResponse.push(data);
+ this.externalData.linkStatus.result = data.error || '';
+ if (this.externalLinksDlg) {
+ this.externalLinksDlg.setLinkStatus(this.externalData.linkStatus.id, this.externalData.linkStatus.result);
+ }
+ }
+ if (this.externalData.stackRequests.length>0)
+ this.requestReferenceData();
+ else if (this.externalData.callback)
+ this.externalData.callback(this.externalData.stackResponse);
+ }
+ },
+
+ onStartUpdateExternalReference: function(status) {
+ this.externalData.isUpdating = status;
+ if (this.externalLinksDlg) {
+ this.externalLinksDlg.setIsUpdating(status);
+ }
+ },
+
+ onNeedUpdateExternalReferenceOnOpen: function() {
+ var links = this.api.asc_getExternalReferences();
+ links && (links.length>0) && this.api.asc_updateExternalReferences(links);
+ },
+
+ onErrorUpdateExternalReference: function(id) {
+ if (this.externalLinksDlg) {
+ this.externalLinksDlg.setLinkStatus(id, this.txtErrorExternalLink);
+ }
},
onWorksheetLocked: function(index,locked) {
@@ -481,7 +573,8 @@ define([
txtRemoveDataValidation: 'The selection contains more than one type of validation.
Erase current settings and continue?',
textEmptyUrl: 'You need to specify URL.',
txtImportWizard: 'Text Import Wizard',
- txtUrlTitle: 'Paste a data URL'
+ txtUrlTitle: 'Paste a data URL',
+ txtErrorExternalLink: 'Error: updating is failed'
}, SSE.Controllers.DataTab || {}));
});
\ No newline at end of file
diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js
index c895ba0f8..2fd02f4cd 100644
--- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js
+++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js
@@ -119,11 +119,7 @@ define([
me._state = {wsLock: false, wsProps: []};
me.fastcoauthtips = [];
me._TtHeight = 20;
- me.externalData = {
- stackRequests: [],
- stackResponse: [],
- callback: undefined
- };
+
/** coauthoring begin **/
this.wrapEvents = {
apiHideComment: _.bind(this.onApiHideComment, this),
@@ -380,10 +376,6 @@ define([
this.api.asc_registerCallback('asc_onShowPivotGroupDialog', _.bind(this.onShowPivotGroupDialog, this));
if (!this.permissions.isEditMailMerge && !this.permissions.isEditDiagram && !this.permissions.isEditOle)
this.api.asc_registerCallback('asc_doubleClickOnTableOleObject', _.bind(this.onDoubleClickOnTableOleObject, this));
- if (this.permissions.canRequestReferenceData) {
- this.api.asc_registerCallback('asc_onUpdateExternalReference', _.bind(this.onUpdateExternalReference, this));
- Common.Gateway.on('setreferencedata', _.bind(this.setReferenceData, this));
- }
this.api.asc_registerCallback('asc_onShowMathTrack', _.bind(this.onShowMathTrack, this));
this.api.asc_registerCallback('asc_onHideMathTrack', _.bind(this.onHideMathTrack, this));
}
@@ -4268,51 +4260,6 @@ define([
}
},
- onUpdateExternalReference: function(arr, callback) {
- if (this.permissions.isEdit && !this._isDisabled) {
- var me = this;
- me.externalData = {
- stackRequests: [],
- stackResponse: [],
- callback: undefined
- };
- arr && arr.length>0 && arr.forEach(function(item) {
- var data;
- switch (item.asc_getType()) {
- case Asc.c_oAscExternalReferenceType.link:
- data = {link: item.asc_getData()};
- break;
- case Asc.c_oAscExternalReferenceType.path:
- data = {path: item.asc_getData()};
- break;
- case Asc.c_oAscExternalReferenceType.referenceData:
- data = {referenceData: item.asc_getData()};
- break;
- }
- data && me.externalData.stackRequests.push(data);
- });
- me.externalData.callback = callback;
- me.requestReferenceData();
- }
- },
-
- requestReferenceData: function() {
- if (this.externalData.stackRequests.length>0) {
- var data = this.externalData.stackRequests.shift();
- Common.Gateway.requestReferenceData(data);
- }
- },
-
- setReferenceData: function(data) {
- if (this.permissions.isEdit && !this._isDisabled) {
- data && this.externalData.stackResponse.push(data);
- if (this.externalData.stackRequests.length>0)
- this.requestReferenceData();
- else if (this.externalData.callback)
- this.externalData.callback(this.externalData.stackResponse);
- }
- },
-
onShowMathTrack: function(bounds) {
if (bounds[3] < 0) {
this.onHideMathTrack();
diff --git a/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js b/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js
index 248135cbc..64efa523d 100644
--- a/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js
+++ b/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js
@@ -92,6 +92,8 @@ define([
this.api = options.api;
this.handler = options.handler;
+ this.isUpdating = options.isUpdating || false;
+ this.linkStatus = [];
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
},
@@ -130,7 +132,8 @@ define([
}]
})
});
- $(this.btnUpdate.cmpEl.find('button')[0]).css('min-width', '87px');
+ var el = $(this.btnUpdate.cmpEl.find('button')[0]);
+ el.css('min-width', Math.max(87, el.outerWidth()) + 'px');
this.btnUpdate.on('click', _.bind(this.onUpdate, this));
this.btnUpdate.menu.on('item:click', _.bind(this.onUpdateMenu, this));
@@ -171,6 +174,7 @@ define([
afterRender: function() {
this._setDefaults();
+ this.isUpdating && this.setIsUpdating(this.isUpdating, true);
},
getFocusedComponents: function() {
@@ -191,27 +195,29 @@ define([
if (links) {
for (var i=0; i0) && this.linksList.selectByIndex(0);
- this.btnUpdate.setDisabled(this.linksList.store.length<1 || !this.linksList.getSelectedRec());
- this.btnDelete.setDisabled(this.linksList.store.length<1 || !this.linksList.getSelectedRec());
- this.btnOpen.setDisabled(this.linksList.store.length<1 || !this.linksList.getSelectedRec());
- this.btnChange.setDisabled(this.linksList.store.length<1 || !this.linksList.getSelectedRec());
+ this.updateButtons();
},
onUpdate: function() {
+ if (this.isUpdating) return;
+
var rec = this.linksList.getSelectedRec();
rec && this.api.asc_updateExternalReferences([rec.get('externalRef')]);
},
onUpdateMenu: function(menu, item) {
+ if (this.isUpdating) return;
+
if (item.value == 1) {
var arr = [];
this.linksList.store.each(function(item){
@@ -223,12 +229,16 @@ define([
},
onDelete: function() {
+ if (this.isUpdating) return;
+
var rec = this.linksList.getSelectedRec();
rec && this.api.asc_removeExternalReferences([rec.get('externalRef')]);
this.refreshList();
},
onDeleteMenu: function(menu, item) {
+ if (this.isUpdating) return;
+
if (item.value == 1) {
var arr = [];
this.linksList.store.each(function(item){
@@ -248,6 +258,44 @@ define([
},
+ updateButtons: function() {
+ var selected = this.linksList.store.length>0 && !!this.linksList.getSelectedRec();
+ this.btnUpdate.setDisabled(!selected || this.isUpdating);
+ this.btnDelete.setDisabled(!selected || this.isUpdating);
+ this.btnOpen.setDisabled(!selected || this.isUpdating);
+ this.btnChange.setDisabled(!selected || this.isUpdating);
+ },
+
+ setIsUpdating: function(status, immediately) {
+ console.log(status);
+ immediately = immediately || !status; // set timeout when start updating only
+ this.isUpdating = status;
+ if (!status && this.timerId) {
+ clearTimeout(this.timerId);
+ this.timerId = 0;
+ }
+ if (immediately) {
+ this.updateButtons();
+ this.btnUpdate.setCaption(status ? this.textUpdating : this.textUpdate);
+ } else if (!this.timerId) {
+ var me = this;
+ me.timerId = setTimeout(function () {
+ me.updateButtons();
+ me.btnUpdate.setCaption(status ? me.textUpdating : me.textUpdate);
+ },500);
+ }
+ },
+
+ setLinkStatus: function(id, result) {
+ if (!id) return;
+ var rec = this.linksList.store.findWhere({linkid: id});
+ if (rec) {
+ rec.set('status', result || this.textOk);
+ this.linkStatus[id] = result || this.textOk;
+ } else
+ delete this.linkStatus[id];
+ },
+
txtTitle: 'External Links',
textUpdate: 'Update Values',
textUpdateAll: 'Update All',
@@ -257,7 +305,10 @@ define([
textDeleteAll: 'Break All Links',
textOpen: 'Open Source',
textChange: 'Change Source',
- textStatus: 'Status'
+ textStatus: 'Status',
+ textOk: 'OK',
+ textUnknown: 'Unknown',
+ textUpdating: 'Updating...'
}, 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 3e8ee1e04..4d5e99d30 100644
--- a/apps/spreadsheeteditor/main/locale/en.json
+++ b/apps/spreadsheeteditor/main/locale/en.json
@@ -662,6 +662,7 @@
"SSE.Controllers.DataTab.txtRemoveDataValidation": "The selection contains more than one type of validation.
Erase current settings and continue?",
"SSE.Controllers.DataTab.txtRemSelected": "Remove in selected",
"SSE.Controllers.DataTab.txtUrlTitle": "Paste a data URL",
+ "SSE.Controllers.DataTab.txtErrorExternalLink": "Error: updating is failed",
"SSE.Controllers.DocumentHolder.alignmentText": "Alignment",
"SSE.Controllers.DocumentHolder.centerText": "Center",
"SSE.Controllers.DocumentHolder.deleteColumnText": "Delete Column",
@@ -2277,6 +2278,10 @@
"SSE.Views.ExternalLinksDlg.textUpdate": "Update Values",
"SSE.Views.ExternalLinksDlg.textUpdateAll": "Update All",
"SSE.Views.ExternalLinksDlg.txtTitle": "External Links",
+ "SSE.Views.ExternalLinksDlg.textStatus": "Status",
+ "SSE.Views.ExternalLinksDlg.textOk": "OK",
+ "SSE.Views.ExternalLinksDlg.textUnknown": "Unknown",
+ "SSE.Views.ExternalLinksDlg.textUpdating": "Updating...",
"SSE.Views.FieldSettingsDialog.strLayout": "Layout",
"SSE.Views.FieldSettingsDialog.strSubtotals": "Subtotals",
"SSE.Views.FieldSettingsDialog.textReport": "Report Form",