[SSE][PE] Fix list settings (different list types)

This commit is contained in:
Julia Radzhabova 2020-06-26 14:02:09 +03:00
parent 260ab8b283
commit b97195489b
4 changed files with 48 additions and 51 deletions

View file

@ -62,8 +62,7 @@ define([
}, },
initialize : function(options) { initialize : function(options) {
this.type = (options.type>0) ? 1 : 0; this.type = options.type || 0;
this.subtype = (options.subtype>=0) ? options.subtype : 1;
_.extend(this.options, { _.extend(this.options, {
title: this.txtTitle title: this.txtTitle
@ -173,7 +172,7 @@ define([
this._changedProps.asc_putListType(1, record.value); this._changedProps.asc_putListType(1, record.value);
} }
}, this)); }, this));
this.cmbNumFormat.setValue(this.subtype); this.cmbNumFormat.setValue(1);
var itemsTemplate = var itemsTemplate =
[ [
@ -222,7 +221,9 @@ define([
formcontrol[0].innerHTML = ''; formcontrol[0].innerHTML = '';
} }
}); });
this.cmbBulletFormat.selectRecord(this.cmbBulletFormat.store.at(1)); var rec = this.cmbBulletFormat.store.at(1);
this.cmbBulletFormat.selectRecord(rec);
this.bulletProps = {symbol: rec.get('symbol'), font: rec.get('font')};
this.cmbBulletFormat.on('selected', _.bind(function (combo, record) { this.cmbBulletFormat.on('selected', _.bind(function (combo, record) {
if (this._changedProps) { if (this._changedProps) {
if (record.value === 1) { if (record.value === 1) {
@ -348,7 +349,14 @@ define([
if (this.options.handler) if (this.options.handler)
{ {
var type = this.btnBullet.pressed ? 0 : 1; var type = this.btnBullet.pressed ? 0 : 1;
if (this._changedProps && (this.type !== type)) { if (this.originalType == AscFormat.BULLET_TYPE_BULLET_NONE) {
this._changedProps = new Asc.asc_CBullet();
this._changedProps.asc_putColor(Common.Utils.ThemeColor.getRgbColor(this.color));
this._changedProps.asc_putSize(this.spnSize.getNumberValue());
}
if (this.originalType == AscFormat.BULLET_TYPE_BULLET_NONE ||
this.originalType == AscFormat.BULLET_TYPE_BULLET_CHAR && type==1 || this.originalType == AscFormat.BULLET_TYPE_BULLET_AUTONUM && type==0) { // changed list type
if (type==0) {//markers if (type==0) {//markers
if (this.cmbBulletFormat.getValue()==-1) { if (this.cmbBulletFormat.getValue()==-1) {
this._changedProps.asc_putListType(0, -1); this._changedProps.asc_putListType(0, -1);
@ -357,8 +365,7 @@ define([
this._changedProps.asc_putSymbol(this.bulletProps.symbol); this._changedProps.asc_putSymbol(this.bulletProps.symbol);
} }
} else { } else {
var value = this.cmbNumFormat.getValue(); this._changedProps.asc_putListType(1, this.cmbNumFormat.getValue());
this._changedProps.asc_putListType(1, value);
this._changedProps.asc_putNumStartAt(this.spnStart.getNumberValue()); this._changedProps.asc_putNumStartAt(this.spnStart.getNumberValue());
} }
} }
@ -378,11 +385,11 @@ define([
_setDefaults: function (props) { _setDefaults: function (props) {
if (props) { if (props) {
(this.type == 0) ? this.btnBullet.toggle(true) : this.btnNumbering.toggle(true); var type = 0;
this.ShowHideElem(this.type);
var bullet = props.asc_getBullet(); var bullet = props.asc_getBullet();
if (bullet) { if (bullet) {
this.originalType = bullet.asc_getType();
this.spnSize.setValue(bullet.asc_getSize() || '', true); this.spnSize.setValue(bullet.asc_getSize() || '', true);
var color = bullet.asc_getColor(); var color = bullet.asc_getColor();
@ -394,6 +401,7 @@ define([
} }
} else } else
color = 'transparent'; color = 'transparent';
this.color = Common.Utils.ThemeColor.colorValue2EffectId(color);
this.btnColor.setColor(color); this.btnColor.setColor(color);
if ( typeof(color) == 'object' ) { if ( typeof(color) == 'object' ) {
var isselected = false; var isselected = false;
@ -408,41 +416,42 @@ define([
} else } else
this.colors.select(color,true); this.colors.select(color,true);
var symbol = bullet.asc_getSymbol(); if (this.originalType == AscFormat.BULLET_TYPE_BULLET_NONE) {
if (symbol===undefined) { // numbered this.cmbNumFormat.setValue(-1);
this.cmbNumFormat.setValue(this.subtype, ''); this.cmbBulletFormat.setValue(-1);
var rec = this.cmbBulletFormat.store.at(1); type = this.type;
this.cmbBulletFormat.selectRecord(rec); } else if (this.originalType == AscFormat.BULLET_TYPE_BULLET_CHAR) {
this.bulletProps = {symbol: rec.get('symbol'), font: rec.get('font')}; var symbol = bullet.asc_getSymbol();
if (symbol) {
var value = bullet.asc_getNumStartAt(); this.bulletProps = {symbol: symbol, font: bullet.asc_getFont()};
this.spnStart.setValue(value || '', true);
this.spnStart.setDisabled(value===null);
} else {
this.bulletProps = {symbol: (symbol!==null) ? symbol : '', font: bullet.asc_getFont()};
if (symbol!==null) {
if (!this.cmbBulletFormat.store.findWhere({value: 0, symbol: this.bulletProps.symbol, font: this.bulletProps.font})) if (!this.cmbBulletFormat.store.findWhere({value: 0, symbol: this.bulletProps.symbol, font: this.bulletProps.font}))
this.cmbBulletFormat.store.add({ displayValue: this.txtSymbol + ': ', value: 0, symbol: this.bulletProps.symbol, font: this.bulletProps.font }, {at: this.cmbBulletFormat.store.length-1}); this.cmbBulletFormat.store.add({ displayValue: this.txtSymbol + ': ', value: 0, symbol: this.bulletProps.symbol, font: this.bulletProps.font }, {at: this.cmbBulletFormat.store.length-1});
this.cmbBulletFormat.setData(this.cmbBulletFormat.store.models); this.cmbBulletFormat.setData(this.cmbBulletFormat.store.models);
this.cmbBulletFormat.selectRecord(this.cmbBulletFormat.store.findWhere({value: 0, symbol: this.bulletProps.symbol, font: this.bulletProps.font})); this.cmbBulletFormat.selectRecord(this.cmbBulletFormat.store.findWhere({value: 0, symbol: this.bulletProps.symbol, font: this.bulletProps.font}));
} else } else
this.cmbBulletFormat.setValue(''); this.cmbBulletFormat.setValue('');
this.cmbNumFormat.setValue(1); this._changedProps = bullet;
type = 0;
} else if (this.originalType == AscFormat.BULLET_TYPE_BULLET_AUTONUM) {
var autonum = bullet.asc_getAutoNumType();
this.cmbNumFormat.setValue(autonum, '');
var value = bullet.asc_getNumStartAt();
this.spnStart.setValue(value || '', true);
this.spnStart.setDisabled(value===null);
this._changedProps = bullet;
type = 1;
} }
this._changedProps = bullet; } else {// different bullet types
} this.cmbNumFormat.setValue(-1);
} this.cmbBulletFormat.setValue(-1);
if (!this._changedProps) { this._changedProps = new Asc.asc_CBullet();
this._changedProps = new Asc.asc_CBullet(); type = this.type;
this._changedProps.asc_putColor(Common.Utils.ThemeColor.getRgbColor(this.color));
this._changedProps.asc_putSize(this.spnSize.getNumberValue());
if (this.type==0) {
this._changedProps.asc_putListType(0, this.cmbBulletFormat.getValue());
} else {
this._changedProps.asc_putListType(1, this.cmbNumFormat.getValue());
this._changedProps.asc_putNumStartAt(this.spnStart.getNumberValue());
} }
} }
(type == 1) ? this.btnNumbering.toggle(true) : this.btnBullet.toggle(true);
this.ShowHideElem(type);
}, },
txtTitle: 'List Settings', txtTitle: 'List Settings',

View file

@ -486,7 +486,6 @@ define([
this.toolbar.mnuMarkersPicker.selectByIndex(this._state.bullets.subtype, true); this.toolbar.mnuMarkersPicker.selectByIndex(this._state.bullets.subtype, true);
else else
this.toolbar.mnuMarkersPicker.deselectAll(true); this.toolbar.mnuMarkersPicker.deselectAll(true);
this.toolbar.mnuMarkerSettings && this.toolbar.mnuMarkerSettings.setDisabled(this._state.bullets.subtype<0);
break; break;
case 1: case 1:
var idx = 0; var idx = 0;
@ -515,7 +514,6 @@ define([
} }
this.toolbar.btnNumbers.toggle(true, true); this.toolbar.btnNumbers.toggle(true, true);
this.toolbar.mnuNumbersPicker.selectByIndex(idx, true); this.toolbar.mnuNumbersPicker.selectByIndex(idx, true);
this.toolbar.mnuNumberSettings && this.toolbar.mnuNumberSettings.setDisabled(idx==0);
break; break;
} }
} }
@ -1136,17 +1134,12 @@ define([
api: me.api, api: me.api,
props: props, props: props,
type: type, type: type,
subtype: this._state.bullets.subtype,
interfaceLang: me.toolbar.mode.lang, interfaceLang: me.toolbar.mode.lang,
handler: function(result, value) { handler: function(result, value) {
if (result == 'ok') { if (result == 'ok') {
if (me.api) { if (me.api) {
if (value==-1) props.asc_putBullet(value);
me.api.put_ListType(0, -1); me.api.paraApply(props);
else {
props.asc_putBullet(value);
me.api.paraApply(props);
}
} }
} }
Common.NotificationCenter.trigger('edit:complete', me.toolbar); Common.NotificationCenter.trigger('edit:complete', me.toolbar);
@ -1715,8 +1708,6 @@ define([
this.toolbar.mnuMarkersPicker.selectByIndex(0, true); this.toolbar.mnuMarkersPicker.selectByIndex(0, true);
this.toolbar.mnuNumbersPicker.selectByIndex(0, true); this.toolbar.mnuNumbersPicker.selectByIndex(0, true);
this.toolbar.mnuMarkerSettings && this.toolbar.mnuMarkerSettings.setDisabled(true);
this.toolbar.mnuNumberSettings && this.toolbar.mnuNumberSettings.setDisabled(true);
}, },
_getApiTextSize: function () { _getApiTextSize: function () {

View file

@ -1111,7 +1111,6 @@ define([
{template: _.template('<div id="id-toolbar-menu-markers" class="menu-markers" style="width: 139px; margin: 0 16px;"></div>')}, {template: _.template('<div id="id-toolbar-menu-markers" class="menu-markers" style="width: 139px; margin: 0 16px;"></div>')},
this.mnuMarkerSettings = new Common.UI.MenuItem({ this.mnuMarkerSettings = new Common.UI.MenuItem({
caption: this.textListSettings, caption: this.textListSettings,
disabled: (this.mnuMarkersPicker.conf.index || 0)==0,
value: 'settings' value: 'settings'
}) })
] ]
@ -1124,7 +1123,6 @@ define([
{template: _.template('<div id="id-toolbar-menu-numbering" class="menu-markers" style="width: 185px; margin: 0 16px;"></div>')}, {template: _.template('<div id="id-toolbar-menu-numbering" class="menu-markers" style="width: 185px; margin: 0 16px;"></div>')},
this.mnuNumberSettings = new Common.UI.MenuItem({ this.mnuNumberSettings = new Common.UI.MenuItem({
caption: this.textListSettings, caption: this.textListSettings,
disabled: (this.mnuNumbersPicker.conf.index || 0)==0,
value: 'settings' value: 'settings'
}) })
] ]

View file

@ -777,8 +777,7 @@ define([
(new Common.Views.ListSettingsDialog({ (new Common.Views.ListSettingsDialog({
api: me.api, api: me.api,
props: props, props: props,
type: listtype.get_ListType(), type: 0,
subtype: listtype.get_ListSubType(),
interfaceLang: me.permissions.lang, interfaceLang: me.permissions.lang,
handler: function(result, value) { handler: function(result, value) {
if (result == 'ok') { if (result == 'ok') {