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 6364a2ca4..5a2c0d5d6 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 41c7b68b7..254381bd1 100644
--- a/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js
+++ b/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js
@@ -75,7 +75,8 @@ define([
'',
'