Load image from storage

This commit is contained in:
Julia Radzhabova 2018-10-03 14:00:08 +03:00
parent f671569c88
commit 3bd78060dc
15 changed files with 73 additions and 25 deletions

View file

@ -4,6 +4,7 @@
* Save to pdfa format * Save to pdfa format
* Add rotation and flip to image and shape settings (bug #19378) * Add rotation and flip to image and shape settings (bug #19378)
* Save file copy to selected folder (bug #23603, bug #32790) * Save file copy to selected folder (bug #23603, bug #32790)
* Load image from storage
### Document Editor ### Document Editor

View file

@ -57,7 +57,7 @@
canBackToFolder: <can return to folder> - deprecated. use "customization.goback" parameter, canBackToFolder: <can return to folder> - deprecated. use "customization.goback" parameter,
createUrl: 'create document url', createUrl: 'create document url',
sharingSettingsUrl: 'document sharing settings url', sharingSettingsUrl: 'document sharing settings url',
fileChoiceUrl: 'mail merge sources url', fileChoiceUrl: 'source url', // for mail merge or image from storage
callbackUrl: <url for connection between sdk and portal>, callbackUrl: <url for connection between sdk and portal>,
mergeFolderUrl: 'folder for saving merged file', // must be deprecated, use saveAsUrl instead mergeFolderUrl: 'folder for saving merged file', // must be deprecated, use saveAsUrl instead
saveAsUrl: 'folder for saving files' saveAsUrl: 'folder for saving files'

View file

@ -40,7 +40,7 @@ define([
'common/main/lib/component/LoadMask' 'common/main/lib/component/LoadMask'
], function () { 'use strict'; ], function () { 'use strict';
DE.Views.MailMergeRecepients = Common.UI.Window.extend(_.extend({ Common.Views.SelectFileDlg = Common.UI.Window.extend(_.extend({
initialize : function(options) { initialize : function(options) {
var _options = {}; var _options = {};
_.extend(_options, { _.extend(_options, {
@ -51,7 +51,7 @@ define([
}, options); }, options);
this.template = [ this.template = [
'<div id="id-mail-recepients-placeholder"></div>' '<div id="id-select-file-placeholder"></div>'
].join(''); ].join('');
_options.tpl = _.template(this.template)(_options); _options.tpl = _.template(this.template)(_options);
@ -71,9 +71,9 @@ define([
iframe.frameBorder = 0; iframe.frameBorder = 0;
iframe.scrolling = "no"; iframe.scrolling = "no";
iframe.onload = _.bind(this._onLoad,this); iframe.onload = _.bind(this._onLoad,this);
$('#id-mail-recepients-placeholder').append(iframe); $('#id-select-file-placeholder').append(iframe);
this.loadMask = new Common.UI.LoadMask({owner: $('#id-mail-recepients-placeholder')}); this.loadMask = new Common.UI.LoadMask({owner: $('#id-select-file-placeholder')});
this.loadMask.setTitle(this.textLoading); this.loadMask.setTitle(this.textLoading);
this.loadMask.show(); this.loadMask.show();
@ -121,7 +121,7 @@ define([
var me = this; var me = this;
setTimeout(function() { setTimeout(function() {
if ( !_.isEmpty(msg.file) ) { if ( !_.isEmpty(msg.file) ) {
me.trigger('mailmergerecepients', me, msg.file); me.trigger('selectfile', me, msg.file);
} }
}, 50); }, 50);
} }
@ -134,5 +134,5 @@ define([
textTitle : 'Select Data Source', textTitle : 'Select Data Source',
textLoading : 'Loading' textLoading : 'Loading'
}, DE.Views.MailMergeRecepients || {})); }, Common.Views.SelectFileDlg || {}));
}); });

View file

@ -46,10 +46,10 @@ define([
'common/main/lib/view/CopyWarningDialog', 'common/main/lib/view/CopyWarningDialog',
'common/main/lib/view/ImageFromUrlDialog', 'common/main/lib/view/ImageFromUrlDialog',
'common/main/lib/view/InsertTableDialog', 'common/main/lib/view/InsertTableDialog',
'common/main/lib/view/SelectFileDlg',
'common/main/lib/util/define', 'common/main/lib/util/define',
'documenteditor/main/app/view/Toolbar', 'documenteditor/main/app/view/Toolbar',
'documenteditor/main/app/view/DropcapSettingsAdvanced', 'documenteditor/main/app/view/DropcapSettingsAdvanced',
'documenteditor/main/app/view/MailMergeRecepients',
'documenteditor/main/app/view/StyleTitleDialog', 'documenteditor/main/app/view/StyleTitleDialog',
'documenteditor/main/app/view/PageMarginsDialog', 'documenteditor/main/app/view/PageMarginsDialog',
'documenteditor/main/app/view/PageSizeDialog', 'documenteditor/main/app/view/PageSizeDialog',
@ -1359,7 +1359,7 @@ define([
Common.NotificationCenter.trigger('edit:complete', me.toolbar); Common.NotificationCenter.trigger('edit:complete', me.toolbar);
Common.component.Analytics.trackEvent('ToolBar', 'Image'); Common.component.Analytics.trackEvent('ToolBar', 'Image');
} else { } else if (item.value === 'url') {
(new Common.Views.ImageFromUrlDialog({ (new Common.Views.ImageFromUrlDialog({
handler: function(result, value) { handler: function(result, value) {
if (result == 'ok') { if (result == 'ok') {
@ -1381,6 +1381,14 @@ define([
} }
} }
})).show(); })).show();
} else if (item.value === 'storage') {
(new Common.Views.SelectFileDlg({
fileChoiceUrl: this.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "").replace("{documentType}", "ImagesOnly")
})).on('selectfile', function(obj, file){
me.toolbar.fireEvent('insertimage', me.toolbar);
me.api.AddImageUrl(file.url);
Common.component.Analytics.trackEvent('ToolBar', 'Image');
}).show();
} }
}, },
@ -2713,10 +2721,10 @@ define([
if (this._mailMergeDlg) return; if (this._mailMergeDlg) return;
var me = this; var me = this;
me._mailMergeDlg = new DE.Views.MailMergeRecepients({ me._mailMergeDlg = new Common.Views.SelectFileDlg({
fileChoiceUrl: this.toolbar.mode.fileChoiceUrl fileChoiceUrl: this.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "xlsx").replace("{documentType}", "")
}); });
me._mailMergeDlg.on('mailmergerecepients', function(obj, recepients){ me._mailMergeDlg.on('selectfile', function(obj, recepients){
me.api.asc_StartMailMerge(recepients); me.api.asc_StartMailMerge(recepients);
if (!me.mergeEditor) if (!me.mergeEditor)
me.mergeEditor = me.getApplication().getController('Common.Controllers.ExternalMergeEditor').getView('Common.Views.ExternalMergeEditor'); me.mergeEditor = me.getApplication().getController('Common.Controllers.ExternalMergeEditor').getView('Common.Views.ExternalMergeEditor');

View file

@ -43,7 +43,7 @@ define([
'common/main/lib/component/Button', 'common/main/lib/component/Button',
'common/main/lib/component/Switcher', 'common/main/lib/component/Switcher',
'common/main/lib/view/SaveAsDlg', 'common/main/lib/view/SaveAsDlg',
'documenteditor/main/app/view/MailMergeRecepients', 'common/main/lib/view/SelectFileDlg',
'documenteditor/main/app/view/MailMergeEmailDlg' 'documenteditor/main/app/view/MailMergeEmailDlg'
], function (menuTemplate, $, _, Backbone) { ], function (menuTemplate, $, _, Backbone) {
'use strict'; 'use strict';

View file

@ -494,7 +494,8 @@ define([
menu: new Common.UI.Menu({ menu: new Common.UI.Menu({
items: [ items: [
{caption: this.mniImageFromFile, value: 'file'}, {caption: this.mniImageFromFile, value: 'file'},
{caption: this.mniImageFromUrl, value: 'url'} {caption: this.mniImageFromUrl, value: 'url'},
{caption: this.mniImageFromStorage, value: 'storage'}
] ]
}) })
}); });
@ -2012,6 +2013,7 @@ define([
this.listStylesAdditionalMenuItem.setVisible(mode.canEditStyles); this.listStylesAdditionalMenuItem.setVisible(mode.canEditStyles);
this.btnContentControls.menu.items[4].setVisible(mode.canEditContentControl); this.btnContentControls.menu.items[4].setVisible(mode.canEditContentControl);
this.btnContentControls.menu.items[5].setVisible(mode.canEditContentControl); this.btnContentControls.menu.items[5].setVisible(mode.canEditContentControl);
this.mnuInsertImage.items[2].setVisible(this.mode.fileChoiceUrl && this.mode.fileChoiceUrl.indexOf("{documentType}")>-1);
}, },
onSendThemeColorSchemes: function (schemas) { onSendThemeColorSchemes: function (schemas) {
@ -2368,7 +2370,8 @@ define([
mniEditControls: 'Settings', mniEditControls: 'Settings',
tipControls: 'Insert content control', tipControls: 'Insert content control',
mniHighlightControls: 'Highlight settings', mniHighlightControls: 'Highlight settings',
textNoHighlight: 'No highlighting' textNoHighlight: 'No highlighting',
mniImageFromStorage: 'Image from Storage'
} }
})(), DE.Views.Toolbar || {})); })(), DE.Views.Toolbar || {}));
}); });

View file

@ -282,6 +282,8 @@
"Common.Views.ReviewPopover.textResolve": "Resolve", "Common.Views.ReviewPopover.textResolve": "Resolve",
"Common.Views.SaveAsDlg.textLoading": "Loading", "Common.Views.SaveAsDlg.textLoading": "Loading",
"Common.Views.SaveAsDlg.textTitle": "Folder for save", "Common.Views.SaveAsDlg.textTitle": "Folder for save",
"Common.Views.SelectFileDlg.textLoading": "Loading",
"Common.Views.SelectFileDlg.textTitle": "Select Data Source",
"Common.Views.SignDialog.cancelButtonText": "Cancel", "Common.Views.SignDialog.cancelButtonText": "Cancel",
"Common.Views.SignDialog.okButtonText": "Ok", "Common.Views.SignDialog.okButtonText": "Ok",
"Common.Views.SignDialog.textBold": "Bold", "Common.Views.SignDialog.textBold": "Bold",
@ -1380,8 +1382,8 @@
"DE.Views.MailMergeEmailDlg.textTo": "To", "DE.Views.MailMergeEmailDlg.textTo": "To",
"DE.Views.MailMergeEmailDlg.textWarning": "Warning!", "DE.Views.MailMergeEmailDlg.textWarning": "Warning!",
"DE.Views.MailMergeEmailDlg.textWarningMsg": "Please note that mailing cannot be stopped once your click the 'Send' button.", "DE.Views.MailMergeEmailDlg.textWarningMsg": "Please note that mailing cannot be stopped once your click the 'Send' button.",
"DE.Views.MailMergeRecepients.textLoading": "Loading", "del_DE.Views.MailMergeRecepients.textLoading": "Loading",
"DE.Views.MailMergeRecepients.textTitle": "Select Data Source", "del_DE.Views.MailMergeRecepients.textTitle": "Select Data Source",
"del_DE.Views.MailMergeSaveDlg.textLoading": "Loading", "del_DE.Views.MailMergeSaveDlg.textLoading": "Loading",
"del_DE.Views.MailMergeSaveDlg.textTitle": "Folder for save", "del_DE.Views.MailMergeSaveDlg.textTitle": "Folder for save",
"DE.Views.MailMergeSettings.downloadMergeTitle": "Merging", "DE.Views.MailMergeSettings.downloadMergeTitle": "Merging",
@ -1968,5 +1970,6 @@
"DE.Views.Toolbar.txtScheme6": "Concourse", "DE.Views.Toolbar.txtScheme6": "Concourse",
"DE.Views.Toolbar.txtScheme7": "Equity", "DE.Views.Toolbar.txtScheme7": "Equity",
"DE.Views.Toolbar.txtScheme8": "Flow", "DE.Views.Toolbar.txtScheme8": "Flow",
"DE.Views.Toolbar.txtScheme9": "Foundry" "DE.Views.Toolbar.txtScheme9": "Foundry",
"DE.Views.Toolbar.mniImageFromStorage": "Image from Storage"
} }

View file

@ -291,6 +291,7 @@ define([
this.appOptions.location = (typeof (this.editorConfig.location) == 'string') ? this.editorConfig.location.toLowerCase() : ''; this.appOptions.location = (typeof (this.editorConfig.location) == 'string') ? this.editorConfig.location.toLowerCase() : '';
this.appOptions.sharingSettingsUrl = this.editorConfig.sharingSettingsUrl; this.appOptions.sharingSettingsUrl = this.editorConfig.sharingSettingsUrl;
this.appOptions.saveAsUrl = this.editorConfig.saveAsUrl; this.appOptions.saveAsUrl = this.editorConfig.saveAsUrl;
this.appOptions.fileChoiceUrl = this.editorConfig.fileChoiceUrl;
this.appOptions.canAnalytics = false; this.appOptions.canAnalytics = false;
this.appOptions.customization = this.editorConfig.customization; this.appOptions.customization = this.editorConfig.customization;
this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object') this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object')

View file

@ -47,6 +47,7 @@ define([
'common/main/lib/view/CopyWarningDialog', 'common/main/lib/view/CopyWarningDialog',
'common/main/lib/view/ImageFromUrlDialog', 'common/main/lib/view/ImageFromUrlDialog',
'common/main/lib/view/InsertTableDialog', 'common/main/lib/view/InsertTableDialog',
'common/main/lib/view/SelectFileDlg',
'common/main/lib/util/define', 'common/main/lib/util/define',
'presentationeditor/main/app/collection/SlideThemes', 'presentationeditor/main/app/collection/SlideThemes',
'presentationeditor/main/app/view/Toolbar', 'presentationeditor/main/app/view/Toolbar',
@ -1340,7 +1341,7 @@ define([
Common.NotificationCenter.trigger('edit:complete', this.toolbar); Common.NotificationCenter.trigger('edit:complete', this.toolbar);
Common.component.Analytics.trackEvent('ToolBar', 'Image'); Common.component.Analytics.trackEvent('ToolBar', 'Image');
} else { } else if (opts === 'url') {
(new Common.Views.ImageFromUrlDialog({ (new Common.Views.ImageFromUrlDialog({
handler: function(result, value) { handler: function(result, value) {
if (result == 'ok') { if (result == 'ok') {
@ -1362,6 +1363,14 @@ define([
} }
} }
})).show(); })).show();
} else if (opts === 'storage') {
(new Common.Views.SelectFileDlg({
fileChoiceUrl: me.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "").replace("{documentType}", "ImagesOnly")
})).on('selectfile', function(obj, file){
me.toolbar.fireEvent('insertimage', me.toolbar);
me.api.AddImageUrl(file.url);
Common.component.Analytics.trackEvent('ToolBar', 'Image');
}).show();
} }
}, },

View file

@ -1027,12 +1027,14 @@ define([
new Common.UI.Menu({ new Common.UI.Menu({
items: [ items: [
{caption: me.mniImageFromFile, value: 'file'}, {caption: me.mniImageFromFile, value: 'file'},
{caption: me.mniImageFromUrl, value: 'url'} {caption: me.mniImageFromUrl, value: 'url'},
{caption: me.mniImageFromStorage, value: 'storage'}
] ]
}).on('item:click', function (menu, item, e) { }).on('item:click', function (menu, item, e) {
me.fireEvent('insert:image', [item.value]); me.fireEvent('insert:image', [item.value]);
}) })
); );
btn.menu.items[2].setVisible(config.fileChoiceUrl && config.fileChoiceUrl.indexOf("{documentType}")>-1);
}); });
me.btnsInsertText.forEach(function (btn) { me.btnsInsertText.forEach(function (btn) {
@ -1731,7 +1733,8 @@ define([
textSurface: 'Surface', textSurface: 'Surface',
textShowPresenterView: 'Show presenter view', textShowPresenterView: 'Show presenter view',
textTabCollaboration: 'Collaboration', textTabCollaboration: 'Collaboration',
textTabProtect: 'Protection' textTabProtect: 'Protection',
mniImageFromStorage: 'Image from Storage'
} }
}()), PE.Views.Toolbar || {})); }()), PE.Views.Toolbar || {}));
}); });

