[DE] Fix context menu for forms

This commit is contained in:
Julia Radzhabova 2020-10-07 19:13:24 +03:00
parent 31b4d48f45
commit d5875737ba
3 changed files with 48 additions and 17 deletions

View file

@ -785,11 +785,12 @@ define([
toolbar.btnContentControls.setDisabled(paragraph_locked || header_locked);
if (!(paragraph_locked || header_locked)) {
var control_disable = control_plain || content_locked;
var control_disable = control_plain || content_locked,
if_form = control_props && control_props.get_FormPr();
for (var i=0; i<7; i++)
toolbar.btnContentControls.menu.items[i].setDisabled(control_disable);
toolbar.btnContentControls.menu.items[8].setDisabled(!in_control || lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.SdtLocked);
toolbar.btnContentControls.menu.items[10].setDisabled(!in_control);
toolbar.btnContentControls.menu.items[8].setDisabled(!in_control || lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.SdtLocked || if_form);
toolbar.btnContentControls.menu.items[10].setDisabled(!in_control || if_form);
}
var need_text_disable = paragraph_locked || header_locked || in_chart || rich_edit_lock || plain_edit_lock;

View file

@ -2786,13 +2786,14 @@ define([
});
var menuTableRemoveControl = new Common.UI.MenuItem({
iconCls: 'menu__icon cc-remove',
caption: me.textRemove,
value: 'remove'
}).on('click', _.bind(me.onControlsSelect, me));
var menuTableControlSettings = new Common.UI.MenuItem({
caption: me.textSettings,
value: 'settings'
caption: me.textSettings,
value: 'settings'
}).on('click', _.bind(me.onControlsSelect, me));
var menuTableControl = new Common.UI.MenuItem({
@ -3222,9 +3223,11 @@ define([
menuTableControl.setVisible(in_control);
if (in_control) {
var control_props = me.api.asc_GetContentControlProperties(),
lock_type = (control_props) ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked;
lock_type = (control_props) ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked,
is_form = control_props && control_props.get_FormPr();
menuTableRemoveControl.setDisabled(lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.SdtLocked);
menuTableControlSettings.setVisible(me.mode.canEditContentControl);
menuTableRemoveControl.setCaption(is_form ? me.getControlLabel(control_props) : me.textRemoveControl);
menuTableControlSettings.setVisible(me.mode.canEditContentControl && !is_form);
var spectype = control_props ? control_props.get_SpecificType() : Asc.c_oAscContentControlSpecificType.None;
control_lock = control_lock || spectype==Asc.c_oAscContentControlSpecificType.CheckBox || spectype==Asc.c_oAscContentControlSpecificType.Picture ||
@ -3669,6 +3672,7 @@ define([
});
var menuParaRemoveControl = new Common.UI.MenuItem({
iconCls: 'menu__icon cc-remove',
caption: me.textRemoveControl,
value: 'remove'
}).on('click', _.bind(me.onControlsSelect, me));
@ -3901,14 +3905,16 @@ define([
!value.paraProps.value.can_DeleteInlineContentControl() || !value.paraProps.value.can_EditInlineContentControl()) : false;
var in_toc = me.api.asc_GetTableOfContentsPr(true),
in_control = !in_toc && me.api.asc_IsContentControl() ;
in_control = !in_toc && me.api.asc_IsContentControl(),
control_props = in_control ? me.api.asc_GetContentControlProperties() : null,
is_form = control_props && control_props.get_FormPr();
menuParaRemoveControl.setVisible(in_control);
menuParaControlSettings.setVisible(in_control && me.mode.canEditContentControl);
menuParaControlSettings.setVisible(in_control && me.mode.canEditContentControl && !is_form);
menuParaControlSeparator.setVisible(in_control);
if (in_control) {
var control_props = me.api.asc_GetContentControlProperties(),
lock_type = (control_props) ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked;
var lock_type = (control_props) ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked;
menuParaRemoveControl.setDisabled(lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.SdtLocked);
menuParaRemoveControl.setCaption(is_form ? me.getControlLabel(control_props) : me.textRemoveControl);
var spectype = control_props ? control_props.get_SpecificType() : Asc.c_oAscContentControlSpecificType.None;
control_lock = control_lock || spectype==Asc.c_oAscContentControlSpecificType.CheckBox || spectype==Asc.c_oAscContentControlSpecificType.Picture ||
@ -4320,6 +4326,23 @@ define([
this._state.lock_doc = false;
},
getControlLabel: function(props) {
var type = props ? props.get_SpecificType() : Asc.c_oAscContentControlSpecificType.None;
switch (type) {
case Asc.c_oAscContentControlSpecificType.CheckBox:
var specProps = props.get_CheckBoxPr();
return (typeof specProps.get_GroupKey() !== 'string') ? this.textRemCheckBox : this.textRemRadioBox;
case Asc.c_oAscContentControlSpecificType.ComboBox:
return this.textRemComboBox;
case Asc.c_oAscContentControlSpecificType.DropDownList:
return this.textRemDropdown;
case Asc.c_oAscContentControlSpecificType.Picture:
return this.textRemPicture;
default:
return this.textRemField;
}
},
focus: function() {
var me = this;
_.defer(function(){ me.cmpEl.focus(); }, 50);
@ -4546,7 +4569,14 @@ define([
txtInsertCaption: 'Insert Caption',
txtEmpty: '(Empty)',
textFromStorage: 'From Storage',
advancedDropCapText: 'Drop Cap Settings'
advancedDropCapText: 'Drop Cap Settings',
textRemCheckBox: 'Remove Checkbox',
textRemRadioBox: 'Remove Radio Button',
textRemComboBox: 'Remove Combo Box',
textRemDropdown: 'Remove Dropdown',
textRemPicture: 'Remove Image',
textRemField: 'Remove Text Field'
}, DE.Views.DocumentHolder || {}));
}, DE.Views.DocumentHolder || {}));
});

View file

@ -227,7 +227,7 @@ define([
this.btnListAdd = new Common.UI.Button({
parentEl: $markup.findById('#form-list-add'),
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-add',
iconCls: 'toolbar__icon btn-zoomup',
hint: this.textTipAdd
});
this.btnListAdd.on('click', _.bind(this.onAddItem, this));
@ -711,7 +711,7 @@ define([
this.btnListDown.setDisabled(disabled || this._state.DisabledControls);
},
textField: 'Text field',
textField: 'Text Field',
textKey: 'Key',
textPlaceholder: 'Placeholder',
textTip: 'Tip',
@ -721,9 +721,9 @@ define([
textDelete: 'Delete',
textLock: 'Lock',
textUnlock: 'Unlock',
textRadiobox: 'Radio button',
textRadiobox: 'Radio Button',
textCheckbox: 'Checkbox',
textCombobox: 'Combo box',
textCombobox: 'Combo Box',
textDropDown: 'Dropdown',
textImage: 'Image',
textGroupKey: 'Group key',