Merge pull request #239 from ONLYOFFICE/feature/Bug_20179

Feature/bug 20179
This commit is contained in:
Julia Radzhabova 2019-09-06 14:41:13 +03:00 committed by GitHub
commit 63ae33ac31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 208 additions and 3 deletions

View file

@ -71,7 +71,7 @@ define([
disabled : false,
rendered : false,
template : _.template('<label class="radiobox"><input type="button" name="<%= name %>" class="img-commonctrl"><%= labelText %></label>'),
template : _.template('<label class="radiobox"><input type="button" name="<%= name %>" class="img-commonctrl"><span><%= labelText %></span></label>'),
initialize : function(options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
@ -101,6 +101,7 @@ define([
}));
this.$radio = el.find('input[type=button]');
this.$label = el.find('label');
this.rendered = true;
return this;
@ -145,6 +146,10 @@ define([
getValue: function() {
return this.$radio.hasClass('checked');
},
setCaption: function(text) {
this.$label.find('span').text(text);
}
});
});

View file

@ -0,0 +1,166 @@
/*
*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
/**
* CellsAddDialog.js
*
* Created by Julia Radzhabova on 06.09.2019
* Copyright (c) 2019 Ascensio System SIA. All rights reserved.
*
*/
define([
'common/main/lib/component/Window',
'common/main/lib/component/ComboBox',
'common/main/lib/component/MetricSpinner',
'common/main/lib/component/RadioBox'
], function () { 'use strict';
DE.Views.CellsAddDialog = Common.UI.Window.extend(_.extend({
options: {
width: 214,
header: true,
style: 'min-width: 214px;',
cls: 'modal-dlg'
},
initialize : function(options) {
_.extend(this.options, {
title: this.textTitle
}, options || {});
this.template = [
'<div class="box">',
'<div style="margin-bottom: 10px;">',
'<div id="table-combo-row-col" class="input-group-nr" style="display: inline-block; margin-right: 5px;"></div>',
'<div id="table-spin-row-col" style="display: inline-block;"></div>',
'</div>',
'<div id="table-radio-before" style="padding-bottom: 8px;"></div>',
'<div id="table-radio-after" style="padding-bottom: 8px;"></div>',
'<div class="footer center">',
'<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">' + this.okButtonText + '</button>',
'<button class="btn normal dlg-btn" result="cancel">' + this.cancelButtonText + '</button>',
'</div>'
].join('');
this.options.tpl = _.template(this.template)(this.options);
Common.UI.Window.prototype.initialize.call(this, this.options);
},
render: function() {
Common.UI.Window.prototype.render.call(this);
this.cmbRowCol = new Common.UI.ComboBox({
el: $('#table-combo-row-col'),
cls: 'input-group-nr',
style: 'width: 110px;',
menuStyle: 'min-width: 110px;',
editable: false,
scrollAlwaysVisible: true,
data: [
{ value: 0, displayValue: this.textRow},
{ value: 1, displayValue: this.textCol}
]
});
this.cmbRowCol.setValue(0);
this.cmbRowCol.on('selected', _.bind(function(combo, record) {
var row = record.value == 0;
this.spnCount.setMaxValue(row ? 100 : 64);
this.spnCount.setValue(this.spnCount.getNumberValue());
this.radioBefore.setCaption(row ? this.textUp : this.textLeft);
this.radioAfter.setCaption(row ? this.textDown : this.textRight);
}, this));
this.spnCount = new Common.UI.MetricSpinner({
el: $('#table-spin-row-col'),
step : 1,
width : 65,
value : 1,
defaultUnit : '',
maxValue : 100,
minValue : 1,
allowDecimal: false
});
this.radioBefore = new Common.UI.RadioBox({
el: $('#table-radio-before'),
labelText: this.textUp,
name: 'asc-radio-table-cells-add',
checked: true
});
this.radioAfter = new Common.UI.RadioBox({
el: $('#table-radio-after'),
labelText: this.textDown,
name: 'asc-radio-table-cells-add'
});
var $window = this.getChild();
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
},
_handleInput: function(state) {
if (this.options.handler) {
this.options.handler.call(this, state, this.getSettings());
}
this.close();
},
onBtnClick: function(event) {
this._handleInput(event.currentTarget.attributes['result'].value);
},
getSettings: function() {
var row = this.cmbRowCol.getValue()==0;
return {row: row, before: this.radioBefore.getValue(), count: this.spnCount.getNumberValue()};
},
onPrimary: function() {
this._handleInput('ok');
return false;
},
cancelButtonText: 'Cancel',
okButtonText: 'Ok',
textTitle: 'Insert Several',
textLeft: 'To the left',
textRight: 'To the right',
textUp: 'Above the cursor',
textDown: 'Below the cursor',
textRow: 'Rows',
textCol: 'Columns'
}, DE.Views.CellsAddDialog || {}))
});

