Merge pull request #1504 from ONLYOFFICE/fix/review-context-menu

Fix/review context menu
This commit is contained in:
Julia Radzhabova 2022-01-21 12:13:41 +03:00 committed by GitHub
commit c57670fc71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 130 additions and 30 deletions

View file

@ -179,20 +179,51 @@ define([
}); });
}, },
onApiShowChange: function (sdkchange) { isSelectedChangesLocked: function(changes, isShow) {
if (!changes || changes.length<1) return true;
if (isShow)
return changes[0].get('lock') || !changes[0].get('editable');
for (var i=0; i<changes.length; i++) {
var change = changes[i];
if (change.get('lock') || !change.get('editable'))
return true; // lock button if at least one change is locked
}
return false;
},
onApiShowChange: function (sdkchange, isShow) {
var btnlock = true,
changes;
if (this.appConfig.canReview && !this.appConfig.isReviewOnly) {
if (sdkchange && sdkchange.length>0) {
changes = this.readSDKChange(sdkchange);
btnlock = this.isSelectedChangesLocked(changes, isShow);
}
if (this._state.lock !== btnlock) {
this.view.btnAccept.setDisabled(btnlock);
this.view.btnReject.setDisabled(btnlock);
if (this.dlgChanges) {
this.dlgChanges.btnAccept.setDisabled(btnlock);
this.dlgChanges.btnReject.setDisabled(btnlock);
}
this._state.lock = btnlock;
Common.Utils.InternalSettings.set(this.view.appPrefix + "accept-reject-lock", btnlock);
}
}
if (this.getPopover()) { if (this.getPopover()) {
if (!this.appConfig.reviewHoverMode && sdkchange && sdkchange.length>0) { if (!this.appConfig.reviewHoverMode && sdkchange && sdkchange.length>0 && isShow) { // show changes balloon only for current position, not selection
var i = 0, var i = 0,
changes = this.readSDKChange(sdkchange),
posX = sdkchange[0].get_X(), posX = sdkchange[0].get_X(),
posY = sdkchange[0].get_Y(), posY = sdkchange[0].get_Y(),
animate = ( Math.abs(this._state.posx-posX)>0.001 || Math.abs(this._state.posy-posY)>0.001) || (sdkchange.length !== this._state.changes_length), animate = ( Math.abs(this._state.posx-posX)>0.001 || Math.abs(this._state.posy-posY)>0.001) || (sdkchange.length !== this._state.changes_length),
lock = (sdkchange[0].get_LockUserId()!==null), lock = (sdkchange[0].get_LockUserId()!==null),
lockUser = this.getUserName(sdkchange[0].get_LockUserId()), lockUser = this.getUserName(sdkchange[0].get_LockUserId());
editable = changes[0].get('editable');
this.getPopover().hideTips(); this.getPopover().hideTips();
this.popoverChanges.reset(changes); this.popoverChanges.reset(changes || this.readSDKChange(sdkchange));
if (animate) { if (animate) {
if ( this.getPopover().isVisible() ) this.getPopover().hide(); if ( this.getPopover().isVisible() ) this.getPopover().hide();
@ -200,18 +231,6 @@ define([
} }
this.getPopover().showReview(animate, lock, lockUser); this.getPopover().showReview(animate, lock, lockUser);
var btnlock = lock || !editable;
if (this.appConfig.canReview && !this.appConfig.isReviewOnly && this._state.lock !== btnlock) {
this.view.btnAccept.setDisabled(btnlock);
this.view.btnReject.setDisabled(btnlock);
if (this.dlgChanges) {
this.dlgChanges.btnAccept.setDisabled(btnlock);
this.dlgChanges.btnReject.setDisabled(btnlock);
}
this._state.lock = btnlock;
Common.Utils.InternalSettings.set(this.view.appPrefix + "accept-reject-lock", btnlock);
}
this._state.posx = posX; this._state.posx = posX;
this._state.posy = posY; this._state.posy = posY;
this._state.changes_length = sdkchange.length; this._state.changes_length = sdkchange.length;

View file

@ -26,7 +26,7 @@
border-left-color: @icon-normal-ie; border-left-color: @icon-normal-ie;
border-left-color: @icon-normal; border-left-color: @icon-normal;
margin-top: 5px; margin-top: 5px;
margin-right: -10px; margin-right: -7px;
} }
&.over:not(.disabled) > .dropdown-menu { &.over:not(.disabled) > .dropdown-menu {

View file

@ -52,7 +52,7 @@ class InitReview extends Component {
}); });
} }
onChangeReview (data) { onChangeReview (data, isShow) {
const storeReview = this.props.storeReview; const storeReview = this.props.storeReview;
storeReview.changeArrReview(data); storeReview.changeArrReview(data);
} }

View file

@ -1895,6 +1895,16 @@ define([
me.fireEvent('editcomplete', me); me.fireEvent('editcomplete', me);
}, },
onAcceptRejectChange: function(item, e) {
if (this.api) {
if (item.value == 'accept')
this.api.asc_AcceptChanges();
else if (item.value == 'reject')
this.api.asc_RejectChanges();
}
this.fireEvent('editcomplete', this);
},
onPrintSelection: function(item){ onPrintSelection: function(item){
if (this.api){ if (this.api){
var printopt = new Asc.asc_CAdjustPrint(); var printopt = new Asc.asc_CAdjustPrint();
@ -2516,6 +2526,20 @@ define([
value : 'cut' value : 'cut'
}).on('click', _.bind(me.onCutCopyPaste, me)); }).on('click', _.bind(me.onCutCopyPaste, me));
var menuImgAccept = new Common.UI.MenuItem({
caption : me.textAccept,
value : 'accept'
}).on('click', _.bind(me.onAcceptRejectChange, me));
var menuImgReject = new Common.UI.MenuItem({
caption : me.textReject,
value : 'reject'
}).on('click', _.bind(me.onAcceptRejectChange, me));
var menuImgReviewSeparator = new Common.UI.MenuItem({
caption : '--'
});
var menuImgPrint = new Common.UI.MenuItem({ var menuImgPrint = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-print', iconCls: 'menu__icon btn-print',
caption : me.txtPrintSelection caption : me.txtPrintSelection
@ -2745,6 +2769,11 @@ define([
menuImgPrint.setVisible(me.mode.canPrint); menuImgPrint.setVisible(me.mode.canPrint);
menuImgPrint.setDisabled(!cancopy); menuImgPrint.setDisabled(!cancopy);
var lockreview = Common.Utils.InternalSettings.get("de-accept-reject-lock");
menuImgAccept.setVisible(!lockreview);
menuImgReject.setVisible(!lockreview);
menuImgReviewSeparator.setVisible(!lockreview);
var signGuid = (value.imgProps && value.imgProps.value && me.mode.isSignatureSupport) ? value.imgProps.value.asc_getSignatureId() : undefined, var signGuid = (value.imgProps && value.imgProps.value && me.mode.isSignatureSupport) ? value.imgProps.value.asc_getSignatureId() : undefined,
isInSign = !!signGuid; isInSign = !!signGuid;
menuSignatureEditSign.setVisible(isInSign); menuSignatureEditSign.setVisible(isInSign);
@ -2767,6 +2796,9 @@ define([
menuImgPaste, menuImgPaste,
menuImgPrint, menuImgPrint,
{ caption: '--' }, { caption: '--' },
menuImgAccept,
menuImgReject,
menuImgReviewSeparator,
menuSignatureEditSign, menuSignatureEditSign,
menuSignatureEditSetup, menuSignatureEditSetup,
menuEditSignSeparator, menuEditSignSeparator,
@ -3081,6 +3113,20 @@ define([
value : 'cut' value : 'cut'
}).on('click', _.bind(me.onCutCopyPaste, me)); }).on('click', _.bind(me.onCutCopyPaste, me));
var menuTableAccept = new Common.UI.MenuItem({
caption : me.textAccept,
value : 'accept'
}).on('click', _.bind(me.onAcceptRejectChange, me));
var menuTableReject = new Common.UI.MenuItem({
caption : me.textReject,
value : 'reject'
}).on('click', _.bind(me.onAcceptRejectChange, me));
var menuTableReviewSeparator = new Common.UI.MenuItem({
caption : '--'
});
var menuTablePrint = new Common.UI.MenuItem({ var menuTablePrint = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-print', iconCls: 'menu__icon btn-print',
caption : me.txtPrintSelection caption : me.txtPrintSelection
@ -3191,6 +3237,7 @@ define([
this.tableMenu = new Common.UI.Menu({ this.tableMenu = new Common.UI.Menu({
cls: 'shifted-right', cls: 'shifted-right',
// maxHeight: 610,
initMenu: function(value){ initMenu: function(value){
// table properties // table properties
if (_.isUndefined(value.tableProps)) if (_.isUndefined(value.tableProps))
@ -3198,7 +3245,7 @@ define([
var isEquation= (value.mathProps && value.mathProps.value); var isEquation= (value.mathProps && value.mathProps.value);
for (var i = 8; i < 27; i++) { for (var i = 11; i < 30; i++) {
me.tableMenu.items[i].setVisible(!isEquation); me.tableMenu.items[i].setVisible(!isEquation);
} }
@ -3239,8 +3286,8 @@ define([
me.menuTableDirect270.setChecked(dir == Asc.c_oAscCellTextDirection.BTLR); me.menuTableDirect270.setChecked(dir == Asc.c_oAscCellTextDirection.BTLR);
var disabled = value.tableProps.locked || (value.headerProps!==undefined && value.headerProps.locked); var disabled = value.tableProps.locked || (value.headerProps!==undefined && value.headerProps.locked);
me.tableMenu.items[11].setDisabled(disabled); me.tableMenu.items[14].setDisabled(disabled);
me.tableMenu.items[12].setDisabled(disabled); me.tableMenu.items[15].setDisabled(disabled);
if (me.api) { if (me.api) {
mnuTableMerge.setDisabled(disabled || !me.api.CheckBeforeMergeCells()); mnuTableMerge.setDisabled(disabled || !me.api.CheckBeforeMergeCells());
@ -3260,6 +3307,11 @@ define([
menuTablePrint.setVisible(me.mode.canPrint); menuTablePrint.setVisible(me.mode.canPrint);
menuTablePrint.setDisabled(!cancopy); menuTablePrint.setDisabled(!cancopy);
var lockreview = Common.Utils.InternalSettings.get("de-accept-reject-lock");
menuTableAccept.setVisible(!lockreview);
menuTableReject.setVisible(!lockreview);
menuTableReviewSeparator.setVisible(!lockreview);
// bullets & numbering // bullets & numbering
var listId = me.api.asc_GetCurrentNumberingId(), var listId = me.api.asc_GetCurrentNumberingId(),
in_list = (listId !== null); in_list = (listId !== null);
@ -3337,9 +3389,9 @@ define([
//equation menu //equation menu
var eqlen = 0; var eqlen = 0;
if (isEquation) { if (isEquation) {
eqlen = me.addEquationMenu(false, 7); eqlen = me.addEquationMenu(false, 10);
} else } else
me.clearEquationMenu(false, 7); me.clearEquationMenu(false, 10);
menuEquationSeparatorInTable.setVisible(isEquation && eqlen>0); menuEquationSeparatorInTable.setVisible(isEquation && eqlen>0);
var control_lock = (value.paraProps) ? (!value.paraProps.value.can_DeleteBlockContentControl() || !value.paraProps.value.can_EditBlockContentControl() || var control_lock = (value.paraProps) ? (!value.paraProps.value.can_DeleteBlockContentControl() || !value.paraProps.value.can_EditBlockContentControl() ||
@ -3383,6 +3435,9 @@ define([
menuTablePaste, menuTablePaste,
menuTablePrint, menuTablePrint,
{ caption: '--' }, { caption: '--' },
menuTableAccept,
menuTableReject,
menuTableReviewSeparator,
menuEquationSeparatorInTable, menuEquationSeparatorInTable,
menuTableRefreshField, menuTableRefreshField,
menuTableFieldSeparator, menuTableFieldSeparator,
@ -3787,6 +3842,20 @@ define([
value : 'cut' value : 'cut'
}).on('click', _.bind(me.onCutCopyPaste, me)); }).on('click', _.bind(me.onCutCopyPaste, me));
var menuParaAccept = new Common.UI.MenuItem({
caption : me.textAccept,
value : 'accept'
}).on('click', _.bind(me.onAcceptRejectChange, me));
var menuParaReject = new Common.UI.MenuItem({
caption : me.textReject,
value : 'reject'
}).on('click', _.bind(me.onAcceptRejectChange, me));
var menuParaReviewSeparator = new Common.UI.MenuItem({
caption : '--'
});
var menuParaPrint = new Common.UI.MenuItem({ var menuParaPrint = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-print', iconCls: 'menu__icon btn-print',
caption : me.txtPrintSelection caption : me.txtPrintSelection
@ -3985,6 +4054,11 @@ define([
menuParaPrint.setVisible(me.mode.canPrint); menuParaPrint.setVisible(me.mode.canPrint);
menuParaPrint.setDisabled(!cancopy); menuParaPrint.setDisabled(!cancopy);
var lockreview = Common.Utils.InternalSettings.get("de-accept-reject-lock");
menuParaAccept.setVisible(!lockreview);
menuParaReject.setVisible(!lockreview);
menuParaReviewSeparator.setVisible(!lockreview);
// spellCheck // spellCheck
var spell = (value.spellProps!==undefined && value.spellProps.value.get_Checked()===false); var spell = (value.spellProps!==undefined && value.spellProps.value.get_Checked()===false);
me.menuSpellPara.setVisible(spell); me.menuSpellPara.setVisible(spell);
@ -4011,9 +4085,9 @@ define([
//equation menu //equation menu
var eqlen = 0; var eqlen = 0;
if (isEquation) { if (isEquation) {
eqlen = me.addEquationMenu(true, 15); eqlen = me.addEquationMenu(true, 18);
} else } else
me.clearEquationMenu(true, 15); me.clearEquationMenu(true, 18);
menuEquationSeparator.setVisible(isEquation && eqlen>0); menuEquationSeparator.setVisible(isEquation && eqlen>0);
menuEquationInsertCaption.setVisible(isEquation); menuEquationInsertCaption.setVisible(isEquation);
menuEquationInsertCaptionSeparator.setVisible(isEquation); menuEquationInsertCaptionSeparator.setVisible(isEquation);
@ -4098,6 +4172,9 @@ define([
menuParaCopy, menuParaCopy,
menuParaPaste, menuParaPaste,
menuParaPrint, menuParaPrint,
menuParaReviewSeparator,
menuParaAccept,
menuParaReject,
menuEquationInsertCaptionSeparator, menuEquationInsertCaptionSeparator,
menuEquationInsertCaption, menuEquationInsertCaption,
{ caption: '--' }, { caption: '--' },
@ -4743,7 +4820,9 @@ define([
txtRemoveWarning: 'Do you want to remove this signature?<br>It can\'t be undone.', txtRemoveWarning: 'Do you want to remove this signature?<br>It can\'t be undone.',
notcriticalErrorTitle: 'Warning', notcriticalErrorTitle: 'Warning',
txtWarnUrl: 'Clicking this link can be harmful to your device and data.<br>Are you sure you want to continue?', txtWarnUrl: 'Clicking this link can be harmful to your device and data.<br>Are you sure you want to continue?',
textEditPoints: 'Edit Points' textEditPoints: 'Edit Points',
textAccept: 'Accept Change',
textReject: 'Reject Change'
}, DE.Views.DocumentHolder || {})); }, DE.Views.DocumentHolder || {}));
}); });

View file

@ -1629,6 +1629,8 @@
"DE.Views.DocumentHolder.txtWarnUrl": "Clicking this link can be harmful to your device and data.<br>Are you sure you want to continue?", "DE.Views.DocumentHolder.txtWarnUrl": "Clicking this link can be harmful to your device and data.<br>Are you sure you want to continue?",
"DE.Views.DocumentHolder.updateStyleText": "Update %1 style", "DE.Views.DocumentHolder.updateStyleText": "Update %1 style",
"DE.Views.DocumentHolder.vertAlignText": "Vertical Alignment", "DE.Views.DocumentHolder.vertAlignText": "Vertical Alignment",
"DE.Views.DocumentHolder.textAccept": "Accept Change",
"DE.Views.DocumentHolder.textReject": "Reject Change",
"DE.Views.DropcapSettingsAdvanced.strBorders": "Borders & Fill", "DE.Views.DropcapSettingsAdvanced.strBorders": "Borders & Fill",
"DE.Views.DropcapSettingsAdvanced.strDropcap": "Drop Cap", "DE.Views.DropcapSettingsAdvanced.strDropcap": "Drop Cap",
"DE.Views.DropcapSettingsAdvanced.strMargins": "Margins", "DE.Views.DropcapSettingsAdvanced.strMargins": "Margins",

View file

@ -63,8 +63,8 @@ class ContextMenu extends ContextMenuController {
this.isComments = false; this.isComments = false;
} }
onApiShowChange(sdkchange) { onApiShowChange(sdkchange, isShow) {
this.inRevisionChange = sdkchange && sdkchange.length>0; this.inRevisionChange = isShow && sdkchange && sdkchange.length>0;
} }
// onMenuClosed() { // onMenuClosed() {