Merge pull request #1064 from ONLYOFFICE/feature/download-file-type
Feature/download file type
This commit is contained in:
commit
d978dc52e6
|
@ -203,12 +203,13 @@ if (window.Common === undefined) {
|
|||
});
|
||||
},
|
||||
|
||||
requestRestore: function(version, url) {
|
||||
requestRestore: function(version, url, fileType) {
|
||||
_postMessage({
|
||||
event: 'onRequestRestore',
|
||||
data: {
|
||||
version: version,
|
||||
url: url
|
||||
url: url,
|
||||
fileType: fileType
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -273,19 +274,23 @@ if (window.Common === undefined) {
|
|||
_postMessage({ event: 'onOutdatedVersion' });
|
||||
},
|
||||
|
||||
downloadAs: function(url) {
|
||||
downloadAs: function(url, fileType) {
|
||||
_postMessage({
|
||||
event: 'onDownloadAs',
|
||||
data: url
|
||||
data: {
|
||||
url: url,
|
||||
fileType: fileType
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
requestSaveAs: function(url, title) {
|
||||
requestSaveAs: function(url, title, fileType) {
|
||||
_postMessage({
|
||||
event: 'onRequestSaveAs',
|
||||
data: {
|
||||
url: url,
|
||||
title: title
|
||||
title: title,
|
||||
fileType: fileType
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -92,6 +92,14 @@
|
|||
str = num.toString();
|
||||
for (var i=str.length; i<digits; i++) strfill += fill;
|
||||
return strfill + str;
|
||||
},
|
||||
getKeyByValue: function(obj, value) {
|
||||
for(var prop in obj) {
|
||||
if(obj.hasOwnProperty(prop)) {
|
||||
if(obj[prop] === value)
|
||||
return prop;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -100,9 +100,10 @@ define([
|
|||
this.panelHistory.$el.find('#history-list').css('padding-bottom', hasChanges ? '45px' : 0);
|
||||
},
|
||||
|
||||
onDownloadUrl: function(url) {
|
||||
if (this.isFromSelectRevision !== undefined)
|
||||
Common.Gateway.requestRestore(this.isFromSelectRevision, url);
|
||||
onDownloadUrl: function(url, fileType) {
|
||||
if (this.isFromSelectRevision !== undefined) {
|
||||
Common.Gateway.requestRestore(this.isFromSelectRevision, url, fileType);
|
||||
}
|
||||
this.isFromSelectRevision = undefined;
|
||||
},
|
||||
|
||||
|
@ -111,7 +112,7 @@ define([
|
|||
var btn = $(e.target);
|
||||
if (btn && btn.hasClass('revision-restore')) {
|
||||
if (record.get('isRevision'))
|
||||
Common.Gateway.requestRestore(record.get('revision'));
|
||||
Common.Gateway.requestRestore(record.get('revision'), undefined, record.get('fileType'));
|
||||
else {
|
||||
this.isFromSelectRevision = record.get('revision');
|
||||
var fileType = Asc.c_oAscFileType[(record.get('fileType') || '').toUpperCase()] || Asc.c_oAscFileType.DOCX;
|
||||
|
@ -216,6 +217,7 @@ define([
|
|||
rev.set('docIdPrev', docIdPrev, {silent: true});
|
||||
}
|
||||
rev.set('token', token, {silent: true});
|
||||
opts.data.fileType && rev.set('fileType', opts.data.fileType, {silent: true});
|
||||
}
|
||||
}
|
||||
var hist = new Asc.asc_CVersionHistory();
|
||||
|
|
|
@ -1072,3 +1072,12 @@ Common.Utils.UserInfoParser = new(function() {
|
|||
}
|
||||
}
|
||||
})();
|
||||
|
||||
Common.Utils.getKeyByValue = function(obj, value) {
|
||||
for(var prop in obj) {
|
||||
if(obj.hasOwnProperty(prop)) {
|
||||
if(obj[prop] === value)
|
||||
return prop;
|
||||
}
|
||||
}
|
||||
};
|
|
@ -266,8 +266,8 @@ DE.ApplicationController = new(function(){
|
|||
}
|
||||
}
|
||||
|
||||
function onDownloadUrl(url) {
|
||||
Common.Gateway.downloadAs(url);
|
||||
function onDownloadUrl(url, fileType) {
|
||||
Common.Gateway.downloadAs(url, fileType);
|
||||
}
|
||||
|
||||
function onPrint() {
|
||||
|
|
|
@ -398,7 +398,7 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
onDownloadUrl: function(url) {
|
||||
onDownloadUrl: function(url, fileType) {
|
||||
if (this.isFromFileDownloadAs) {
|
||||
var me = this,
|
||||
defFileName = this.getApplication().getController('Viewport').getView('Common.Views.Header').getDocumentCaption();
|
||||
|
@ -411,7 +411,7 @@ define([
|
|||
}
|
||||
|
||||
if (me.mode.canRequestSaveAs) {
|
||||
Common.Gateway.requestSaveAs(url, defFileName);
|
||||
Common.Gateway.requestSaveAs(url, defFileName, fileType);
|
||||
} else {
|
||||
me._saveCopyDlg = new Common.Views.SaveAsDlg({
|
||||
saveFolderUrl: me.mode.saveAsUrl,
|
||||
|
|
|
@ -2053,9 +2053,10 @@ define([
|
|||
});
|
||||
},
|
||||
|
||||
onDownloadUrl: function(url) {
|
||||
if (this._state.isFromGatewayDownloadAs)
|
||||
Common.Gateway.downloadAs(url);
|
||||
onDownloadUrl: function(url, fileType) {
|
||||
if (this._state.isFromGatewayDownloadAs) {
|
||||
Common.Gateway.downloadAs(url, fileType);
|
||||
}
|
||||
this._state.isFromGatewayDownloadAs = false;
|
||||
},
|
||||
|
||||
|
|
|
@ -570,7 +570,7 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
onSaveMailMerge: function(url) {
|
||||
onSaveMailMerge: function(url, fileType) {
|
||||
var loadMask = DE.getController('Main').loadMask;
|
||||
loadMask && loadMask.hide();
|
||||
|
||||
|
@ -579,7 +579,7 @@ define([
|
|||
if (this.cmbMergeTo.getValue() != Asc.c_oAscFileType.HTML) {
|
||||
var defFileName = me.defFileName + ((this.cmbMergeTo.getValue() == Asc.c_oAscFileType.PDF) ? '.pdf' : '.docx');
|
||||
if (me.mode.canRequestSaveAs) {
|
||||
Common.Gateway.requestSaveAs(url, defFileName);
|
||||
Common.Gateway.requestSaveAs(url, defFileName, fileType);
|
||||
} else {
|
||||
me._mailMergeDlg = new Common.Views.SaveAsDlg({
|
||||
saveFolderUrl: me.mode.mergeFolderUrl,
|
||||
|
|
|
@ -687,9 +687,9 @@ class MainController extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
onDownloadUrl () {
|
||||
onDownloadUrl (url, fileType) {
|
||||
if (this._state.isFromGatewayDownloadAs) {
|
||||
Common.Gateway.downloadAs(url);
|
||||
Common.Gateway.downloadAs(url, fileType);
|
||||
}
|
||||
|
||||
this._state.isFromGatewayDownloadAs = false;
|
||||
|
|
|
@ -225,8 +225,8 @@ PE.ApplicationController = new(function(){
|
|||
}
|
||||
}
|
||||
|
||||
function onDownloadUrl(url) {
|
||||
Common.Gateway.downloadAs(url);
|
||||
function onDownloadUrl(url, fileType) {
|
||||
Common.Gateway.downloadAs(url, fileType);
|
||||
}
|
||||
|
||||
function onPrint() {
|
||||
|
|
|
@ -296,7 +296,7 @@ define([
|
|||
menu.hide();
|
||||
},
|
||||
|
||||
onDownloadUrl: function(url) {
|
||||
onDownloadUrl: function(url, fileType) {
|
||||
if (this.isFromFileDownloadAs) {
|
||||
var me = this,
|
||||
defFileName = this.getApplication().getController('Viewport').getView('Common.Views.Header').getDocumentCaption();
|
||||
|
@ -309,7 +309,7 @@ define([
|
|||
}
|
||||
|
||||
if (me.mode.canRequestSaveAs) {
|
||||
Common.Gateway.requestSaveAs(url, defFileName);
|
||||
Common.Gateway.requestSaveAs(url, defFileName, fileType);
|
||||
} else {
|
||||
me._saveCopyDlg = new Common.Views.SaveAsDlg({
|
||||
saveFolderUrl: me.mode.saveAsUrl,
|
||||
|
|
|
@ -1703,9 +1703,10 @@ define([
|
|||
});
|
||||
},
|
||||
|
||||
onDownloadUrl: function(url) {
|
||||
if (this._state.isFromGatewayDownloadAs)
|
||||
Common.Gateway.downloadAs(url);
|
||||
onDownloadUrl: function(url, fileType) {
|
||||
if (this._state.isFromGatewayDownloadAs) {
|
||||
Common.Gateway.downloadAs(url, fileType);
|
||||
}
|
||||
this._state.isFromGatewayDownloadAs = false;
|
||||
},
|
||||
|
||||
|
|
|
@ -179,8 +179,8 @@ SSE.ApplicationController = new(function(){
|
|||
setActiveWorkSheet(api.asc_getActiveWorksheetIndex());
|
||||
}
|
||||
|
||||
function onDownloadUrl(url) {
|
||||
Common.Gateway.downloadAs(url);
|
||||
function onDownloadUrl(url, fileType) {
|
||||
Common.Gateway.downloadAs(url, fileType);
|
||||
}
|
||||
|
||||
function onPrint() {
|
||||
|
|
|
@ -373,7 +373,7 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
onDownloadUrl: function(url) {
|
||||
onDownloadUrl: function(url, fileType) {
|
||||
if (this.isFromFileDownloadAs) {
|
||||
var me = this,
|
||||
defFileName = this.getApplication().getController('Viewport').getView('Common.Views.Header').getDocumentCaption();
|
||||
|
@ -386,7 +386,7 @@ define([
|
|||
}
|
||||
|
||||
if (me.mode.canRequestSaveAs) {
|
||||
Common.Gateway.requestSaveAs(url, defFileName);
|
||||
Common.Gateway.requestSaveAs(url, defFileName, fileType);
|
||||
} else {
|
||||
me._saveCopyDlg = new Common.Views.SaveAsDlg({
|
||||
saveFolderUrl: me.mode.saveAsUrl,
|
||||
|
|
|
@ -2010,9 +2010,10 @@ define([
|
|||
});
|
||||
},
|
||||
|
||||
onDownloadUrl: function(url) {
|
||||
if (this._state.isFromGatewayDownloadAs)
|
||||
Common.Gateway.downloadAs(url);
|
||||
onDownloadUrl: function(url, fileType) {
|
||||
if (this._state.isFromGatewayDownloadAs) {
|
||||
Common.Gateway.downloadAs(url, fileType);
|
||||
}
|
||||
this._state.isFromGatewayDownloadAs = false;
|
||||
},
|
||||
|
||||
|
|
|
@ -650,9 +650,9 @@ class MainController extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
onDownloadUrl () {
|
||||
onDownloadUrl (url, fileType) {
|
||||
if (this._state.isFromGatewayDownloadAs) {
|
||||
Common.Gateway.downloadAs(url);
|
||||
Common.Gateway.downloadAs(url, fileType);
|
||||
}
|
||||
|
||||
this._state.isFromGatewayDownloadAs = false;
|
||||
|
|
Loading…
Reference in a new issue