/*
*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
/**
* ReviewChanges.js
*
* View
*
* Created by Julia.Radzhabova on 05.08.15
* Copyright (c) 2018 Ascensio System SIA. All rights reserved.
*
*/
if (Common === undefined)
var Common = {};
Common.Views = Common.Views || {};
define([
'common/main/lib/util/utils',
'common/main/lib/component/Button',
'common/main/lib/component/DataView',
'common/main/lib/component/Layout',
'common/main/lib/component/Window'
], function () {
'use strict';
Common.Views.ReviewChanges = Common.UI.BaseView.extend(_.extend((function(){
var template =
'' +
'
' +
'' +
'' +
'
' +
'' +
'
' +
'' +
'' +
'' +
'
' +
'' +
'
' +
'' +
'
' +
'
' +
'' +
'
' +
'
' +
'' +
'' +
'' +
'' +
'
' +
'' +
'
' +
'' +
'
' +
'' +
'
' +
'' +
'
' +
'' +
'
' +
'' +
'
' +
'';
function setEvents() {
var me = this;
if ( me.appConfig.canReview ) {
this.btnAccept.on('click', function (e) {
me.fireEvent('reviewchange:accept', [me.btnAccept, 'current']);
});
this.btnAccept.menu && this.btnAccept.menu.on('item:click', function (menu, item, e) {
me.fireEvent('reviewchange:accept', [menu, item]);
});
this.btnReject.on('click', function (e) {
me.fireEvent('reviewchange:reject', [me.btnReject, 'current']);
});
this.btnReject.menu && this.btnReject.menu.on('item:click', function (menu, item, e) {
me.fireEvent('reviewchange:reject', [menu, item]);
});
if (me.appConfig.canFeatureComparison) {
this.btnCompare.on('click', function (e) {
me.fireEvent('reviewchange:compare', ['file']);
});
this.btnCompare.menu.on('item:click', function (menu, item, e) {
me.fireEvent('reviewchange:compare', [item.value]);
});
}
this.btnsTurnReview.forEach(function (button) {
button.on('click', function (btn, e) {
Common.NotificationCenter.trigger('reviewchanges:turn', btn.pressed);
Common.NotificationCenter.trigger('edit:complete');
});
!me.appConfig.isReviewOnly && button.menu.on('item:toggle', function (menu, item, state, e) {
if (!!state) {
if (item.value==2) // ON track changes for everyone
Common.UI.warning({
title: me.textWarnTrackChangesTitle,
msg: me.textWarnTrackChanges,
maxwidth: 600,
buttons: [{
value: 'enable',
caption: me.textEnable
}, 'cancel'],
primary: 'enable',
callback: function(btn){
if (btn == 'enable') {
Common.NotificationCenter.trigger('reviewchanges:turn', item.value==0 || item.value==2, item.value>1);
} else {
var old = Common.Utils.InternalSettings.get(me.appPrefix + "track-changes");
me.turnChanges(old==0 || old==2, old>1);
}
Common.NotificationCenter.trigger('edit:complete');
}
});
else
Common.NotificationCenter.trigger('reviewchanges:turn', item.value==0 || item.value==2, item.value>1);
}
});
});
}
if (this.appConfig.canViewReview) {
this.btnPrev.on('click', function (e) {
me.fireEvent('reviewchange:preview', [me.btnPrev, 'prev']);
});
this.btnNext.on('click', function (e) {
me.fireEvent('reviewchange:preview', [me.btnNext, 'next']);
});
this.btnReviewView && this.btnReviewView.menu.on('item:click', function (menu, item, e) {
me.fireEvent('reviewchange:view', [menu, item]);
});
}
this.btnsSpelling.forEach(function(button) {
button.on('click', function (b, e) {
Common.NotificationCenter.trigger('spelling:turn', b.pressed ? 'on' : 'off');
Common.NotificationCenter.trigger('edit:complete', me);
});
});
this.btnsDocLang.forEach(function(button) {
button.on('click', function (b, e) {
me.fireEvent('lang:document', this);
});
});
this.btnSharing && this.btnSharing.on('click', function (btn, e) {
Common.NotificationCenter.trigger('collaboration:sharing');
});
this.btnCoAuthMode && this.btnCoAuthMode.menu.on('item:click', function (menu, item, e) {
me.fireEvent('collaboration:coauthmode', [menu, item]);
});
this.btnHistory && this.btnHistory.on('click', function (btn, e) {
Common.NotificationCenter.trigger('collaboration:history');
});
this.btnChat && this.btnChat.on('click', function (btn, e) {
me.fireEvent('collaboration:chat', [btn.pressed]);
});
if (this.btnCommentRemove) {
this.btnCommentRemove.on('click', function (e) {
me.fireEvent('comment:removeComments', ['current']);
});
this.btnCommentRemove.menu.on('item:click', function (menu, item, e) {
me.fireEvent('comment:removeComments', [item.value]);
});
}
if (this.btnCommentResolve) {
this.btnCommentResolve.on('click', function (e) {
me.fireEvent('comment:resolveComments', ['current']);
});
this.btnCommentResolve.menu.on('item:click', function (menu, item, e) {
me.fireEvent('comment:resolveComments', [item.value]);
});
}
}
return {
// el: '#review-changes-panel',
options: {},
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
this.appConfig = options.mode;
var filter = Common.localStorage.getKeysFilter();
this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : '';
if ( this.appConfig.canReview ) {
this.btnAccept = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
caption: this.txtAccept,
split: !this.appConfig.canUseReviewPermissions,
iconCls: 'toolbar__icon btn-review-save'
});
this.btnReject = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
caption: this.txtReject,
split: !this.appConfig.canUseReviewPermissions,
iconCls: 'toolbar__icon btn-review-deny'
});
if (this.appConfig.canFeatureComparison)
this.btnCompare = new Common.UI.Button({
cls : 'btn-toolbar x-huge icon-top',
caption : this.txtCompare,
split : true,
iconCls: 'toolbar__icon btn-compare'
});
this.btnTurnOn = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-ic-review',
caption: this.txtTurnon,
split: !this.appConfig.isReviewOnly,
enableToggle: true
});
this.btnsTurnReview = [this.btnTurnOn];
}
if (this.appConfig.canViewReview) {
this.btnPrev = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-review-prev',
caption: this.txtPrev
});
this.btnNext = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-review-next',
caption: this.txtNext
});
if (!this.appConfig.isRestrictedEdit) {// hide Display mode option for fillForms and commenting mode
var menuTemplate = _.template('