[SSE] Update status for external link
This commit is contained in:
parent
cafc0a5e72
commit
ca9b3b0cb8
|
@ -63,6 +63,13 @@ define([
|
||||||
this._state = {
|
this._state = {
|
||||||
CSVOptions: new Asc.asc_CTextOptions(0, 4, '')
|
CSVOptions: new Asc.asc_CTextOptions(0, 4, '')
|
||||||
};
|
};
|
||||||
|
this.externalData = {
|
||||||
|
stackRequests: [],
|
||||||
|
stackResponse: [],
|
||||||
|
callback: undefined,
|
||||||
|
isUpdating: false,
|
||||||
|
linkStatus: {}
|
||||||
|
};
|
||||||
},
|
},
|
||||||
onLaunch: function () {
|
onLaunch: function () {
|
||||||
},
|
},
|
||||||
|
@ -106,6 +113,13 @@ define([
|
||||||
});
|
});
|
||||||
Common.NotificationCenter.on('data:remduplicates', _.bind(this.onRemoveDuplicates, this));
|
Common.NotificationCenter.on('data:remduplicates', _.bind(this.onRemoveDuplicates, this));
|
||||||
Common.NotificationCenter.on('data:sortcustom', _.bind(this.onCustomSort, 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) {
|
SetDisabled: function(state) {
|
||||||
|
@ -432,12 +446,90 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onExternalLinks: function() {
|
onExternalLinks: function() {
|
||||||
(new SSE.Views.ExternalLinksDlg({
|
var me = this;
|
||||||
|
this.externalLinksDlg = (new SSE.Views.ExternalLinksDlg({
|
||||||
api: this.api,
|
api: this.api,
|
||||||
|
isUpdating: this.externalData.isUpdating,
|
||||||
handler: function(result) {
|
handler: function(result) {
|
||||||
Common.NotificationCenter.trigger('edit:complete');
|
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) {
|
onWorksheetLocked: function(index,locked) {
|
||||||
|
@ -481,7 +573,8 @@ define([
|
||||||
txtRemoveDataValidation: 'The selection contains more than one type of validation.<br>Erase current settings and continue?',
|
txtRemoveDataValidation: 'The selection contains more than one type of validation.<br>Erase current settings and continue?',
|
||||||
textEmptyUrl: 'You need to specify URL.',
|
textEmptyUrl: 'You need to specify URL.',
|
||||||
txtImportWizard: 'Text Import Wizard',
|
txtImportWizard: 'Text Import Wizard',
|
||||||
txtUrlTitle: 'Paste a data URL'
|
txtUrlTitle: 'Paste a data URL',
|
||||||
|
txtErrorExternalLink: 'Error: updating is failed'
|
||||||
|
|
||||||
}, SSE.Controllers.DataTab || {}));
|
}, SSE.Controllers.DataTab || {}));
|
||||||
});
|
});
|
|
@ -119,11 +119,7 @@ define([
|
||||||
me._state = {wsLock: false, wsProps: []};
|
me._state = {wsLock: false, wsProps: []};
|
||||||
me.fastcoauthtips = [];
|
me.fastcoauthtips = [];
|
||||||
me._TtHeight = 20;
|
me._TtHeight = 20;
|
||||||
me.externalData = {
|
|
||||||
stackRequests: [],
|
|
||||||
stackResponse: [],
|
|
||||||
callback: undefined
|
|
||||||
};
|
|
||||||
/** coauthoring begin **/
|
/** coauthoring begin **/
|
||||||
this.wrapEvents = {
|
this.wrapEvents = {
|
||||||
apiHideComment: _.bind(this.onApiHideComment, this),
|
apiHideComment: _.bind(this.onApiHideComment, this),
|
||||||
|
@ -380,10 +376,6 @@ define([
|
||||||
this.api.asc_registerCallback('asc_onShowPivotGroupDialog', _.bind(this.onShowPivotGroupDialog, this));
|
this.api.asc_registerCallback('asc_onShowPivotGroupDialog', _.bind(this.onShowPivotGroupDialog, this));
|
||||||
if (!this.permissions.isEditMailMerge && !this.permissions.isEditDiagram && !this.permissions.isEditOle)
|
if (!this.permissions.isEditMailMerge && !this.permissions.isEditDiagram && !this.permissions.isEditOle)
|
||||||
this.api.asc_registerCallback('asc_doubleClickOnTableOleObject', _.bind(this.onDoubleClickOnTableOleObject, this));
|
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_onShowMathTrack', _.bind(this.onShowMathTrack, this));
|
||||||
this.api.asc_registerCallback('asc_onHideMathTrack', _.bind(this.onHideMathTrack, 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) {
|
onShowMathTrack: function(bounds) {
|
||||||
if (bounds[3] < 0) {
|
if (bounds[3] < 0) {
|
||||||
this.onHideMathTrack();
|
this.onHideMathTrack();
|
||||||
|
|
|
@ -92,6 +92,8 @@ define([
|
||||||
|
|
||||||
this.api = options.api;
|
this.api = options.api;
|
||||||
this.handler = options.handler;
|
this.handler = options.handler;
|
||||||
|
this.isUpdating = options.isUpdating || false;
|
||||||
|
this.linkStatus = [];
|
||||||
|
|
||||||
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
|
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.on('click', _.bind(this.onUpdate, this));
|
||||||
this.btnUpdate.menu.on('item:click', _.bind(this.onUpdateMenu, this));
|
this.btnUpdate.menu.on('item:click', _.bind(this.onUpdateMenu, this));
|
||||||
|
|
||||||
|
@ -171,6 +174,7 @@ define([
|
||||||
|
|
||||||
afterRender: function() {
|
afterRender: function() {
|
||||||
this._setDefaults();
|
this._setDefaults();
|
||||||
|
this.isUpdating && this.setIsUpdating(this.isUpdating, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
getFocusedComponents: function() {
|
getFocusedComponents: function() {
|
||||||
|
@ -191,27 +195,29 @@ define([
|
||||||
if (links) {
|
if (links) {
|
||||||
for (var i=0; i<links.length; i++) {
|
for (var i=0; i<links.length; i++) {
|
||||||
arr.push({
|
arr.push({
|
||||||
|
linkid: links[i].asc_getId(),
|
||||||
value: (links[i].asc_getSource() || '').replace(new RegExp("%20",'g')," "),
|
value: (links[i].asc_getSource() || '').replace(new RegExp("%20",'g')," "),
|
||||||
idx: i,
|
idx: i,
|
||||||
externalRef: links[i],
|
externalRef: links[i],
|
||||||
status: ''
|
status: this.linkStatus[links[i].asc_getId()] || this.textUnknown
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.linksList.store.reset(arr);
|
this.linksList.store.reset(arr);
|
||||||
(this.linksList.store.length>0) && this.linksList.selectByIndex(0);
|
(this.linksList.store.length>0) && this.linksList.selectByIndex(0);
|
||||||
this.btnUpdate.setDisabled(this.linksList.store.length<1 || !this.linksList.getSelectedRec());
|
this.updateButtons();
|
||||||
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());
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onUpdate: function() {
|
onUpdate: function() {
|
||||||
|
if (this.isUpdating) return;
|
||||||
|
|
||||||
var rec = this.linksList.getSelectedRec();
|
var rec = this.linksList.getSelectedRec();
|
||||||
rec && this.api.asc_updateExternalReferences([rec.get('externalRef')]);
|
rec && this.api.asc_updateExternalReferences([rec.get('externalRef')]);
|
||||||
},
|
},
|
||||||
|
|
||||||
onUpdateMenu: function(menu, item) {
|
onUpdateMenu: function(menu, item) {
|
||||||
|
if (this.isUpdating) return;
|
||||||
|
|
||||||
if (item.value == 1) {
|
if (item.value == 1) {
|
||||||
var arr = [];
|
var arr = [];
|
||||||
this.linksList.store.each(function(item){
|
this.linksList.store.each(function(item){
|
||||||
|
@ -223,12 +229,16 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onDelete: function() {
|
onDelete: function() {
|
||||||
|
if (this.isUpdating) return;
|
||||||
|
|
||||||
var rec = this.linksList.getSelectedRec();
|
var rec = this.linksList.getSelectedRec();
|
||||||
rec && this.api.asc_removeExternalReferences([rec.get('externalRef')]);
|
rec && this.api.asc_removeExternalReferences([rec.get('externalRef')]);
|
||||||
this.refreshList();
|
this.refreshList();
|
||||||
},
|
},
|
||||||
|
|
||||||
onDeleteMenu: function(menu, item) {
|
onDeleteMenu: function(menu, item) {
|
||||||
|
if (this.isUpdating) return;
|
||||||
|
|
||||||
if (item.value == 1) {
|
if (item.value == 1) {
|
||||||
var arr = [];
|
var arr = [];
|
||||||
this.linksList.store.each(function(item){
|
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',
|
txtTitle: 'External Links',
|
||||||
textUpdate: 'Update Values',
|
textUpdate: 'Update Values',
|
||||||
textUpdateAll: 'Update All',
|
textUpdateAll: 'Update All',
|
||||||
|
@ -257,7 +305,10 @@ define([
|
||||||
textDeleteAll: 'Break All Links',
|
textDeleteAll: 'Break All Links',
|
||||||
textOpen: 'Open Source',
|
textOpen: 'Open Source',
|
||||||
textChange: 'Change Source',
|
textChange: 'Change Source',
|
||||||
textStatus: 'Status'
|
textStatus: 'Status',
|
||||||
|
textOk: 'OK',
|
||||||
|
textUnknown: 'Unknown',
|
||||||
|
textUpdating: 'Updating...'
|
||||||
|
|
||||||
}, SSE.Views.ExternalLinksDlg || {}));
|
}, SSE.Views.ExternalLinksDlg || {}));
|
||||||
});
|
});
|
|
@ -662,6 +662,7 @@
|
||||||
"SSE.Controllers.DataTab.txtRemoveDataValidation": "The selection contains more than one type of validation.<br>Erase current settings and continue?",
|
"SSE.Controllers.DataTab.txtRemoveDataValidation": "The selection contains more than one type of validation.<br>Erase current settings and continue?",
|
||||||
"SSE.Controllers.DataTab.txtRemSelected": "Remove in selected",
|
"SSE.Controllers.DataTab.txtRemSelected": "Remove in selected",
|
||||||
"SSE.Controllers.DataTab.txtUrlTitle": "Paste a data URL",
|
"SSE.Controllers.DataTab.txtUrlTitle": "Paste a data URL",
|
||||||
|
"SSE.Controllers.DataTab.txtErrorExternalLink": "Error: updating is failed",
|
||||||
"SSE.Controllers.DocumentHolder.alignmentText": "Alignment",
|
"SSE.Controllers.DocumentHolder.alignmentText": "Alignment",
|
||||||
"SSE.Controllers.DocumentHolder.centerText": "Center",
|
"SSE.Controllers.DocumentHolder.centerText": "Center",
|
||||||
"SSE.Controllers.DocumentHolder.deleteColumnText": "Delete Column",
|
"SSE.Controllers.DocumentHolder.deleteColumnText": "Delete Column",
|
||||||
|
@ -2277,6 +2278,10 @@
|
||||||
"SSE.Views.ExternalLinksDlg.textUpdate": "Update Values",
|
"SSE.Views.ExternalLinksDlg.textUpdate": "Update Values",
|
||||||
"SSE.Views.ExternalLinksDlg.textUpdateAll": "Update All",
|
"SSE.Views.ExternalLinksDlg.textUpdateAll": "Update All",
|
||||||
"SSE.Views.ExternalLinksDlg.txtTitle": "External Links",
|
"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.strLayout": "Layout",
|
||||||
"SSE.Views.FieldSettingsDialog.strSubtotals": "Subtotals",
|
"SSE.Views.FieldSettingsDialog.strSubtotals": "Subtotals",
|
||||||
"SSE.Views.FieldSettingsDialog.textReport": "Report Form",
|
"SSE.Views.FieldSettingsDialog.textReport": "Report Form",
|
||||||
|
|
Loading…
Reference in a new issue