[DE] Disable view form button when no roles

This commit is contained in:
Julia Radzhabova 2022-04-18 15:50:58 +03:00
parent 3c870469f2
commit bdbe8d0f1c
3 changed files with 46 additions and 64 deletions

View file

@ -155,20 +155,20 @@ define([
Common.Utils.lockControls(Common.enumLock.contentLock, content_locked, {array: arr});
},
onChangeSpecialFormsGlobalSettings: function() {
if (this.view && this.view.mnuFormsColorPicker) {
var clr = this.api.asc_GetSpecialFormsHighlightColor(),
show = !!clr;
this.view.mnuNoFormsColor.setChecked(!show, true);
this.view.mnuFormsColorPicker.clearSelection();
if (clr) {
clr = Common.Utils.ThemeColor.getHexColor(clr.get_r(), clr.get_g(), clr.get_b());
this.view.mnuFormsColorPicker.selectByRGB(clr, true);
}
this.view.btnHighlight.currentColor = clr;
this.view.btnHighlight.setColor(this.view.btnHighlight.currentColor || 'transparent');
}
},
// onChangeSpecialFormsGlobalSettings: function() {
// if (this.view && this.view.mnuFormsColorPicker) {
// var clr = this.api.asc_GetSpecialFormsHighlightColor(),
// show = !!clr;
// this.view.mnuNoFormsColor.setChecked(!show, true);
// this.view.mnuFormsColorPicker.clearSelection();
// if (clr) {
// clr = Common.Utils.ThemeColor.getHexColor(clr.get_r(), clr.get_g(), clr.get_b());
// this.view.mnuFormsColorPicker.selectByRGB(clr, true);
// }
// this.view.btnHighlight.currentColor = clr;
// this.view.btnHighlight.setColor(this.view.btnHighlight.currentColor || 'transparent');
// }
// },
onControlsSelect: function(type) {
if (!(this.toolbar.mode && this.toolbar.mode.canFeatureContentControl && this.toolbar.mode.canFeatureForms)) return;
@ -215,21 +215,21 @@ define([
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
onNoControlsColor: function(item) {
if (!item.isChecked())
this.api.asc_SetSpecialFormsHighlightColor(201, 200, 255);
else
this.api.asc_SetSpecialFormsHighlightColor();
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
// onNoControlsColor: function(item) {
// if (!item.isChecked())
// this.api.asc_SetSpecialFormsHighlightColor(201, 200, 255);
// else
// this.api.asc_SetSpecialFormsHighlightColor();
// Common.NotificationCenter.trigger('edit:complete', this.toolbar);
// },
onSelectControlsColor: function(color) {
var clr = Common.Utils.ThemeColor.getRgbColor(color);
if (this.api) {
this.api.asc_SetSpecialFormsHighlightColor(clr.get_r(), clr.get_g(), clr.get_b());
}
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
// onSelectControlsColor: function(color) {
// var clr = Common.Utils.ThemeColor.getRgbColor(color);
// if (this.api) {
// this.api.asc_SetSpecialFormsHighlightColor(clr.get_r(), clr.get_g(), clr.get_b());
// }
// Common.NotificationCenter.trigger('edit:complete', this.toolbar);
// },
onGoTo: function(type) {
if (this.api)
@ -363,11 +363,11 @@ define([
(new Promise(function (accept, reject) {
accept();
})).then(function(){
if (config.canEditContentControl && me.view.btnHighlight) {
var clr = me.api.asc_GetSpecialFormsHighlightColor();
clr && (clr = Common.Utils.ThemeColor.getHexColor(clr.get_r(), clr.get_g(), clr.get_b()));
me.view.btnHighlight.currentColor = clr;
}
// if (config.canEditContentControl && me.view.btnHighlight) {
// var clr = me.api.asc_GetSpecialFormsHighlightColor();
// clr && (clr = Common.Utils.ThemeColor.getHexColor(clr.get_r(), clr.get_g(), clr.get_b()));
// me.view.btnHighlight.currentColor = clr;
// }
config.isEdit && config.canFeatureContentControl && config.isFormCreator && me.showCreateFormTip(); // show tip only when create form in docxf
// change to event asc_onRefreshRolesList

View file

@ -93,9 +93,6 @@ define([
this.btnImageField && this.btnImageField.on('click', function (b, e) {
me.fireEvent('forms:insert', ['picture']);
});
this.btnViewForm && this.btnViewForm.on('click', function (b, e) {
me.fireEvent('forms:mode', [b.pressed]);
});
this.btnViewFormRoles && this.btnViewFormRoles.on('click', function (b, e) {
var item = b.menu.getChecked();
me.fireEvent('forms:mode', [b.pressed, item ? item.caption : undefined]);
@ -112,14 +109,14 @@ define([
this.btnClear && this.btnClear.on('click', function (b, e) {
me.fireEvent('forms:clear');
});
if (this.mnuFormsColorPicker) {
this.btnHighlight.on('color:select', function(btn, color) {
me.fireEvent('forms:select-color', [color]);
});
this.mnuNoFormsColor.on('click', function (item) {
me.fireEvent('forms:no-color', [item]);
});
}
// if (this.mnuFormsColorPicker) {
// this.btnHighlight.on('color:select', function(btn, color) {
// me.fireEvent('forms:select-color', [color]);
// });
// this.mnuNoFormsColor.on('click', function (item) {
// me.fireEvent('forms:no-color', [item]);
// });
// }
this.btnPrevForm && this.btnPrevForm.on('click', function (b, e) {
me.fireEvent('forms:goto', ['prev']);
});
@ -228,22 +225,10 @@ define([
});
this.paragraphControls.push(this.btnManager);
this.btnViewForm = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-sheet-view',
lock: [ _set.previewReviewMode, _set.lostConnect, _set.disableOnStart],
caption: this.capBtnView,
enableToggle: true,
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
this.paragraphControls.push(this.btnViewForm);
this.btnViewFormRoles = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-sheet-view',
lock: [ _set.previewReviewMode, _set.lostConnect, _set.disableOnStart],
lock: [ _set.previewReviewMode, _set.formsNoRoles, _set.lostConnect, _set.disableOnStart],
caption: this.capBtnView,
split: true,
menu: new Common.UI.Menu({
@ -254,8 +239,7 @@ define([
enableToggle: true,
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small',
visible: false
dataHintOffset: 'small'
});
this.paragraphControls.push(this.btnViewFormRoles);
@ -380,7 +364,6 @@ define([
me.btnCheckBox.updateHint(me.tipCheckBox);
me.btnRadioBox.updateHint(me.tipRadioBox);
me.btnImageField.updateHint(me.tipImageField);
me.btnViewForm.updateHint(me.tipViewForm);
me.btnViewFormRoles.updateHint(me.tipViewForm);
me.btnManager.updateHint(me.tipManager);
}
@ -409,7 +392,6 @@ define([
this.btnCheckBox.render($host.find('#slot-btn-form-checkbox'));
this.btnRadioBox.render($host.find('#slot-btn-form-radiobox'));
this.btnImageField.render($host.find('#slot-btn-form-image'));
this.btnViewForm.render($host.find('#slot-btn-form-view'));
this.btnViewFormRoles.render($host.find('#slot-btn-form-view-roles'));
this.btnManager.render($host.find('#slot-btn-manager'));
// this.btnHighlight.render($host.find('#slot-form-highlight'));
@ -448,8 +430,7 @@ define([
var len = this.btnViewFormRoles.menu.items.length>0;
len && this.btnViewFormRoles.menu.items[checkedIndex].setChecked(true, true);
this.btnViewFormRoles.setVisible(len);
this.btnViewForm.setVisible(!len);
Common.Utils.lockControls(Common.enumLock.formsNoRoles, !len,{array: [this.btnViewFormRoles]});
},
show: function () {

View file

@ -115,7 +115,8 @@ define([
cantArrange: 'cant-arrange',
noObjectSelected: 'no-object',
lostConnect: 'disconnect',
disableOnStart: 'on-start'
disableOnStart: 'on-start',
formsNoRoles: 'no-roles'
};
for (var key in enumLock) {
if (enumLock.hasOwnProperty(key)) {