View file

@ -204,6 +204,8 @@
"Common.Views.ReviewPopover.textResolve": "Resolve", "Common.Views.ReviewPopover.textResolve": "Resolve",
"Common.Views.SaveAsDlg.textLoading": "Loading", "Common.Views.SaveAsDlg.textLoading": "Loading",
"Common.Views.SaveAsDlg.textTitle": "Folder for save", "Common.Views.SaveAsDlg.textTitle": "Folder for save",
"Common.Views.SelectFileDlg.textLoading": "Loading",
"Common.Views.SelectFileDlg.textTitle": "Select Data Source",
"Common.Views.SignDialog.cancelButtonText": "Cancel", "Common.Views.SignDialog.cancelButtonText": "Cancel",
"Common.Views.SignDialog.okButtonText": "Ok", "Common.Views.SignDialog.okButtonText": "Ok",
"Common.Views.SignDialog.textBold": "Bold", "Common.Views.SignDialog.textBold": "Bold",
@ -1567,5 +1569,6 @@
"PE.Views.Toolbar.txtScheme7": "Equity", "PE.Views.Toolbar.txtScheme7": "Equity",
"PE.Views.Toolbar.txtScheme8": "Flow", "PE.Views.Toolbar.txtScheme8": "Flow",
"PE.Views.Toolbar.txtScheme9": "Foundry", "PE.Views.Toolbar.txtScheme9": "Foundry",
"PE.Views.Toolbar.txtUngroup": "Ungroup" "PE.Views.Toolbar.txtUngroup": "Ungroup",
"PE.Views.Toolbar.mniImageFromStorage": "Image from Storage"
} }

