[SSE mobile] Disable editing in opensource version

This commit is contained in:
Julia Radzhabova 2020-02-10 19:26:27 +03:00
parent 32cb105d4d
commit ae69d00eb7
8 changed files with 46 additions and 199 deletions

View file

@ -606,6 +606,21 @@ define([
applyLicense: function() {
var me = this;
if (this.editorConfig.mode !== 'view' && !this.isSupportEditFeature()) {
var value = Common.localStorage.getItem("sse-opensource-warning");
value = (value!==null) ? parseInt(value) : 0;
var now = (new Date).getTime();
if (now - value > 86400000) {
Common.localStorage.setItem("sse-opensource-warning", now);
uiApp.modal({
title: me.notcriticalErrorTitle,
text : me.errorOpensource,
buttons: [{text: 'OK'}]
});
}
SSE.getController('Toolbar').activateControls();
return;
}
if (this._state.licenseType) {
var license = this._state.licenseType,
buttons = [{text: 'OK'}];
@ -712,8 +727,9 @@ define([
me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights;
me.appOptions.canEdit = me.permissions.edit !== false && // can edit
(me.editorConfig.canRequestEditRights || me.editorConfig.mode !== 'view'); // if mode=="view" -> canRequestEditRights must be defined
me.appOptions.isEdit = (me.appOptions.canLicense || me.appOptions.isEditDiagram || me.appOptions.isEditMailMerge) && me.permissions.edit !== false && me.editorConfig.mode !== 'view';
(me.editorConfig.canRequestEditRights || me.editorConfig.mode !== 'view') && // if mode=="view" -> canRequestEditRights must be defined
me.isSupportEditFeature();
me.appOptions.isEdit = (me.appOptions.canLicense || me.appOptions.isEditDiagram || me.appOptions.isEditMailMerge) && me.permissions.edit !== false && me.editorConfig.mode !== 'view' && me.isSupportEditFeature();
me.appOptions.canDownload = (me.permissions.download !== false);
me.appOptions.canPrint = (me.permissions.print !== false);
@ -1247,7 +1263,6 @@ define([
},
onSendThemeColors: function(colors, standart_colors) {
Common.Utils.ThemeColor.setColors(colors, standart_colors);
},
onAdvancedOptions: function(type, advOptions, mode, formatOptions) {
@ -1460,6 +1475,10 @@ define([
}
},
isSupportEditFeature: function() {
return false;
},
leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.',
criticalErrorTitle: 'Error',
notcriticalErrorTitle: 'Warning',
@ -1642,7 +1661,8 @@ define([
errorFrmlMaxTextLength: 'Text values in formulas are limited to 255 characters.<br>Use the CONCATENATE function or concatenation operator (&)',
waitText: 'Please, wait...',
errorFileSizeExceed: 'The file size exceeds the limitation set for your server.<br>Please contact your Document Server administrator for details.',
errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.<br>Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.'
errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.<br>Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.',
errorOpensource: 'Files can be opened for viewing only. Mobile web editors are not available in the Open Source version.'
}
})(), SSE.Controllers.Main || {}))
});

View file

@ -78,10 +78,6 @@ define([
onInsertChart: function (type) {
SSE.getController('AddContainer').hideModal();
var settings = this.api.asc_getChartObject();
settings.changeType(type);
this.api.asc_addChartDrawingObject(settings);
},
txtDiagramTitle: 'Chart Title',

View file

@ -69,6 +69,7 @@ define([
'function:info': me.onFunctionInfo.bind(me)
}
});
this.fd = fd;
},
setApi: function (api) {
@ -111,40 +112,7 @@ define([
editorLang = (editorLang ? editorLang : 'en').split(/[\-\_]/)[0].toLowerCase();
var localizationFunctionsDesc = function (data) {
var jsonDesc = {},
view = me.getView('AddFunction');
fd = data;
try {
jsonDesc = JSON.parse(fd);
} catch (e) {
jsonDesc = fd
}
var grouparr = me.api.asc_getFormulasInfo();
for (var g in grouparr) {
var group = grouparr[g];
var groupname = group.asc_getGroupName();
var funcarr = group.asc_getFormulasArray();
for (var f in funcarr) {
var func = funcarr[f];
var _name = func.asc_getName();
functions[_name] = {
type: _name,
group: groupname,
caption: func.asc_getLocaleName(),
args: (jsonDesc && jsonDesc[_name]) ? jsonDesc[_name].a : '',
descr: (jsonDesc && jsonDesc[_name]) ? jsonDesc[_name].d : ''
};
}
}
view.setFunctions(functions, editorLang);
view.render();
};
var localizationFunctionsDesc = function (data) {};
$.getJSON(Common.Utils.String.format("{0}/{1}_desc.json", "resources/l10n/functions", editorLang), function(json) {
localizationFunctionsDesc(json);
@ -155,8 +123,6 @@ define([
onInsertFunction: function (type) {
SSE.getController('AddContainer').hideModal();
this.api.asc_insertFormula(this.api.asc_getFormulaLocaleName(type), Asc.c_oAscPopUpSelectorType.Func, true);
},
onFunctionInfo: function (type) {

View file

@ -49,54 +49,6 @@ define([
var cfgLink;
// Handlers
function onInsertLink (args) {
var link = new Asc.asc_CHyperlink();
if ( args.type == 'ext' ) {
var url = args.url,
urltype = this.api.asc_getUrlType($.trim(url)),
isEmail = (urltype == 2);
if (urltype < 1) {
uiApp.alert(this.txtNotUrl);
return;
}
url = url.replace(/^\s+|\s+$/g,'');
if (! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) )
url = (isEmail ? 'mailto:' : 'http://' ) + url;
url = url.replace(new RegExp("%20",'g')," ");
link.asc_setType(Asc.c_oAscHyperlinkType.WebLink);
link.asc_setHyperlinkUrl(url);
display = url;
} else {
var isValid = /^[A-Z]+[1-9]\d*:[A-Z]+[1-9]\d*$/.test(args.url);
if (!isValid)
isValid = /^[A-Z]+[1-9]\d*$/.test(args.url);
if (!isValid) {
uiApp.alert(this.textInvalidRange);
return;
}
link.asc_setType(Asc.c_oAscHyperlinkType.RangeLink);
link.asc_setSheet(args.sheet);
link.asc_setRange(args.url);
var display = args.sheet + '!' + args.url;
}
link.asc_setText(args.text == null ? null : !!args.text ? args.text : display);
link.asc_setTooltip(args.tooltip);
this.api.asc_insertHyperlink(link);
SSE.getController('AddContainer').hideModal();
}
function onChangePanel (view, pageId) {
var me = this;
@ -142,7 +94,7 @@ define([
this.addListeners({
'AddLink': {
'panel:change' : onChangePanel.bind(this)
, 'link:insert': onInsertLink.bind(this)
, 'link:insert': this.onInsertLink.bind(this)
, 'link:changetype': onChangeLinkType.bind(this)
, 'link:changesheet': onChangeLinkSheet.bind(this)
}
@ -218,6 +170,10 @@ define([
view.fireEvent('page:show', [this, '#addlink']);
},
onInsertLink: function(args){
SSE.getController('AddContainer').hideModal();
},
textInvalidRange : 'ERROR! Invalid cells range',
txtNotUrl : 'This field should be a URL in the format \"http://www.example.com\"'
}

View file

@ -112,10 +112,6 @@ define([
if (!_.isEmpty(url)) {
if ((/((^https?)|(^ftp)):\/\/.+/i.test(url))) {
SSE.getController('AddContainer').hideModal();
_.defer(function () {
me.api.asc_addImageDrawingObject(url);
});
} else {
uiApp.alert(me.txtNotUrl);
}
@ -124,7 +120,6 @@ define([
}
} else {
SSE.getController('AddContainer').hideModal();
this.api.asc_addImage();
}
},
@ -133,11 +128,6 @@ define([
},
onInsertFilter: function(checked) {
var formatTableInfo = this.api.asc_getCellInfo().asc_getFormatTableInfo();
var tablename = (formatTableInfo) ? formatTableInfo.asc_getTableName() : undefined;
if (checked)
this.api.asc_addAutoFilter(); else
this.api.asc_changeAutoFilter(tablename, Asc.c_oAscChangeFilterOptions.filter, checked);
},
onError: function(id, level, errData) {

View file

@ -211,12 +211,6 @@ define([
},
onShapeClick: function (e) {
var $target = $(e.currentTarget);
if ($target && this.api) {
this.api.asc_addShapeOnSheet($target.data('type'));
}
SSE.getController('AddContainer').hideModal();
},

View file

@ -53,11 +53,9 @@ define([
SSE.Controllers.EditChart = Backbone.Controller.extend(_.extend((function() {
var _stack = [],
_chartObject = undefined,
_shapeObject = undefined,
_borderInfo = {color: '000000', width: 1},
_metricText = Common.Utils.Metric.getCurrentMetricName(),
_isEdit = false;
_metricText = Common.Utils.Metric.getCurrentMetricName();
var borderSizeTransform = (function() {
var _sizes = [0, 0.5, 1, 1.5, 2.25, 3, 4.5, 6];
@ -101,23 +99,19 @@ define([
'page:show' : this.onPageShow
}
});
this._chartObject = undefined;
this._isEdit = false;
},
setApi: function (api) {
var me = this;
me.api = api;
me.api.asc_registerCallback('asc_onSelectionChanged', _.bind(me.onApiSelectionChanged, me));
me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me));
me.api.asc_registerCallback('asc_onUpdateChartStyles', _.bind(me.onApiUpdateChartStyles, me));
// me.api.asc_registerCallback('asc_onSelectionChanged', _.bind(me.onApiSelectionChanged, me));
// me.api.asc_registerCallback('asc_onEditorSelectionChanged', _.bind(me.onApiEditorSelectionChanged, me));
// me.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(me.onApiInitEditorStyles, me)); // TODO: It does not work until the error in the SDK
},
setMode: function (mode) {
_isEdit = mode.isEdit;
this._isEdit = mode.isEdit;
},
onLaunch: function () {
@ -178,15 +172,17 @@ define([
initRootPage: function () {
$('#chart-remove').single('click', _.bind(this.onRemoveChart, this));
if (!_.isUndefined(_chartObject)) {
this.updateAxisProps(_chartObject.get_ChartProperties().getType());
if (!_.isUndefined(this._chartObject)) {
this.updateAxisProps(this._chartObject.get_ChartProperties().getType());
}
},
initStylePage: function () {
if (_.isUndefined(this._chartObject)) return;
var me = this,
color,
chartProperties = _chartObject.get_ChartProperties(),
chartProperties = me._chartObject.get_ChartProperties(),
shapeProperties = _shapeObject.get_ShapeProperties();
// Type
@ -199,7 +195,7 @@ define([
// Styles
_.defer(function () {
me._updateChartStyles(me.api.asc_getChartPreviews(_chartObject.get_ChartProperties().getType()));
me._updateChartStyles(me.api.asc_getChartPreviews(me._chartObject.get_ChartProperties().getType()));
});
// Fill
@ -247,8 +243,10 @@ define([
},
initLayoutPage: function () {
if (_.isUndefined(this._chartObject)) return;
var me = this,
chartProperties = _chartObject.get_ChartProperties(),
chartProperties = me._chartObject.get_ChartProperties(),
chartType = chartProperties.getType(),
$layoutPage = $('.page[data-page=edit-chart-layout]');
@ -564,41 +562,9 @@ define([
},
onType: function (e) {
var me = this,
$target = $(e.currentTarget),
type = $target.data('type');
$('.chart-types li').removeClass('active');
$target.addClass('active');
_.defer(function() {
var image = new Asc.asc_CImgProperty(),
chart = _chartObject.get_ChartProperties();
chart.changeType(type);
image.put_ChartProperties(chart);
me.api.asc_setGraphicObjectProps(image);
// Force update styles
me._updateChartStyles(me.api.asc_getChartPreviews(chart.getType()));
me.updateAxisProps(type);
});
},
onStyle: function (e) {
var me = this,
$target = $(e.currentTarget),
type = $target.data('type');
var image = new Asc.asc_CImgProperty(),
chart = _chartObject.get_ChartProperties();
chart.putStyle(type);
image.put_ChartProperties(chart);
me.api.asc_setGraphicObjectProps(image);
},
onFillColor:function (palette, color) {
@ -937,32 +903,10 @@ define([
// API handlers
onApiUpdateChartStyles: function () {
if (this.api && _chartObject && _chartObject.get_ChartProperties()) {
this._updateChartStyles(this.api.asc_getChartPreviews(_chartObject.get_ChartProperties().getType()));
}
},
onApiSelectionChanged: function(info) {
if (!_isEdit) {
return;
}
var me = this,
selectedObjects = [],
selectType = info.asc_getFlags().asc_getSelectionType();
if (selectType == Asc.c_oAscSelectionType.RangeChart) {
selectedObjects = me.api.asc_getGraphicObjectProps();
}
me.onApiFocusObject(selectedObjects);
},
onApiFocusObject: function (objects) {
_stack = objects;
if (!_isEdit) {
if (!this._isEdit) {
return;
}
@ -989,7 +933,7 @@ define([
}
};
_chartObject = getTopObject(charts);
this._chartObject = getTopObject(charts);
_shapeObject = getTopObject(shapes);
},

View file

@ -241,28 +241,9 @@ define([
},
onReorder: function(e) {
var $target = $(e.currentTarget),
type = $target.data('type'),
ascType;
if (type == 'all-up') {
ascType = Asc.c_oAscDrawingLayerType.BringToFront;
} else if (type == 'all-down') {
ascType = Asc.c_oAscDrawingLayerType.SendToBack;
} else if (type == 'move-up') {
ascType = Asc.c_oAscDrawingLayerType.BringForward;
} else {
ascType = Asc.c_oAscDrawingLayerType.SendBackward;
}
this.api.asc_setSelectedDrawingObjectLayer(ascType);
},
onReplace: function (e) {
var $target = $(e.currentTarget),
type = $target.data('type');
this.api.asc_changeShapeType(type);
},
onBorderSize: function (e) {