Merge pull request #2053 from ONLYOFFICE/fix/sse-check-status
Fix/sse check status
This commit is contained in:
commit
4cfd6199bf
|
@ -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.<br>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 || {}));
|
||||
});
|
|
@ -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();
|
||||
|
|
|
@ -75,7 +75,8 @@ define([
|
|||
'</tr>',
|
||||
'<tr>',
|
||||
'<td class="padding-small">',
|
||||
'<label class="header">', me.textSource,'</label>',
|
||||
'<label class="header" style="display: inline-block; width: 245px;">', me.textSource,'</label>',
|
||||
'<label class="header" style="display: inline-block;">', me.textStatus,'</label>',
|
||||
'<div id="external-links-list" class="range-tableview" style="width:100%; height: 148px;"></div>',
|
||||
'</td>',
|
||||
'</tr>',
|
||||
|
@ -91,6 +92,11 @@ define([
|
|||
|
||||
this.api = options.api;
|
||||
this.handler = options.handler;
|
||||
this.isUpdating = options.isUpdating || false;
|
||||
this.linkStatus = [];
|
||||
this.wrapEvents = {
|
||||
onUpdateExternalReferenceList: _.bind(this.refreshList, this)
|
||||
};
|
||||
|
||||
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
|
||||
},
|
||||
|
@ -102,6 +108,12 @@ define([
|
|||
el: $('#external-links-list', this.$window),
|
||||
store: new Common.UI.DataViewStore(),
|
||||
simpleAddMode: true,
|
||||
itemTemplate: _.template([
|
||||
'<div id="<%= id %>" class="list-item" style="width: 100%;display:inline-block;">',
|
||||
'<div style="width:240px;padding-right: 5px;"><%= value %></div>',
|
||||
'<div style="width:175px;"><%= status %></div>',
|
||||
'</div>'
|
||||
].join('')),
|
||||
tabindex: 1
|
||||
});
|
||||
|
||||
|
@ -123,7 +135,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));
|
||||
|
||||
|
@ -164,12 +177,20 @@ define([
|
|||
|
||||
afterRender: function() {
|
||||
this._setDefaults();
|
||||
this.api.asc_registerCallback('asc_onUpdateExternalReferenceList', this.wrapEvents.onUpdateExternalReferenceList);
|
||||
this.isUpdating && this.setIsUpdating(this.isUpdating, true);
|
||||
},
|
||||
|
||||
getFocusedComponents: function() {
|
||||
return [ this.btnUpdate, this.btnDelete, this.btnOpen, this.btnChange, this.linksList ];
|
||||
},
|
||||
|
||||
close: function () {
|
||||
this.api.asc_unregisterCallback('asc_onUpdateExternalReferenceList', this.wrapEvents.onUpdateExternalReferenceList);
|
||||
|
||||
Common.Views.AdvancedSettingsWindow.prototype.close.call(this);
|
||||
},
|
||||
|
||||
getDefaultFocusableComponent: function () {
|
||||
return this.linksList;
|
||||
},
|
||||
|
@ -184,26 +205,29 @@ define([
|
|||
if (links) {
|
||||
for (var i=0; i<links.length; i++) {
|
||||
arr.push({
|
||||
value: links[i].asc_getSource(),
|
||||
linkid: links[i].asc_getId(),
|
||||
value: (links[i].asc_getSource() || '').replace(new RegExp("%20",'g')," "),
|
||||
idx: i,
|
||||
externalRef: links[i]
|
||||
externalRef: links[i],
|
||||
status: this.linkStatus[links[i].asc_getId()] || this.textUnknown
|
||||
});
|
||||
}
|
||||
}
|
||||
this.linksList.store.reset(arr);
|
||||
(this.linksList.store.length>0) && 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){
|
||||
|
@ -215,12 +239,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){
|
||||
|
@ -240,6 +268,40 @@ 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);
|
||||
}
|
||||
!status && this.refreshList();
|
||||
},
|
||||
|
||||
setLinkStatus: function(id, result) {
|
||||
if (!id) return;
|
||||
this.linkStatus[id] = result || this.textOk;
|
||||
},
|
||||
|
||||
txtTitle: 'External Links',
|
||||
textUpdate: 'Update Values',
|
||||
textUpdateAll: 'Update All',
|
||||
|
@ -248,7 +310,11 @@ define([
|
|||
textDelete: 'Break Links',
|
||||
textDeleteAll: 'Break All Links',
|
||||
textOpen: 'Open Source',
|
||||
textChange: 'Change Source'
|
||||
textChange: 'Change Source',
|
||||
textStatus: 'Status',
|
||||
textOk: 'OK',
|
||||
textUnknown: 'Unknown',
|
||||
textUpdating: 'Updating...'
|
||||
|
||||
}, SSE.Views.ExternalLinksDlg || {}));
|
||||
});
|
|
@ -663,6 +663,7 @@
|
|||
"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.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",
|
||||
|
@ -2283,6 +2284,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",
|
||||
|
|
Loading…
Reference in a new issue