View file

@ -298,6 +298,7 @@ define([
this.appOptions.canAnalytics = false; this.appOptions.canAnalytics = false;
this.appOptions.sharingSettingsUrl = this.editorConfig.sharingSettingsUrl; this.appOptions.sharingSettingsUrl = this.editorConfig.sharingSettingsUrl;
this.appOptions.saveAsUrl = this.editorConfig.saveAsUrl; this.appOptions.saveAsUrl = this.editorConfig.saveAsUrl;
this.appOptions.fileChoiceUrl = this.editorConfig.fileChoiceUrl;
this.appOptions.isEditDiagram = this.editorConfig.mode == 'editdiagram'; this.appOptions.isEditDiagram = this.editorConfig.mode == 'editdiagram';
this.appOptions.isEditMailMerge = this.editorConfig.mode == 'editmerge'; this.appOptions.isEditMailMerge = this.editorConfig.mode == 'editmerge';
this.appOptions.customization = this.editorConfig.customization; this.appOptions.customization = this.editorConfig.customization;

View file

@ -43,6 +43,7 @@ define([
'common/main/lib/component/Window', 'common/main/lib/component/Window',
'common/main/lib/view/CopyWarningDialog', 'common/main/lib/view/CopyWarningDialog',
'common/main/lib/view/ImageFromUrlDialog', 'common/main/lib/view/ImageFromUrlDialog',
'common/main/lib/view/SelectFileDlg',
'common/main/lib/util/define', 'common/main/lib/util/define',
'spreadsheeteditor/main/app/view/Toolbar', 'spreadsheeteditor/main/app/view/Toolbar',
'spreadsheeteditor/main/app/collection/TableTemplates', 'spreadsheeteditor/main/app/collection/TableTemplates',
@ -822,7 +823,7 @@ define([
Common.NotificationCenter.trigger('edit:complete', this.toolbar); Common.NotificationCenter.trigger('edit:complete', this.toolbar);
Common.component.Analytics.trackEvent('ToolBar', 'Image'); Common.component.Analytics.trackEvent('ToolBar', 'Image');
} else { } else if (item.value === 'url') {
var me = this; var me = this;
(new Common.Views.ImageFromUrlDialog({ (new Common.Views.ImageFromUrlDialog({
@ -846,6 +847,15 @@ define([
} }
} }
})).show(); })).show();
} else if (item.value === 'storage') {
var me = this;
(new Common.Views.SelectFileDlg({
fileChoiceUrl: me.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "").replace("{documentType}", "ImagesOnly")
})).on('selectfile', function(obj, file){
me.toolbar.fireEvent('insertimage', me.toolbar);
me.api.asc_addImageDrawingObject(file.url);
Common.component.Analytics.trackEvent('ToolBar', 'Image');
}).show();
} }
}, },

