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

View file

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

View file

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