View file

@ -55,7 +55,8 @@ define([
'documenteditor/main/app/view/TableSettingsAdvanced',
'documenteditor/main/app/view/ControlSettingsDialog',
'documenteditor/main/app/view/NumberingValueDialog',
'documenteditor/main/app/view/CellsRemoveDialog'
'documenteditor/main/app/view/CellsRemoveDialog',
'documenteditor/main/app/view/CellsAddDialog'
], function ($, _, Backbone, gateway) { 'use strict';
DE.Views.DocumentHolder = Backbone.View.extend(_.extend({
@ -1948,6 +1949,23 @@ define([
this.fireEvent('editcomplete', this);
},
onCellsAdd: function() {
var me = this;
(new DE.Views.CellsAddDialog({
handler: function (result, settings) {
if (result == 'ok') {
if (settings.row) {
settings.before ? me.api.addRowAbove(settings.count) : me.api.addRowBelow(settings.count);
} else {
settings.before ? me.api.addColumnLeft(settings.count) : me.api.addColumnRight(settings.count);
}
}
me.fireEvent('editcomplete', me);
}
})).show();
this.fireEvent('editcomplete', this);
},
createDelayedElementsViewer: function() {
var me = this;
@ -3157,6 +3175,11 @@ define([
}).on('click', function(item) {
if (me.api)
me.api.addRowBelow();
}),
new Common.UI.MenuItem({
caption: me.textSeveral
}).on('click', function(item) {
me.onCellsAdd();
})
]
})
@ -4135,7 +4158,8 @@ define([
textFollow: 'Follow move',
toDictionaryText: 'Add to Dictionary',
txtPrintSelection: 'Print Selection',
textCells: 'Cells'
textCells: 'Cells',
textSeveral: 'Several Rows/Columns'
}, DE.Views.DocumentHolder || {}));
});

View file

@ -1028,6 +1028,15 @@
"DE.Views.CellsRemoveDialog.textLeft": "Shift cells left",
"DE.Views.CellsRemoveDialog.textRow": "Delete entire row",
"DE.Views.CellsRemoveDialog.textCol": "Delete entire column",
"DE.Views.CellsAddDialog.cancelButtonText": "Cancel",
"DE.Views.CellsAddDialog.okButtonText": "Ok",
"DE.Views.CellsAddDialog.textTitle": "Insert Several",
"DE.Views.CellsAddDialog.textLeft": "To the left",
"DE.Views.CellsAddDialog.textRight": "To the right",
"DE.Views.CellsAddDialog.textUp": "Above the cursor",
"DE.Views.CellsAddDialog.textDown": "Below the cursor",
"DE.Views.CellsAddDialog.textRow": "Rows",
"DE.Views.CellsAddDialog.textCol": "Columns",
"DE.Views.ChartSettings.textAdvanced": "Show advanced settings",
"DE.Views.ChartSettings.textArea": "Area",
"DE.Views.ChartSettings.textBar": "Bar",
@ -1286,6 +1295,7 @@
"DE.Views.DocumentHolder.updateStyleText": "Update %1 style",
"DE.Views.DocumentHolder.vertAlignText": "Vertical Alignment",
"DE.Views.DocumentHolder.textCells": "Cells",
"DE.Views.DocumentHolder.textSeveral": "Several Rows/Columns",
"DE.Views.DropcapSettingsAdvanced.cancelButtonText": "Cancel",
"DE.Views.DropcapSettingsAdvanced.okButtonText": "OK",
"DE.Views.DropcapSettingsAdvanced.strBorders": "Borders & Fill",