View file

@ -675,7 +675,8 @@ define([
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
items: [ items: [
{ caption: me.mniImageFromFile, value: 'file' }, { caption: me.mniImageFromFile, value: 'file' },
{ caption: me.mniImageFromUrl, value: 'url' } { caption: me.mniImageFromUrl, value: 'url' },
{ caption: me.mniImageFromStorage, value: 'storage'}
] ]
}) })
}); });
@ -1537,6 +1538,7 @@ define([
$(mnu.el).html(mnu.template({id: Common.UI.getId(), caption : mnu.caption, options : mnu.options})); $(mnu.el).html(mnu.template({id: Common.UI.getId(), caption : mnu.caption, options : mnu.options}));
} else } else
this.btnPageMargins.menu.items[0].setVisible(false); this.btnPageMargins.menu.items[0].setVisible(false);
this.btnInsertImage.menu.items[2].setVisible(mode.fileChoiceUrl && mode.fileChoiceUrl.indexOf("{documentType}")>-1);
} }
me.setTab('home'); me.setTab('home');
@ -2412,6 +2414,7 @@ define([
textBottom: 'Bottom: ', textBottom: 'Bottom: ',
textRight: 'Right: ', textRight: 'Right: ',
textPortrait: 'Portrait', textPortrait: 'Portrait',
textLandscape: 'Landscape' textLandscape: 'Landscape',
mniImageFromStorage: 'Image from Storage'
}, SSE.Views.Toolbar || {})); }, SSE.Views.Toolbar || {}));
}); });

