2021-06-21 15:00:20 +00:00
/ *
*
* ( c ) Copyright Ascensio System SIA 2010 - 2021
*
* 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 20 A - 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
*
* /
/ * *
* WBProtection . js
*
* Created by Julia Radzhabova on 21.06 . 2021
* Copyright ( c ) 2021 Ascensio System SIA . All rights reserved .
*
* /
define ( [
'common/main/lib/util/utils' ,
'common/main/lib/component/BaseView' ,
'common/main/lib/component/Layout' ,
'common/main/lib/component/Window'
] , function ( template ) {
'use strict' ;
SSE . Views . WBProtection = Common . UI . BaseView . extend ( _ . extend ( ( function ( ) {
var template =
'<div class="group">' +
'<span id="slot-btn-protect-wb" class="btn-slot text x-huge"></span>' +
'<span id="slot-btn-protect-sheet" class="btn-slot text x-huge"></span>' +
'<span id="slot-btn-allow-ranges" class="btn-slot text x-huge"></span>' +
'</div>' +
'<div class="group small">' +
'<div class="elset">' +
'<span class="btn-slot text" id="slot-chk-locked-cell"></span>' +
'</div>' +
'<div class="elset">' +
'<span class="btn-slot text" id="slot-chk-hidden-formula"></span>' +
'</div>' +
'</div>' +
'<div class="group small">' +
'<div class="elset">' +
'<span class="btn-slot text" id="slot-chk-locked-shape"></span>' +
'</div>' +
'<div class="elset">' +
'<span class="btn-slot text" id="slot-chk-locked-text"></span>' +
'</div>' +
'</div>' ;
function setEvents ( ) {
var me = this ;
this . btnProtectWB . on ( 'click' , function ( btn , e ) {
me . fireEvent ( 'protect:workbook' , [ btn . pressed ] ) ;
} ) ;
this . btnProtectSheet . on ( 'click' , function ( btn , e ) {
me . fireEvent ( 'protect:sheet' , [ btn . pressed ] ) ;
} ) ;
this . btnAllowRanges . on ( 'click' , function ( btn , e ) {
me . fireEvent ( 'protect:ranges' ) ;
} ) ;
this . chLockedCell . on ( 'change' , function ( field , value ) {
me . fireEvent ( 'protect:lock-options' , [ 0 , value ] ) ;
} ) ;
this . chLockedShape . on ( 'change' , function ( field , value ) {
me . fireEvent ( 'protect:lock-options' , [ 1 , value ] ) ;
} ) ;
this . chLockedText . on ( 'change' , function ( field , value ) {
me . fireEvent ( 'protect:lock-options' , [ 2 , value ] ) ;
} ) ;
this . chHiddenFormula . on ( 'change' , function ( field , value ) {
me . fireEvent ( 'protect:lock-options' , [ 3 , value ] ) ;
} ) ;
me . _isSetEvents = true ;
}
return {
options : { } ,
initialize : function ( options ) {
Common . UI . BaseView . prototype . initialize . call ( this , options ) ;
this . appConfig = options . mode ;
var _set = SSE . enumLock ;
this . lockedControls = [ ] ;
this . _state = { disabled : false } ;
this . btnProtectWB = new Common . UI . Button ( {
cls : 'btn-toolbar x-huge icon-top' ,
iconCls : 'toolbar__icon protect-workbook' ,
enableToggle : true ,
caption : this . txtProtectWB ,
lock : [ _set . lostConnect , _set . coAuth ]
} ) ;
this . lockedControls . push ( this . btnProtectWB ) ;
this . btnProtectSheet = new Common . UI . Button ( {
cls : 'btn-toolbar x-huge icon-top' ,
iconCls : 'toolbar__icon protect-sheet' ,
enableToggle : true ,
caption : this . txtProtectSheet ,
lock : [ _set . lostConnect , _set . coAuth ]
} ) ;
this . lockedControls . push ( this . btnProtectSheet ) ;
this . btnAllowRanges = new Common . UI . Button ( {
cls : 'btn-toolbar x-huge icon-top' ,
iconCls : 'toolbar__icon allow-edit-ranges' ,
caption : this . txtAllowRanges ,
lock : [ _set . lostConnect , _set . coAuth ]
} ) ;
this . lockedControls . push ( this . btnAllowRanges ) ;
this . chLockedCell = new Common . UI . CheckBox ( {
labelText : this . txtLockedCell ,
lock : [ _set . lostConnect , _set . coAuth ]
} ) ;
this . lockedControls . push ( this . chLockedCell ) ;
this . chLockedShape = new Common . UI . CheckBox ( {
labelText : this . txtLockedShape ,
lock : [ _set . lostConnect , _set . coAuth ]
} ) ;
this . lockedControls . push ( this . chLockedShape ) ;
this . chLockedText = new Common . UI . CheckBox ( {
labelText : this . txtLockedText ,
lock : [ _set . lostConnect , _set . coAuth ]
} ) ;
this . lockedControls . push ( this . chLockedText ) ;
this . chHiddenFormula = new Common . UI . CheckBox ( {
labelText : this . txtHiddenFormula ,
lock : [ _set . lostConnect , _set . coAuth ]
} ) ;
this . lockedControls . push ( this . chHiddenFormula ) ;
Common . NotificationCenter . on ( 'app:ready' , this . onAppReady . bind ( this ) ) ;
} ,
render : function ( el ) {
return this ;
} ,
onAppReady : function ( config ) {
var me = this ;
( new Promise ( function ( accept , reject ) {
accept ( ) ;
} ) ) . then ( function ( ) {
me . btnProtectWB . updateHint ( me . hintProtectWB ) ;
me . btnProtectSheet . updateHint ( me . hintProtectSheet ) ;
me . btnAllowRanges . updateHint ( me . hintAllowRanges ) ;
setEvents . call ( me ) ;
} ) ;
} ,
getPanel : function ( ) {
this . $el = $ ( _ . template ( template ) ( { } ) ) ;
this . btnProtectWB . render ( this . $el . find ( '#slot-btn-protect-wb' ) ) ;
this . btnProtectSheet . render ( this . $el . find ( '#slot-btn-protect-sheet' ) ) ;
this . btnAllowRanges . render ( this . $el . find ( '#slot-btn-allow-ranges' ) ) ;
this . chLockedCell . render ( this . $el . find ( '#slot-chk-locked-cell' ) ) ;
this . chLockedShape . render ( this . $el . find ( '#slot-chk-locked-shape' ) ) ;
this . chLockedText . render ( this . $el . find ( '#slot-chk-locked-text' ) ) ;
this . chHiddenFormula . render ( this . $el . find ( '#slot-chk-hidden-formula' ) ) ;
return this . $el ;
} ,
show : function ( ) {
Common . UI . BaseView . prototype . show . call ( this ) ;
this . fireEvent ( 'show' , this ) ;
} ,
txtProtectWB : 'Protect Workbook' ,
txtProtectSheet : 'Protect Sheet' ,
txtAllowRanges : 'Allow Edit Ranges' ,
hintProtectWB : 'Protect workbook' ,
hintProtectSheet : 'Protect sheet' ,
hintAllowRanges : 'Allow edit ranges' ,
txtLockedCell : 'Locked Cell' ,
txtLockedShape : 'Shape Locked' ,
txtLockedText : 'Lock Text' ,
2021-06-21 20:53:28 +00:00
txtHiddenFormula : 'Hidden Formulas' ,
txtProtect : 'Protect' ,
txtWBDescription : 'To prevent other users from viewing hidden worksheets, adding, moving, deleting, or hiding worksheets and renaming worksheets, you can protect the structure of your workbook with a password.' ,
txtWBTitle : 'Protect Workbook structure'
2021-06-21 15:00:20 +00:00
}
} ( ) ) , SSE . Views . WBProtection || { } ) ) ;
} ) ;