View file

@ -194,6 +194,8 @@
"Common.Views.ReviewPopover.textResolve": "Resolve", "Common.Views.ReviewPopover.textResolve": "Resolve",
"Common.Views.SaveAsDlg.textLoading": "Loading", "Common.Views.SaveAsDlg.textLoading": "Loading",
"Common.Views.SaveAsDlg.textTitle": "Folder for save", "Common.Views.SaveAsDlg.textTitle": "Folder for save",
"Common.Views.SelectFileDlg.textLoading": "Loading",
"Common.Views.SelectFileDlg.textTitle": "Select Data Source",
"Common.Views.SignDialog.cancelButtonText": "Cancel", "Common.Views.SignDialog.cancelButtonText": "Cancel",
"Common.Views.SignDialog.okButtonText": "Ok", "Common.Views.SignDialog.okButtonText": "Ok",
"Common.Views.SignDialog.textBold": "Bold", "Common.Views.SignDialog.textBold": "Bold",
@ -2081,6 +2083,7 @@
"SSE.Views.Toolbar.txtTime": "Time", "SSE.Views.Toolbar.txtTime": "Time",
"SSE.Views.Toolbar.txtUnmerge": "Unmerge Cells", "SSE.Views.Toolbar.txtUnmerge": "Unmerge Cells",
"SSE.Views.Toolbar.txtYen": "¥ Yen", "SSE.Views.Toolbar.txtYen": "¥ Yen",
"SSE.Views.Toolbar.mniImageFromStorage": "Image from Storage",
"SSE.Views.Top10FilterDialog.cancelButtonText": "Cancel", "SSE.Views.Top10FilterDialog.cancelButtonText": "Cancel",
"SSE.Views.Top10FilterDialog.okButtonText": "OK", "SSE.Views.Top10FilterDialog.okButtonText": "OK",
"SSE.Views.Top10FilterDialog.textType": "Show", "SSE.Views.Top10FilterDialog.textType": "Show",