From 696a43a4f7ec3a25121b54d74e55ddb2a6805b41 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 2 Jun 2021 02:09:20 +0300 Subject: [PATCH 01/50] [SSE] Add icons --- .../img/toolbar/1.25x/big/allow-edit-ranges.png | Bin 0 -> 445 bytes .../img/toolbar/1.25x/big/protect-sheet.png | Bin 0 -> 448 bytes .../img/toolbar/1.25x/big/protect-workbook.png | Bin 0 -> 506 bytes .../img/toolbar/1.5x/big/allow-edit-ranges.png | Bin 0 -> 494 bytes .../img/toolbar/1.5x/big/protect-sheet.png | Bin 0 -> 507 bytes .../img/toolbar/1.5x/big/protect-workbook.png | Bin 0 -> 574 bytes .../img/toolbar/1.75x/big/allow-edit-ranges.png | Bin 0 -> 573 bytes .../img/toolbar/1.75x/big/protect-sheet.png | Bin 0 -> 555 bytes .../img/toolbar/1.75x/big/protect-workbook.png | Bin 0 -> 626 bytes .../img/toolbar/1x/big/allow-edit-ranges.png | Bin 0 -> 391 bytes .../img/toolbar/1x/big/protect-sheet.png | Bin 0 -> 379 bytes .../img/toolbar/1x/big/protect-workbook.png | Bin 0 -> 439 bytes .../img/toolbar/2x/big/allow-edit-ranges.png | Bin 0 -> 679 bytes .../img/toolbar/2x/big/protect-sheet.png | Bin 0 -> 675 bytes .../img/toolbar/2x/big/protect-workbook.png | Bin 0 -> 772 bytes 15 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1.25x/big/allow-edit-ranges.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1.25x/big/protect-sheet.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1.25x/big/protect-workbook.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1.5x/big/allow-edit-ranges.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1.5x/big/protect-sheet.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1.5x/big/protect-workbook.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1.75x/big/allow-edit-ranges.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1.75x/big/protect-sheet.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1.75x/big/protect-workbook.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1x/big/allow-edit-ranges.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1x/big/protect-sheet.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/1x/big/protect-workbook.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/2x/big/allow-edit-ranges.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/2x/big/protect-sheet.png create mode 100644 apps/spreadsheeteditor/main/resources/img/toolbar/2x/big/protect-workbook.png diff --git a/apps/spreadsheeteditor/main/resources/img/toolbar/1.25x/big/allow-edit-ranges.png b/apps/spreadsheeteditor/main/resources/img/toolbar/1.25x/big/allow-edit-ranges.png new file mode 100644 index 0000000000000000000000000000000000000000..5ca1006cfb628eae1150b635893a708e3f4dfabb GIT binary patch literal 445 zcmeAS@N?(olHy`uVBq!ia0vp^Za}Qe!3HEX#cOhb6lZ})WHAE+w=f7ZGR&GI0Tg5` z4sv&5Sa(k5C6L3C?&#~tz_78O`%fY(P%g;R#WAFU@$K~PwTBFNT=o6)8QeasSaZll zcHvzWl^}=QtmUP4ETMLjT0N4@_igoM^LW*S?Kf{fdE3`$@%+T?H@Tn8zUVxB z<|rbbdq|;4AaIKLtIdBF@`~8cU%ge)Uo(WO?ukxI?r)n%<%gzw-adX?xlX-C^3cB8 zcM>03!WPxsQt!I_N9T1*Ft@;F^|d1B%G)NXJmmdoWms)CRcXiS^Pl{@nhJEhJY()D zaw)`Ei!4>iyXGIEKBaq7x3)D0=ar60-PJFSuMvFZGV#$f*%>TZt`i^4`;>eQL_d?Q zNL&RJpZDo--2<;h7E539O**iq)}_!Zph5WBlKAlwf ztuDRNKls!jk)`Nqgvku4JLT>#C)hZ9dViBzaW?Kl)w``>LO@9$iN-tCXPWFbCpXSp ldU;M{f<#-QL|dU@+_$UT%Rtjs!QLH}Ra+)v^*N?UV$N{!g+{Y7<+=b`22#0002M zbK(}~t4K#}7)5rLl9`*v;+)&144Cp93fUxmNn*0Gh{>Ul&5f@Y0#T3{10=>^IedMu zy;B=LBmRE_nfkt2EHZpu$^gSxxo0amdJtmO(lRken)W3B>zqXfx)V|$N53cW#93s> zeuwh>r!n`09NusqME`#qd^t6)T3<_-ip^uCwomg!<~}|1aVQq2BXK_30@623k|4 zrRY-oN?0}6d<|m5xAgr?`HH#GubDBM0ulV3xr&+fTUzO%7qZeUTWK`xtmicuH$Hzl q=55!Krf(%q(<~MM0001hT6_bz?fZ&W_(DJc0000!V2+al=!K1h@>0`P<=4f6zQnG=)2^9@oRDyuU7Pjy7-EkOXgd+bDHh`ii zilQhR;)Klzw<3%&CnF5}1AFr;tN<7LDq^wtEH17b|3ufK97Fm=pB72XDwJb_egIk3 z3~V4IF|HqsENm>X#N=dlm}qDHM-r2a1;+5fnvH6h+w*KUhGj0apcD{Qv*}07*qoM6N<$g2#f`DF6Tf literal 0 HcmV?d00001 diff --git a/apps/spreadsheeteditor/main/resources/img/toolbar/1.5x/big/allow-edit-ranges.png b/apps/spreadsheeteditor/main/resources/img/toolbar/1.5x/big/allow-edit-ranges.png new file mode 100644 index 0000000000000000000000000000000000000000..d4bfc9f5a4ed34e23eb435d64bc8f02a302a6e6f GIT binary patch literal 494 zcmVJGjxSuVbCbCZmy6xWjGm?5(^zm68sUs2@1Dkz33a#52``}!9Hj<0B6*vBg+4N= z0gl*?`4dN}0gl)m^JgYCz!7=R+)H&sp=bU{#Q;iuu+$T0;rW#1lkzO+pwtITJ+UBj zW6JVLbglCzx8fa1W`Lfqi(oIU^3E(s3Q(e{bDHDixrIzkoqF)eMlED&>Zo#5o>|E} zt8*S)*{GGwvpVV=!n~!-S{+@muu)5ywK|t_6y~gDN_F(Xg^gOvl_5p)uTx!RZ6QuG~Ps3=p4X{mELhcH(=<{pIxO-xIjJ)dafhJU~lOp~g_CF%)Wy=Er`;m`i3wAM2ot kX$2vK5JCtcgpdn-1G0d<#l+qH7ytkO07*qoM6N<$f*rBaZvX%Q literal 0 HcmV?d00001 diff --git a/apps/spreadsheeteditor/main/resources/img/toolbar/1.5x/big/protect-sheet.png b/apps/spreadsheeteditor/main/resources/img/toolbar/1.5x/big/protect-sheet.png new file mode 100644 index 0000000000000000000000000000000000000000..ad5d8150496b70ffe3b1b902c863132252838d76 GIT binary patch literal 507 zcmVVK~#7F?U>PR zgFp<1P1OPD2G>cVF4L}&5%StBkrARykP*TLWP__+t`eemoJkH$qW_aDkg?8|WuNaL z0ssI20000yJXJ(@VR5uP4a>XM*n4jlXH`||I0dh?`z&my_1hUUN;{SR33j7?UkDTh z2`vl~S{Nj>FtI5wo9-7a&o{;6i4ul`Nt`_8)o}`#@^|<}%NJ%%37ynNR^-~#K_taIR z1hyM|+p=s}K5~o9J>|Kx_fn1gdgAxp!1tCP8`fvz{Iw??_e^>5QAhNmYe~TpQ$DnK z9nsga1;o~|+(WMkT}>;3tMHo8MdP$c=p{UTLi#plgx`aIRr-&S->P)PR z0x=AReW(Mp8(b%;ScZ-PBk)?5U@F!JH_dTokQ<(HNteBcLuVj|^4BJ1$_V>ZK%58P~ z#cJRFJ~FO~FrZWsA4Yd&F6Iis&Bv3RI&l#3>qTeE)L=&>keLFT-jTeH59%24gLDtZyuZhxy|0?m=k zXanj->Pz89>fZ*R$>yaf@3nU}rK-H6;ea_Rk5dHI5dZ)H000=v8C!)+qWZ<$jsO4v M07*qoM6N<$f`@Say#N3J literal 0 HcmV?d00001 diff --git a/apps/spreadsheeteditor/main/resources/img/toolbar/1.75x/big/allow-edit-ranges.png b/apps/spreadsheeteditor/main/resources/img/toolbar/1.75x/big/allow-edit-ranges.png new file mode 100644 index 0000000000000000000000000000000000000000..713d290ca027682d02e2cf7ca5d4dfa2efff1556 GIT binary patch literal 573 zcmV-D0>b@?P)WD}06>0Le?V{?QW>3t-tKfu)Rs2G(900000006)+q=+fT z6gTRS7~>FMj45u^A#Vxq=uXB$LhMz>oz@bTGP)og_&xG;vxn>a`5<0~d(vTF=g$Xc zf;!-N9WAe*2dyOpa?X4mjqfXnkrBu_%bvi=2;`i&?g^ZXK+f4V=B$6g78iBa$T4xQ@(?aeK&$`9tO)1N{SQ zJ->N|xo1nT*7Hg*Z2W8q)_PWX%6Tm$SnBypP;R`11WP@;JjI+=614TK6BHY7B|%#c zo0l1HDM3@uJ|VO5mJ&4e9OemQttI5@;S+?7x0aBrN6gENX(beW`N4PE5@Zo-38e>U zsYlE^2x%-R*C-9!1`d$MI0-eO0<6D?K=ySkwD?5?>pHdS5%V%*+Mdvhh)}Xlt$Mzx zj0<(nB|(n(BH#juZ~{a)0V13rHLO~%otl^$Y^~Q$O-ddKAA5GzTIbX6f6F?!nw$U; zPJjp}K!g(@!U+)J1nEz|iF`d_C$cj+d%{ix0000000000fD`xu!RqbA#D2O000000 LNkvXXu0mjfrvK-P literal 0 HcmV?d00001 diff --git a/apps/spreadsheeteditor/main/resources/img/toolbar/1.75x/big/protect-sheet.png b/apps/spreadsheeteditor/main/resources/img/toolbar/1.75x/big/protect-sheet.png new file mode 100644 index 0000000000000000000000000000000000000000..b6bdb51c395806118182895d96a334cec309c4e9 GIT binary patch literal 555 zcmeAS@N?(olHy`uVBq!ia0vp^NkDAK!3HE1_t%62Db50q$YKTtZeb8+WSBKa0w~B> z9OUlAuZJjIsQyzT%; z&jIe9i+u;QW0z@faI|HTmY8X=H{i{YM@1*+fBXNg#5Y-W;~I~!P(ddS#TEe&G2!ZE zk#qAy<~(>1DyJ*nBJdz5W7e@0XO)iL@QsOAx1UqDI#klTYWA}){C^Mryu;bp(8tgS zLkmOp9h3d%TkvDTrBjq-xkT*qTYvsjDenbAg*8V7pWW#?cH>{etB&4N zez)d@d(7WmQYZRi+J?ZJN9ToSST21ZDJ>u?s9qIP8BjUNOlscJ++VV(tmizsYqu%7 z9=_Q&$N0jj>&;v8_XSs;?AgD%X5}0Acbg-AuF9_K$loVtW&1C=x$p0d1{nm}# zcg$pqZqH5=yHk^%W_vl`J~YEy_gB2aGPUKOA|*aIeU*3al;Dk&{<3F!53f$VqeHQa z_@+dMUsVMqnd&?juD{+Pt~2M#-!y~mHfcw$ewm{8-C&uTK-;P7J2Nj8XDcTKoR2c~ zb?j;RapzXYi`TvrXRX`!*MQx}S7D0G!=-&udsROOzrHK7wNiFl)~dU+^}b#>6|P^} o{f1RM{w0q-B)ma^e*LJqr}d+4?_yRh1I8_br>mdKI;Vst0DYoq9>}Da6hWH!84ghOEKkBxfBnH5q@o`qyBB4!*53wt$X?PE$$Z__hG$jAGV`5 zSagJ+=uYHW8{DAq1A|P8;)P4bk`Kp&}u}t4U3N##8Ok~g4l|D zj~sKPSUuJD=`-S^A!>u{cNDP!?W+;2IpP?ysZXcL^i+yt+Tp~f(_wnb`7pEuE$LEY zPQ6;1R+Acs^(rTq&S`wCOS^_v@A6L>#X6T*mzJ8#x!xQRakp>3bAn=Rgd9h>iF8Wh zCepckv^m^tvDVh1p&n9`5v;YZj&x7EBfB_dR5$_v00000002-wzv=^eldNyM<^TWy M07*qoM6N<$f-r~_&;S4c literal 0 HcmV?d00001 diff --git a/apps/spreadsheeteditor/main/resources/img/toolbar/1x/big/allow-edit-ranges.png b/apps/spreadsheeteditor/main/resources/img/toolbar/1x/big/allow-edit-ranges.png new file mode 100644 index 0000000000000000000000000000000000000000..8aac863726251d37b950f98690bc8a6549c22018 GIT binary patch literal 391 zcmV;20eJq2P)) z5RqPE)acNFbLbgk#KEYkv)rNjeW9LTjem`w`1=nBqK2CG3u`$~t;21ShY{CO=G6?7 z#72T}F(S|>XP2dxB&aot!ZYw_ZsxN1UkZIqq;Q^^8&Fs0F)5lc&Qo(kO&wO)T63j3 zd6FS)t+`SiR#=TWtB#$N2&*w?)p;dsdG9Q9LIx!)xp$d4ApwcNHatAZVd~gP`2@4c zG2*S9Z*ZK@kduO)*z%!&3rbIl-sKHF?#))*otMqX=}W_$>ifmyeEf=jyus32bizI> lIDuo@X-y|Mj^j8E&lM8mf4G*e)T#gg002ovPDHLkV1nbcqeTD! literal 0 HcmV?d00001 diff --git a/apps/spreadsheeteditor/main/resources/img/toolbar/1x/big/protect-sheet.png b/apps/spreadsheeteditor/main/resources/img/toolbar/1x/big/protect-sheet.png new file mode 100644 index 0000000000000000000000000000000000000000..fb3caef38b99c7245af1b5b8af6089a5dc5ee97c GIT binary patch literal 379 zcmV->0fhdEP)*TRp3AzniS7^)nq}6QLxWR_^xuLYMUfAJySg?VTqIfv& zaokfp9Ji_OrFzhPn0uvA55|7tx%3uYZW8=9!}X#pHy3`D;d~+!(ONeccErCSU|cXf`o!n}P{;(-0>@C{MCdr>PysmQ#R6qtR&C za3Db=iGqj+Gy+yKEc}K__`Oy0H~RErl}yejUo(@)#^NW-0<4xv48|U8ve=8xSb%=) z(FW0<6rh&!ed4@mM+i_`w@;jZu=52UPRE|n>wNrye0~EzlQW_t_-N&CuqVAJRiYxL zN;ITIiEc^GFdfjv>&2izwKO literal 0 HcmV?d00001 diff --git a/apps/spreadsheeteditor/main/resources/img/toolbar/2x/big/allow-edit-ranges.png b/apps/spreadsheeteditor/main/resources/img/toolbar/2x/big/allow-edit-ranges.png new file mode 100644 index 0000000000000000000000000000000000000000..30706da3be57c1fcf1c26948e6763ddfd1a6bb29 GIT binary patch literal 679 zcmeAS@N?(olHy`uVBq!ia0vp^1wd@U!3HE%U)Oj6Db50q$YKTtF;x&|^bAt@02E{_ z4sv&5Sa(k5C6L3C?&#~tz_78O`%fY(0|S$dr;B4q1>@V9w+jy$2)OFc6mjrg*&-Fh z=%=dLS;8Rez~1HZrpNh9#7%9<%y%pSA`^___tZpIi>4yEEzGY0f(Du}E(eHgHe=arCVg5BSok?i-r00`wOtzVS z#P@mmhC}LGbt_3 zO8Q%JypHW~>fD%^bgWqA)1K4ICN4DF|9i%X+xON_3|};_V$)2ChabD2PF>+XMfg+O z)M?YB{jDP14tt$Gz1Dq>@TRt_6Q&3E>&)DcX!_*omB~|uU$$MHq`uaDp3j91QJz>%zSHJN6y=vw${*O(c&OH5kV!e%xA?`|H}Z%^K>T zSeD(}uqHLT@uInoM$Gvm+Ft^8irZ?htiBj_We5ADrhtUUK$Ky_p67e<`GK{SZOdX50U7W-aBzVH*+% z0U`hZ000000001h+qB|nI85SE%f3c2#;iCRlfIf`G{4L<&;Bq4>CkdK#B5-H7*dp9 zmSs`-S?&mrwU#*7c9Ztg9o`g)H(A@DNPpNaXg}`=R6_wOhXPa%1*jYfP&r>W!d>}1 zQQF?+GmF`%b7iL@Kkh~h=7$=1h0qW5Z-;&$%~u+2f=_o#j;%S2l-TKVY&$JY=!T;@nzxi#aJ-OWTu{CF@v;TCroH*4+z6asj$$ zbDX|sW1N~MJR@@{MxM>-eD~@suYJ$Rq+Ea%#nr5W4i^9#R5U|=DR(0Z`3$||(s!Or zRbl^x-f@xIc#@HCZyrmhcuW&AoHNyNM}6+~Q!wQX zshX59)83F$lb=;mSW9rO7GYKqEx}n@1ONa400000004lLeFKw=!Vuv?k%0gJ002ov JPDHLkV1kS%D%Jo1 literal 0 HcmV?d00001 diff --git a/apps/spreadsheeteditor/main/resources/img/toolbar/2x/big/protect-workbook.png b/apps/spreadsheeteditor/main/resources/img/toolbar/2x/big/protect-workbook.png new file mode 100644 index 0000000000000000000000000000000000000000..b96369801fd09e90febd0a92c8ba8d038504ce64 GIT binary patch literal 772 zcmV+f1N;1mP)KL)ER9nHW#mM<9GBIBJXR;C5Xwlm@^-XA z+;!#cXrpA`vNW;8j9-&)LcN+06YmOrg5dydDkcsG$Zaqt4hLvcF>yFRZi6v#=)mk- z)|!ks@Y6GXO{6if&w+Hs!*l3U7TA{urz;+wS)%q8V>S%hhSz?;cBG4z<%dMkkBC1O zOypXnecU~feV(Z;G<8dT46>AdQh&N>Exi^z@6pSG`ZxPCXA1?2fCG&K2O4Ki64PD( zA|3n-$3mhkNMcml*Y$4*R^SG)mW3u^Eeo9jE6_NW9JptBrfU_*pI5XIcvbFMp53(y z|-Y#S=u18?OQtwjrFG- zX)8lpLqgWhLSy}5%8|A*v_i`qBlz=DKTjfL@BOMm9Yz6W-k zN$_2;2++#7@ZGU@JxZ_r>_)x|YF>dyN?Tbwx+VY?I8p}tBr`FVg)T)b`<)_H|NTet zEOZfK+3yrFeN Date: Mon, 21 Jun 2021 18:00:20 +0300 Subject: [PATCH 02/50] [SSE] Add sheet/workbook protection buttons --- apps/spreadsheeteditor/main/app.js | 2 + .../main/app/controller/Main.js | 4 +- .../main/app/controller/Toolbar.js | 13 +- .../main/app/controller/WBProtection.js | 139 +++++++++++ .../main/app/view/WBProtection.js | 215 ++++++++++++++++++ apps/spreadsheeteditor/main/app_dev.js | 2 + 6 files changed, 366 insertions(+), 9 deletions(-) create mode 100644 apps/spreadsheeteditor/main/app/controller/WBProtection.js create mode 100644 apps/spreadsheeteditor/main/app/view/WBProtection.js diff --git a/apps/spreadsheeteditor/main/app.js b/apps/spreadsheeteditor/main/app.js index 2057534bec..469b003615 100644 --- a/apps/spreadsheeteditor/main/app.js +++ b/apps/spreadsheeteditor/main/app.js @@ -159,6 +159,7 @@ require([ 'PivotTable', 'DataTab', 'ViewTab', + 'WBProtection', 'Common.Controllers.Fonts', 'Common.Controllers.Chat', 'Common.Controllers.Comments', @@ -183,6 +184,7 @@ require([ 'spreadsheeteditor/main/app/controller/PivotTable', 'spreadsheeteditor/main/app/controller/DataTab', 'spreadsheeteditor/main/app/controller/ViewTab', + 'spreadsheeteditor/main/app/controller/WBProtection', 'spreadsheeteditor/main/app/view/FileMenuPanels', 'spreadsheeteditor/main/app/view/ParagraphSettings', 'spreadsheeteditor/main/app/view/ImageSettings', diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 1c151ad97b..8655a8abff 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1276,8 +1276,8 @@ define([ // statusbarController && statusbarController.setApi(me.api); rightmenuController && rightmenuController.setApi(me.api); - if (me.appOptions.canProtect) - application.getController('Common.Controllers.Protection').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api); + application.getController('Common.Controllers.Protection').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api); + application.getController('WBProtection').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api); if (statusbarController) { statusbarController.getView('Statusbar').changeViewMode(true); diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 47e2e43e8f..7aeb53e47b 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -3705,13 +3705,12 @@ define([ me.toolbar.btnCopy.$el.removeClass('split'); } - if ( config.isDesktopApp ) { - if ( config.canProtect ) { - var tab = {action: 'protect', caption: me.toolbar.textTabProtect}; - var $panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel(); - if ($panel) - me.toolbar.addTab(tab, $panel, 7); - } + var tab = {action: 'protect', caption: me.toolbar.textTabProtect}; + var $panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel(); + if ($panel) { + config.canProtect && $panel.append($('
')); + $panel.append(me.getApplication().getController('WBProtection').createToolbarPanel()); + me.toolbar.addTab(tab, $panel, 7); } var viewtab = me.getApplication().getController('ViewTab'); diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js new file mode 100644 index 0000000000..9c46a21c45 --- /dev/null +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -0,0 +1,139 @@ +/* + * + * (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 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 + * + */ + +/** + * WBProtection.js + * + * Created by Julia Radzhabova on 21.06.2021 + * Copyright (c) 2021Ascensio System SIA. All rights reserved. + * + */ +define([ + 'core', + 'common/main/lib/view/Protection', + 'spreadsheeteditor/main/app/view/WBProtection' +], function () { + 'use strict'; + + SSE.Controllers.WBProtection = Backbone.Controller.extend(_.extend({ + models : [], + collections : [ + ], + views : [ + 'WBProtection' + ], + sdkViewName : '#id_main', + + initialize: function () { + + this.addListeners({ + 'WBProtection': { + 'protect:workbook': _.bind(this.onWorkbookClick, this), + 'protect:sheet': _.bind(this.onSheetClick, this), + 'protect:ranges': _.bind(this.onRangesClick, this), + 'protect:lock-options': _.bind(this.onLockOptionClick, this) + } + }); + }, + onLaunch: function () { + this._state = {}; + + Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); + }, + setConfig: function (data, api) { + this.setApi(api); + + if (data) { + this.sdkViewName = data['sdkviewname'] || this.sdkViewName; + } + }, + setApi: function (api) { + if (api) { + this.api = api; + this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); + } + }, + + setMode: function(mode) { + this.appConfig = mode; + + this.view = this.createView('WBProtection', { + mode: mode + }); + + return this; + }, + + createToolbarPanel: function() { + return this.view.getPanel(); + }, + + getView: function(name) { + return !name && this.view ? + this.view : Backbone.Controller.prototype.getView.call(this, name); + }, + + onWorkbookClick: function(state) { + }, + + onSheetClick: function(state) { + }, + + onRangesClick: function() { + }, + + onLockOptionClick: function(type, value) { + switch (type) { + case 0: // cell + // this._originalProps.asc_getStyleInfo().asc_setShowRowHeaders(this.api, this._originalProps, value=='checked'); + break; + case 1: // shape + break; + case 2: // text + break; + case 3: // formula + break; + } + Common.NotificationCenter.trigger('edit:complete', this); + }, + + onAppReady: function (config) { + }, + + onCoAuthoringDisconnect: function() { + this.SetDisabled(true); + } + + }, SSE.Controllers.WBProtection || {})); +}); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/WBProtection.js b/apps/spreadsheeteditor/main/app/view/WBProtection.js new file mode 100644 index 0000000000..363458c378 --- /dev/null +++ b/apps/spreadsheeteditor/main/app/view/WBProtection.js @@ -0,0 +1,215 @@ +/* + * + * (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 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 + * + */ + +/** + * WBProtection.js + * + * Created by Julia Radzhabova on 21.06.2021 + * Copyright (c) 2021Ascensio 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 = + '
' + + '' + + '' + + '' + + '
' + + '
' + + '
' + + '' + + '
' + + '
' + + '' + + '
' + + '
' + + '
' + + '
' + + '' + + '
' + + '
' + + '' + + '
' + + '
'; + + 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', + txtHiddenFormula: 'Hidden Formulas' + } + }()), SSE.Views.WBProtection || {})); +}); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app_dev.js b/apps/spreadsheeteditor/main/app_dev.js index 86e7902540..1622fc00f0 100644 --- a/apps/spreadsheeteditor/main/app_dev.js +++ b/apps/spreadsheeteditor/main/app_dev.js @@ -149,6 +149,7 @@ require([ 'PivotTable', 'DataTab', 'ViewTab', + 'WBProtection', 'Common.Controllers.Fonts', 'Common.Controllers.Chat', 'Common.Controllers.Comments', @@ -173,6 +174,7 @@ require([ 'spreadsheeteditor/main/app/controller/PivotTable', 'spreadsheeteditor/main/app/controller/DataTab', 'spreadsheeteditor/main/app/controller/ViewTab', + 'spreadsheeteditor/main/app/controller/WBProtection', 'spreadsheeteditor/main/app/view/FileMenuPanels', 'spreadsheeteditor/main/app/view/ParagraphSettings', 'spreadsheeteditor/main/app/view/ImageSettings', From 7617a9681ec8903f80d3aecb0f6e52103a727977 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 21 Jun 2021 23:53:28 +0300 Subject: [PATCH 03/50] [SSE] Protect workbook --- apps/common/main/lib/controller/Protection.js | 1 - apps/common/main/lib/view/PasswordDialog.js | 25 +++++++++-------- .../main/app/controller/WBProtection.js | 27 +++++++++++++++++++ .../main/app/view/WBProtection.js | 5 +++- 4 files changed, 45 insertions(+), 13 deletions(-) diff --git a/apps/common/main/lib/controller/Protection.js b/apps/common/main/lib/controller/Protection.js index d7a45c1c6a..cb144953f4 100644 --- a/apps/common/main/lib/controller/Protection.js +++ b/apps/common/main/lib/controller/Protection.js @@ -153,7 +153,6 @@ define([ var me = this, win = new Common.Views.PasswordDialog({ api: me.api, - signType: 'invisible', handler: function(result, props) { if (result == 'ok') { me.api.asc_setCurrentPassword(props); diff --git a/apps/common/main/lib/view/PasswordDialog.js b/apps/common/main/lib/view/PasswordDialog.js index 05545ad1bc..d8884ad71f 100644 --- a/apps/common/main/lib/view/PasswordDialog.js +++ b/apps/common/main/lib/view/PasswordDialog.js @@ -55,22 +55,27 @@ define([ _.extend(_options, { width : 395, - height : 270, + height : options.height || 261, header : true, cls : 'modal-dlg', contentTemplate : '', - title : t.txtTitle, - buttons: ['ok', 'cancel'] + title : options.txtTitle || t.txtTitle, + passwordOptional: !!options.passwordOptional, + buttons: options.buttons || ['ok', 'cancel'] }, options); + this.handler = options.handler; + this.passwordOptional = options.passwordOptional || false; + this.txtDescription = options.txtDescription || t.txtDescription; + this.template = options.template || [ '
', - '
', + '
', '', '
', '
', - '', + '', '
', '
', '
', @@ -81,9 +86,6 @@ define([ '
' ].join(''); - this.handler = options.handler; - this.settings = options.settings; - _options.tpl = _.template(this.template)(_options); Common.UI.Window.prototype.initialize.call(this, _options); @@ -97,7 +99,7 @@ define([ this.inputPwd = new Common.UI.InputField({ el: $('#id-password-txt'), type: 'password', - allowBlank : false, + allowBlank : this.passwordOptional, style : 'width: 100%;', maxLength: 255, validateOnBlur: false @@ -105,7 +107,7 @@ define([ this.repeatPwd = new Common.UI.InputField({ el: $('#id-repeat-txt'), type: 'password', - allowBlank : false, + allowBlank : this.passwordOptional, style : 'width: 100%;', maxLength: 255, validateOnBlur: false, @@ -157,7 +159,8 @@ define([ txtDescription : "A Password is required to open this document", txtRepeat: 'Repeat password', txtIncorrectPwd: 'Confirmation password is not identical', - txtWarning: 'Warning: If you lose or forget the password, it cannot be recovered. Please keep it in a safe place.' + txtWarning: 'Warning: If you lose or forget the password, it cannot be recovered. Please keep it in a safe place.', + txtOptional: 'Optional' }, Common.Views.PasswordDialog || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index 9c46a21c45..560fc76162 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -105,6 +105,27 @@ define([ }, onWorkbookClick: function(state) { + var me = this, + win = new Common.Views.PasswordDialog({ + api: me.api, + txtTitle: me.view.txtWBTitle, + txtDescription: me.view.txtWBDescription, + passwordOptional: true, + height: 291, + buttons: [{ + value: 'ok', + caption: me.view.txtProtect + }, 'cancel'], + primary: 'ok', + handler: function(result, props) { + if (result == 'ok') { + me.api.asc_setProtectedWorkbook(me.api.asc_getProtectedWorkbook()); + } + Common.NotificationCenter.trigger('edit:complete'); + } + }); + + win.show(); }, onSheetClick: function(state) { @@ -129,6 +150,12 @@ define([ }, onAppReady: function (config) { + var me = this; + (new Promise(function (resolve) { + resolve(); + })).then(function () { + me.view.btnProtectWB.toggle(me.api.asc_isProtectedWorkbook(), true); + }); }, onCoAuthoringDisconnect: function() { diff --git a/apps/spreadsheeteditor/main/app/view/WBProtection.js b/apps/spreadsheeteditor/main/app/view/WBProtection.js index 363458c378..44d3f08999 100644 --- a/apps/spreadsheeteditor/main/app/view/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/view/WBProtection.js @@ -209,7 +209,10 @@ define([ txtLockedCell: 'Locked Cell', txtLockedShape: 'Shape Locked', txtLockedText: 'Lock Text', - txtHiddenFormula: 'Hidden Formulas' + 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' } }()), SSE.Views.WBProtection || {})); }); \ No newline at end of file From 72378721fda93d017576b27329bb3e249adb195b Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 22 Jun 2021 00:23:45 +0300 Subject: [PATCH 04/50] [SSE] Unprotect workbook --- apps/common/main/lib/view/OpenDialog.js | 2 + .../main/app/controller/WBProtection.js | 80 ++++++++++++++----- .../main/app/view/WBProtection.js | 6 +- 3 files changed, 68 insertions(+), 20 deletions(-) diff --git a/apps/common/main/lib/view/OpenDialog.js b/apps/common/main/lib/view/OpenDialog.js index fce9a2ee19..5d7d7ba19d 100644 --- a/apps/common/main/lib/view/OpenDialog.js +++ b/apps/common/main/lib/view/OpenDialog.js @@ -91,6 +91,8 @@ define([ }, options); + this.txtOpenFile = options.txtOpenFile || this.txtOpenFile; + this.template = options.template || [ '
', '
', diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index 560fc76162..ea885d7d81 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -105,30 +105,72 @@ define([ }, onWorkbookClick: function(state) { - var me = this, - win = new Common.Views.PasswordDialog({ - api: me.api, - txtTitle: me.view.txtWBTitle, - txtDescription: me.view.txtWBDescription, - passwordOptional: true, - height: 291, - buttons: [{ - value: 'ok', - caption: me.view.txtProtect - }, 'cancel'], - primary: 'ok', - handler: function(result, props) { - if (result == 'ok') { - me.api.asc_setProtectedWorkbook(me.api.asc_getProtectedWorkbook()); + if (state) { + var me = this, + win = new Common.Views.PasswordDialog({ + api: me.api, + title: me.view.txtWBTitle, + txtDescription: me.view.txtWBDescription, + passwordOptional: true, + height: 291, + buttons: [{ + value: 'ok', + caption: me.view.txtProtect + }, 'cancel'], + primary: 'ok', + handler: function(result, props) { + if (result == 'ok') { + me.api.asc_setProtectedWorkbook(me.api.asc_getProtectedWorkbook()); + } + Common.NotificationCenter.trigger('edit:complete'); } - Common.NotificationCenter.trigger('edit:complete'); - } - }); + }); - win.show(); + win.show(); + } else { + var me = this, + win = new Common.Views.OpenDialog({ + title: me.view.txtWBUnlockTitle, + closable: true, + type: Common.Utils.importTextType.DRM, + txtOpenFile: me.view.txtWBUnlockDescription, + validatePwd: false, + handler: function (result, value) { + if (result == 'ok') { + if (me.api) { + me.api.asc_setProtectedWorkbook(me.api.asc_getProtectedWorkbook()); + } + Common.NotificationCenter.trigger('edit:complete'); + } + } + }); + + win.show(); + } }, onSheetClick: function(state) { + if (state) { + + } else { + var me = this, + win = new Common.Views.OpenDialog({ + title: me.view.txtSheetUnlockTitle, + closable: true, + type: Common.Utils.importTextType.DRM, + txtOpenFile: me.view.txtSheetUnlockDescription, + validatePwd: false, + handler: function (result, value) { + if (result == 'ok') { + if (me.api) { + } + Common.NotificationCenter.trigger('edit:complete'); + } + } + }); + + win.show(); + } }, onRangesClick: function() { diff --git a/apps/spreadsheeteditor/main/app/view/WBProtection.js b/apps/spreadsheeteditor/main/app/view/WBProtection.js index 44d3f08999..998820242a 100644 --- a/apps/spreadsheeteditor/main/app/view/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/view/WBProtection.js @@ -212,7 +212,11 @@ define([ 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' + txtWBTitle: 'Protect Workbook structure', + txtWBUnlockTitle: 'Unprotect Workbook', + txtWBUnlockDescription: 'Enter a password to unprotect workbook', + txtSheetUnlockTitle: 'Unprotect Sheet', + txtSheetUnlockDescription: 'Enter a password to unprotect sheet' } }()), SSE.Views.WBProtection || {})); }); \ No newline at end of file From 05099e883cf63e8e1f2df0dc565827e4b4643c3a Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 22 Jun 2021 00:43:55 +0300 Subject: [PATCH 05/50] [SSE] Protect workbook --- apps/common/main/lib/view/PasswordDialog.js | 18 +- .../main/app/controller/WBProtection.js | 14 +- .../main/app/view/ProtectDialog.js | 158 ++++++++++++++++++ 3 files changed, 169 insertions(+), 21 deletions(-) create mode 100644 apps/spreadsheeteditor/main/app/view/ProtectDialog.js diff --git a/apps/common/main/lib/view/PasswordDialog.js b/apps/common/main/lib/view/PasswordDialog.js index d8884ad71f..862446e9cf 100644 --- a/apps/common/main/lib/view/PasswordDialog.js +++ b/apps/common/main/lib/view/PasswordDialog.js @@ -55,23 +55,20 @@ define([ _.extend(_options, { width : 395, - height : options.height || 261, + height : 270, header : true, cls : 'modal-dlg', contentTemplate : '', - title : options.txtTitle || t.txtTitle, - passwordOptional: !!options.passwordOptional, - buttons: options.buttons || ['ok', 'cancel'] + title : t.txtTitle, + buttons: ['ok', 'cancel'] }, options); this.handler = options.handler; - this.passwordOptional = options.passwordOptional || false; - this.txtDescription = options.txtDescription || t.txtDescription; this.template = options.template || [ '
', - '
', + '
', '', '
', '
', @@ -99,7 +96,7 @@ define([ this.inputPwd = new Common.UI.InputField({ el: $('#id-password-txt'), type: 'password', - allowBlank : this.passwordOptional, + allowBlank : false, style : 'width: 100%;', maxLength: 255, validateOnBlur: false @@ -107,7 +104,7 @@ define([ this.repeatPwd = new Common.UI.InputField({ el: $('#id-repeat-txt'), type: 'password', - allowBlank : this.passwordOptional, + allowBlank : false, style : 'width: 100%;', maxLength: 255, validateOnBlur: false, @@ -159,8 +156,7 @@ define([ txtDescription : "A Password is required to open this document", txtRepeat: 'Repeat password', txtIncorrectPwd: 'Confirmation password is not identical', - txtWarning: 'Warning: If you lose or forget the password, it cannot be recovered. Please keep it in a safe place.', - txtOptional: 'Optional' + txtWarning: 'Warning: If you lose or forget the password, it cannot be recovered. Please keep it in a safe place.' }, Common.Views.PasswordDialog || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index ea885d7d81..d1fd83802b 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -41,7 +41,8 @@ define([ 'core', 'common/main/lib/view/Protection', - 'spreadsheeteditor/main/app/view/WBProtection' + 'spreadsheeteditor/main/app/view/WBProtection', + 'spreadsheeteditor/main/app/view/ProtectDialog' ], function () { 'use strict'; @@ -107,17 +108,10 @@ define([ onWorkbookClick: function(state) { if (state) { var me = this, - win = new Common.Views.PasswordDialog({ - api: me.api, + win = new SSE.Views.ProtectDialog({ title: me.view.txtWBTitle, txtDescription: me.view.txtWBDescription, - passwordOptional: true, - height: 291, - buttons: [{ - value: 'ok', - caption: me.view.txtProtect - }, 'cancel'], - primary: 'ok', + height: 306, handler: function(result, props) { if (result == 'ok') { me.api.asc_setProtectedWorkbook(me.api.asc_getProtectedWorkbook()); diff --git a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js new file mode 100644 index 0000000000..b1068269b5 --- /dev/null +++ b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js @@ -0,0 +1,158 @@ +/* + * + * (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 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 + * + */ +/** + * ProtectDialog.js + * + * Created by Julia Radzhabova on 21.06.2021 + * Copyright (c) 2021 Ascensio System SIA. All rights reserved. + * + */ + +define([ + 'common/main/lib/component/Window' +], function () { + 'use strict'; + + SSE.Views.ProtectDialog = Common.UI.Window.extend(_.extend({ + + initialize : function (options) { + var t = this, + _options = {}; + + _.extend(_options, { + width: 350, + cls: 'modal-dlg', + height : options.height || 306, + buttons: [{ + value: 'ok', + caption: this.txtProtect + }, 'cancel'] + }, options); + + this.handler = options.handler; + this.txtDescription = options.txtDescription || ''; + + this.template = options.template || [ + '
', + '
', + '', + '
', + '
', + '', + '
', + '
', + '
', + '', + '
', + '
', + '', + '
' + ].join(''); + + _options.tpl = _.template(this.template)(_options); + + Common.UI.Window.prototype.initialize.call(this, _options); + }, + render: function () { + Common.UI.Window.prototype.render.call(this); + + if (this.$window) { + var me = this; + this.$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); + this.inputPwd = new Common.UI.InputField({ + el: $('#id-password-txt'), + type: 'password', + allowBlank : true, + style : 'width: 100%;', + maxLength: 255, + validateOnBlur: false + }); + this.repeatPwd = new Common.UI.InputField({ + el: $('#id-repeat-txt'), + type: 'password', + allowBlank : true, + style : 'width: 100%;', + maxLength: 255, + validateOnBlur: false, + validation : function(value) { + return me.txtIncorrectPwd; + } + }); + } + }, + + getFocusedComponents: function() { + return [this.inputPwd, this.repeatPwd]; + }, + + getDefaultFocusableComponent: function () { + return this.inputPwd; + }, + + onPrimary: function(event) { + this._handleInput('ok'); + return false; + }, + + onBtnClick: function(event) { + this._handleInput(event.currentTarget.attributes['result'].value); + }, + + _handleInput: function(state) { + if (this.handler) { + if (state == 'ok') { + if (this.inputPwd.checkValidate() !== true) { + this.inputPwd.focus(); + return; + } + if (this.inputPwd.getValue() !== this.repeatPwd.getValue()) { + this.repeatPwd.checkValidate(); + this.repeatPwd.focus(); + return; + } + } + this.handler.call(this, state, this.inputPwd.getValue()); + } + + this.close(); + }, + + txtPassword : "Password", + txtRepeat: 'Repeat password', + txtIncorrectPwd: 'Confirmation password is not identical', + txtWarning: 'Warning: If you lose or forget the password, it cannot be recovered. Please keep it in a safe place.', + txtOptional: 'optional', + txtProtect: 'Protect' + + }, SSE.Views.ProtectDialog || {})); +}); From 8bb87afdee393a56864611a3bb96028650ea8aa9 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 22 Jun 2021 12:16:38 +0300 Subject: [PATCH 06/50] [SSE] Use sdk protect functions --- .../main/app/controller/WBProtection.js | 59 ++++++++++++++----- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index d1fd83802b..0e521add6e 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -82,6 +82,7 @@ define([ setApi: function (api) { if (api) { this.api = api; + this.api.asc_registerCallback('asc_onChangeProtectWorkbook',_.bind(this.onChangeProtectWorkbook, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); } }, @@ -108,38 +109,60 @@ define([ onWorkbookClick: function(state) { if (state) { var me = this, + btn, win = new SSE.Views.ProtectDialog({ title: me.view.txtWBTitle, txtDescription: me.view.txtWBDescription, height: 306, - handler: function(result, props) { + handler: function(result, value) { + btn = result; if (result == 'ok') { - me.api.asc_setProtectedWorkbook(me.api.asc_getProtectedWorkbook()); + var props = new Asc.CWorkbookProtection(); + props.asc_setLockStructure(true); + value && props.asc_setPassword(value); + me.api.asc_setProtectedWorkbook(props); } Common.NotificationCenter.trigger('edit:complete'); } + }).on('close', function() { + if (btn!=='ok') + me.view.btnProtectWB.toggle(false, true); }); win.show(); } else { var me = this, - win = new Common.Views.OpenDialog({ - title: me.view.txtWBUnlockTitle, - closable: true, - type: Common.Utils.importTextType.DRM, - txtOpenFile: me.view.txtWBUnlockDescription, - validatePwd: false, - handler: function (result, value) { - if (result == 'ok') { - if (me.api) { - me.api.asc_setProtectedWorkbook(me.api.asc_getProtectedWorkbook()); + btn, + props = me.api.asc_getProtectedWorkbook(); + if (props.asc_isPassword()) { + var win = new Common.Views.OpenDialog({ + title: me.view.txtWBUnlockTitle, + closable: true, + type: Common.Utils.importTextType.DRM, + txtOpenFile: me.view.txtWBUnlockDescription, + validatePwd: false, + handler: function (result, value) { + btn = result; + if (result == 'ok') { + if (me.api) { + props = new Asc.CWorkbookProtection(); + props.asc_setLockStructure(false, value); + me.api.asc_setProtectedWorkbook(props); + } + Common.NotificationCenter.trigger('edit:complete'); } - Common.NotificationCenter.trigger('edit:complete'); } - } - }); + }).on('close', function() { + if (btn!=='ok') + me.view.btnProtectWB.toggle(true, true); + }); - win.show(); + win.show(); + } else { + props = new Asc.CWorkbookProtection(); + props.asc_setLockStructure(false); + me.api.asc_setProtectedWorkbook(props); + } } }, @@ -194,6 +217,10 @@ define([ }); }, + onChangeProtectWorkbook: function() { + this.view.btnProtectWB.toggle(this.api.asc_isProtectedWorkbook(), true); + }, + onCoAuthoringDisconnect: function() { this.SetDisabled(true); } From bb9877ccca967e9c26c77257085199a0ad7d1d18 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 22 Jun 2021 14:56:07 +0300 Subject: [PATCH 07/50] [SSE] Protect sheet --- .../main/app/controller/WBProtection.js | 43 +++- .../main/app/view/ProtectDialog.js | 226 +++++++++++++++--- .../main/app/view/WBProtection.js | 3 - 3 files changed, 236 insertions(+), 36 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index 0e521add6e..29dccb812b 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -111,9 +111,7 @@ define([ var me = this, btn, win = new SSE.Views.ProtectDialog({ - title: me.view.txtWBTitle, - txtDescription: me.view.txtWBDescription, - height: 306, + type: 'workbook', handler: function(result, value) { btn = result; if (result == 'ok') { @@ -168,25 +166,60 @@ define([ onSheetClick: function(state) { if (state) { + var me = this, + btn, + win = new SSE.Views.ProtectDialog({ + type: 'sheet', + props: me.api.asc_getProtectedSheet(), + handler: function(result, value, props) { + btn = result; + if (result == 'ok') { + !props && (props = new Asc.CSheetProtection()); + props.asc_setSheet(true); + value && props.asc_setPassword(value); + me.api.asc_setProtectedSheet(props); + } + Common.NotificationCenter.trigger('edit:complete'); + } + }).on('close', function() { + if (btn!=='ok') + me.view.btnProtectSheet.toggle(false, true); + }); + win.show(); } else { var me = this, - win = new Common.Views.OpenDialog({ + btn, + props = me.api.asc_getProtectedSheet(); + if (props.asc_isPassword()) { + var win = new Common.Views.OpenDialog({ title: me.view.txtSheetUnlockTitle, closable: true, type: Common.Utils.importTextType.DRM, txtOpenFile: me.view.txtSheetUnlockDescription, validatePwd: false, handler: function (result, value) { + btn = result; if (result == 'ok') { if (me.api) { + props = new Asc.CSheetProtection(); + props.asc_setSheet(false, value); + me.api.asc_setProtectedSheet(props); } Common.NotificationCenter.trigger('edit:complete'); } } + }).on('close', function() { + if (btn!=='ok') + me.view.btnProtectSheet.toggle(true, true); }); - win.show(); + win.show(); + } else { + props = new Asc.CSheetProtection(); + props.asc_setSheet(false); + me.api.asc_setProtectedSheet(props); + } } }, diff --git a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js index b1068269b5..517d010d5f 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js @@ -50,9 +50,10 @@ define([ _options = {}; _.extend(_options, { - width: 350, + title: options.type=='sheet' ? this.txtSheetTitle : this.txtWBTitle, cls: 'modal-dlg', - height : options.height || 306, + width: 350, + height: options.type=='sheet' ? 447 : 306, buttons: [{ value: 'ok', caption: this.txtProtect @@ -61,20 +62,28 @@ define([ this.handler = options.handler; this.txtDescription = options.txtDescription || ''; + this.type = options.type || 'workbook'; + this.props = options.props; this.template = options.template || [ '
', '
', - '', + '', '
', '
', '', '
', '
', '
', - '', + '', '
', '
', + '<% if (type=="sheet") { %>', + '
', + '', + '
', + '
', + '<% } %>', '', '
' ].join(''); @@ -86,39 +95,71 @@ define([ render: function () { Common.UI.Window.prototype.render.call(this); - if (this.$window) { - var me = this; - this.$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); - this.inputPwd = new Common.UI.InputField({ - el: $('#id-password-txt'), - type: 'password', - allowBlank : true, - style : 'width: 100%;', - maxLength: 255, - validateOnBlur: false + var me = this; + this.$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); + this.inputPwd = new Common.UI.InputField({ + el: $('#id-password-txt'), + type: 'password', + allowBlank : true, + style : 'width: 100%;', + maxLength: 255, + validateOnBlur: false + }); + this.repeatPwd = new Common.UI.InputField({ + el: $('#id-repeat-txt'), + type: 'password', + allowBlank : true, + style : 'width: 100%;', + maxLength: 255, + validateOnBlur: false, + validation : function(value) { + return me.txtIncorrectPwd; + } + }); + + if (this.type == 'sheet') { + this.optionsList = new Common.UI.ListView({ + el: $('#protect-dlg-options', this.$window), + store: new Common.UI.DataViewStore(), + simpleAddMode: true, + scrollAlwaysVisible: true, + template: _.template(['
'].join('')), + itemTemplate: _.template([ + '
', + '', + '
', + '
<%= Common.Utils.String.htmlEncode(value) %>
', + '
', + '
' + ].join('')) }); - this.repeatPwd = new Common.UI.InputField({ - el: $('#id-repeat-txt'), - type: 'password', - allowBlank : true, - style : 'width: 100%;', - maxLength: 255, - validateOnBlur: false, - validation : function(value) { - return me.txtIncorrectPwd; - } + this.optionsList.on({ + 'item:change': this.onItemChanged.bind(this), + 'item:add': this.onItemChanged.bind(this), + 'item:select': this.onCellCheck.bind(this) }); + this.optionsList.onKeyDown = _.bind(this.onListKeyDown, this); + this.optionsList.on('entervalue', _.bind(this.onPrimary, this)); } + + this.afterRender(); }, getFocusedComponents: function() { - return [this.inputPwd, this.repeatPwd]; + return this.optionsList ? [this.inputPwd, this.repeatPwd, this.optionsList] : [this.inputPwd, this.repeatPwd]; }, getDefaultFocusableComponent: function () { return this.inputPwd; }, + afterRender: function() { + this._setDefaults(this.props); + }, + onPrimary: function(event) { this._handleInput('ok'); return false; @@ -141,18 +182,147 @@ define([ return; } } - this.handler.call(this, state, this.inputPwd.getValue()); + this.handler.call(this, state, this.inputPwd.getValue(), this.getSheetSettings()); } this.close(); }, - txtPassword : "Password", + _setDefaults: function (props) { + this.optionsList && this.updateOptionsList(props); + }, + + onItemChanged: function (view, record) { + var state = record.model.get('check'); + if ( state == 'indeterminate' ) + $('input[type=checkbox]', record.$el).prop('indeterminate', true); + else $('input[type=checkbox]', record.$el).prop({checked: state, indeterminate: false}); + }, + + onCellCheck: function (listView, itemView, record) { + if (this.checkCellTrigerBlock) + return; + + var target = '', isLabel = false, bound = null; + + var event = window.event ? window.event : window._event; + if (event) { + target = $(event.currentTarget).find('.list-item'); + + if (target.length) { + bound = target.get(0).getBoundingClientRect(); + var _clientX = event.clientX*Common.Utils.zoom(), + _clientY = event.clientY*Common.Utils.zoom(); + if (bound.left < _clientX && _clientX < bound.right && + bound.top < _clientY && _clientY < bound.bottom) { + isLabel = true; + } + } + + if (isLabel || event.target.className.match('checkbox')) { + this.updateCellCheck(listView, record); + + _.delay(function () { + listView.focus(); + }, 100, this); + } + } + }, + + onListKeyDown: function (e, data) { + var record = null, listView = this.optionsList; + + if (listView.disabled) return; + if (_.isUndefined(undefined)) data = e; + + if (data.keyCode == Common.UI.Keys.SPACE) { + data.preventDefault(); + data.stopPropagation(); + + this.updateCellCheck(listView, listView.getSelectedRec()); + + } else { + Common.UI.DataView.prototype.onKeyDown.call(this.optionsList, e, data); + } + }, + + updateCellCheck: function (listView, record) { + if (record && listView) { + record.set('check', !record.get('check')); + // listView.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true, suppressScrollX: true}); + } + }, + + updateOptionsList: function(props) { + var optionsArr = [ + { value: this.txtSelLocked, optionName: 'SelectLockedCells'}, + { value: this.txtSelUnLocked, optionName: 'SelectUnlockedCells'}, + { value: this.txtFormatCells, optionName: 'FormatCells'}, + { value: this.txtFormatCols, optionName: 'FormatColumns'}, + { value: this.txtFormatRows, optionName: 'FormatRows'}, + { value: this.txtInsCols, optionName: 'InsertColumns'}, + { value: this.txtInsRows, optionName: 'InsertRows'}, + { value: this.txtInsHyper, optionName: 'InsertHyperlinks'}, + { value: this.txtDelCols, optionName: 'DeleteColumns'}, + { value: this.txtDelRows, optionName: 'DeleteRows'}, + { value: this.txtSort, optionName: 'Sort'}, + { value: this.txtAutofilter, optionName: 'AutoFilter'}, + { value: this.txtPivot, optionName: 'PivotTables'}, + { value: this.txtObjs, optionName: 'Objects'}, + { value: this.txtScen, optionName: 'Scenarios'} + ]; + + var arr = []; + optionsArr.forEach(function (item, index) { + arr.push(new Common.UI.DataViewModel({ + selected : false, + allowSelected : true, + value : item.value, + optionName : item.optionName, + check : props && props['asc_get' + item.optionName] ? props['asc_get' + item.optionName]() : false + })); + }); + + this.optionsList.store.reset(arr); + this.optionsList.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true, suppressScrollX: true}); + }, + + getSheetSettings: function() { + if (this.type !== 'sheet') return null; + + var props = new Asc.CSheetProtection(); + this.optionsList.store.each(function (item, index) { + props && props['asc_set' + item.get('optionName')] && props['asc_set' + item.get('optionName')](item.get('check')); + }); + return props; + }, + + txtPassword : "Password", txtRepeat: 'Repeat password', txtIncorrectPwd: 'Confirmation password is not identical', txtWarning: 'Warning: If you lose or forget the password, it cannot be recovered. Please keep it in a safe place.', txtOptional: 'optional', - txtProtect: 'Protect' + txtProtect: 'Protect', + txtSelLocked: 'Select locked cells', + txtSelUnLocked: 'Select unlocked cells', + txtFormatCells: 'Format cells', + txtFormatCols: 'Format columns', + txtFormatRows: 'Format rows', + txtInsCols: 'Insert columns', + txtInsRows: 'Insert rows', + txtInsHyper: 'Insert hyperlink', + txtDelCols: 'Delete columns', + txtDelRows: 'Delete rows', + txtSort: 'Sort', + txtAutofilter: 'Use AutoFilter', + txtPivot: 'Use PivotTable and PivotChart', + txtObjs: 'Edit objects', + txtScen: 'Edit scenarios', + 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', + txtSheetDescription: 'Prevent unwanted changes from others by limiting their ability to edit.', + txtSheetTitle: 'Protect Sheet', + txtAllow: 'Allow all users of this sheet to' }, SSE.Views.ProtectDialog || {})); }); diff --git a/apps/spreadsheeteditor/main/app/view/WBProtection.js b/apps/spreadsheeteditor/main/app/view/WBProtection.js index 998820242a..65e77e0a90 100644 --- a/apps/spreadsheeteditor/main/app/view/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/view/WBProtection.js @@ -210,9 +210,6 @@ define([ txtLockedShape: 'Shape Locked', txtLockedText: 'Lock Text', 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', txtWBUnlockTitle: 'Unprotect Workbook', txtWBUnlockDescription: 'Enter a password to unprotect workbook', txtSheetUnlockTitle: 'Unprotect Sheet', From dad7205a5e407c9dee85827baeda42a385d51e29 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 22 Jun 2021 15:04:10 +0300 Subject: [PATCH 08/50] [SSE] Show protected sheet --- .../main/app/controller/WBProtection.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index 29dccb812b..49b52b5c52 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -83,6 +83,8 @@ define([ if (api) { this.api = api; this.api.asc_registerCallback('asc_onChangeProtectWorkbook',_.bind(this.onChangeProtectWorkbook, this)); + this.api.asc_registerCallback('asc_onChangeProtectSheet',_.bind(this.onChangeProtectSheet, this)); + this.api.asc_registerCallback('asc_onSheetsChanged', _.bind(this.onApiSheetChanged, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); } }, @@ -247,6 +249,7 @@ define([ resolve(); })).then(function () { me.view.btnProtectWB.toggle(me.api.asc_isProtectedWorkbook(), true); + me.view.btnProtectSheet.toggle(me.api.asc_isProtectedSheet(), true); //current sheet }); }, @@ -254,6 +257,14 @@ define([ this.view.btnProtectWB.toggle(this.api.asc_isProtectedWorkbook(), true); }, + onChangeProtectSheet: function() { + this.view.btnProtectSheet.toggle(this.api.asc_isProtectedSheet(), true); //current sheet + }, + + onApiSheetChanged: function() { + this.view.btnProtectSheet.toggle(this.api.asc_isProtectedSheet(), true); //current sheet + }, + onCoAuthoringDisconnect: function() { this.SetDisabled(true); } From e6c67dc0efc198a8e3cb8be1a1959aacfbeb008f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 22 Jun 2021 15:45:04 +0300 Subject: [PATCH 09/50] [SSE] Fix sheet protection --- apps/spreadsheeteditor/main/app/view/ProtectDialog.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js index 517d010d5f..b2551ae4d0 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js @@ -279,7 +279,7 @@ define([ allowSelected : true, value : item.value, optionName : item.optionName, - check : props && props['asc_get' + item.optionName] ? props['asc_get' + item.optionName]() : false + check : props && props['asc_get' + item.optionName] ? !props['asc_get' + item.optionName]() : false })); }); @@ -292,7 +292,7 @@ define([ var props = new Asc.CSheetProtection(); this.optionsList.store.each(function (item, index) { - props && props['asc_set' + item.get('optionName')] && props['asc_set' + item.get('optionName')](item.get('check')); + props && props['asc_set' + item.get('optionName')] && props['asc_set' + item.get('optionName')](!item.get('check')); }); return props; }, From 65498d9582e2e79e270d9d6f40acb9e38d723d52 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 22 Jun 2021 16:07:10 +0300 Subject: [PATCH 10/50] [SSE] Change existing protection props --- .../main/app/controller/WBProtection.js | 10 +++------- apps/spreadsheeteditor/main/app/view/ProtectDialog.js | 2 +- apps/spreadsheeteditor/main/app/view/WBProtection.js | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index 49b52b5c52..6fe5be03c4 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -117,7 +117,7 @@ define([ handler: function(result, value) { btn = result; if (result == 'ok') { - var props = new Asc.CWorkbookProtection(); + var props = me.api.asc_getProtectedWorkbook(); props.asc_setLockStructure(true); value && props.asc_setPassword(value); me.api.asc_setProtectedWorkbook(props); @@ -145,7 +145,6 @@ define([ btn = result; if (result == 'ok') { if (me.api) { - props = new Asc.CWorkbookProtection(); props.asc_setLockStructure(false, value); me.api.asc_setProtectedWorkbook(props); } @@ -159,7 +158,6 @@ define([ win.show(); } else { - props = new Asc.CWorkbookProtection(); props.asc_setLockStructure(false); me.api.asc_setProtectedWorkbook(props); } @@ -170,13 +168,13 @@ define([ if (state) { var me = this, btn, + props = me.api.asc_getProtectedSheet(), win = new SSE.Views.ProtectDialog({ type: 'sheet', - props: me.api.asc_getProtectedSheet(), + props: props, handler: function(result, value, props) { btn = result; if (result == 'ok') { - !props && (props = new Asc.CSheetProtection()); props.asc_setSheet(true); value && props.asc_setPassword(value); me.api.asc_setProtectedSheet(props); @@ -204,7 +202,6 @@ define([ btn = result; if (result == 'ok') { if (me.api) { - props = new Asc.CSheetProtection(); props.asc_setSheet(false, value); me.api.asc_setProtectedSheet(props); } @@ -218,7 +215,6 @@ define([ win.show(); } else { - props = new Asc.CSheetProtection(); props.asc_setSheet(false); me.api.asc_setProtectedSheet(props); } diff --git a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js index b2551ae4d0..c3b6f9e0b1 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js @@ -290,7 +290,7 @@ define([ getSheetSettings: function() { if (this.type !== 'sheet') return null; - var props = new Asc.CSheetProtection(); + var props = this.props ? this.props : new Asc.CSheetProtection(); this.optionsList.store.each(function (item, index) { props && props['asc_set' + item.get('optionName')] && props['asc_set' + item.get('optionName')](!item.get('check')); }); diff --git a/apps/spreadsheeteditor/main/app/view/WBProtection.js b/apps/spreadsheeteditor/main/app/view/WBProtection.js index 65e77e0a90..554211db4a 100644 --- a/apps/spreadsheeteditor/main/app/view/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/view/WBProtection.js @@ -49,8 +49,8 @@ define([ SSE.Views.WBProtection = Common.UI.BaseView.extend(_.extend((function(){ var template = '
' + - '' + - '' + + '' + + '' + '' + '
' + '
' + From fb57f2d0e2b45ab4279284eb63afc8c1a2c62d0f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 22 Jun 2021 16:15:15 +0300 Subject: [PATCH 11/50] [SSE] Add error on a protected sheet --- apps/spreadsheeteditor/main/app/controller/Main.js | 7 ++++++- apps/spreadsheeteditor/mobile/locale/en.json | 3 ++- apps/spreadsheeteditor/mobile/src/controller/Error.jsx | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 8655a8abff..e874bb1007 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1692,6 +1692,10 @@ define([ config.msg = this.errorPivotWithoutUnderlying; break; + case Asc.c_oAscError.ID.ChangeOnProtectedSheet: + config.msg = this.errorChangeOnProtectedSheet; + break; + default: config.msg = (typeof id == 'string') ? id : this.errorDefaultMessage.replace('%1', id); break; @@ -2952,7 +2956,8 @@ define([ errorPivotWithoutUnderlying: 'The Pivot Table report was saved without the underlying data.
Use the \'Refresh\' button to update the report.', txtQuarter: 'Qtr', txtOr: '%1 or %2', - confirmReplaceFormulaInTable: 'Formulas in the header row will be removed and converted to static text.
Do you want to continue?' + confirmReplaceFormulaInTable: 'Formulas in the header row will be removed and converted to static text.
Do you want to continue?', + errorChangeOnProtectedSheet: 'The cell or chart you are trying to change is on a protected sheet.
To make a change, unprotect the sheet. You might be requested to enter a password.' } })(), SSE.Controllers.Main || {})) }); diff --git a/apps/spreadsheeteditor/mobile/locale/en.json b/apps/spreadsheeteditor/mobile/locale/en.json index afedbcdc06..5a1bb9c8c9 100644 --- a/apps/spreadsheeteditor/mobile/locale/en.json +++ b/apps/spreadsheeteditor/mobile/locale/en.json @@ -164,7 +164,8 @@ "errorFrmlMaxTextLength": "Text values in formulas are limited to 255 characters.
Use the CONCATENATE function or concatenation operator (&)", "errorFrmlMaxLength": "You cannot add this formula as its length exceeded the allowed number of characters.
Please edit it and try again.", "errorFrmlMaxReference": "You cannot enter this formula because it has too many values,
cell references, and/or names.", - "errorDataValidate":"The value you entered is not valid.
A user has restricted values that can be entered into this cell." + "errorDataValidate":"The value you entered is not valid.
A user has restricted values that can be entered into this cell.", + "errorChangeOnProtectedSheet": "The cell or chart you are trying to change is on a protected sheet.
To make a change, unprotect the sheet." }, "ContextMenu": { "menuViewComment": "View Comment", diff --git a/apps/spreadsheeteditor/mobile/src/controller/Error.jsx b/apps/spreadsheeteditor/mobile/src/controller/Error.jsx index 340da6739e..484e6ef1aa 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Error.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Error.jsx @@ -298,6 +298,10 @@ const ErrorController = inject('storeAppOptions')(({storeAppOptions, LoadingDocu case Asc.c_oAscError.ID.UpdateVersion: config.msg = _t.errorUpdateVersionOnDisconnect; break; + + case Asc.c_oAscError.ID.ChangeOnProtectedSheet: + config.msg = _t.errorChangeOnProtectedSheet; + break; default: config.msg = _t.errorDefaultMessage.replace('%1', id); From 2e6bff5c0e1a7cf7d729c26bd0035d0884051933 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Jun 2021 00:46:43 +0300 Subject: [PATCH 12/50] [SSE] Show protected ranges --- .../main/app/controller/WBProtection.js | 21 +- .../app/template/ProtectRangesDlg.template | 35 ++ .../main/app/view/ProtectRangesDlg.js | 414 ++++++++++++++++++ 3 files changed, 468 insertions(+), 2 deletions(-) create mode 100644 apps/spreadsheeteditor/main/app/template/ProtectRangesDlg.template create mode 100644 apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index 6fe5be03c4..e524cd9261 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -42,7 +42,8 @@ define([ 'core', 'common/main/lib/view/Protection', 'spreadsheeteditor/main/app/view/WBProtection', - 'spreadsheeteditor/main/app/view/ProtectDialog' + 'spreadsheeteditor/main/app/view/ProtectDialog', + 'spreadsheeteditor/main/app/view/ProtectRangesDlg' ], function () { 'use strict'; @@ -83,7 +84,7 @@ define([ if (api) { this.api = api; this.api.asc_registerCallback('asc_onChangeProtectWorkbook',_.bind(this.onChangeProtectWorkbook, this)); - this.api.asc_registerCallback('asc_onChangeProtectSheet',_.bind(this.onChangeProtectSheet, this)); + this.api.asc_registerCallback('asc_onChangeProtectWorksheet',_.bind(this.onChangeProtectSheet, this)); this.api.asc_registerCallback('asc_onSheetsChanged', _.bind(this.onApiSheetChanged, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); } @@ -222,6 +223,22 @@ define([ }, onRangesClick: function() { + var me = this, + props = me.api.asc_getProtectedRanges(), + win = new SSE.Views.ProtectRangesDlg({ + api: me.api, + props: props, + handler: function(result, settings) { + if (result=='protect-sheet') { + me.onSheetClick(true); + } else if (result == 'ok') { + me.api.asc_setProtectedRanges(settings.arr, settings.deletedArr); + } + Common.NotificationCenter.trigger('edit:complete'); + } + }); + + win.show(); }, onLockOptionClick: function(type, value) { diff --git a/apps/spreadsheeteditor/main/app/template/ProtectRangesDlg.template b/apps/spreadsheeteditor/main/app/template/ProtectRangesDlg.template new file mode 100644 index 0000000000..fee4ace453 --- /dev/null +++ b/apps/spreadsheeteditor/main/app/template/ProtectRangesDlg.template @@ -0,0 +1,35 @@ +
+
+ + + + + + + + + + + + + + + + + +
+ +
+ + + +
+
+
+ + + + +
+
+
\ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js new file mode 100644 index 0000000000..67a3aa1aed --- /dev/null +++ b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js @@ -0,0 +1,414 @@ +/* + * + * (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 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 + * +*/ +/** + * + * ProtectRangesDlg.js + * + * Created by Julia.Radzhabova on 22.06.21 + * Copyright (c) 2021 Ascensio System SIA. All rights reserved. + * + */ + +define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', + 'common/main/lib/view/AdvancedSettingsWindow', + 'common/main/lib/component/ListView' +], function (contentTemplate) { + 'use strict'; + + SSE.Views = SSE.Views || {}; + + SSE.Views.ProtectRangesDlg = Common.Views.AdvancedSettingsWindow.extend(_.extend({ + options: { + alias: 'ProtectRangesDlg', + contentWidth: 480, + height: 353 + }, + + initialize: function (options) { + var me = this; + _.extend(this.options, { + title: this.txtTitle, + template: [ + '
', + '
' + _.template(contentTemplate)({scope: this}) + '
', + '
', + '
' + ].join(''), + buttons: [{ + value: 'protect-sheet', + caption: this.textProtect + }, 'ok','cancel'], + primary: 'protect-sheet' + }, options); + + this.api = options.api; + this.handler = options.handler; + this.props = options.props; + this.locked = options.locked || false; + this.userTooltip = true; + this.currentRange = undefined; + + this.wrapEvents = { + onLockProtectedRangeManager: _.bind(this.onLockProtectedRangeManager, this), + onUnLockProtectedRangeManager: _.bind(this.onUnLockProtectedRangeManager, this), + onLockProtectedRange: _.bind(this.onLockProtectedRange, this), + onUnLockProtectedRange: _.bind(this.onUnLockProtectedRange, this) + }; + + Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); + }, + render: function () { + Common.Views.AdvancedSettingsWindow.prototype.render.call(this); + var me = this; + + this.rangeList = new Common.UI.ListView({ + el: $('#protect-ranges-list', this.$window), + store: new Common.UI.DataViewStore(), + simpleAddMode: true, + emptyText: this.textEmpty, + itemTemplate: _.template([ + '
', + '
<%= Common.Utils.String.htmlEncode(name) %>
', + '
<%= range %>
', + '
<% if (pwd) { %>', me.txtYes, '<% } else { %>', me.txtNo, '<% } %>
', + '<% if (lock) { %>', + '
<%=lockuser%>
', + '<% } %>', + '
' + ].join('')), + tabindex: 1 + }); + this.rangeList.store.comparator = function(item1, item2) { + var n1 = item1.get('name').toLowerCase(), + n2 = item2.get('name').toLowerCase(); + if (n1==n2) return 0; + return (n10) ? this.textnoNames : this.textEmpty); + } + + var me = this, + store = this.rangeList.store, + val = store.length; + this.btnEditRange.setDisabled(!val); + this.btnDeleteRange.setDisabled(!val); + if (val>0) { + if (selectedItem===undefined || selectedItem===null) selectedItem = 0; + if (_.isNumber(selectedItem)) { + if (selectedItem>val-1) selectedItem = val-1; + this.rangeList.selectByIndex(selectedItem); + setTimeout(function() { + me.rangeList.scrollToRecord(store.at(selectedItem)); + }, 50); + + } else if (selectedItem){ // object + var rec = store.findWhere({name: selectedItem.asc_getName(true), scope: selectedItem.asc_getScope()}); + if (rec) { + this.rangeList.selectRecord(rec); + setTimeout(function() { + me.rangeList.scrollToRecord(rec); + }, 50); + } + } + + if (this.userTooltip===true && this.rangeList.cmpEl.find('.lock-user').length>0) + this.rangeList.cmpEl.on('mouseover', _.bind(me.onMouseOverLock, me)).on('mouseout', _.bind(me.onMouseOutLock, me)); + } + _.delay(function () { + me.rangeList.scroller.update({alwaysVisibleY: true}); + }, 100, this); + }, + + onMouseOverLock: function (evt, el, opt) { + if (this.userTooltip===true && $(evt.target).hasClass('lock-user')) { + var me = this, + tipdata = $(evt.target).tooltip({title: this.tipIsLocked,trigger:'manual'}).data('bs.tooltip'); + + this.userTooltip = tipdata.tip(); + this.userTooltip.css('z-index', parseInt(this.$window.css('z-index')) + 10); + tipdata.show(); + + setTimeout(function() { me.userTipHide(); }, 5000); + } + }, + + userTipHide: function () { + if (typeof this.userTooltip == 'object') { + this.userTooltip.remove(); + this.userTooltip = undefined; + this.rangeList.cmpEl.off('mouseover').off('mouseout'); + } + }, + + onMouseOutLock: function (evt, el, opt) { + if (typeof this.userTooltip == 'object') this.userTipHide(); + }, + + onEditRange: function (isEdit) { + if (this._isWarningVisible) return; + + if (this.locked) { + Common.NotificationCenter.trigger('namedrange:locked'); + return; + } + var me = this, + xy = me.$window.offset(), + rec = this.rangeList.getSelectedRec(), + idx = _.indexOf(this.rangeList.store.models, rec), + oldname = (isEdit && rec) ? new Asc.asc_CDefName(rec.get('name'), rec.get('range'), rec.get('scope'), rec.get('type'), undefined, undefined, undefined, true) : null; + + var win = new SSE.Views.NamedRangeEditDlg({ + api: me.api, + sheets : this.sheets, + props : (isEdit) ? oldname : this.props, + isEdit : isEdit, + handler : function(result, settings) { + if (result == 'ok' && settings) { + if (isEdit) { + me.currentNamedRange = settings; + me.api.asc_editDefinedNames(oldname, settings); + } else { + me.cmbFilter.setValue(0); + me.currentNamedRange = settings; + me.api.asc_setDefinedNames(settings); + } + } + } + }).on('close', function() { + me.show(); + setTimeout(function(){ me.getDefaultFocusableComponent().focus(); }, 100); + }); + + me.hide(); + win.show(xy.left + 65, xy.top + 77); + }, + + onDeleteRange: function () { + var rec = this.rangeList.getSelectedRec(); + if (rec) { + var me = this; + me._isWarningVisible = true; + Common.UI.warning({ + msg: Common.Utils.String.format(me.warnDelete, rec.get('name')), + buttons: ['ok', 'cancel'], + callback: function(btn) { + if (btn == 'ok') { + me.currentNamedRange = _.indexOf(me.rangeList.store.models, rec); + me.api.asc_delDefinedNames(new Asc.asc_CDefName(rec.get('name'), rec.get('range'), rec.get('scope'), rec.get('type'), undefined, undefined, undefined, true)); + } + setTimeout(function(){ me.getDefaultFocusableComponent().focus(); }, 100); + me._isWarningVisible = false; + } + }); + } + }, + + getSettings: function() { + return {}; + }, + + onPrimary: function() { + return true; + }, + + onDlgBtnClick: function(event) { + this.handler && this.handler.call(this, event.currentTarget.attributes['result'].value); + this.close(); + }, + + getUserName: function(id){ + var usersStore = SSE.getCollection('Common.Collections.Users'); + if (usersStore){ + var rec = usersStore.findUser(id); + if (rec) + return AscCommon.UserInfoParser.getParsedName(rec.get('username')); + } + return this.guestText; + }, + + onSelectRangeItem: function(lisvView, itemView, record) { + if (!record) return; + + this.userTipHide(); + var rawData = {}, + isViewSelect = _.isFunction(record.toJSON); + + if (isViewSelect){ + if (record.get('selected')) { + rawData = record.toJSON(); + } else {// record deselected + return; + } + this.currentNamedRange = _.indexOf(this.rangeList.store.models, record); + this.btnEditRange.setDisabled(rawData.lock); + this.btnDeleteRange.setDisabled(rawData.lock); + } + }, + + hide: function () { + this.userTipHide(); + Common.UI.Window.prototype.hide.call(this); + }, + + close: function () { + this.userTipHide(); + this.api.asc_unregisterCallback('asc_onLockProtectedRangeManager', this.wrapEvents.onLockProtectedRangeManager); + this.api.asc_unregisterCallback('asc_onUnLockProtectedRangeManager', this.wrapEvents.onUnLockProtectedRangeManager); + this.api.asc_unregisterCallback('asc_onLockProtectedRange', this.wrapEvents.onLockProtectedRange); + this.api.asc_unregisterCallback('asc_onUnLockProtectedRange', this.wrapEvents.onUnLockProtectedRange); + Common.UI.Window.prototype.close.call(this); + }, + + onKeyDown: function (lisvView, record, e) { + if (e.keyCode==Common.UI.Keys.DELETE && !this.btnDeleteRange.isDisabled()) + this.onDeleteRange(); + }, + + onDblClickItem: function (lisvView, record, e) { + if (!this.btnEditRange.isDisabled()) + this.onEditRange(true); + }, + + onLockProtectedRangeManager: function(index) { + if (this.currentSheet !== index) return; + this.locked = true; + this.updateButtons(); + if (this.userTooltip===true && this.rulesList.cmpEl.find('.lock-user').length>0) + this.rulesList.cmpEl.on('mouseover', _.bind(this.onMouseOverLock, this)).on('mouseout', _.bind(this.onMouseOutLock, this)); + }, + + onUnLockProtectedRangeManager: function(index) { + if (this.currentSheet !== index) return; + this.locked = false; + this.updateButtons(); + }, + + onLockProtectedRange: function(index, ruleId, userId) { + if (this.currentSheet !== index) return; + var store = this.rulesList.store, + rec = store.findWhere({ruleId: ruleId}); + if (rec) { + rec.set('lockuser', (userId) ? this.getUserName(userId) : this.guestText); + rec.set('lock', true); + this.updateButtons(); + } + if (this.userTooltip===true && this.rulesList.cmpEl.find('.lock-user').length>0) + this.rulesList.cmpEl.on('mouseover', _.bind(this.onMouseOverLock, this)).on('mouseout', _.bind(this.onMouseOutLock, this)); + }, + + onUnLockProtectedRange: function(index, ruleId) { + if (this.currentSheet !== index) return; + var store = this.rulesList.store, + rec = store.findWhere({ruleId: ruleId}); + if (rec) { + rec.set('lockuser', ''); + rec.set('lock', false); + this.updateButtons(); + } + }, + + txtTitle: 'Allow Users to Edit Ranges', + textRangesDesc: 'Ranges unlocked by a password when sheet is protected (this works only for locked cells):', + textTitle: 'Title', + textRange: 'Range', + textPwd: 'Password', + textNew: 'New', + textEdit: 'Edit', + textDelete: 'Delete', + textEmpty: 'No ranges allowed for edit.', + guestText: 'Guest', + tipIsLocked: 'This element is being edited by another user.', + warnDelete: 'Are you sure you want to delete the name {0}?', + textProtect: 'Protect Sheet', + txtYes: 'Yes', + txtNo: 'No' + + }, SSE.Views.ProtectRangesDlg || {})); +}); \ No newline at end of file From 46ec6ba23c7141d2838a9f61c7ccba67f295e6de Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Jun 2021 01:44:35 +0300 Subject: [PATCH 13/50] [SSE] Edit protected ranges --- .../main/app/view/ProtectDialog.js | 114 ++++++++++++++++-- .../main/app/view/ProtectRangesDlg.js | 72 ++++++----- 2 files changed, 141 insertions(+), 45 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js index c3b6f9e0b1..d6648ee17e 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js @@ -50,11 +50,11 @@ define([ _options = {}; _.extend(_options, { - title: options.type=='sheet' ? this.txtSheetTitle : this.txtWBTitle, + title: options.title ? options.title : (options.type=='sheet' ? this.txtSheetTitle : this.txtWBTitle), cls: 'modal-dlg', width: 350, - height: options.type=='sheet' ? 447 : 306, - buttons: [{ + height: options.type=='sheet' ? 447 : (options.type=='range' ? 338 : 306), + buttons: options.buttons ? options.buttons : [{ value: 'ok', caption: this.txtProtect }, 'cancel'] @@ -64,12 +64,24 @@ define([ this.txtDescription = options.txtDescription || ''; this.type = options.type || 'workbook'; this.props = options.props; + this.api = options.api; this.template = options.template || [ '
', - '
', - '', - '
', + '<% if (type=="range") { %>', + '
', + '', + '
', + '
', + '
', + '', + '
', + '
', + '<% } else { %>', + '
', + '', + '
', + '<% } %>', '
', '', '
', @@ -145,15 +157,44 @@ define([ this.optionsList.on('entervalue', _.bind(this.onPrimary, this)); } + if (this.type == 'range') { + this.inputRangeName = new Common.UI.InputField({ + el: $('#id-range-name-txt'), + allowBlank : false, + blankError : this.txtEmpty, + style : 'width: 100%;', + maxLength: 255, + validateOnBlur: false + }); + this.txtDataRange = new Common.UI.InputFieldBtn({ + el : $('#id-range-txt'), + name : 'range', + style : 'width: 100%;', + allowBlank : true, + btnHint : this.textSelectData, + blankError : this.txtEmpty, + validateOnChange: true, + validation : function(value) { + if (_.isEmpty(value)) { + return true; + } + } + }); + this.txtDataRange.on('button:click', _.bind(this.onSelectData, this)); + } this.afterRender(); }, getFocusedComponents: function() { - return this.optionsList ? [this.inputPwd, this.repeatPwd, this.optionsList] : [this.inputPwd, this.repeatPwd]; + var arr = []; + (this.type == 'range') && (arr = arr.concat([this.inputRangeName, this.txtDataRange])); + arr = arr.concat([this.inputPwd, this.repeatPwd]); + (this.type == 'sheet') && (arr = arr.concat([this.optionsList])); + return arr; }, getDefaultFocusableComponent: function () { - return this.inputPwd; + return (this.type == 'range') ? this.inputRangeName : this.inputPwd; }, afterRender: function() { @@ -172,6 +213,10 @@ define([ _handleInput: function(state) { if (this.handler) { if (state == 'ok') { + if (this.inputRangeName && this.inputRangeName.checkValidate() !== true) { + this.inputRangeName.focus(); + return; + } if (this.inputPwd.checkValidate() !== true) { this.inputPwd.focus(); return; @@ -182,7 +227,7 @@ define([ return; } } - this.handler.call(this, state, this.inputPwd.getValue(), this.getSheetSettings()); + this.handler.call(this, state, this.inputPwd.getValue(), this.getSettings()); } this.close(); @@ -287,9 +332,12 @@ define([ this.optionsList.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true, suppressScrollX: true}); }, - getSheetSettings: function() { - if (this.type !== 'sheet') return null; + getSettings: function() { + if (this.type == 'sheet') return this.getSheetSettings(); + if (this.type == 'range') return this.getRangeSettings(); + }, + getSheetSettings: function() { var props = this.props ? this.props : new Asc.CSheetProtection(); this.optionsList.store.each(function (item, index) { props && props['asc_set' + item.get('optionName')] && props['asc_set' + item.get('optionName')](!item.get('check')); @@ -297,6 +345,44 @@ define([ return props; }, + getRangeSettings: function() { + var props = this.props ? this.props : new Asc.CProtectedRange(); + props.asc_setName(this.inputRangeName.getValue()); + props.asc_setSqref(this.txtDataRange.getValue()); + return props; + }, + + onSelectData: function() { + var me = this; + if (me.api) { + var handlerDlg = function(dlg, result) { + if (result == 'ok') { + me.dataRangeValid = dlg.getSettings(); + me.txtDataRange.setValue(me.dataRangeValid); + me.txtDataRange.checkValidate(); + } + }; + + var win = new SSE.Views.CellRangeDialog({ + handler: handlerDlg + }).on('close', function() { + me.show(); + _.delay(function(){ + me.txtDataRange.focus(); + },1); + }); + + var xy = me.$window.offset(); + me.hide(); + win.show(xy.left + 65, xy.top + 77); + win.setSettings({ + api : me.api, + range : (!_.isEmpty(me.txtDataRange.getValue()) && (me.txtDataRange.checkValidate()==true)) ? me.txtDataRange.getValue() : me.dataRangeValid, + type : Asc.c_oAscSelectionDialogType.Chart + }); + } + }, + txtPassword : "Password", txtRepeat: 'Repeat password', txtIncorrectPwd: 'Confirmation password is not identical', @@ -322,7 +408,11 @@ define([ txtWBTitle: 'Protect Workbook structure', txtSheetDescription: 'Prevent unwanted changes from others by limiting their ability to edit.', txtSheetTitle: 'Protect Sheet', - txtAllow: 'Allow all users of this sheet to' + txtAllow: 'Allow all users of this sheet to', + txtRangeName: 'Title', + txtRange: 'Range', + txtEmpty: 'This field is required', + textSelectData: 'Select Data' }, SSE.Views.ProtectDialog || {})); }); diff --git a/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js index 67a3aa1aed..101491b2fb 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js @@ -77,6 +77,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', this.locked = options.locked || false; this.userTooltip = true; this.currentRange = undefined; + this.deletedArr = []; this.wrapEvents = { onLockProtectedRangeManager: _.bind(this.onLockProtectedRangeManager, this), @@ -98,8 +99,8 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', emptyText: this.textEmpty, itemTemplate: _.template([ '
', - '
<%= Common.Utils.String.htmlEncode(name) %>
', - '
<%= range %>
', + '
<%= Common.Utils.String.htmlEncode(name) %>
', + '
<%= range %>
', '
<% if (pwd) { %>', me.txtYes, '<% } else { %>', me.txtNo, '<% } %>
', '<% if (lock) { %>', '
<%=lockuser%>
', @@ -163,9 +164,10 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', for (var i=0; i0) && this.rangeList.selectByIndex(index); + this.rangeList.scrollToRecord(this.rangeList.getSelectedRec()); } }, @@ -395,7 +399,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', }, txtTitle: 'Allow Users to Edit Ranges', - textRangesDesc: 'Ranges unlocked by a password when sheet is protected (this works only for locked cells):', + textRangesDesc: 'Ranges unlocked by a password when sheet is protected (this works only for locked cells)', textTitle: 'Title', textRange: 'Range', textPwd: 'Password', @@ -408,7 +412,9 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', warnDelete: 'Are you sure you want to delete the name {0}?', textProtect: 'Protect Sheet', txtYes: 'Yes', - txtNo: 'No' + txtNo: 'No', + txtEditRange: 'Edit Range', + txtNewRange: 'New Range' }, SSE.Views.ProtectRangesDlg || {})); }); \ No newline at end of file From d564b24dd469f5335eb4be02bdcb36fc5ab6c0c2 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Jun 2021 01:51:11 +0300 Subject: [PATCH 14/50] [SSE] Fix protected ranges --- apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js index 101491b2fb..081656b455 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js @@ -295,7 +295,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', }, getSettings: function() { - return {}; + return {arr: [], deletedArr: this.deletedArr}; }, onPrimary: function() { @@ -303,7 +303,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', }, onDlgBtnClick: function(event) { - this.handler && this.handler.call(this, event.currentTarget.attributes['result'].value); + this.handler && this.handler.call(this, event.currentTarget.attributes['result'].value, this.getSettings()); this.close(); }, From 897c3ca1ac2a7b834b96be2e14ade55bb869ec67 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Jun 2021 12:20:24 +0300 Subject: [PATCH 15/50] Fix protect ranges dialog --- .../main/app/view/ProtectDialog.js | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js index d6648ee17e..3c0164bef3 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js @@ -170,14 +170,13 @@ define([ el : $('#id-range-txt'), name : 'range', style : 'width: 100%;', - allowBlank : true, + allowBlank : false, btnHint : this.textSelectData, blankError : this.txtEmpty, validateOnChange: true, validation : function(value) { - if (_.isEmpty(value)) { - return true; - } + var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.ConditionalFormattingRule, value, false); + return (isvalid!==Asc.c_oAscError.ID.DataRangeError) ? true : me.textInvalidRange; } }); this.txtDataRange.on('button:click', _.bind(this.onSelectData, this)); @@ -217,6 +216,10 @@ define([ this.inputRangeName.focus(); return; } + if (this.txtDataRange && this.txtDataRange.checkValidate() !== true) { + this.txtDataRange.focus(); + return; + } if (this.inputPwd.checkValidate() !== true) { this.inputPwd.focus(); return; @@ -227,7 +230,7 @@ define([ return; } } - this.handler.call(this, state, this.inputPwd.getValue(), this.getSettings()); + this.handler.call(this, state, this.inputPwd.getValue(), (state == 'ok') ? this.getSettings() : undefined); } this.close(); @@ -235,6 +238,7 @@ define([ _setDefaults: function (props) { this.optionsList && this.updateOptionsList(props); + (this.type=='range') && this.updateRangeSettings(props); }, onItemChanged: function (view, record) { @@ -297,6 +301,12 @@ define([ // listView.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true, suppressScrollX: true}); } }, + updateRangeSettings: function (props) { + if (props) { + this.inputRangeName.setValue(props.asc_getName()); + this.txtDataRange.setValue(props.asc_getSqref()); + } + }, updateOptionsList: function(props) { var optionsArr = [ @@ -378,7 +388,8 @@ define([ win.setSettings({ api : me.api, range : (!_.isEmpty(me.txtDataRange.getValue()) && (me.txtDataRange.checkValidate()==true)) ? me.txtDataRange.getValue() : me.dataRangeValid, - type : Asc.c_oAscSelectionDialogType.Chart + type : Asc.c_oAscSelectionDialogType.ConditionalFormattingRule, + validation: function() {return true;} }); } }, From a429b83a3da483bc099177e877c62f9560764fae Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Jun 2021 17:15:35 +0300 Subject: [PATCH 16/50] [SSE] Fix protected ranges --- .../main/app/view/ProtectRangesDlg.js | 39 ++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js index 081656b455..1ba9eeba27 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js @@ -179,8 +179,6 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', var me = this, store = this.rangeList.store, val = store.length; - this.btnEditRange.setDisabled(!val); - this.btnDeleteRange.setDisabled(!val); if (val>0) { if (selectedItem===undefined || selectedItem===null) selectedItem = 0; if (_.isNumber(selectedItem)) { @@ -191,7 +189,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', }, 50); } else if (selectedItem){ // object - var rec = store.findWhere({name: selectedItem.asc_getName(true), scope: selectedItem.asc_getScope()}); + var rec = store.findWhere({name: selectedItem.asc_getName(true)}); if (rec) { this.rangeList.selectRecord(rec); setTimeout(function() { @@ -203,6 +201,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', if (this.userTooltip===true && this.rangeList.cmpEl.find('.lock-user').length>0) this.rangeList.cmpEl.on('mouseover', _.bind(me.onMouseOverLock, me)).on('mouseout', _.bind(me.onMouseOutLock, me)); } + this.updateButtons(); _.delay(function () { me.rangeList.scroller.update({alwaysVisibleY: true}); }, 100, this); @@ -243,7 +242,13 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', var me = this, xy = me.$window.offset(), rec = this.rangeList.getSelectedRec(), - props = isEdit ? rec.get('props') : new Asc.CProtectedRange(); + props; + if (isEdit) + props = rec.get('props') + else { + props = new Asc.CProtectedRange(); + props.asc_setSqref(me.api.asc_getActiveRangeStr(Asc.referenceType.A)); + } var win = new SSE.Views.ProtectDialog({ title : isEdit ? me.txtEditRange : me.txtNewRange, @@ -267,9 +272,13 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', pwd: props.asc_isPassword(), range: props.asc_getSqref(), props: props, + isNew: true, lock: false, lockuser: this.guestText }); + me.rangeList.selectByIndex(me.rangeList.store.length-1); + me.rangeList.scrollToRecord(me.rangeList.getSelectedRec()); + me.updateButtons(); } } } @@ -286,16 +295,21 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', var store = this.rangeList.store, rec = this.rangeList.getSelectedRec(); if (rec) { - this.deletedArr.push(rec.get('props')); + !rec.get('isNew') && this.deletedArr.push(rec.get('props')); var index = store.indexOf(rec); store.remove(rec); (this.rangeList.length>0) && this.rangeList.selectByIndex(index); this.rangeList.scrollToRecord(this.rangeList.getSelectedRec()); } + this.updateButtons(); }, getSettings: function() { - return {arr: [], deletedArr: this.deletedArr}; + var arr = []; + this.rangeList.store.each(function(item){ + arr.push(item.get('props')); + }); + return {arr: arr, deletedArr: this.deletedArr}; }, onPrimary: function() { @@ -331,9 +345,8 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', return; } this.currentNamedRange = _.indexOf(this.rangeList.store.models, record); - this.btnEditRange.setDisabled(rawData.lock); - this.btnDeleteRange.setDisabled(rawData.lock); } + this.updateButtons(); }, hide: function () { @@ -397,7 +410,15 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', this.updateButtons(); } }, - + + updateButtons: function() { + var rec = this.rangeList.getSelectedRec(), + lock = rec ? rec.get('lock') : false, + length = this.rangeList.store.length; + this.btnDeleteRange.setDisabled(length<1 || lock); + this.btnEditRange.setDisabled(length<1 || lock); + }, + txtTitle: 'Allow Users to Edit Ranges', textRangesDesc: 'Ranges unlocked by a password when sheet is protected (this works only for locked cells)', textTitle: 'Title', From 1eb0264d64fd794226e816a04667da7ac2095a02 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Jun 2021 17:46:21 +0300 Subject: [PATCH 17/50] Refactoring --- apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js index 1ba9eeba27..de158bbb2f 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js @@ -164,7 +164,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', for (var i=0; i0) ? this.textnoNames : this.textEmpty); } var me = this, @@ -244,7 +243,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', rec = this.rangeList.getSelectedRec(), props; if (isEdit) - props = rec.get('props') + props = rec.get('props'); else { props = new Asc.CProtectedRange(); props.asc_setSqref(me.api.asc_getActiveRangeStr(Asc.referenceType.A)); @@ -267,7 +266,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', rec.set('pwd', props.asc_isPassword()); props.asc_setName(); } else { - me.rangeList.store.add({ + rec = me.rangeList.store.add({ name: props.asc_getName(), pwd: props.asc_isPassword(), range: props.asc_getSqref(), @@ -276,7 +275,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', lock: false, lockuser: this.guestText }); - me.rangeList.selectByIndex(me.rangeList.store.length-1); + me.rangeList.selectRecord(rec); me.rangeList.scrollToRecord(me.rangeList.getSelectedRec()); me.updateButtons(); } From 877ac8f18d1d6ec1b80c0503ad60b78491e36abe Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Jun 2021 17:54:24 +0300 Subject: [PATCH 18/50] Refactoring --- apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js index de158bbb2f..24f8992003 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js @@ -297,7 +297,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', !rec.get('isNew') && this.deletedArr.push(rec.get('props')); var index = store.indexOf(rec); store.remove(rec); - (this.rangeList.length>0) && this.rangeList.selectByIndex(index); + (store.length>0) && this.rangeList.selectByIndex(index); this.rangeList.scrollToRecord(this.rangeList.getSelectedRec()); } this.updateButtons(); From 9a8a40dd09b3048d13eac3d471617c44b06ef616 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Jun 2021 18:07:56 +0300 Subject: [PATCH 19/50] [SSE] Fix range validation --- apps/spreadsheeteditor/main/app/view/ProtectDialog.js | 6 ++++-- apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js index 3c0164bef3..fe3da91a09 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js @@ -174,8 +174,9 @@ define([ btnHint : this.textSelectData, blankError : this.txtEmpty, validateOnChange: true, + validateOnBlur: false, validation : function(value) { - var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.ConditionalFormattingRule, value, false); + var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.ConditionalFormattingRule, value, true); return (isvalid!==Asc.c_oAscError.ID.DataRangeError) ? true : me.textInvalidRange; } }); @@ -423,7 +424,8 @@ define([ txtRangeName: 'Title', txtRange: 'Range', txtEmpty: 'This field is required', - textSelectData: 'Select Data' + textSelectData: 'Select Data', + textInvalidRange: 'ERROR! Invalid cells range' }, SSE.Views.ProtectDialog || {})); }); diff --git a/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js index 24f8992003..7605710025 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js @@ -166,7 +166,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', arr.push({ name: ranges[i].asc_getName() || '', pwd: ranges[i].asc_isPassword(), - range: ranges[i].asc_getSqref(), + range: ranges[i].asc_getSqref() || '', props: ranges[i], lock: (id!==null && id!==undefined), lockuser: (id) ? this.getUserName(id) : this.guestText From acb4d52781382ae54f6e892290860cfc134e0b0f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Jun 2021 18:49:47 +0300 Subject: [PATCH 20/50] [SSE] Edit protected range --- .../main/app/controller/Main.js | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index e874bb1007..ad4b37ef14 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -2009,7 +2009,7 @@ define([ } }, - onConfirmAction: function(id, apiCallback) { + onConfirmAction: function(id, apiCallback, data) { var me = this; if (id == Asc.c_oAscConfirm.ConfirmReplaceRange || id == Asc.c_oAscConfirm.ConfirmReplaceFormulaInTable) { Common.UI.warning({ @@ -2040,6 +2040,31 @@ define([ me.onEditComplete(me.application.getController('DocumentHolder').getView('DocumentHolder')); }, this) }); + } else if (id == Asc.c_oAscConfirm.ConfirmChangeProtectRange) { + var win = new Common.Views.OpenDialog({ + title: this.txtUnlockRange, + closable: true, + type: Common.Utils.importTextType.DRM, + warning: true, + warningMsg: this.txtUnlockRangeWarning, + txtOpenFile: this.txtUnlockRangeDescription, + validatePwd: false, + buttons: [ + { + value: 'ok', + caption: this.txtUnlock + }, 'cancel'], + primary: 'ok', + handler: function (result, value) { + if (result == 'ok') { + if (me.api) { + me.api.asc_checkProtectedRangesPassword(value, data); + } + me.onEditComplete(me.application.getController('DocumentHolder').getView('DocumentHolder')); + } + } + }); + win.show(); } }, @@ -2957,7 +2982,11 @@ define([ txtQuarter: 'Qtr', txtOr: '%1 or %2', confirmReplaceFormulaInTable: 'Formulas in the header row will be removed and converted to static text.
Do you want to continue?', - errorChangeOnProtectedSheet: 'The cell or chart you are trying to change is on a protected sheet.
To make a change, unprotect the sheet. You might be requested to enter a password.' + errorChangeOnProtectedSheet: 'The cell or chart you are trying to change is on a protected sheet.
To make a change, unprotect the sheet. You might be requested to enter a password.', + txtUnlockRange: 'Unlock Range', + txtUnlockRangeWarning: 'A range you are trying to change is password protected.', + txtUnlockRangeDescription: 'Enter the password to change this range:', + txtUnlock: 'Unlock' } })(), SSE.Controllers.Main || {})) }); From 56200c79874c660d6a392f30aa843dc3d2ee4092 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 24 Jun 2021 01:01:25 +0300 Subject: [PATCH 21/50] [SSE] Fix protected ranges --- apps/spreadsheeteditor/main/app/controller/Main.js | 10 +++------- .../main/app/controller/WBProtection.js | 1 + .../main/app/view/ProtectRangesDlg.js | 1 - 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index ad4b37ef14..f8084bb82c 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -2049,16 +2049,12 @@ define([ warningMsg: this.txtUnlockRangeWarning, txtOpenFile: this.txtUnlockRangeDescription, validatePwd: false, - buttons: [ - { - value: 'ok', - caption: this.txtUnlock - }, 'cancel'], - primary: 'ok', handler: function (result, value) { if (result == 'ok') { if (me.api) { - me.api.asc_checkProtectedRangesPassword(value, data); + if (apiCallback) { + apiCallback(me.api.asc_checkProtectedRangesPassword(value.drmOptions.asc_getPassword(), data)); + } } me.onEditComplete(me.application.getController('DocumentHolder').getView('DocumentHolder')); } diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index e524cd9261..7edc649a74 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -230,6 +230,7 @@ define([ props: props, handler: function(result, settings) { if (result=='protect-sheet') { + me.api.asc_setProtectedRanges(settings.arr, settings.deletedArr); me.onSheetClick(true); } else if (result == 'ok') { me.api.asc_setProtectedRanges(settings.arr, settings.deletedArr); diff --git a/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js index 7605710025..66701f65f6 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectRangesDlg.js @@ -264,7 +264,6 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template', rec.set('name', props.asc_getName()); rec.set('range', props.asc_getSqref()); rec.set('pwd', props.asc_isPassword()); - props.asc_setName(); } else { rec = me.rangeList.store.add({ name: props.asc_getName(), From be22bc97a516fb4343bc7ecf1733560434f82e95 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 25 Jun 2021 18:29:17 +0300 Subject: [PATCH 22/50] [SSE] Disable workbook actions when workbook is protected --- .../main/app/controller/DataTab.js | 5 ++++ .../main/app/controller/Statusbar.js | 27 +++++++++++++++---- .../main/app/view/DataTab.js | 2 +- .../main/app/view/Statusbar.js | 26 +++++++++--------- .../main/app/view/Toolbar.js | 3 ++- 5 files changed, 44 insertions(+), 19 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js index 486cffcb8b..78daa73f81 100644 --- a/apps/spreadsheeteditor/main/app/controller/DataTab.js +++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js @@ -71,6 +71,7 @@ define([ this.api = api; this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this)); this.api.asc_registerCallback('asc_onWorksheetLocked', _.bind(this.onWorksheetLocked, this)); + this.api.asc_registerCallback('asc_onChangeProtectWorkbook',_.bind(this.onChangeProtectWorkbook, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); } @@ -408,6 +409,10 @@ define([ } }, + onChangeProtectWorkbook: function() { + Common.Utils.lockControls(SSE.enumLock.wbLock, this.api.asc_isProtectedWorkbook(), {array: [this.view.btnDataFromText]}); + }, + onApiSheetChanged: function() { if (!this.toolbar.mode || !this.toolbar.mode.isEdit || this.toolbar.mode.isEditDiagram || this.toolbar.mode.isEditMailMerge) return; diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index d3b0697c2a..bd4ecc7f47 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -100,6 +100,7 @@ define([ /** coauthoring begin **/ this.api.asc_registerCallback('asc_onWorkbookLocked', _.bind(this.onWorkbookLocked, this)); this.api.asc_registerCallback('asc_onWorksheetLocked', _.bind(this.onWorksheetLocked, this)); + this.api.asc_registerCallback('asc_onChangeProtectWorkbook',_.bind(this.onChangeProtectWorkbook, this)); /** coauthoring end **/ this.api.asc_registerCallback('asc_onError', _.bind(this.onError, this)); this.api.asc_registerCallback('asc_onFilterInfo', _.bind(this.onApiFilterInfo , this)); @@ -154,7 +155,8 @@ define([ this.statusbar.tabbar[locked?'addClass':'removeClass']('coauth-locked'); this.statusbar.btnAddWorksheet.setDisabled(locked || this.api.isCellEdited || this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.Chart || this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.FormatTable|| - this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.PrintTitles); + this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.PrintTitles || + this.api.asc_isProtectedWorkbook()); var item, i = this.statusbar.tabbar.getCount(); while (i-- > 0) { item = this.statusbar.tabbar.getAt(i); @@ -170,16 +172,30 @@ define([ onWorksheetLocked: function(index,locked) { var count = this.statusbar.tabbar.getCount(), tab; + var wbprotected = this.api.asc_isProtectedWorkbook(); for (var i = count; i-- > 0; ) { tab = this.statusbar.tabbar.getAt(i); if (index == tab.sheetindex) { tab[locked?'addClass':'removeClass']('coauth-locked'); - tab.isLockTheDrag = locked || (this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.FormatTable) || (this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.PrintTitles); + tab.isLockTheDrag = locked || wbprotected || (this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.FormatTable) || (this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.PrintTitles); tab.$el.children(':first-child').attr('draggable', tab.isLockTheDrag?'false':'true'); break; } } }, + + onChangeProtectWorkbook: function() { + this.statusbar.btnAddWorksheet.setDisabled(this.api.isCellEdited || this.api.asc_isWorkbookLocked() || this.api.asc_isProtectedWorkbook() || this.statusbar.rangeSelectionMode!=Asc.c_oAscSelectionDialogType.None); + var count = this.statusbar.tabbar.getCount(), tab; + var wbprotected = this.api.asc_isProtectedWorkbook(); + for (var i = count; i-- > 0; ) { + tab = this.statusbar.tabbar.getAt(i); + var islocked = tab.hasClass('coauth-locked'); + tab.isLockTheDrag = islocked || wbprotected || (this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.FormatTable) || (this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.PrintTitles); + tab.$el.children(':first-child').attr('draggable', tab.isLockTheDrag?'false':'true'); + } + }, + /** coauthoring end **/ onApiMathChanged: function(info) { @@ -213,7 +229,7 @@ define([ statusbar.btnZoomUp.setDisabled(disable); statusbar.btnZoomDown.setDisabled(disable); statusbar.labelZoom[disable?'addClass':'removeClass']('disabled'); - statusbar.btnAddWorksheet.setDisabled(disable || this.api.asc_isWorkbookLocked() || statusbar.rangeSelectionMode!=Asc.c_oAscSelectionDialogType.None); + statusbar.btnAddWorksheet.setDisabled(disable || this.api.asc_isWorkbookLocked() || this.api.asc_isProtectedWorkbook() || statusbar.rangeSelectionMode!=Asc.c_oAscSelectionDialogType.None); statusbar.$el.find('#statusbar_bottom li span').attr('oo_editor_input', !disableAdd); @@ -244,15 +260,16 @@ define([ onRangeDialogMode: function (mode) { var islocked = this.statusbar.tabbar.hasClass('coauth-locked'), currentIdx = this.api.asc_getActiveWorksheetIndex(); - this.statusbar.btnAddWorksheet.setDisabled(islocked || this.api.isCellEdited || mode!=Asc.c_oAscSelectionDialogType.None); + this.statusbar.btnAddWorksheet.setDisabled(islocked || this.api.isCellEdited || this.api.asc_isProtectedWorkbook() || mode!=Asc.c_oAscSelectionDialogType.None); var item, i = this.statusbar.tabbar.getCount(); + var wbprotected = this.api.asc_isProtectedWorkbook(); while (i-- > 0) { item = this.statusbar.tabbar.getAt(i); if (item.sheetindex !== currentIdx) { item.disable(mode==Asc.c_oAscSelectionDialogType.FormatTable || mode==Asc.c_oAscSelectionDialogType.PrintTitles); } - item.isLockTheDrag = (item.hasClass('coauth-locked') || (mode!=Asc.c_oAscSelectionDialogType.None)); + item.isLockTheDrag = (item.hasClass('coauth-locked') || wbprotected || (mode!=Asc.c_oAscSelectionDialogType.None)); } this.statusbar.rangeSelectionMode = mode; }, diff --git a/apps/spreadsheeteditor/main/app/view/DataTab.js b/apps/spreadsheeteditor/main/app/view/DataTab.js index 4ed17b13e9..702be91f90 100644 --- a/apps/spreadsheeteditor/main/app/view/DataTab.js +++ b/apps/spreadsheeteditor/main/app/view/DataTab.js @@ -130,7 +130,7 @@ define([ caption: this.capDataFromText, menu: !this.toolbar.mode.isDesktopApp, disabled: true, - lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.lostConnect, _set.coAuth] + lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.wbLock, _set.lostConnect, _set.coAuth] }); this.lockedControls.push(this.btnDataFromText); diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index 9801ab48f9..a9c6461730 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -498,6 +498,7 @@ define([ var wc = this.api.asc_getWorksheetsCount(), i = -1; var hidentems = [], items = [], tab, locked, name; var sindex = this.api.asc_getActiveWorksheetIndex(); + var wbprotected = this.api.asc_isProtectedWorkbook(); while (++i < wc) { locked = me.api.asc_isWorksheetLockedOrDeleted(i); @@ -509,7 +510,7 @@ define([ label : me.api.asc_getWorksheetName(i), // reorderable : !locked, cls : locked ? 'coauth-locked':'', - isLockTheDrag : locked || me.mode.isDisconnected, + isLockTheDrag : locked || me.mode.isDisconnected || wbprotected, iconCls : 'btn-sheet-view', iconTitle : name, iconVisible : name!=='' @@ -538,7 +539,7 @@ define([ if (!this.tabbar.isTabVisible(sindex)) this.tabbar.setTabVisible(sindex); - this.btnAddWorksheet.setDisabled(me.mode.isDisconnected || me.api.asc_isWorkbookLocked() || me.api.isCellEdited); + this.btnAddWorksheet.setDisabled(me.mode.isDisconnected || me.api.asc_isWorkbookLocked() || me.api.asc_isProtectedWorkbook() || me.api.isCellEdited); $('#status-label-zoom').text(Common.Utils.String.format(this.zoomText, Math.floor((this.api.asc_getZoom() +.005)*100))); me.fireEvent('sheet:changed', [me, sindex]); @@ -647,15 +648,16 @@ define([ } var isdoclocked = this.api.asc_isWorkbookLocked(); + var isdocprotected = this.api.asc_isProtectedWorkbook(); - this.tabMenu.items[0].setDisabled(isdoclocked); - this.tabMenu.items[1].setDisabled(issheetlocked); - this.tabMenu.items[2].setDisabled(issheetlocked); - this.tabMenu.items[3].setDisabled(issheetlocked); - this.tabMenu.items[4].setDisabled(issheetlocked); - this.tabMenu.items[5].setDisabled(issheetlocked); - this.tabMenu.items[6].setDisabled(isdoclocked); - this.tabMenu.items[7].setDisabled(issheetlocked); + this.tabMenu.items[0].setDisabled(isdoclocked || isdocprotected); + this.tabMenu.items[1].setDisabled(issheetlocked || isdocprotected); + this.tabMenu.items[2].setDisabled(issheetlocked || isdocprotected); + this.tabMenu.items[3].setDisabled(issheetlocked || isdocprotected); + this.tabMenu.items[4].setDisabled(issheetlocked || isdocprotected); + this.tabMenu.items[5].setDisabled(issheetlocked || isdocprotected); + this.tabMenu.items[6].setDisabled(isdoclocked || isdocprotected); + this.tabMenu.items[7].setDisabled(issheetlocked || isdocprotected); if (select.length === 1) { this.tabMenu.items[10].hide(); @@ -663,8 +665,8 @@ define([ this.tabMenu.items[10].show(); } - this.tabMenu.items[9].setDisabled(issheetlocked); - this.tabMenu.items[10].setDisabled(issheetlocked); + this.tabMenu.items[9].setDisabled(issheetlocked || isdocprotected); + this.tabMenu.items[10].setDisabled(issheetlocked || isdocprotected); this.api.asc_closeCellEditor(); this.api.asc_enableKeyEvents(false); diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 54e6b0f389..9b7b68bee0 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -98,7 +98,8 @@ define([ cantSort: 'cant-sort', pivotLock: 'pivot-lock', tableHasSlicer: 'table-has-slicer', - sheetView: 'sheet-view' + sheetView: 'sheet-view', + wbLock: 'workbook-lock' }; SSE.Views.Toolbar = Common.UI.Mixtbar.extend(_.extend({ From 2e9391d907d631a00f4107547cf85c6a18aadc44 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 16 Jul 2021 15:47:24 +0300 Subject: [PATCH 23/50] [SSE] Lock format editing on protected sheet --- .../main/app/controller/Toolbar.js | 20 +++++- .../main/app/controller/WBProtection.js | 31 ++++++++- .../main/app/view/PivotTable.js | 14 ++-- .../main/app/view/ProtectDialog.js | 2 + .../main/app/view/Toolbar.js | 67 ++++++++++--------- .../main/app/view/WBProtection.js | 20 ++++-- 6 files changed, 103 insertions(+), 51 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 7aeb53e47b..ea0e6deb84 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -194,7 +194,9 @@ define([ pgorient: undefined, lock_doc: undefined, cf_locked: [], - selectedCells: 0 + selectedCells: 0, + wsLock: false, + wsProps: {} }; this.binding = {}; @@ -1818,6 +1820,7 @@ define([ this.api.asc_registerCallback('asc_onUpdateDocumentProps', _.bind(this.onUpdateDocumentProps, this)); this.api.asc_registerCallback('asc_onLockDocumentProps', _.bind(this.onApiLockDocumentProps, this)); this.api.asc_registerCallback('asc_onUnLockDocumentProps', _.bind(this.onApiUnLockDocumentProps, this)); + Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this)); } if ( !this.appConfig.isEditMailMerge ) { @@ -2500,6 +2503,12 @@ define([ toolbar.btnImgAlign.menu.items[7].setDisabled(objcount<3); toolbar.btnImgAlign.menu.items[8].setDisabled(objcount<3); + // disable on protected sheet + need_disable = (selectionType === Asc.c_oAscSelectionType.RangeImage || selectionType === Asc.c_oAscSelectionType.RangeChart || selectionType === Asc.c_oAscSelectionType.RangeChartText || + selectionType === Asc.c_oAscSelectionType.RangeShape || selectionType === Asc.c_oAscSelectionType.RangeShapeText || selectionType === Asc.c_oAscSelectionType.RangeSlicer); + toolbar.lockToolbar(need_disable ? SSE.enumLock['Objects'] : SSE.enumLock['FormatCells'], need_disable ? this._state.wsProps['Objects'] : this._state.wsProps['FormatCells'], + { clear: [SSE.enumLock['FormatCells'], SSE.enumLock['Objects']]}); + if (editOptionsDisabled) return; /* read font params */ @@ -3709,8 +3718,10 @@ define([ var $panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel(); if ($panel) { config.canProtect && $panel.append($('
')); - $panel.append(me.getApplication().getController('WBProtection').createToolbarPanel()); + var wbtab = me.getApplication().getController('WBProtection'); + $panel.append(wbtab.createToolbarPanel()); me.toolbar.addTab(tab, $panel, 7); + Array.prototype.push.apply(me.toolbar.lockControls, wbtab.getView('WBProtection').getButtons()); } var viewtab = me.getApplication().getController('ViewTab'); @@ -3981,6 +3992,11 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, + onChangeProtectSheet: function(props) { + this._state.wsProps = props; + this.onApiSelectionChanged(this.api.asc_getCellInfo()); + }, + textEmptyImgUrl : 'You need to specify image URL.', warnMergeLostData : 'Operation can destroy data in the selected cells.
Continue?', textWarning : 'Warning', diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index 7edc649a74..c1c1a3226a 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -68,7 +68,12 @@ define([ }); }, onLaunch: function () { - this._state = {}; + this._state = {wsLock: false}; + this.wsLockOptions = ['SelectLockedCells', 'SelectUnlockedCells', 'FormatCells', 'FormatColumns', 'FormatRows', 'InsertColumns', 'InsertRows', 'InsertHyperlinks', 'DeleteColumns', + 'DeleteRows', 'Sort', 'AutoFilter', 'PivotTables', 'Objects', 'Scenarios']; + SSE.enumLock && this.wsLockOptions.forEach(function(item){ + SSE.enumLock[item] = item; + }); Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); @@ -86,6 +91,7 @@ define([ this.api.asc_registerCallback('asc_onChangeProtectWorkbook',_.bind(this.onChangeProtectWorkbook, this)); this.api.asc_registerCallback('asc_onChangeProtectWorksheet',_.bind(this.onChangeProtectSheet, this)); this.api.asc_registerCallback('asc_onSheetsChanged', _.bind(this.onApiSheetChanged, this)); + this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onApiSelectionChanged, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); } }, @@ -272,11 +278,32 @@ define([ }, onChangeProtectSheet: function() { + var wsProtected = this.api.asc_isProtectedSheet(); + if (this._state.wsLock===wsProtected && !wsProtected) return; + this.view.btnProtectSheet.toggle(this.api.asc_isProtectedSheet(), true); //current sheet + var arr = []; + if (wsProtected) { + var props = this.api.asc_getProtectedSheet(); + props && this.wsLockOptions.forEach(function(item){ + arr[item] = props['asc_get' + item] ? props['asc_get' + item]() : false; + }); + } + this._state.wsLock = wsProtected; + Common.NotificationCenter.trigger('protect:wslock', arr); }, onApiSheetChanged: function() { - this.view.btnProtectSheet.toggle(this.api.asc_isProtectedSheet(), true); //current sheet + this.onChangeProtectSheet(); //current sheet + }, + + onApiSelectionChanged: function(info) { + if ($('.asc-window.enable-key-events:visible').length>0) return; + + var selectionType = info.asc_getSelectionType(); + var need_disable = (selectionType === Asc.c_oAscSelectionType.RangeCells || selectionType === Asc.c_oAscSelectionType.RangeCol || + selectionType === Asc.c_oAscSelectionType.RangeRow || selectionType === Asc.c_oAscSelectionType.RangeMax); + Common.Utils.lockControls(SSE.enumLock.selRange, need_disable, { array: [this.view.chLockedText, this.view.chLockedShape]}); }, onCoAuthoringDisconnect: function() { diff --git a/apps/spreadsheeteditor/main/app/view/PivotTable.js b/apps/spreadsheeteditor/main/app/view/PivotTable.js index 0b6be69386..3cc33e902a 100644 --- a/apps/spreadsheeteditor/main/app/view/PivotTable.js +++ b/apps/spreadsheeteditor/main/app/view/PivotTable.js @@ -157,29 +157,29 @@ define([ var _set = SSE.enumLock; this.btnsAddPivot = Common.Utils.injectButtons(this.toolbar.$el.find('.btn-slot.slot-add-pivot'), '', 'toolbar__icon btn-pivot-sum', this.txtPivotTable, - [_set.lostConnect, _set.coAuth, _set.editPivot, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.editCell]); + [_set.lostConnect, _set.coAuth, _set.editPivot, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.editCell, _set.wsLock]); this.chRowHeader = new Common.UI.CheckBox({ labelText: this.textRowHeader, - lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock] + lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells']] }); this.lockedControls.push(this.chRowHeader); this.chColHeader = new Common.UI.CheckBox({ labelText: this.textColHeader, - lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock] + lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells']] }); this.lockedControls.push(this.chColHeader); this.chRowBanded = new Common.UI.CheckBox({ labelText: this.textRowBanded, - lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock] + lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells']] }); this.lockedControls.push(this.chRowBanded); this.chColBanded = new Common.UI.CheckBox({ labelText: this.textColBanded, - lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock] + lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells']] }); this.lockedControls.push(this.chColBanded); @@ -246,7 +246,7 @@ define([ itemWidth : 61, itemHeight : 49, menuMaxHeight : 300, - lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock], + lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells']], beforeOpenHandler: function(e) { var cmp = this, menu = cmp.openButton.menu; @@ -326,7 +326,7 @@ define([ var _set = SSE.enumLock; this.btnsAddPivot = this.btnsAddPivot.concat(Common.Utils.injectButtons(this.$el.find('.btn-slot.slot-add-pivot'), '', 'toolbar__icon btn-pivot-sum', this.txtCreate, - [_set.lostConnect, _set.coAuth, _set.editPivot, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.editCell])); + [_set.lostConnect, _set.coAuth, _set.editPivot, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.editCell, _set.wsLock])); this.chRowHeader.render(this.$el.find('#slot-chk-header-row')); this.chColHeader.render(this.$el.find('#slot-chk-header-column')); diff --git a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js index fe3da91a09..76b5151c85 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js @@ -299,6 +299,8 @@ define([ updateCellCheck: function (listView, record) { if (record && listView) { record.set('check', !record.get('check')); + if (record.get('optionName') == 'SelectLockedCells' && record.get('check')) + this.optionsList.store.findWhere({optionName: 'SelectUnlockedCells'}).set('check', true); // listView.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true, suppressScrollX: true}); } }, diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 9b7b68bee0..4165621c03 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -99,7 +99,8 @@ define([ pivotLock: 'pivot-lock', tableHasSlicer: 'table-has-slicer', sheetView: 'sheet-view', - wbLock: 'workbook-lock' + wbLock: 'workbook-lock', + wsLock: 'worksheet-lock' }; SSE.Views.Toolbar = Common.UI.Mixtbar.extend(_.extend({ @@ -405,21 +406,21 @@ define([ id : 'id-toolbar-btn-incfont', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-incfont', - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect] + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']] }); me.btnDecFontSize = new Common.UI.Button({ id : 'id-toolbar-btn-decfont', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-decfont', - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect] + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']] }); me.btnBold = new Common.UI.Button({ id : 'id-toolbar-btn-bold', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-bold', - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect], + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], enableToggle: true }); @@ -427,7 +428,7 @@ define([ id : 'id-toolbar-btn-italic', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-italic', - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect], + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], enableToggle: true }); @@ -435,7 +436,7 @@ define([ id : 'id-toolbar-btn-underline', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-underline', - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect], + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], enableToggle: true }); @@ -443,7 +444,7 @@ define([ id: 'id-toolbar-btn-strikeout', cls: 'btn-toolbar', iconCls: 'toolbar__icon btn-strikeout', - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect], + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], enableToggle: true }); @@ -454,7 +455,7 @@ define([ icls : 'btn-subscript', split : true, enableToggle: true, - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect], + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], menu : new Common.UI.Menu({ items: [ { @@ -487,7 +488,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-fontcolor', split : true, - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect], + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], menu : new Common.UI.Menu({ cls: 'shifted-left', items: [ @@ -509,7 +510,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-paracolor', split : true, - lock : [_set.selImage, _set.editCell, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect], + lock : [_set.selImage, _set.editCell, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], menu : new Common.UI.Menu({ items: [ { template: _.template('
') }, @@ -525,7 +526,7 @@ define([ icls : 'btn-border-out', borderId : 'outer', borderswidth: Asc.c_oAscBorderStyles.Thin, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set['FormatCells']], split : true, menu : true }); @@ -535,7 +536,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-align-left', enableToggle: true, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], toggleGroup : 'alignGroup' }); @@ -544,7 +545,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-align-center', enableToggle: true, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], toggleGroup : 'alignGroup' }); @@ -553,7 +554,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-align-right', enableToggle: true, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], toggleGroup : 'alignGroup' }); @@ -562,7 +563,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-align-just', enableToggle: true, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], toggleGroup: 'alignGroup' }); @@ -573,7 +574,7 @@ define([ enableToggle: true, allowDepress: true, split : true, - lock : [_set.editCell, _set.selShape, _set.selShapeText, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleMerge, _set.editPivot], + lock : [_set.editCell, _set.selShape, _set.selShapeText, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleMerge, _set.editPivot, _set.wsLock], menu : new Common.UI.Menu({ items: [ { @@ -604,7 +605,7 @@ define([ id : 'id-toolbar-rtn-valign-top', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-align-top', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], enableToggle: true, toggleGroup : 'vAlignGroup' }); @@ -614,7 +615,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-align-middle', enableToggle: true, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], toggleGroup : 'vAlignGroup' }); @@ -622,7 +623,7 @@ define([ id : 'id-toolbar-rtn-valign-bottom', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-align-bottom', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], enableToggle: true, toggleGroup : 'vAlignGroup' }); @@ -631,7 +632,7 @@ define([ id : 'id-toolbar-rtn-wrap', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-wrap', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set['FormatCells']], enableToggle: true, allowDepress: true }); @@ -640,7 +641,7 @@ define([ id : 'id-toolbar-rtn-textorient', cls : 'btn-toolbar', iconCls : 'toolbar__icon text-orient-ccw', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], menu : new Common.UI.Menu({ items: [ { @@ -715,7 +716,7 @@ define([ cls : 'btn-toolbar x-huge icon-top', iconCls : 'toolbar__icon btn-inserthyperlink', caption : me.capInsertHyperlink, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selShape, _set.cantHyperlink, _set.selSlicer, _set.multiselect, _set.lostConnect, _set.coAuth, _set.editPivot] + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selShape, _set.cantHyperlink, _set.selSlicer, _set.multiselect, _set.lostConnect, _set.coAuth, _set.editPivot, _set.wsLock] }); me.btnInsertChart = new Common.UI.Button({ @@ -731,7 +732,7 @@ define([ id : 'tlbtn-insertsparkline', cls : 'btn-toolbar x-huge icon-top', iconCls : 'toolbar__icon btn-sparkline', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selShape, _set.selSlicer, _set.multiselect, _set.lostConnect, _set.coAuth, _set.coAuthText, _set.editPivot], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selShape, _set.selSlicer, _set.multiselect, _set.lostConnect, _set.coAuth, _set.coAuthText, _set.editPivot, _set.wsLock], caption : me.capInsertSpark, menu : true }); @@ -784,7 +785,7 @@ define([ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-symbol', caption: me.capBtnInsSymbol, - lock: [_set.selImage, _set.selChart, _set.selShape, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect] + lock: [_set.selImage, _set.selChart, _set.selShape, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.wsLock] }); me.btnInsertSlicer = new Common.UI.Button({ @@ -799,7 +800,7 @@ define([ id : 'id-toolbar-btn-ttempl', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-menu-table', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set['FormatCells']], menu : new Common.UI.Menu({ items: [ { template: _.template('
') } @@ -812,7 +813,7 @@ define([ cls : 'btn-toolbar x-huge icon-top', iconCls : 'toolbar__icon btn-inserttable', caption : me.capInsertTable, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set.ruleMerge, _set.editPivot] + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set.ruleMerge, _set.editPivot, _set['FormatCells']] }); me.listStyles = new Common.UI.ComboDataView({ @@ -821,7 +822,7 @@ define([ itemWidth : 112, itemHeight : 38, menuMaxHeight : 226, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set['FormatCells']], beforeOpenHandler: function(e) { var cmp = this, menu = cmp.openButton.menu, @@ -869,7 +870,7 @@ define([ cls : 'input-group-nr', menuStyle : 'min-width: 180px;', hint : me.tipNumFormat, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.selRangeEdit, _set.lostConnect, _set.coAuth], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set['FormatCells']], itemsTemplate: formatTemplate, editable : false, data : me.numFormatData @@ -879,7 +880,7 @@ define([ id : 'id-toolbar-btn-percent-style', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-percent-style', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set['FormatCells']], styleName : 'Percent' }); @@ -887,7 +888,7 @@ define([ id : 'id-toolbar-btn-accounting-style', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-currency-style', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set['FormatCells']], styleName : 'Currency', split : true, menu : new Common.UI.Menu({ @@ -925,14 +926,14 @@ define([ id : 'id-toolbar-btn-decdecimal', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-decdecimal', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth] + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set['FormatCells']] }); me.btnIncDecimal = new Common.UI.Button({ id : 'id-toolbar-btn-incdecimal', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-incdecimal', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth] + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set['FormatCells']] }); me.btnInsertFormula = new Common.UI.Button({ @@ -1088,7 +1089,7 @@ define([ id : 'id-toolbar-btn-condformat', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-cond-format', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set['FormatCells']], menu : true }); diff --git a/apps/spreadsheeteditor/main/app/view/WBProtection.js b/apps/spreadsheeteditor/main/app/view/WBProtection.js index 554211db4a..ad7e0e4834 100644 --- a/apps/spreadsheeteditor/main/app/view/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/view/WBProtection.js @@ -116,7 +116,7 @@ define([ iconCls: 'toolbar__icon protect-workbook', enableToggle: true, caption: this.txtProtectWB, - lock : [_set.lostConnect, _set.coAuth] + lock : [_set.selRangeEdit, _set.lostConnect, _set.coAuth] }); this.lockedControls.push(this.btnProtectWB); @@ -125,7 +125,7 @@ define([ iconCls: 'toolbar__icon protect-sheet', enableToggle: true, caption: this.txtProtectSheet, - lock : [_set.lostConnect, _set.coAuth] + lock : [_set.selRangeEdit, _set.lostConnect, _set.coAuth] }); this.lockedControls.push(this.btnProtectSheet); @@ -133,31 +133,31 @@ define([ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon allow-edit-ranges', caption: this.txtAllowRanges, - lock : [_set.lostConnect, _set.coAuth] + lock : [_set.selRangeEdit, _set.lostConnect, _set.coAuth] }); this.lockedControls.push(this.btnAllowRanges); this.chLockedCell = new Common.UI.CheckBox({ labelText: this.txtLockedCell, - lock : [_set.lostConnect, _set.coAuth] + lock : [_set.editCell, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.wsLock, _set.wbLock, _set.lostConnect, _set.coAuth] }); this.lockedControls.push(this.chLockedCell); this.chLockedShape = new Common.UI.CheckBox({ labelText: this.txtLockedShape, - lock : [_set.lostConnect, _set.coAuth] + lock : [_set.selRange, _set.selRangeEdit, _set.wsLock, _set.wbLock, _set.lostConnect, _set.coAuth] }); this.lockedControls.push(this.chLockedShape); this.chLockedText = new Common.UI.CheckBox({ labelText: this.txtLockedText, - lock : [_set.lostConnect, _set.coAuth] + lock : [_set.selRange, _set.selRangeEdit, _set.selRangeEdit, _set.wsLock, _set.wbLock, _set.lostConnect, _set.coAuth] }); this.lockedControls.push(this.chLockedText); this.chHiddenFormula = new Common.UI.CheckBox({ labelText: this.txtHiddenFormula, - lock : [_set.lostConnect, _set.coAuth] + lock : [_set.editCell, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.wsLock, _set.wbLock, _set.lostConnect, _set.coAuth] }); this.lockedControls.push(this.chHiddenFormula); @@ -195,6 +195,12 @@ define([ return this.$el; }, + getButtons: function(type) { + if (type===undefined) + return this.lockedControls; + return []; + }, + show: function () { Common.UI.BaseView.prototype.show.call(this); this.fireEvent('show', this); From 304af6ae6ef7d8e45e384bb401e482b4ac7398c3 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Sat, 17 Jul 2021 00:49:36 +0300 Subject: [PATCH 24/50] [SSE] Sheet protection --- .../main/app/controller/Toolbar.js | 21 +++++++----- .../main/app/controller/WBProtection.js | 15 +++++++-- .../main/app/view/DataTab.js | 16 +++++----- .../main/app/view/FormulaTab.js | 2 +- .../main/app/view/PivotTable.js | 22 ++++++------- .../main/app/view/Toolbar.js | 32 +++++++++++-------- 6 files changed, 64 insertions(+), 44 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index ea0e6deb84..857f19a091 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -148,6 +148,7 @@ define([ }); Common.NotificationCenter.on('page:settings', _.bind(this.onApiSheetChanged, this)); Common.NotificationCenter.on('formula:settings', _.bind(this.applyFormulaSettings, this)); + Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this)); this.editMode = true; this._isAddingShape = false; @@ -196,7 +197,7 @@ define([ cf_locked: [], selectedCells: 0, wsLock: false, - wsProps: {} + wsProps: [] }; this.binding = {}; @@ -1820,7 +1821,6 @@ define([ this.api.asc_registerCallback('asc_onUpdateDocumentProps', _.bind(this.onUpdateDocumentProps, this)); this.api.asc_registerCallback('asc_onLockDocumentProps', _.bind(this.onApiLockDocumentProps, this)); this.api.asc_registerCallback('asc_onUnLockDocumentProps', _.bind(this.onApiUnLockDocumentProps, this)); - Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this)); } if ( !this.appConfig.isEditMailMerge ) { @@ -2837,13 +2837,13 @@ define([ } val = filterInfo && filterInfo.asc_getIsApplyAutoFilter(); - if ( this._state.controlsdisabled.cells_right!==(this._state.controlsdisabled.rows || val) ) { - this._state.controlsdisabled.cells_right = (this._state.controlsdisabled.rows || val); + if ( this._state.controlsdisabled.cells_right!==(this._state.controlsdisabled.rows || val || this._state.wsLock) ) { + this._state.controlsdisabled.cells_right = (this._state.controlsdisabled.rows || val || this._state.wsLock); toolbar.btnAddCell.menu.items[0].setDisabled(this._state.controlsdisabled.cells_right); toolbar.btnDeleteCell.menu.items[0].setDisabled(this._state.controlsdisabled.cells_right); } - if ( this._state.controlsdisabled.cells_down!==(this._state.controlsdisabled.cols || val) ) { - this._state.controlsdisabled.cells_down = (this._state.controlsdisabled.cols || val); + if ( this._state.controlsdisabled.cells_down!==(this._state.controlsdisabled.cols || val || this._state.wsLock) ) { + this._state.controlsdisabled.cells_down = (this._state.controlsdisabled.cols || val || this._state.wsLock); toolbar.btnAddCell.menu.items[1].setDisabled(this._state.controlsdisabled.cells_down); toolbar.btnDeleteCell.menu.items[1].setDisabled(this._state.controlsdisabled.cells_down); } @@ -3992,9 +3992,14 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, - onChangeProtectSheet: function(props) { + onChangeProtectSheet: function(props, state) { this._state.wsProps = props; - this.onApiSelectionChanged(this.api.asc_getCellInfo()); + this._state.wsLock = state; + + if (this._state.activated) { + this.toolbar.lockToolbar(SSE.enumLock.wsLock, state); + this.onApiSelectionChanged(this.api.asc_getCellInfo()); + } }, textEmptyImgUrl : 'You need to specify image URL.', diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index c1c1a3226a..1877fb0c1a 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -94,6 +94,7 @@ define([ this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onApiSelectionChanged, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); } + Common.NotificationCenter.on('document:ready', _.bind(this.onDocumentReady, this)); }, setMode: function(mode) { @@ -270,6 +271,7 @@ define([ })).then(function () { me.view.btnProtectWB.toggle(me.api.asc_isProtectedWorkbook(), true); me.view.btnProtectSheet.toggle(me.api.asc_isProtectedSheet(), true); //current sheet + me.onChangeProtectSheet(); }); }, @@ -278,19 +280,24 @@ define([ }, onChangeProtectSheet: function() { - var wsProtected = this.api.asc_isProtectedSheet(); + var wsProtected = !!this.api.asc_isProtectedSheet(); if (this._state.wsLock===wsProtected && !wsProtected) return; this.view.btnProtectSheet.toggle(this.api.asc_isProtectedSheet(), true); //current sheet var arr = []; if (wsProtected) { + arr = []; var props = this.api.asc_getProtectedSheet(); props && this.wsLockOptions.forEach(function(item){ arr[item] = props['asc_get' + item] ? props['asc_get' + item]() : false; }); + } else { + this.wsLockOptions.forEach(function(item){ + arr[item] = false; + }); } this._state.wsLock = wsProtected; - Common.NotificationCenter.trigger('protect:wslock', arr); + Common.NotificationCenter.trigger('protect:wslock', arr, this._state.wsLock); }, onApiSheetChanged: function() { @@ -308,6 +315,10 @@ define([ onCoAuthoringDisconnect: function() { this.SetDisabled(true); + }, + + onDocumentReady: function() { + // this.onChangeProtectSheet(); } }, SSE.Controllers.WBProtection || {})); diff --git a/apps/spreadsheeteditor/main/app/view/DataTab.js b/apps/spreadsheeteditor/main/app/view/DataTab.js index 702be91f90..957b8483e4 100644 --- a/apps/spreadsheeteditor/main/app/view/DataTab.js +++ b/apps/spreadsheeteditor/main/app/view/DataTab.js @@ -130,7 +130,7 @@ define([ caption: this.capDataFromText, menu: !this.toolbar.mode.isDesktopApp, disabled: true, - lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.wbLock, _set.lostConnect, _set.coAuth] + lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.wbLock, _set.lostConnect, _set.coAuth, _set.wsLock] }); this.lockedControls.push(this.btnDataFromText); @@ -142,7 +142,7 @@ define([ split: true, menu: true, disabled: true, - lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.lostConnect, _set.coAuth] + lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.lostConnect, _set.coAuth, _set.wsLock] }); this.lockedControls.push(this.btnGroup); @@ -154,7 +154,7 @@ define([ split: true, menu: true, disabled: true, - lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.lostConnect, _set.coAuth] + lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.lostConnect, _set.coAuth, _set.wsLock] }); this.lockedControls.push(this.btnUngroup); @@ -165,7 +165,7 @@ define([ caption: this.capBtnTextToCol, split: false, disabled: true, - lock: [_set.multiselect, _set.multiselectCols, _set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth] + lock: [_set.multiselect, _set.multiselectCols, _set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.wsLock] }); this.lockedControls.push(this.btnTextToColumns); @@ -195,7 +195,7 @@ define([ iconCls: 'toolbar__icon btn-remove-duplicates', caption: this.capBtnTextRemDuplicates, disabled: true, - lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.sheetLock] + lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.sheetLock, _set.wsLock] }); this.lockedControls.push(this.btnRemoveDuplicates); @@ -205,7 +205,7 @@ define([ iconCls: 'toolbar__icon btn-data-validation', caption: this.capBtnTextDataValidation, disabled: true, - lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.sheetLock] + lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.sheetLock, _set.wsLock] }); this.lockedControls.push(this.btnDataValidation); @@ -226,11 +226,11 @@ define([ [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.cantModifyFilter, _set.sheetLock, _set.cantSort]); this.btnsSetAutofilter = Common.Utils.injectButtons($host.find('.slot-btn-setfilter'), '', 'toolbar__icon btn-autofilter', '', - [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.tableHasSlicer], + [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.tableHasSlicer, _set.wsLock], false, false, true); this.btnsClearAutofilter = Common.Utils.injectButtons($host.find('.slot-btn-clear-filter'), '', 'toolbar__icon btn-clear-filter', '', - [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleDelFilter]); + [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleDelFilter, _set.wsLock]); Array.prototype.push.apply(this.lockedControls, this.btnsSortDown.concat(this.btnsSortUp, this.btnsSetAutofilter,this.btnsClearAutofilter)); diff --git a/apps/spreadsheeteditor/main/app/view/FormulaTab.js b/apps/spreadsheeteditor/main/app/view/FormulaTab.js index 92343ba624..59182c5f3f 100644 --- a/apps/spreadsheeteditor/main/app/view/FormulaTab.js +++ b/apps/spreadsheeteditor/main/app/view/FormulaTab.js @@ -260,7 +260,7 @@ define([ hint: this.toolbar.txtNamedRange, split: false, disabled: true, - lock : [_set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.selRangeEdit], + lock : [_set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.selRangeEdit, _set.wsLock], menu: new Common.UI.Menu({ items: [ { diff --git a/apps/spreadsheeteditor/main/app/view/PivotTable.js b/apps/spreadsheeteditor/main/app/view/PivotTable.js index 3cc33e902a..e2659e6685 100644 --- a/apps/spreadsheeteditor/main/app/view/PivotTable.js +++ b/apps/spreadsheeteditor/main/app/view/PivotTable.js @@ -161,25 +161,25 @@ define([ this.chRowHeader = new Common.UI.CheckBox({ labelText: this.textRowHeader, - lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells']] + lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells'], _set['PivotTables']] }); this.lockedControls.push(this.chRowHeader); this.chColHeader = new Common.UI.CheckBox({ labelText: this.textColHeader, - lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells']] + lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells'], _set['PivotTables']] }); this.lockedControls.push(this.chColHeader); this.chRowBanded = new Common.UI.CheckBox({ labelText: this.textRowBanded, - lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells']] + lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells'], _set['PivotTables']] }); this.lockedControls.push(this.chRowBanded); this.chColBanded = new Common.UI.CheckBox({ labelText: this.textColBanded, - lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells']] + lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells'], _set['PivotTables']] }); this.lockedControls.push(this.chColBanded); @@ -188,7 +188,7 @@ define([ iconCls : 'toolbar__icon btn-pivot-layout', caption : this.capLayout, disabled : true, - lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock], + lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set.wsLock], menu : true }); this.lockedControls.push(this.btnPivotLayout); @@ -198,7 +198,7 @@ define([ iconCls : 'toolbar__icon btn-blank-rows', caption : this.capBlankRows, disabled : true, - lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock], + lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set.wsLock], menu : true }); this.lockedControls.push(this.btnPivotBlankRows); @@ -208,7 +208,7 @@ define([ iconCls : 'toolbar__icon btn-subtotals', caption : this.capSubtotals, disabled : true, - lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock], + lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set.wsLock], menu : true }); this.lockedControls.push(this.btnPivotSubtotals); @@ -218,7 +218,7 @@ define([ iconCls : 'toolbar__icon btn-grand-totals', caption : this.capGrandTotals, disabled : true, - lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock], + lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set.wsLock], menu : true }); this.lockedControls.push(this.btnPivotGrandTotals); @@ -228,7 +228,7 @@ define([ iconCls: 'toolbar__icon btn-update', caption: this.txtRefresh, disabled : true, - lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock] + lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set.wsLock] }); this.lockedControls.push(this.btnRefreshPivot); @@ -236,7 +236,7 @@ define([ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-select-pivot', caption: this.txtSelect, - lock: [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit] + lock: [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set['PivotTables']] }); this.lockedControls.push(this.btnSelectPivot); @@ -246,7 +246,7 @@ define([ itemWidth : 61, itemHeight : 49, menuMaxHeight : 300, - lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells']], + lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells'], _set['PivotTables']], beforeOpenHandler: function(e) { var cmp = this, menu = cmp.openButton.menu; diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 4165621c03..63657c7192 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -716,7 +716,7 @@ define([ cls : 'btn-toolbar x-huge icon-top', iconCls : 'toolbar__icon btn-inserthyperlink', caption : me.capInsertHyperlink, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selShape, _set.cantHyperlink, _set.selSlicer, _set.multiselect, _set.lostConnect, _set.coAuth, _set.editPivot, _set.wsLock] + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selShape, _set.cantHyperlink, _set.selSlicer, _set.multiselect, _set.lostConnect, _set.coAuth, _set.editPivot] }); me.btnInsertChart = new Common.UI.Button({ @@ -785,7 +785,7 @@ define([ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-symbol', caption: me.capBtnInsSymbol, - lock: [_set.selImage, _set.selChart, _set.selShape, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.wsLock] + lock: [_set.selImage, _set.selChart, _set.selShape, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect] }); me.btnInsertSlicer = new Common.UI.Button({ @@ -793,14 +793,14 @@ define([ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-slicer', caption: me.capBtnInsSlicer, - lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.multiselect, _set.noSlicerSource] + lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.multiselect, _set.noSlicerSource, _set.wsLock] }); me.btnTableTemplate = new Common.UI.Button({ id : 'id-toolbar-btn-ttempl', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-menu-table', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set['FormatCells']], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set.wsLock, _set['FormatCells']], menu : new Common.UI.Menu({ items: [ { template: _.template('
') } @@ -813,7 +813,7 @@ define([ cls : 'btn-toolbar x-huge icon-top', iconCls : 'toolbar__icon btn-inserttable', caption : me.capInsertTable, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set.ruleMerge, _set.editPivot, _set['FormatCells']] + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set.ruleMerge, _set.editPivot, _set.wsLock, _set['FormatCells']] }); me.listStyles = new Common.UI.ComboDataView({ @@ -964,7 +964,7 @@ define([ id : 'id-toolbar-btn-insertrange', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-named-range', - lock : [_set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.selRangeEdit], + lock : [_set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.selRangeEdit, _set.wsLock], menu : new Common.UI.Menu({ style : 'min-width: 110px', items : [ @@ -1040,11 +1040,13 @@ define([ items : [ { caption : me.textInsRight, - value : Asc.c_oAscInsertOptions.InsertCellsAndShiftRight + value : Asc.c_oAscInsertOptions.InsertCellsAndShiftRight, + lock : [_set.wsLock] }, { caption : me.textInsDown, - value : Asc.c_oAscInsertOptions.InsertCellsAndShiftDown + value : Asc.c_oAscInsertOptions.InsertCellsAndShiftDown, + lock : [_set.wsLock] }, { caption : me.textEntireRow, @@ -1067,11 +1069,13 @@ define([ items : [ { caption : me.textDelLeft, - value : Asc.c_oAscDeleteOptions.DeleteCellsAndShiftLeft + value : Asc.c_oAscDeleteOptions.DeleteCellsAndShiftLeft, + lock : [_set.wsLock] }, { caption : me.textDelUp, - value : Asc.c_oAscDeleteOptions.DeleteCellsAndShiftTop + value : Asc.c_oAscDeleteOptions.DeleteCellsAndShiftTop, + lock : [_set.wsLock] }, { caption : me.textEntireRow, @@ -1429,7 +1433,7 @@ define([ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-img-align', caption: me.capImgAlign, - lock : [_set.selRange, _set.selRangeEdit, _set.cantGroup, _set.lostConnect, _set.coAuth, _set.coAuthText], + lock : [_set.selRange, _set.selRangeEdit, _set.cantGroup, _set.lostConnect, _set.coAuth, _set.coAuthText, _set["Objects"]], menu: true }); @@ -1437,7 +1441,7 @@ define([ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-img-group', caption: me.capImgGroup, - lock : [_set.selRange, _set.selRangeEdit, _set.cantGroupUngroup, _set.lostConnect, _set.coAuth, _set.coAuthText], + lock : [_set.selRange, _set.selRangeEdit, _set.cantGroupUngroup, _set.lostConnect, _set.coAuth, _set.coAuthText, _set["Objects"]], menu: true }); me.btnImgForward = new Common.UI.Button({ @@ -1445,14 +1449,14 @@ define([ iconCls: 'toolbar__icon btn-img-frwd', caption: me.capImgForward, split: true, - lock : [_set.selRange, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.coAuthText], + lock : [_set.selRange, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.coAuthText, _set["Objects"]], menu: true }); me.btnImgBackward = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-img-bkwd', caption: me.capImgBackward, - lock : [_set.selRange, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.coAuthText], + lock : [_set.selRange, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.coAuthText, _set["Objects"]], split: true, menu: true }); From 6aeda263a83bd3f2aaa9f5323e6a5e9711edc639 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Sat, 17 Jul 2021 01:31:56 +0300 Subject: [PATCH 25/50] [SSE] Protect refactoring, lock hyperlink insert --- .../main/app/controller/Toolbar.js | 23 ++++++++------ .../main/app/controller/WBProtection.js | 31 +++++++++---------- .../main/app/view/Toolbar.js | 2 +- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 857f19a091..fe2107b259 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -148,7 +148,6 @@ define([ }); Common.NotificationCenter.on('page:settings', _.bind(this.onApiSheetChanged, this)); Common.NotificationCenter.on('formula:settings', _.bind(this.applyFormulaSettings, this)); - Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this)); this.editMode = true; this._isAddingShape = false; @@ -1821,6 +1820,7 @@ define([ this.api.asc_registerCallback('asc_onUpdateDocumentProps', _.bind(this.onUpdateDocumentProps, this)); this.api.asc_registerCallback('asc_onLockDocumentProps', _.bind(this.onApiLockDocumentProps, this)); this.api.asc_registerCallback('asc_onUnLockDocumentProps', _.bind(this.onApiUnLockDocumentProps, this)); + Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this)); } if ( !this.appConfig.isEditMailMerge ) { @@ -1950,7 +1950,7 @@ define([ }; Common.util.Shortcuts.delegateShortcuts({shortcuts: shortcuts}); - this.onApiSelectionChanged(this.api.asc_getCellInfo()); + this.onChangeProtectSheet(); this.attachToControlEvents(); this.onApiSheetChanged(); @@ -2506,7 +2506,7 @@ define([ // disable on protected sheet need_disable = (selectionType === Asc.c_oAscSelectionType.RangeImage || selectionType === Asc.c_oAscSelectionType.RangeChart || selectionType === Asc.c_oAscSelectionType.RangeChartText || selectionType === Asc.c_oAscSelectionType.RangeShape || selectionType === Asc.c_oAscSelectionType.RangeShapeText || selectionType === Asc.c_oAscSelectionType.RangeSlicer); - toolbar.lockToolbar(need_disable ? SSE.enumLock['Objects'] : SSE.enumLock['FormatCells'], need_disable ? this._state.wsProps['Objects'] : this._state.wsProps['FormatCells'], + toolbar.lockToolbar(need_disable ? SSE.enumLock['Objects'] : SSE.enumLock['FormatCells'], need_disable ? !!this._state.wsProps['Objects'] : !!this._state.wsProps['FormatCells'], { clear: [SSE.enumLock['FormatCells'], SSE.enumLock['Objects']]}); if (editOptionsDisabled) return; @@ -3992,12 +3992,17 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, - onChangeProtectSheet: function(props, state) { - this._state.wsProps = props; - this._state.wsLock = state; - - if (this._state.activated) { - this.toolbar.lockToolbar(SSE.enumLock.wsLock, state); + onChangeProtectSheet: function(props) { + if (!props) { + var wbprotect = this.getApplication().getController('WBProtection'); + props = wbprotect ? wbprotect.getWSProps() : null; + } + if (props) { + this._state.wsProps = props.wsProps; + this._state.wsLock = props.wsLock; + + this.toolbar.lockToolbar(SSE.enumLock.wsLock, this._state.wsLock); + this.toolbar.lockToolbar(SSE.enumLock['InsertHyperlinks'], this._state.wsProps['InsertHyperlinks'], {array: [this.toolbar.btnInsertHyperlink]}); this.onApiSelectionChanged(this.api.asc_getCellInfo()); } }, diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index 1877fb0c1a..d595c3c32b 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -68,7 +68,7 @@ define([ }); }, onLaunch: function () { - this._state = {wsLock: false}; + this._state = {}; this.wsLockOptions = ['SelectLockedCells', 'SelectUnlockedCells', 'FormatCells', 'FormatColumns', 'FormatRows', 'InsertColumns', 'InsertRows', 'InsertHyperlinks', 'DeleteColumns', 'DeleteRows', 'Sort', 'AutoFilter', 'PivotTables', 'Objects', 'Scenarios']; SSE.enumLock && this.wsLockOptions.forEach(function(item){ @@ -94,7 +94,6 @@ define([ this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onApiSelectionChanged, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); } - Common.NotificationCenter.on('document:ready', _.bind(this.onDocumentReady, this)); }, setMode: function(mode) { @@ -271,7 +270,7 @@ define([ })).then(function () { me.view.btnProtectWB.toggle(me.api.asc_isProtectedWorkbook(), true); me.view.btnProtectSheet.toggle(me.api.asc_isProtectedSheet(), true); //current sheet - me.onChangeProtectSheet(); + me.onChangeProtectSheet(true); }); }, @@ -279,11 +278,19 @@ define([ this.view.btnProtectWB.toggle(this.api.asc_isProtectedWorkbook(), true); }, - onChangeProtectSheet: function() { - var wsProtected = !!this.api.asc_isProtectedSheet(); - if (this._state.wsLock===wsProtected && !wsProtected) return; + onChangeProtectSheet: function(suppressEvent) { + var props = this.getWSProps(); - this.view.btnProtectSheet.toggle(this.api.asc_isProtectedSheet(), true); //current sheet + this.view.btnProtectSheet.toggle(props.wsLock, true); //current sheet + !suppressEvent && Common.NotificationCenter.trigger('protect:wslock', props); + }, + + onApiSheetChanged: function() { + this.onChangeProtectSheet(); //current sheet + }, + + getWSProps: function() { + var wsProtected = !!this.api.asc_isProtectedSheet(); var arr = []; if (wsProtected) { arr = []; @@ -296,12 +303,8 @@ define([ arr[item] = false; }); } - this._state.wsLock = wsProtected; - Common.NotificationCenter.trigger('protect:wslock', arr, this._state.wsLock); - }, - onApiSheetChanged: function() { - this.onChangeProtectSheet(); //current sheet + return {wsLock: wsProtected, wsProps: arr}; }, onApiSelectionChanged: function(info) { @@ -315,10 +318,6 @@ define([ onCoAuthoringDisconnect: function() { this.SetDisabled(true); - }, - - onDocumentReady: function() { - // this.onChangeProtectSheet(); } }, SSE.Controllers.WBProtection || {})); diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 63657c7192..994c19d6e1 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -716,7 +716,7 @@ define([ cls : 'btn-toolbar x-huge icon-top', iconCls : 'toolbar__icon btn-inserthyperlink', caption : me.capInsertHyperlink, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selShape, _set.cantHyperlink, _set.selSlicer, _set.multiselect, _set.lostConnect, _set.coAuth, _set.editPivot] + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selShape, _set.cantHyperlink, _set.selSlicer, _set.multiselect, _set.lostConnect, _set.coAuth, _set.editPivot, _set['InsertHyperlinks']] }); me.btnInsertChart = new Common.UI.Button({ From ef2af067b0b30cbd6827eeb2719503831b3ae5f3 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Sun, 18 Jul 2021 00:22:55 +0300 Subject: [PATCH 26/50] [SSE] Protect row/columns insert/delete --- .../main/app/controller/DataTab.js | 14 ++++ .../main/app/controller/Toolbar.js | 79 ++++++++++--------- .../main/app/controller/WBProtection.js | 5 +- .../main/app/view/DataTab.js | 6 +- .../main/app/view/Toolbar.js | 4 +- 5 files changed, 64 insertions(+), 44 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js index 78daa73f81..31be82dfc2 100644 --- a/apps/spreadsheeteditor/main/app/controller/DataTab.js +++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js @@ -74,6 +74,8 @@ define([ this.api.asc_registerCallback('asc_onChangeProtectWorkbook',_.bind(this.onChangeProtectWorkbook, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); + Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this)); + Common.NotificationCenter.on('document:ready', _.bind(this.onDocumentReady, this)); } return this; }, @@ -420,6 +422,18 @@ define([ this.onWorksheetLocked(currentSheet, this.api.asc_isWorksheetLockedOrDeleted(currentSheet)); }, + onChangeProtectSheet: function(props) { + if (!props) { + var wbprotect = this.getApplication().getController('WBProtection'); + props = wbprotect ? wbprotect.getWSProps() : null; + } + props && props.wsProps && Common.Utils.lockControls(SSE.enumLock['Sort'], props.wsProps['Sort'], {array: this.view.btnsSortDown.concat(this.view.btnsSortUp, this.view.btnCustomSort)}); + }, + + onDocumentReady: function() { + this.onChangeProtectSheet(); + }, + textWizard: 'Text to Columns Wizard', txtRemDuplicates: 'Remove Duplicates', txtExpandRemDuplicates: 'The data next to the selection will not be removed. Do you want to expand the selection to include the adjacent data or continue with the currently selected cells only?', diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index fe2107b259..10e1077036 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -170,10 +170,6 @@ define([ merge: undefined, angle: undefined, controlsdisabled: { - rows: undefined, - cols: undefined, - cells_right: undefined, - cells_down: undefined, filters: undefined }, selection_type: undefined, @@ -1836,7 +1832,7 @@ define([ var shortcuts = { 'command+l,ctrl+l': function(e) { - if ( me.editMode && !me._state.multiselect && me.appConfig.canModifyFilter) { + if ( me.editMode && !me._state.multiselect && me.appConfig.canModifyFilter && !me._state.wsLock) { var cellinfo = me.api.asc_getCellInfo(), filterinfo = cellinfo.asc_getAutoFilterInfo(), formattableinfo = cellinfo.asc_getFormatTableInfo(); @@ -1849,7 +1845,7 @@ define([ return false; }, 'command+shift+l,ctrl+shift+l': function(e) { - if (me.editMode && me.api && !me._state.multiselect && me.appConfig.canModifyFilter) { + if (me.editMode && me.api && !me._state.multiselect && me.appConfig.canModifyFilter && !me._state.wsLock) { var state = me._state.filter; me._state.filter = undefined; @@ -1868,7 +1864,7 @@ define([ }, 'command+k,ctrl+k': function (e) { if (me.editMode && !me.toolbar.mode.isEditMailMerge && !me.toolbar.mode.isEditDiagram && !me.api.isCellEdited && !me._state.multiselect && !me._state.inpivot && - !me.getApplication().getController('LeftMenu').leftMenu.menuFile.isVisible()) { + !me.getApplication().getController('LeftMenu').leftMenu.menuFile.isVisible() && !me._state.wsProps['InsertHyperlinks']) { var cellinfo = me.api.asc_getCellInfo(), selectionType = cellinfo.asc_getSelectionType(); if (selectionType !== Asc.c_oAscSelectionType.RangeShapeText || me.api.asc_canAddShapeHyperlink()!==false) @@ -1899,14 +1895,18 @@ define([ var cellinfo = me.api.asc_getCellInfo(), selectionType = cellinfo.asc_getSelectionType(); if (selectionType === Asc.c_oAscSelectionType.RangeRow || selectionType === Asc.c_oAscSelectionType.RangeCol) { - me.api.asc_insertCells(selectionType === Asc.c_oAscSelectionType.RangeRow ? Asc.c_oAscInsertOptions.InsertRows :Asc.c_oAscInsertOptions.InsertColumns ); + (selectionType === Asc.c_oAscSelectionType.RangeRow) && !me.toolbar.btnAddCell.menu.items[2].isDisabled() && me.api.asc_insertCells(Asc.c_oAscInsertOptions.InsertRows); + (selectionType === Asc.c_oAscSelectionType.RangeCol) && !me.toolbar.btnAddCell.menu.items[3].isDisabled() && me.api.asc_insertCells(Asc.c_oAscInsertOptions.InsertColumns); Common.NotificationCenter.trigger('edit:complete', me.toolbar); } else { var items = me.toolbar.btnAddCell.menu.items, - arr = []; - for (var i=0; i<4; i++) + arr = [], + enabled = false; + for (var i=0; i<4; i++) { arr.push({caption: items[i].caption, value: items[i].value, disabled: items[i].isDisabled()}); - (new Common.Views.OptionsDialog({ + !items[i].isDisabled() && (enabled = true); + } + enabled && (new Common.Views.OptionsDialog({ title: me.txtInsertCells, items: arr, handler: function (dlg, result) { @@ -1930,10 +1930,13 @@ define([ Common.NotificationCenter.trigger('edit:complete', me.toolbar); } else { var items = me.toolbar.btnDeleteCell.menu.items, - arr = []; - for (var i=0; i<4; i++) + arr = [], + enabled = false; + for (var i=0; i<4; i++) { arr.push({caption: items[i].caption, value: items[i].value, disabled: items[i].isDisabled()}); - (new Common.Views.OptionsDialog({ + !items[i].isDisabled() && (enabled = true); + } + enabled && (new Common.Views.OptionsDialog({ title: me.txtDeleteCells, items: arr, handler: function (dlg, result) { @@ -2823,30 +2826,34 @@ define([ } } - val = (selectionType==Asc.c_oAscSelectionType.RangeRow); - if ( this._state.controlsdisabled.rows!==val ) { - this._state.controlsdisabled.rows=val; - toolbar.btnAddCell.menu.items[3].setDisabled(val); - toolbar.btnDeleteCell.menu.items[3].setDisabled(val); - } - val = (selectionType==Asc.c_oAscSelectionType.RangeCol); - if ( this._state.controlsdisabled.cols!==val ) { - this._state.controlsdisabled.cols=val; - toolbar.btnAddCell.menu.items[2].setDisabled(val); - toolbar.btnDeleteCell.menu.items[2].setDisabled(val); - } + var selCol = selectionType==Asc.c_oAscSelectionType.RangeCol, + selRow = selectionType==Asc.c_oAscSelectionType.RangeRow, + selMax = selectionType==Asc.c_oAscSelectionType.RangeMax; + + need_disable = selRow || selMax && this._state.wsLock || this._state.wsProps['InsertColumns']; + toolbar.btnAddCell.menu.items[3].setDisabled(need_disable); + + need_disable = selRow || selMax && this._state.wsLock || !selCol && this._state.wsLock || this._state.wsProps['DeleteColumns']; + toolbar.btnDeleteCell.menu.items[3].setDisabled(need_disable); + + need_disable = selCol || selMax && this._state.wsLock || this._state.wsProps['InsertRows']; + toolbar.btnAddCell.menu.items[2].setDisabled(need_disable); + + need_disable = selCol || selMax && this._state.wsLock || !selRow && this._state.wsLock || this._state.wsProps['DeleteRows']; + toolbar.btnDeleteCell.menu.items[2].setDisabled(need_disable); val = filterInfo && filterInfo.asc_getIsApplyAutoFilter(); - if ( this._state.controlsdisabled.cells_right!==(this._state.controlsdisabled.rows || val || this._state.wsLock) ) { - this._state.controlsdisabled.cells_right = (this._state.controlsdisabled.rows || val || this._state.wsLock); - toolbar.btnAddCell.menu.items[0].setDisabled(this._state.controlsdisabled.cells_right); - toolbar.btnDeleteCell.menu.items[0].setDisabled(this._state.controlsdisabled.cells_right); - } - if ( this._state.controlsdisabled.cells_down!==(this._state.controlsdisabled.cols || val || this._state.wsLock) ) { - this._state.controlsdisabled.cells_down = (this._state.controlsdisabled.cols || val || this._state.wsLock); - toolbar.btnAddCell.menu.items[1].setDisabled(this._state.controlsdisabled.cells_down); - toolbar.btnDeleteCell.menu.items[1].setDisabled(this._state.controlsdisabled.cells_down); - } + need_disable = selRow || val || !(selCol || selMax) && this._state.wsLock || selCol && this._state.wsProps['InsertColumns'] || selMax && this._state.wsProps['InsertColumns'] && this._state.wsProps['InsertRows']; + toolbar.btnAddCell.menu.items[0].setDisabled(need_disable); + + need_disable = selRow || val || !(selCol || selMax) && this._state.wsLock || selCol && this._state.wsProps['DeleteColumns'] || selMax && this._state.wsProps['DeleteColumns'] && this._state.wsProps['DeleteRows']; + toolbar.btnDeleteCell.menu.items[0].setDisabled(need_disable); + + need_disable = selCol || val || !(selRow || selMax) && this._state.wsLock || selRow && this._state.wsProps['InsertRows'] || selMax && this._state.wsProps['InsertColumns'] && this._state.wsProps['InsertRows']; + toolbar.btnAddCell.menu.items[1].setDisabled(need_disable); + + need_disable = selCol || val || !(selRow || selMax) && this._state.wsLock || selRow && this._state.wsProps['DeleteRows'] || selMax && this._state.wsProps['DeleteColumns'] && this._state.wsProps['DeleteRows']; + toolbar.btnDeleteCell.menu.items[1].setDisabled(need_disable); toolbar.lockToolbar(SSE.enumLock.commentLock, (selectionType == Asc.c_oAscSelectionType.RangeCells) && (info.asc_getComments().length>0 || info.asc_getLocked()) || this.toolbar.mode.compatibleFeatures && (selectionType != Asc.c_oAscSelectionType.RangeCells), diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index d595c3c32b..4e9bbfcb48 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -270,7 +270,6 @@ define([ })).then(function () { me.view.btnProtectWB.toggle(me.api.asc_isProtectedWorkbook(), true); me.view.btnProtectSheet.toggle(me.api.asc_isProtectedSheet(), true); //current sheet - me.onChangeProtectSheet(true); }); }, @@ -278,11 +277,11 @@ define([ this.view.btnProtectWB.toggle(this.api.asc_isProtectedWorkbook(), true); }, - onChangeProtectSheet: function(suppressEvent) { + onChangeProtectSheet: function() { var props = this.getWSProps(); this.view.btnProtectSheet.toggle(props.wsLock, true); //current sheet - !suppressEvent && Common.NotificationCenter.trigger('protect:wslock', props); + Common.NotificationCenter.trigger('protect:wslock', props); }, onApiSheetChanged: function() { diff --git a/apps/spreadsheeteditor/main/app/view/DataTab.js b/apps/spreadsheeteditor/main/app/view/DataTab.js index 957b8483e4..1ededb67ce 100644 --- a/apps/spreadsheeteditor/main/app/view/DataTab.js +++ b/apps/spreadsheeteditor/main/app/view/DataTab.js @@ -215,15 +215,15 @@ define([ iconCls: 'toolbar__icon btn-custom-sort', caption: this.capBtnTextCustomSort, disabled: true, - lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.sheetLock] + lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.sheetLock, _set['Sort']] }); this.lockedControls.push(this.btnCustomSort); this.btnsSortDown = Common.Utils.injectButtons($host.find('.slot-sortdesc'), '', 'toolbar__icon btn-sort-down', '', - [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.cantModifyFilter, _set.sheetLock, _set.cantSort]); + [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.cantModifyFilter, _set.sheetLock, _set.cantSort, _set['Sort']]); this.btnsSortUp = Common.Utils.injectButtons($host.find('.slot-sortasc'), '', 'toolbar__icon btn-sort-up', '', - [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.cantModifyFilter, _set.sheetLock, _set.cantSort]); + [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.cantModifyFilter, _set.sheetLock, _set.cantSort, _set['Sort']]); this.btnsSetAutofilter = Common.Utils.injectButtons($host.find('.slot-btn-setfilter'), '', 'toolbar__icon btn-autofilter', '', [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.tableHasSlicer, _set.wsLock], diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 994c19d6e1..b70a46f521 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -800,7 +800,7 @@ define([ id : 'id-toolbar-btn-ttempl', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-menu-table', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set.wsLock, _set['FormatCells']], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set.wsLock], menu : new Common.UI.Menu({ items: [ { template: _.template('
') } @@ -813,7 +813,7 @@ define([ cls : 'btn-toolbar x-huge icon-top', iconCls : 'toolbar__icon btn-inserttable', caption : me.capInsertTable, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set.ruleMerge, _set.editPivot, _set.wsLock, _set['FormatCells']] + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set.ruleMerge, _set.editPivot, _set.wsLock] }); me.listStyles = new Common.UI.ComboDataView({ From 02660913117fbcd05a87c2d4dc853750c9243340 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Sun, 18 Jul 2021 01:09:26 +0300 Subject: [PATCH 27/50] Fix disabled buttons --- .../main/app/controller/Toolbar.js | 14 ++++++++++++++ apps/spreadsheeteditor/main/app/view/Toolbar.js | 7 ++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 10e1077036..e992b27aba 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -2855,6 +2855,20 @@ define([ need_disable = selCol || val || !(selRow || selMax) && this._state.wsLock || selRow && this._state.wsProps['DeleteRows'] || selMax && this._state.wsProps['DeleteColumns'] && this._state.wsProps['DeleteRows']; toolbar.btnDeleteCell.menu.items[1].setDisabled(need_disable); + var items = toolbar.btnAddCell.menu.items, + enabled = false; + for (var i=0; i<4; i++) { + !items[i].isDisabled() && (enabled = true); + } + toolbar.lockToolbar(SSE.enumLock.itemsDisabled, !enabled, {array: [toolbar.btnAddCell]}); + + items = me.toolbar.btnDeleteCell.menu.items; + enabled = false; + for (var i=0; i<4; i++) { + !items[i].isDisabled() && (enabled = true); + } + toolbar.lockToolbar(SSE.enumLock.itemsDisabled, !enabled, {array: [toolbar.btnDeleteCell]}); + toolbar.lockToolbar(SSE.enumLock.commentLock, (selectionType == Asc.c_oAscSelectionType.RangeCells) && (info.asc_getComments().length>0 || info.asc_getLocked()) || this.toolbar.mode.compatibleFeatures && (selectionType != Asc.c_oAscSelectionType.RangeCells), { array: this.btnsComment }); diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index b70a46f521..c57d8529fe 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -100,7 +100,8 @@ define([ tableHasSlicer: 'table-has-slicer', sheetView: 'sheet-view', wbLock: 'workbook-lock', - wsLock: 'worksheet-lock' + wsLock: 'worksheet-lock', + itemsDisabled: 'all-items-disabled' }; SSE.Views.Toolbar = Common.UI.Mixtbar.extend(_.extend({ @@ -1035,7 +1036,7 @@ define([ id : 'id-toolbar-btn-addcell', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-addcell', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.itemsDisabled, _set.lostConnect, _set.coAuth], menu : new Common.UI.Menu({ items : [ { @@ -1064,7 +1065,7 @@ define([ id : 'id-toolbar-btn-delcell', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-delcell', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.itemsDisabled, _set.lostConnect, _set.coAuth], menu : new Common.UI.Menu({ items : [ { From 16557cd2f83f9f669d36e4f533594db9fd4ed69d Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Sun, 18 Jul 2021 02:11:58 +0300 Subject: [PATCH 28/50] [SSE] Disable context menu on protected sheet --- .../main/app/controller/DocumentHolder.js | 57 +++++++++++++------ 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 657726150a..fc9567d414 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -169,9 +169,9 @@ define([ 'cells:range': function(status){ me.onCellsRange(status); }, - 'tabs:dragend': _.bind(me.onDragEndMouseUp, me) + 'tabs:dragend': _.bind(me.onDragEndMouseUp, me), + 'protect:wslock': _.bind(me.onChangeProtectSheet, me) }); - Common.Gateway.on('processmouse', _.bind(me.onProcessMouse, me)); }, @@ -289,6 +289,7 @@ define([ } Common.Utils.isChrome ? addEvent(document, 'mousewheel', _.bind(this.onDocumentWheel,this), { passive: false } ) : $(document).on('mousewheel', _.bind(this.onDocumentWheel, this)); + this.onChangeProtectSheet(); }, loadConfig: function(data) { @@ -1911,6 +1912,8 @@ define([ item.setDisabled(isObjLocked); }); documentHolder.pmiTextCopy.setDisabled(false); + documentHolder.menuHyperlinkShape.setDisabled(isObjLocked || this._state.wsLock); + documentHolder.menuAddHyperlinkShape.setDisabled(isObjLocked || this._state.wsLock); //equation menu var eqlen = 0; @@ -2018,28 +2021,35 @@ define([ item.setDisabled(isCellLocked); }); documentHolder.pmiCopy.setDisabled(false); - documentHolder.pmiCut.setDisabled(isCellLocked); // can't edit pivot cells - documentHolder.pmiPaste.setDisabled(isCellLocked); - documentHolder.pmiInsertEntire.setDisabled(isCellLocked || isTableLocked); - documentHolder.pmiInsertCells.setDisabled(isCellLocked || isTableLocked || inPivot); - documentHolder.pmiInsertTable.setDisabled(isCellLocked || isTableLocked); - documentHolder.pmiDeleteEntire.setDisabled(isCellLocked || isTableLocked); - documentHolder.pmiDeleteCells.setDisabled(isCellLocked || isTableLocked || inPivot); - documentHolder.pmiDeleteTable.setDisabled(isCellLocked || isTableLocked); + documentHolder.pmiSelectTable.setDisabled(this._state.wsLock); + documentHolder.pmiInsertEntire.setDisabled(isCellLocked || isTableLocked || isrowmenu && this._state.wsProps['InsertRows'] || iscolmenu && this._state.wsProps['InsertColumns']); + documentHolder.pmiInsertCells.setDisabled(isCellLocked || isTableLocked || inPivot || this._state.wsLock); + documentHolder.pmiInsertTable.setDisabled(isCellLocked || isTableLocked || this._state.wsLock); + documentHolder.pmiDeleteEntire.setDisabled(isCellLocked || isTableLocked || isrowmenu && this._state.wsProps['DeleteRows'] || iscolmenu && this._state.wsProps['DeleteColumns']); + documentHolder.pmiDeleteCells.setDisabled(isCellLocked || isTableLocked || inPivot || this._state.wsLock); + documentHolder.pmiDeleteTable.setDisabled(isCellLocked || isTableLocked || this._state.wsLock); documentHolder.pmiClear.setDisabled(isCellLocked || inPivot); - documentHolder.pmiFilterCells.setDisabled(isCellLocked || isTableLocked|| (filterInfo==null) || inPivot || !filterInfo && !this.permissions.canModifyFilter); - documentHolder.pmiSortCells.setDisabled(isCellLocked || isTableLocked|| (filterInfo==null) || inPivot || !this.permissions.canModifyFilter); + documentHolder.pmiFilterCells.setDisabled(isCellLocked || isTableLocked|| (filterInfo==null) || inPivot || !filterInfo && !this.permissions.canModifyFilter || this._state.wsLock); + documentHolder.pmiSortCells.setDisabled(isCellLocked || isTableLocked|| (filterInfo==null) || inPivot || !this.permissions.canModifyFilter || this._state.wsProps['Sort']); documentHolder.pmiReapply.setDisabled(isCellLocked || isTableLocked|| (isApplyAutoFilter!==true)); - documentHolder.pmiCondFormat.setDisabled(isCellLocked || isTableLocked); - documentHolder.menuHyperlink.setDisabled(isCellLocked || inPivot); - documentHolder.menuAddHyperlink.setDisabled(isCellLocked || inPivot); + documentHolder.pmiCondFormat.setDisabled(isCellLocked || isTableLocked || this._state.wsProps['FormatCells']); + documentHolder.menuHyperlink.setDisabled(isCellLocked || inPivot || this._state.wsProps['InsertHyperlinks']); + documentHolder.menuAddHyperlink.setDisabled(isCellLocked || inPivot || this._state.wsProps['InsertHyperlinks']); documentHolder.pmiInsFunction.setDisabled(isCellLocked || inPivot); documentHolder.pmiFreezePanes.setDisabled(this.api.asc_isWorksheetLockedOrDeleted(this.api.asc_getActiveWorksheetIndex())); + documentHolder.pmiRowHeight.setDisabled(isCellLocked || this._state.wsProps['FormatRows']); + documentHolder.pmiColumnWidth.setDisabled(isCellLocked || this._state.wsProps['FormatColumns']); + documentHolder.pmiEntireHide.setDisabled(isCellLocked || iscolmenu && this._state.wsProps['FormatColumns'] || isrowmenu && this._state.wsProps['FormatRows']); + documentHolder.pmiEntireShow.setDisabled(isCellLocked || iscolmenu && this._state.wsProps['FormatColumns'] ||isrowmenu && this._state.wsProps['FormatRows']); + documentHolder.pmiNumFormat.setDisabled(isCellLocked || this._state.wsProps['FormatCells']); + documentHolder.pmiSparklines.setDisabled(isCellLocked || this._state.wsLock); + documentHolder.pmiEntriesList.setDisabled(isCellLocked || this._state.wsLock); + documentHolder.pmiAddNamedRange.setDisabled(isCellLocked || this._state.wsLock); if (inPivot) { var canGroup = this.api.asc_canGroupPivot(); - documentHolder.mnuGroupPivot.setDisabled(isPivotLocked || !canGroup); - documentHolder.mnuUnGroupPivot.setDisabled(isPivotLocked || !canGroup); + documentHolder.mnuGroupPivot.setDisabled(isPivotLocked || !canGroup || this._state.wsLock); + documentHolder.mnuUnGroupPivot.setDisabled(isPivotLocked || !canGroup || this._state.wsLock); } if (showMenu) this.showPopupMenu(documentHolder.ssMenu, {}, event); @@ -3617,7 +3627,18 @@ define([ win.setActiveCategory(2); } }, - + + onChangeProtectSheet: function(props) { + if (!props) { + var wbprotect = this.getApplication().getController('WBProtection'); + props = wbprotect ? wbprotect.getWSProps() : null; + } + if (props) { + this._state.wsProps = props.wsProps; + this._state.wsLock = props.wsLock; + } + }, + SetDisabled: function(state, canProtect) { this._isDisabled = state; this._canProtect = canProtect; From bad734231e24c8894f3b5460eb96630d2a23af97 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 19 Jul 2021 16:43:58 +0300 Subject: [PATCH 29/50] [SSE] Disable context menu for protected sheet --- .../main/app/controller/DocumentHolder.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index fc9567d414..e52f593c03 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -1451,6 +1451,8 @@ define([ } if (me.permissions.isEdit) { if (!me.dlgFilter) { + if (me._state.wsProps['PivotTables'] && config.asc_getPivotObj() || me._state.wsProps['AutoFilter'] && !config.asc_getPivotObj()) return; + me.dlgFilter = new SSE.Views.AutoFilterDialog({api: this.api}).on({ 'close': function () { if (me.api) { @@ -1746,7 +1748,7 @@ define([ if (!documentHolder.copyPasteMenu || !showMenu && !documentHolder.copyPasteMenu.isVisible()) return; if (showMenu) this.showPopupMenu(documentHolder.copyPasteMenu, {}, event); } else if (isimagemenu || isshapemenu || ischartmenu) { - if (!documentHolder.imgMenu || !showMenu && !documentHolder.imgMenu.isVisible()) return; + if (!documentHolder.imgMenu || !showMenu && !documentHolder.imgMenu.isVisible() || this._state.wsProps['Objects']) return; isimagemenu = isshapemenu = ischartmenu = isslicermenu = false; documentHolder.mnuImgAdvanced.imageInfo = undefined; @@ -1835,7 +1837,7 @@ define([ documentHolder.menuSignatureEditSetup.cmpEl.attr('data-value', signGuid); // edit signature settings } } else if (istextshapemenu || istextchartmenu) { - if (!documentHolder.textInShapeMenu || !showMenu && !documentHolder.textInShapeMenu.isVisible()) return; + if (!documentHolder.textInShapeMenu || !showMenu && !documentHolder.textInShapeMenu.isVisible() || this._state.wsProps['Objects']) return; documentHolder.pmiTextAdvanced.textInfo = undefined; @@ -1912,8 +1914,8 @@ define([ item.setDisabled(isObjLocked); }); documentHolder.pmiTextCopy.setDisabled(false); - documentHolder.menuHyperlinkShape.setDisabled(isObjLocked || this._state.wsLock); - documentHolder.menuAddHyperlinkShape.setDisabled(isObjLocked || this._state.wsLock); + documentHolder.menuHyperlinkShape.setDisabled(isObjLocked || this._state.wsProps['InsertHyperlinks']); + documentHolder.menuAddHyperlinkShape.setDisabled(isObjLocked || this._state.wsProps['InsertHyperlinks']); //equation menu var eqlen = 0; From 1199804ae6fb6e5d6a9cf2a1f96e90d1ba39f147 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 19 Jul 2021 16:56:46 +0300 Subject: [PATCH 30/50] [SSE] Protect objects --- apps/spreadsheeteditor/main/app/controller/WBProtection.js | 6 +++++- apps/spreadsheeteditor/main/app/view/WBProtection.js | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index 4e9bbfcb48..669ee7f034 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -269,7 +269,10 @@ define([ resolve(); })).then(function () { me.view.btnProtectWB.toggle(me.api.asc_isProtectedWorkbook(), true); - me.view.btnProtectSheet.toggle(me.api.asc_isProtectedSheet(), true); //current sheet + + var props = me.getWSProps(); + me.view.btnProtectSheet.toggle(props.wsLock, true); //current sheet + Common.Utils.lockControls(SSE.enumLock['Objects'], props.wsProps['Objects'], { array: [me.view.chLockedText, me.view.chLockedShape]}); }); }, @@ -281,6 +284,7 @@ define([ var props = this.getWSProps(); this.view.btnProtectSheet.toggle(props.wsLock, true); //current sheet + Common.Utils.lockControls(SSE.enumLock['Objects'], props.wsProps['Objects'], { array: [this.view.chLockedText, this.view.chLockedShape]}); Common.NotificationCenter.trigger('protect:wslock', props); }, diff --git a/apps/spreadsheeteditor/main/app/view/WBProtection.js b/apps/spreadsheeteditor/main/app/view/WBProtection.js index ad7e0e4834..46dbc13173 100644 --- a/apps/spreadsheeteditor/main/app/view/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/view/WBProtection.js @@ -145,13 +145,13 @@ define([ this.chLockedShape = new Common.UI.CheckBox({ labelText: this.txtLockedShape, - lock : [_set.selRange, _set.selRangeEdit, _set.wsLock, _set.wbLock, _set.lostConnect, _set.coAuth] + lock : [_set.selRange, _set.selRangeEdit, _set.wbLock, _set.lostConnect, _set.coAuth, _set['Objects']] }); this.lockedControls.push(this.chLockedShape); this.chLockedText = new Common.UI.CheckBox({ labelText: this.txtLockedText, - lock : [_set.selRange, _set.selRangeEdit, _set.selRangeEdit, _set.wsLock, _set.wbLock, _set.lostConnect, _set.coAuth] + lock : [_set.selRange, _set.selRangeEdit, _set.selRangeEdit, _set.selImage, _set.wbLock, _set.lostConnect, _set.coAuth, _set['Objects']] }); this.lockedControls.push(this.chLockedText); From c18ed375cab4872d35c58c4ffa55e4eb5cd5cd04 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 19 Jul 2021 20:48:36 +0300 Subject: [PATCH 31/50] [SSE] Disable right panel on protected sheet --- .../main/app/controller/RightMenu.js | 30 +++++++++++++------ .../main/app/view/TableSettings.js | 27 ++++++++++------- .../main/app/view/WBProtection.js | 2 +- 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/RightMenu.js b/apps/spreadsheeteditor/main/app/controller/RightMenu.js index 76477378c7..b95001c5c2 100644 --- a/apps/spreadsheeteditor/main/app/controller/RightMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/RightMenu.js @@ -104,6 +104,7 @@ define([ this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('cells:range', _.bind(this.onCellsRange, this)); + Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this)); }, setMode: function(mode) { @@ -171,10 +172,10 @@ define([ if (!this.editMode) return; - var isCellLocked = cellInfo.asc_getLocked(), - isTableLocked = (cellInfo.asc_getLockedTable()===true || !this.rightmenu.mode.canModifyFilter), - isSparkLocked = (cellInfo.asc_getLockedSparkline()===true), - isPivotLocked = (cellInfo.asc_getLockedPivotTable()===true); + var isCellLocked = cellInfo.asc_getLocked() || this._state.wsProps['FormatCells'], + isTableLocked = (cellInfo.asc_getLockedTable()===true || !this.rightmenu.mode.canModifyFilter) || this._state.wsProps['FormatCells'], + isSparkLocked = (cellInfo.asc_getLockedSparkline()===true) || this._state.wsLock, + isPivotLocked = (cellInfo.asc_getLockedPivotTable()===true) || this._state.wsProps['PivotTables']; for (var i=0; i Date: Mon, 19 Jul 2021 20:52:32 +0300 Subject: [PATCH 32/50] Fix right panel settings --- apps/spreadsheeteditor/main/app/controller/RightMenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/controller/RightMenu.js b/apps/spreadsheeteditor/main/app/controller/RightMenu.js index b95001c5c2..be2acfa894 100644 --- a/apps/spreadsheeteditor/main/app/controller/RightMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/RightMenu.js @@ -139,7 +139,7 @@ define([ var panel = this._settings[type].panel; var props = this._settings[type].props; if (props && panel) - panel.ChangeSettings.call(panel, (type==Common.Utils.documentSettingsType.Signature) ? undefined : props); + panel.ChangeSettings.call(panel, (type==Common.Utils.documentSettingsType.Signature) ? undefined : props, this._state.wsLock, this._state.wsProps); } Common.NotificationCenter.trigger('layout:changed', 'rightmenu'); }, From 3c09b6d32568b2b78d796f2bddeec114fcff6fce Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 19 Jul 2021 23:49:51 +0300 Subject: [PATCH 33/50] [SSE] Lock allow ranges button --- apps/spreadsheeteditor/main/app/controller/WBProtection.js | 2 ++ apps/spreadsheeteditor/main/app/view/WBProtection.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index 669ee7f034..e4dffaee04 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -273,6 +273,7 @@ define([ var props = me.getWSProps(); me.view.btnProtectSheet.toggle(props.wsLock, true); //current sheet Common.Utils.lockControls(SSE.enumLock['Objects'], props.wsProps['Objects'], { array: [me.view.chLockedText, me.view.chLockedShape]}); + Common.Utils.lockControls(SSE.enumLock.wsLock, props.wsLock, { array: [me.view.btnAllowRanges]}); }); }, @@ -285,6 +286,7 @@ define([ this.view.btnProtectSheet.toggle(props.wsLock, true); //current sheet Common.Utils.lockControls(SSE.enumLock['Objects'], props.wsProps['Objects'], { array: [this.view.chLockedText, this.view.chLockedShape]}); + Common.Utils.lockControls(SSE.enumLock.wsLock, props.wsLock, { array: [this.view.btnAllowRanges]}); Common.NotificationCenter.trigger('protect:wslock', props); }, diff --git a/apps/spreadsheeteditor/main/app/view/WBProtection.js b/apps/spreadsheeteditor/main/app/view/WBProtection.js index bac5bad620..da36a529ac 100644 --- a/apps/spreadsheeteditor/main/app/view/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/view/WBProtection.js @@ -133,7 +133,7 @@ define([ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon allow-edit-ranges', caption: this.txtAllowRanges, - lock : [_set.selRangeEdit, _set.lostConnect, _set.coAuth] + lock : [_set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock] }); this.lockedControls.push(this.btnAllowRanges); From 992b831a791735138ee45a719a382e6750b7166f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 19 Jul 2021 23:50:45 +0300 Subject: [PATCH 34/50] [SSE] Check insert hyperlink on protected sheet --- .../main/app/controller/DocumentHolder.js | 4 ++ .../main/app/controller/Main.js | 52 +++++++++++++++++-- .../main/app/controller/Toolbar.js | 4 ++ 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index e52f593c03..c7891973e8 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -569,6 +569,10 @@ define([ }, onInsHyperlink: function(item) { + Common.NotificationCenter.trigger('protect:check', this.onInsHyperlinkCallback, this, [item]); + }, + + onInsHyperlinkCallback: function(item) { var me = this; var win, props; diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index f8084bb82c..da8762ffee 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -209,7 +209,8 @@ define([ Common.NotificationCenter.on('download:cancel', _.bind(this.onDownloadCancel, this)); Common.NotificationCenter.on('download:advanced', _.bind(this.onAdvancedOptions, this)); Common.NotificationCenter.on('showmessage', _.bind(this.onExternalMessage, this)); - Common.NotificationCenter.on('markfavorite', _.bind(this.markFavorite, this)); + Common.NotificationCenter.on('markfavorite', _.bind(this.markFavorite, this)); + Common.NotificationCenter.on('protect:check', _.bind(this.checkProtectedRange, this)); this.stackLongActions = new Common.IrregularStack({ strongCompare : this._compareActionStrong, @@ -1701,7 +1702,6 @@ define([ break; } - if (level == Asc.c_oAscError.Level.Critical) { Common.Gateway.reportError(id, config.msg); @@ -2064,6 +2064,51 @@ define([ } }, + checkProtectedRange: function(callback, scope, args) { + var result = this.api.asc_checkActiveCellProtectedRange(); + if (result===null) { + this.onError(Asc.c_oAscError.ID.ChangeOnProtectedSheet, Asc.c_oAscError.Level.NoCritical); + return; + } + + if (result) { + var me = this; + var win = new Common.Views.OpenDialog({ + title: this.txtUnlockRange, + closable: true, + type: Common.Utils.importTextType.DRM, + warning: true, + warningMsg: this.txtUnlockRangeWarning, + txtOpenFile: this.txtUnlockRangeDescription, + validatePwd: false, + handler: function (result, value) { + if (result == 'ok') { + if (me.api) { + if (me.api.asc_checkActiveCellPassword(value.drmOptions.asc_getPassword())) { + callback && setTimeout(function() { + callback.apply(scope, args); + }, 1); + } else { + Common.UI.warning({ + msg: me.errorWrongPassword, + callback: function() { + Common.NotificationCenter.trigger('edit:complete', me.toolbar); + } + }); + } + } + } + Common.NotificationCenter.trigger('edit:complete', me.toolbar); + } + }); + win.show(); + } else { + callback && setTimeout(function() { + callback.apply(scope, args); + }, 1); + } + }, + initNames: function() { this.shapeGroupNames = [ this.txtBasicShapes, @@ -2982,7 +3027,8 @@ define([ txtUnlockRange: 'Unlock Range', txtUnlockRangeWarning: 'A range you are trying to change is password protected.', txtUnlockRangeDescription: 'Enter the password to change this range:', - txtUnlock: 'Unlock' + txtUnlock: 'Unlock', + errorWrongPassword: 'The password you supplied is not correct.' } })(), SSE.Controllers.Main || {})) }); diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index e992b27aba..31524634de 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -927,6 +927,10 @@ define([ }, onHyperlink: function(btn) { + Common.NotificationCenter.trigger('protect:check', this.onHyperlinkCallback, this, [btn]); + }, + + onHyperlinkCallback: function(btn) { var me = this; var win, props; From 0d666fe210d3b92d8b0f44d66f122a5e5084a240 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 20 Jul 2021 00:02:30 +0300 Subject: [PATCH 35/50] [SSE] Check insert on protected sheet --- .../main/app/controller/DocumentHolder.js | 4 ++++ apps/spreadsheeteditor/main/app/controller/Toolbar.js | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index c7891973e8..c2870b3e02 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -416,6 +416,10 @@ define([ }, onSortCells: function(menu, item) { + Common.NotificationCenter.trigger('protect:check', this.onSortCellsCallback, this, [menu, item]); + }, + + onSortCellsCallback: function(menu, item) { if (item.value=='advanced') { Common.NotificationCenter.trigger('data:sortcustom', this); return; diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 31524634de..8d924eab01 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -1199,6 +1199,10 @@ define([ }, onSortType: function(type, btn) { + Common.NotificationCenter.trigger('protect:check', this.onSortTypeCallback, this, [type, btn]); + }, + + onSortTypeCallback: function(type, btn) { if (this.api) { if (this.api.asc_getCellInfo().asc_getSelectionType()==Asc.c_oAscSelectionType.RangeSlicer) { var selectedObjects = this.api.asc_getGraphicObjectProps(); @@ -3234,6 +3238,10 @@ define([ }, onInsertSymbolClick: function() { + Common.NotificationCenter.trigger('protect:check', this.onInsertSymbolClickCallback, this, []); + }, + + onInsertSymbolClickCallback: function() { if (this.api) { var me = this, selected = me.api.asc_GetSelectedText(), From de3786afae9afe5d4ea0f13b14f6fd7c4458f5f0 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 20 Jul 2021 13:03:44 +0300 Subject: [PATCH 36/50] [SSE] Check clear cell on protected sheet --- .../spreadsheeteditor/main/app/controller/DocumentHolder.js | 6 +++++- apps/spreadsheeteditor/main/app/controller/Toolbar.js | 4 ++++ apps/spreadsheeteditor/main/app/controller/WBProtection.js | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index c2870b3e02..1c45139402 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -526,7 +526,11 @@ define([ win.setSettings(rangePr, dateTypes, defRangePr); }, - onClear: function(menu, item) { + onClear: function(menu, item, e) { + Common.NotificationCenter.trigger('protect:check', this.onClearCallback, this, [menu, item]); + }, + + onClearCallback: function(menu, item) { if (this.api) { if (item.value == Asc.c_oAscCleanOptions.Comments) { this.api.asc_RemoveAllComments(!this.permissions.canDeleteComments, true);// 1 param = true if remove only my comments, 2 param - remove current comments diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 8d924eab01..e6dd181753 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -1478,6 +1478,10 @@ define([ }, onClearStyleMenu: function(menu, item, e) { + Common.NotificationCenter.trigger('protect:check', this.onClearStyleMenuCallback, this, [menu, item]); + }, + + onClearStyleMenuCallback: function(menu, item, e) { if (this.api) { if (item.value == Asc.c_oAscCleanOptions.Comments) { this.api.asc_RemoveAllComments(!this.mode.canDeleteComments, true);// 1 param = true if remove only my comments, 2 param - remove current comments diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index e4dffaee04..2e143e4c42 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -251,7 +251,7 @@ define([ onLockOptionClick: function(type, value) { switch (type) { case 0: // cell - // this._originalProps.asc_getStyleInfo().asc_setShowRowHeaders(this.api, this._originalProps, value=='checked'); + this.api.asc_setCellLocked(value=='checked'); break; case 1: // shape break; @@ -319,6 +319,10 @@ define([ var need_disable = (selectionType === Asc.c_oAscSelectionType.RangeCells || selectionType === Asc.c_oAscSelectionType.RangeCol || selectionType === Asc.c_oAscSelectionType.RangeRow || selectionType === Asc.c_oAscSelectionType.RangeMax); Common.Utils.lockControls(SSE.enumLock.selRange, need_disable, { array: [this.view.chLockedText, this.view.chLockedShape]}); + + var xfs = info.asc_getXfs(); + this.view.chLockedCell.setValue(!!xfs.asc_getLocked(), true); + this.view.chHiddenFormula.setValue(!!xfs.asc_getHidden(), true); }, onCoAuthoringDisconnect: function() { From a256c9413b40b03f860630088364cb399fc5859f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 4 Aug 2021 20:54:21 +0300 Subject: [PATCH 37/50] [SSE] Set shape/text protect settings --- .../main/app/controller/WBProtection.js | 24 +++++++++++++++++++ .../main/app/view/Toolbar.js | 4 +++- .../main/app/view/WBProtection.js | 4 ++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index 2e143e4c42..f11880bc81 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -254,8 +254,14 @@ define([ this.api.asc_setCellLocked(value=='checked'); break; case 1: // shape + var props = new Asc.asc_CImgProperty(); + props.asc_putProtectionLocked(value=='checked'); + this.api.asc_setGraphicObjectProps(props); break; case 2: // text + var props = new Asc.asc_CImgProperty(); + props.asc_putProtectionLockText(value=='checked'); + this.api.asc_setGraphicObjectProps(props); break; case 3: // formula break; @@ -323,6 +329,24 @@ define([ var xfs = info.asc_getXfs(); this.view.chLockedCell.setValue(!!xfs.asc_getLocked(), true); this.view.chHiddenFormula.setValue(!!xfs.asc_getHidden(), true); + + if (selectionType === Asc.c_oAscSelectionType.RangeSlicer || selectionType === Asc.c_oAscSelectionType.RangeImage || + selectionType === Asc.c_oAscSelectionType.RangeShape || selectionType === Asc.c_oAscSelectionType.RangeShapeText || + selectionType === Asc.c_oAscSelectionType.RangeChart || selectionType === Asc.c_oAscSelectionType.RangeChartText) { + var selectedObjects = this.api.asc_getGraphicObjectProps(); + for (var i = 0; i < selectedObjects.length; i++) { + if (selectedObjects[i].asc_getObjectType() == Asc.c_oAscTypeSelectElement.Image) { + var elValue = selectedObjects[i].asc_getObjectValue(); + var locktext = elValue.asc_getProtectionLockText(), + lock = elValue.asc_getProtectionLocked(); + this.view.chLockedText.setValue(locktext!==undefined ? !!locktext : 'indeterminate', true); + this.view.chLockedShape.setValue(lock!==undefined ? !!lock : 'indeterminate', true); + Common.Utils.lockControls(SSE.enumLock.wsLockText, locktext===null, { array: [this.view.chLockedText]}); + Common.Utils.lockControls(SSE.enumLock.wsLockShape, lock===null, { array: [this.view.chLockedShape]}); + break; + } + } + } }, onCoAuthoringDisconnect: function() { diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index c57d8529fe..a11b5d399d 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -101,7 +101,9 @@ define([ sheetView: 'sheet-view', wbLock: 'workbook-lock', wsLock: 'worksheet-lock', - itemsDisabled: 'all-items-disabled' + itemsDisabled: 'all-items-disabled', + wsLockText: 'worksheet-lock-text', + wsLockShape: 'worksheet-lock-shape' }; SSE.Views.Toolbar = Common.UI.Mixtbar.extend(_.extend({ diff --git a/apps/spreadsheeteditor/main/app/view/WBProtection.js b/apps/spreadsheeteditor/main/app/view/WBProtection.js index da36a529ac..3bcc55f717 100644 --- a/apps/spreadsheeteditor/main/app/view/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/view/WBProtection.js @@ -145,13 +145,13 @@ define([ this.chLockedShape = new Common.UI.CheckBox({ labelText: this.txtLockedShape, - lock : [_set.selRange, _set.selRangeEdit, _set.wbLock, _set.lostConnect, _set.coAuth, _set['Objects']] + lock : [_set.selRange, _set.selRangeEdit, _set.wbLock, _set.lostConnect, _set.coAuth, _set['Objects'], _set.wsLockShape] }); this.lockedControls.push(this.chLockedShape); this.chLockedText = new Common.UI.CheckBox({ labelText: this.txtLockedText, - lock : [_set.selRange, _set.selRangeEdit, _set.selRangeEdit, _set.selImage, _set.selSlicer, _set.wbLock, _set.lostConnect, _set.coAuth, _set['Objects']] + lock : [_set.selRange, _set.selRangeEdit, _set.selRangeEdit, _set.selImage, _set.selSlicer, _set.wbLock, _set.lostConnect, _set.coAuth, _set['Objects'], _set.wsLockText] }); this.lockedControls.push(this.chLockedText); From 1603e3cf9b13890c02ab05d14e70c84bdf26bb05 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 4 Aug 2021 22:32:07 +0300 Subject: [PATCH 38/50] [SSE] Set hidden formulas --- apps/spreadsheeteditor/main/app/controller/WBProtection.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index f11880bc81..6ab13e791a 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -264,6 +264,7 @@ define([ this.api.asc_setGraphicObjectProps(props); break; case 3: // formula + this.api.asc_setCellHiddenFormulas(value=='checked'); break; } Common.NotificationCenter.trigger('edit:complete', this); From 6a270a5e038856297ba40feba67cca32a73d96af Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 5 Aug 2021 00:37:48 +0300 Subject: [PATCH 39/50] [SSE] Protect sheet from context menu --- .../main/app/controller/Statusbar.js | 7 +++++++ .../main/app/controller/WBProtection.js | 1 + .../spreadsheeteditor/main/app/view/Statusbar.js | 16 +++++++++++----- apps/spreadsheeteditor/main/locale/en.json | 2 ++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index bd4ecc7f47..1a10b17a57 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -308,6 +308,9 @@ define([ me.hideWorksheet(true, arrIndex); }, 1); break; + case 'protect': + this.protectWorksheet(); + break; } }, @@ -779,6 +782,10 @@ define([ this._sheetViewTip.hide(); }, + protectWorksheet: function() { + Common.NotificationCenter.trigger('protect:sheet', !this.api.asc_isProtectedSheet()); + }, + zoomText : 'Zoom {0}%', errorLastSheet : 'Workbook must have at least one visible worksheet.', errorRemoveSheet: 'Can\'t delete the worksheet.', diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index 6ab13e791a..7a6b8f69be 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -77,6 +77,7 @@ define([ Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); + Common.NotificationCenter.on('protect:sheet', _.bind(this.onSheetClick, this)); }, setConfig: function (data, api) { this.setApi(api); diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index a9c6461730..75ade6956b 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -342,6 +342,7 @@ define([ caption: this.itemHidden, menu: menuHiddenItems }, + {caption: this.itemProtect, value: 'protect'}, { caption: this.itemTabColor, menu: menuColorItems @@ -657,16 +658,19 @@ define([ this.tabMenu.items[4].setDisabled(issheetlocked || isdocprotected); this.tabMenu.items[5].setDisabled(issheetlocked || isdocprotected); this.tabMenu.items[6].setDisabled(isdoclocked || isdocprotected); - this.tabMenu.items[7].setDisabled(issheetlocked || isdocprotected); + this.tabMenu.items[7].setDisabled(select.length>1); + this.tabMenu.items[8].setDisabled(issheetlocked || isdocprotected); + + this.tabMenu.items[7].setCaption(this.api.asc_isProtectedSheet() ? this.itemUnProtect : this.itemProtect); if (select.length === 1) { - this.tabMenu.items[10].hide(); + this.tabMenu.items[11].hide(); } else { - this.tabMenu.items[10].show(); + this.tabMenu.items[11].show(); } - this.tabMenu.items[9].setDisabled(issheetlocked || isdocprotected); this.tabMenu.items[10].setDisabled(issheetlocked || isdocprotected); + this.tabMenu.items[11].setDisabled(issheetlocked || isdocprotected); this.api.asc_closeCellEditor(); this.api.asc_enableKeyEvents(false); @@ -857,7 +861,9 @@ define([ itemCount : 'Count', itemMinimum : 'Minimum', itemMaximum : 'Maximum', - itemSum : 'Sum' + itemSum : 'Sum', + itemProtect : 'Protect', + itemUnProtect : 'Unprotect' }, SSE.Views.Statusbar || {})); SSE.Views.Statusbar.RenameDialog = Common.UI.Window.extend(_.extend({ diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 9737392c36..3b7ec4e908 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -2978,6 +2978,8 @@ "SSE.Views.Statusbar.itemRename": "Rename", "SSE.Views.Statusbar.itemSum": "Sum", "SSE.Views.Statusbar.itemTabColor": "Tab Color", + "SSE.Views.Statusbar.itemProtect": "Protect", + "SSE.Views.Statusbar.itemUnProtect": "Unprotect", "SSE.Views.Statusbar.RenameDialog.errNameExists": "Worksheet with such a name already exists.", "SSE.Views.Statusbar.RenameDialog.errNameWrongChar": "A sheet name cannot contain the following characters: \\/*?[]:", "SSE.Views.Statusbar.RenameDialog.labelSheetName": "Sheet Name", From 68f8032022da59eeca69cae29ef84a865086e4da Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 5 Aug 2021 14:11:18 +0300 Subject: [PATCH 40/50] [SSE] Support hints for protection tab --- apps/common/main/lib/view/Protection.js | 15 ++++++-- .../main/app/view/WBProtection.js | 35 +++++++++++++++---- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/apps/common/main/lib/view/Protection.js b/apps/common/main/lib/view/Protection.js index 7c607a539e..603d5bf13d 100644 --- a/apps/common/main/lib/view/Protection.js +++ b/apps/common/main/lib/view/Protection.js @@ -121,7 +121,10 @@ define([ this.btnAddPwd = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-ic-protect', - caption: this.txtEncrypt + caption: this.txtEncrypt, + dataHint : '1', + dataHintDirection: 'bottom', + dataHintOffset: 'small' }); this.btnsAddPwd.push(this.btnAddPwd); @@ -130,7 +133,10 @@ define([ iconCls: 'toolbar__icon btn-ic-protect', caption: this.txtEncrypt, menu: true, - visible: false + visible: false, + dataHint : '1', + dataHintDirection: 'bottom', + dataHintOffset: 'small' }); } if (this.appConfig.isSignatureSupport) { @@ -138,7 +144,10 @@ define([ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-ic-signature', caption: this.txtSignature, - menu: (this.appPrefix !== 'pe-') + menu: (this.appPrefix !== 'pe-'), + dataHint : '1', + dataHintDirection: 'bottom', + dataHintOffset: 'small' }); if (!this.btnSignature.menu) this.btnsInvisibleSignature.push(this.btnSignature); diff --git a/apps/spreadsheeteditor/main/app/view/WBProtection.js b/apps/spreadsheeteditor/main/app/view/WBProtection.js index 3bcc55f717..f1a076f307 100644 --- a/apps/spreadsheeteditor/main/app/view/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/view/WBProtection.js @@ -116,7 +116,10 @@ define([ iconCls: 'toolbar__icon protect-workbook', enableToggle: true, caption: this.txtProtectWB, - lock : [_set.selRangeEdit, _set.lostConnect, _set.coAuth] + lock : [_set.selRangeEdit, _set.lostConnect, _set.coAuth], + dataHint : '1', + dataHintDirection: 'bottom', + dataHintOffset: 'small' }); this.lockedControls.push(this.btnProtectWB); @@ -125,7 +128,10 @@ define([ iconCls: 'toolbar__icon protect-sheet', enableToggle: true, caption: this.txtProtectSheet, - lock : [_set.selRangeEdit, _set.lostConnect, _set.coAuth] + lock : [_set.selRangeEdit, _set.lostConnect, _set.coAuth], + dataHint : '1', + dataHintDirection: 'bottom', + dataHintOffset: 'small' }); this.lockedControls.push(this.btnProtectSheet); @@ -133,31 +139,46 @@ define([ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon allow-edit-ranges', caption: this.txtAllowRanges, - lock : [_set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock] + lock : [_set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock], + dataHint : '1', + dataHintDirection: 'bottom', + dataHintOffset: 'small' }); this.lockedControls.push(this.btnAllowRanges); this.chLockedCell = new Common.UI.CheckBox({ labelText: this.txtLockedCell, - lock : [_set.editCell, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.wsLock, _set.wbLock, _set.lostConnect, _set.coAuth] + lock : [_set.editCell, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.wsLock, _set.wbLock, _set.lostConnect, _set.coAuth], + dataHint : '1', + dataHintDirection: 'left', + dataHintOffset: 'small' }); this.lockedControls.push(this.chLockedCell); this.chLockedShape = new Common.UI.CheckBox({ labelText: this.txtLockedShape, - lock : [_set.selRange, _set.selRangeEdit, _set.wbLock, _set.lostConnect, _set.coAuth, _set['Objects'], _set.wsLockShape] + lock : [_set.selRange, _set.selRangeEdit, _set.wbLock, _set.lostConnect, _set.coAuth, _set['Objects'], _set.wsLockShape], + dataHint : '1', + dataHintDirection: 'left', + dataHintOffset: 'small' }); this.lockedControls.push(this.chLockedShape); this.chLockedText = new Common.UI.CheckBox({ labelText: this.txtLockedText, - lock : [_set.selRange, _set.selRangeEdit, _set.selRangeEdit, _set.selImage, _set.selSlicer, _set.wbLock, _set.lostConnect, _set.coAuth, _set['Objects'], _set.wsLockText] + lock : [_set.selRange, _set.selRangeEdit, _set.selRangeEdit, _set.selImage, _set.selSlicer, _set.wbLock, _set.lostConnect, _set.coAuth, _set['Objects'], _set.wsLockText], + dataHint : '1', + dataHintDirection: 'left', + dataHintOffset: 'small' }); this.lockedControls.push(this.chLockedText); this.chHiddenFormula = new Common.UI.CheckBox({ labelText: this.txtHiddenFormula, - lock : [_set.editCell, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.wsLock, _set.wbLock, _set.lostConnect, _set.coAuth] + lock : [_set.editCell, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.wsLock, _set.wbLock, _set.lostConnect, _set.coAuth], + dataHint : '1', + dataHintDirection: 'left', + dataHintOffset: 'small' }); this.lockedControls.push(this.chHiddenFormula); From 4ef10c6f06456228d4a90f7d49b4f8e8f5ccb759 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 5 Aug 2021 14:17:50 +0300 Subject: [PATCH 41/50] [SSE] Fix protection dialog --- apps/spreadsheeteditor/main/app/view/ProtectDialog.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js index 76b5151c85..b6ada38676 100644 --- a/apps/spreadsheeteditor/main/app/view/ProtectDialog.js +++ b/apps/spreadsheeteditor/main/app/view/ProtectDialog.js @@ -301,6 +301,8 @@ define([ record.set('check', !record.get('check')); if (record.get('optionName') == 'SelectLockedCells' && record.get('check')) this.optionsList.store.findWhere({optionName: 'SelectUnlockedCells'}).set('check', true); + if (record.get('optionName') == 'SelectUnlockedCells' && !record.get('check')) + this.optionsList.store.findWhere({optionName: 'SelectLockedCells'}).set('check', false); // listView.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true, suppressScrollX: true}); } }, From c9b181ea3f3970015d66f46e540fec4748b35b93 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 5 Aug 2021 18:53:04 +0300 Subject: [PATCH 42/50] Fix editing on protected sheet --- apps/spreadsheeteditor/main/app/controller/Main.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 148ae1d6a3..89b4fd7729 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -2152,14 +2152,10 @@ define([ txtOpenFile: this.txtUnlockRangeDescription, validatePwd: false, handler: function (result, value) { - if (result == 'ok') { - if (me.api) { - if (apiCallback) { - apiCallback(me.api.asc_checkProtectedRangesPassword(value.drmOptions.asc_getPassword(), data)); - } - } - me.onEditComplete(me.application.getController('DocumentHolder').getView('DocumentHolder')); + if (me.api && apiCallback) { + apiCallback((result == 'ok') ? me.api.asc_checkProtectedRangesPassword(value.drmOptions.asc_getPassword(), data) : false, result !== 'ok'); } + me.onEditComplete(me.application.getController('DocumentHolder').getView('DocumentHolder')); } }); win.show(); From d769334e38a7ee2df81658e62b03ca49fe093a62 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 5 Aug 2021 19:04:14 +0300 Subject: [PATCH 43/50] Refactoring --- apps/spreadsheeteditor/main/app/controller/Main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 89b4fd7729..73cc99db78 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1790,6 +1790,7 @@ define([ case Asc.c_oAscError.ID.ChangeOnProtectedSheet: config.msg = this.errorChangeOnProtectedSheet; + break; case Asc.c_oAscError.ID.SingleColumnOrRowError: config.msg = this.errorSingleColumnOrRowError; From 4fecc63ba0544f58391a59e940632ad6bb5feb8f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 5 Aug 2021 19:09:21 +0300 Subject: [PATCH 44/50] [SSE] Fix protect sheet --- .../main/app/controller/Toolbar.js | 7 ++- .../main/app/view/Toolbar.js | 47 ++++++++++--------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index ce82ce22c3..9de7ecafcb 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -2505,10 +2505,13 @@ define([ toolbar.btnImgAlign.menu.items[8].setDisabled(objcount<3); // disable on protected sheet + // lock formatting controls in cell with FormatCells protection or in shape and Objects protection need_disable = (selectionType === Asc.c_oAscSelectionType.RangeImage || selectionType === Asc.c_oAscSelectionType.RangeChart || selectionType === Asc.c_oAscSelectionType.RangeChartText || selectionType === Asc.c_oAscSelectionType.RangeShape || selectionType === Asc.c_oAscSelectionType.RangeShapeText || selectionType === Asc.c_oAscSelectionType.RangeSlicer); - toolbar.lockToolbar(need_disable ? SSE.enumLock['Objects'] : SSE.enumLock['FormatCells'], need_disable ? !!this._state.wsProps['Objects'] : !!this._state.wsProps['FormatCells'], - { clear: [SSE.enumLock['FormatCells'], SSE.enumLock['Objects']]}); + toolbar.lockToolbar(SSE.enumLock.wsLockFormat, need_disable && !!this._state.wsProps['Objects'] || !need_disable && !!this._state.wsProps['FormatCells']); + + toolbar.lockToolbar(SSE.enumLock['Objects'], !!this._state.wsProps['Objects']); + toolbar.lockToolbar(SSE.enumLock['FormatCells'], !!this._state.wsProps['FormatCells']); if (editOptionsDisabled) return; diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 1ed44bef43..723d340cf6 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -103,7 +103,8 @@ define([ wsLock: 'worksheet-lock', itemsDisabled: 'all-items-disabled', wsLockText: 'worksheet-lock-text', - wsLockShape: 'worksheet-lock-shape' + wsLockShape: 'worksheet-lock-shape', + wsLockFormat: 'worksheet-lock-format' }; SSE.Views.Toolbar = Common.UI.Mixtbar.extend(_.extend({ @@ -422,7 +423,7 @@ define([ id : 'id-toolbar-btn-incfont', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-incfont', - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.wsLockFormat], dataHint : '1', dataHintDirection: 'top' }); @@ -431,7 +432,7 @@ define([ id : 'id-toolbar-btn-decfont', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-decfont', - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.wsLockFormat], dataHint : '1', dataHintDirection: 'top' }); @@ -440,7 +441,7 @@ define([ id : 'id-toolbar-btn-bold', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-bold', - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.wsLockFormat], enableToggle: true, dataHint : '1', dataHintDirection: 'bottom' @@ -450,7 +451,7 @@ define([ id : 'id-toolbar-btn-italic', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-italic', - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.wsLockFormat], enableToggle: true, dataHint : '1', dataHintDirection: 'bottom' @@ -460,7 +461,7 @@ define([ id : 'id-toolbar-btn-underline', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-underline', - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.wsLockFormat], enableToggle: true, dataHint : '1', dataHintDirection: 'bottom' @@ -470,7 +471,7 @@ define([ id: 'id-toolbar-btn-strikeout', cls: 'btn-toolbar', iconCls: 'toolbar__icon btn-strikeout', - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.wsLockFormat], enableToggle: true, dataHint : '1', dataHintDirection: 'bottom' @@ -483,7 +484,7 @@ define([ icls : 'btn-subscript', split : true, enableToggle: true, - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.wsLockFormat], menu : new Common.UI.Menu({ items: [ { @@ -519,7 +520,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-fontcolor', split : true, - lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.wsLockFormat], menu: true, auto: true, dataHint : '1', @@ -533,7 +534,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-paracolor', split : true, - lock : [_set.selImage, _set.editCell, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set['FormatCells'], _set['Objects']], + lock : [_set.selImage, _set.editCell, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.wsLockFormat], transparent: true, menu: true, dataHint: '1', @@ -561,7 +562,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-align-left', enableToggle: true, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set.wsLockFormat], toggleGroup : 'alignGroup', dataHint : '1', dataHintDirection: 'bottom' @@ -572,7 +573,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-align-center', enableToggle: true, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set.wsLockFormat], toggleGroup : 'alignGroup', dataHint : '1', dataHintDirection: 'bottom' @@ -583,7 +584,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-align-right', enableToggle: true, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set.wsLockFormat], toggleGroup : 'alignGroup', dataHint : '1', dataHintDirection: 'bottom' @@ -594,7 +595,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-align-just', enableToggle: true, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set.wsLockFormat], toggleGroup: 'alignGroup', dataHint : '1', dataHintDirection: 'bottom' @@ -641,7 +642,7 @@ define([ id : 'id-toolbar-rtn-valign-top', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-align-top', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set.wsLockFormat], enableToggle: true, toggleGroup : 'vAlignGroup', dataHint : '1', @@ -653,7 +654,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-align-middle', enableToggle: true, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set.wsLockFormat], toggleGroup : 'vAlignGroup', dataHint : '1', dataHintDirection: 'top' @@ -663,7 +664,7 @@ define([ id : 'id-toolbar-rtn-valign-bottom', cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-align-bottom', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set.wsLockFormat], enableToggle: true, toggleGroup : 'vAlignGroup', dataHint : '1', @@ -685,7 +686,7 @@ define([ id : 'id-toolbar-rtn-textorient', cls : 'btn-toolbar', iconCls : 'toolbar__icon text-orient-ccw', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['FormatCells'], _set['Objects']], + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set.wsLockFormat], menu : new Common.UI.Menu({ items: [ { @@ -747,7 +748,7 @@ define([ cls : 'btn-toolbar x-huge icon-top', iconCls : 'toolbar__icon btn-insertimage', caption : me.capInsertImage, - lock : [_set.editCell, _set.lostConnect, _set.coAuth], + lock : [_set.editCell, _set.lostConnect, _set.coAuth, _set['Objects']], menu : new Common.UI.Menu({ items: [ { caption: me.mniImageFromFile, value: 'file' }, @@ -775,7 +776,7 @@ define([ id : 'tlbtn-insertchart', cls : 'btn-toolbar x-huge icon-top', iconCls : 'toolbar__icon btn-insertchart', - lock : [_set.editCell, _set.lostConnect, _set.coAuth, _set.coAuthText], + lock : [_set.editCell, _set.lostConnect, _set.coAuth, _set.coAuthText, _set['Objects']], caption : me.capInsertChart, menu : true, dataHint : '1', @@ -801,7 +802,7 @@ define([ iconCls : 'toolbar__icon btn-insertshape', enableToggle: true, caption : me.capInsertShape, - lock : [_set.editCell, _set.lostConnect, _set.coAuth], + lock : [_set.editCell, _set.lostConnect, _set.coAuth, _set['Objects']], menu : new Common.UI.Menu({cls: 'menu-shapes'}), dataHint : '1', dataHintDirection: 'bottom', @@ -813,7 +814,7 @@ define([ cls : 'btn-toolbar x-huge icon-top', iconCls : 'toolbar__icon btn-text', caption : me.capInsertText, - lock : [_set.editCell, _set.lostConnect, _set.coAuth], + lock : [_set.editCell, _set.lostConnect, _set.coAuth, _set['Objects']], enableToggle: true, dataHint : '1', dataHintDirection: 'bottom', @@ -825,7 +826,7 @@ define([ cls : 'btn-toolbar x-huge icon-top', iconCls : 'toolbar__icon btn-textart', caption : me.capInsertTextart, - lock : [_set.editCell, _set.lostConnect, _set.coAuth], + lock : [_set.editCell, _set.lostConnect, _set.coAuth, _set['Objects']], menu : new Common.UI.Menu({ cls: 'menu-shapes', items: [ From 85882cf1131bc6ae313e455a0146963fe32296ae Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Sun, 8 Aug 2021 23:10:52 +0300 Subject: [PATCH 45/50] [SSE] Fix hyperlinks editing. Add errors --- .../main/app/controller/DocumentHolder.js | 15 +++++---------- .../main/app/controller/Main.js | 19 +++++++++++++++++-- .../main/app/view/Toolbar.js | 2 +- apps/spreadsheeteditor/main/locale/en.json | 3 +++ 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index cade3f2e2d..ebe965730c 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -237,7 +237,7 @@ define([ view.menuParagraphBullets.menu.on('show:after', _.bind(me.onBulletMenuShowAfter, me)); view.menuAddHyperlinkShape.on('click', _.bind(me.onInsHyperlink, me)); view.menuEditHyperlinkShape.on('click', _.bind(me.onInsHyperlink, me)); - view.menuRemoveHyperlinkShape.on('click', _.bind(me.onRemoveHyperlinkShape, me)); + view.menuRemoveHyperlinkShape.on('click', _.bind(me.onDelHyperlink, me)); view.pmiTextAdvanced.on('click', _.bind(me.onTextAdvanced, me)); view.mnuShapeAdvanced.on('click', _.bind(me.onShapeAdvanced, me)); view.mnuChartEdit.on('click', _.bind(me.onChartEdit, me)); @@ -638,6 +638,10 @@ define([ }, onDelHyperlink: function(item) { + Common.NotificationCenter.trigger('protect:check', this.onDelHyperlinkCallback, this); + }, + + onDelHyperlinkCallback: function(item) { if (this.api) { this.api.asc_removeHyperlink(); @@ -898,15 +902,6 @@ define([ Common.component.Analytics.trackEvent('DocumentHolder', 'List Type'); }, - onRemoveHyperlinkShape: function(item) { - if (this.api) { - this.api.asc_removeHyperlink(); - - Common.NotificationCenter.trigger('edit:complete', this.documentHolder); - Common.component.Analytics.trackEvent('DocumentHolder', 'Remove Hyperlink'); - } - }, - onTextAdvanced: function(item) { var me = this; diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 73cc99db78..72b37c1099 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1800,6 +1800,18 @@ define([ config.msg = this.errorLocationOrDataRangeError; break; + case Asc.c_oAscError.ID.PasswordIsNotCorrect: + config.msg = this.errorPasswordIsNotCorrect; + break; + + case Asc.c_oAscError.ID.DeleteColumnContainsLockedCell: + config.msg = this.errorDeleteColumnContainsLockedCell; + break; + + case Asc.c_oAscError.ID.DeleteRowContainsLockedCell: + config.msg = this.errorDeleteRowContainsLockedCell; + break; + default: config.msg = (typeof id == 'string') ? id : this.errorDefaultMessage.replace('%1', id); break; @@ -2164,7 +2176,7 @@ define([ }, checkProtectedRange: function(callback, scope, args) { - var result = this.api.asc_checkActiveCellProtectedRange(); + var result = this.api.asc_isProtectedSheet() ? this.api.asc_checkActiveCellProtectedRange() : false; if (result===null) { this.onError(Asc.c_oAscError.ID.ChangeOnProtectedSheet, Asc.c_oAscError.Level.NoCritical); return; @@ -3311,7 +3323,10 @@ define([ textLearnMore: 'Learn More', errorSingleColumnOrRowError: 'Location reference is not valid because the cells are not all in the same column or row.
Select cells that are all in a single column or row.', errorLocationOrDataRangeError: 'The reference for the location or data range is not valid.', - txtErrorLoadHistory: 'Loading history failed' + txtErrorLoadHistory: 'Loading history failed', + errorPasswordIsNotCorrect: 'The password you supplied is not correct.
Verify that the CAPS LOCK key is off and be sure to use the correct capitalization.', + errorDeleteColumnContainsLockedCell: 'You are trying to delete a column that contains a locked cell. Locked cells cannot be deleted while the worksheet is protected.
To delete a locked cell, unprotect the sheet. You might be requested to enter a password.', + errorDeleteRowContainsLockedCell: 'You are trying to delete a row that contains a locked cell. Locked cells cannot be deleted while the worksheet is protected.
To delete a locked cell, unprotect the sheet. You might be requested to enter a password.' } })(), SSE.Controllers.Main || {})) }); diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 723d340cf6..a11d75f43a 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -1219,7 +1219,7 @@ define([ cls : 'btn-toolbar x-huge icon-top', iconCls : 'toolbar__icon btn-colorschemas', caption : me.capBtnColorSchemas, - lock : [_set.editCell, _set.lostConnect, _set.coAuth], + lock : [_set.editCell, _set.lostConnect, _set.coAuth, _set.wsLock], menu : new Common.UI.Menu({ cls: 'shifted-left', items: [], diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index b7605e2da2..03703ded1c 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -707,6 +707,9 @@ "SSE.Controllers.Main.errorViewerDisconnect": "Connection is lost. You can still view the document,
but will not be able to download or print it until the connection is restored and page is reloaded.", "SSE.Controllers.Main.errorWrongBracketsCount": "An error in the entered formula.
Wrong number of brackets is used.", "SSE.Controllers.Main.errorWrongOperator": "An error in the entered formula. Wrong operator is used.
Please correct the error.", + "SSE.Controllers.Main.errorPasswordIsNotCorrect": "The password you supplied is not correct.
Verify that the CAPS LOCK key is off and be sure to use the correct capitalization.", + "SSE.Controllers.Main.errorDeleteColumnContainsLockedCell": "You are trying to delete a column that contains a locked cell. Locked cells cannot be deleted while the worksheet is protected.
To delete a locked cell, unprotect the sheet. You might be requested to enter a password.", + "SSE.Controllers.Main.errorDeleteRowContainsLockedCell": "You are trying to delete a row that contains a locked cell. Locked cells cannot be deleted while the worksheet is protected.
To delete a locked cell, unprotect the sheet. You might be requested to enter a password.", "SSE.Controllers.Main.errRemDuplicates": "Duplicate values found and deleted: {0}, unique values left: {1}.", "SSE.Controllers.Main.leavePageText": "You have unsaved changes in this spreadsheet. Click 'Stay on this Page' then 'Save' to save them. Click 'Leave this Page' to discard all the unsaved changes.", "SSE.Controllers.Main.leavePageTextOnClose": "All unsaved changes in this spreadsheet will be lost.
Click \"Cancel\" then \"Save\" to save them. Click \"OK\" to discard all the unsaved changes.", From cda49d94f8dfb665991ae3a85ffe615587291e34 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 9 Aug 2021 01:00:41 +0300 Subject: [PATCH 46/50] [SSE] Disable name manager on protected sheet. Disable adding comments when objects are protected --- apps/spreadsheeteditor/main/app/controller/CellEditor.js | 1 + apps/spreadsheeteditor/main/app/controller/DocumentHolder.js | 5 ++++- apps/spreadsheeteditor/main/app/controller/Toolbar.js | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/CellEditor.js b/apps/spreadsheeteditor/main/app/controller/CellEditor.js index f6f88365fb..ba3f04cc04 100644 --- a/apps/spreadsheeteditor/main/app/controller/CellEditor.js +++ b/apps/spreadsheeteditor/main/app/controller/CellEditor.js @@ -316,6 +316,7 @@ define([ } prev_name = name; }); + this.editor.btnNamedRanges.menu.items[0].setDisabled(!!this.api.asc_isProtectedSheet()); this.editor.btnNamedRanges.menu.items[1].setVisible(rangesMenu.items.length>2); }, diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index ebe965730c..a54a0ba105 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -701,6 +701,8 @@ define([ }, onAddComment: function(item) { + if (this._state.wsProps['Objects']) return; + if (this.api && this.permissions.canCoAuthoring && this.permissions.canComments) { var controller = SSE.getController('Common.Controllers.Comments'), @@ -2111,6 +2113,7 @@ define([ documentHolder.pmiSparklines.setDisabled(isCellLocked || this._state.wsLock); documentHolder.pmiEntriesList.setDisabled(isCellLocked || this._state.wsLock); documentHolder.pmiAddNamedRange.setDisabled(isCellLocked || this._state.wsLock); + documentHolder.pmiAddComment.setDisabled(isCellLocked || this._state.wsProps['Objects']); if (inPivot) { var canGroup = this.api.asc_canGroupPivot(); @@ -2182,7 +2185,7 @@ define([ documentHolder.menuViewAddComment.setVisible(canComment); commentsController && commentsController.blockPopover(true); - documentHolder.menuViewAddComment.setDisabled(isCellLocked || isTableLocked); + documentHolder.menuViewAddComment.setDisabled(isCellLocked || isTableLocked || this._state.wsProps['Objects']); if (showMenu) this.showPopupMenu(documentHolder.viewModeMenu, {}, event); if (isInSign) { diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 9de7ecafcb..94e5cbfa08 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -3762,7 +3762,8 @@ define([ this.btnsComment = []; if ( config.canCoAuthoring && config.canComments ) { var _set = SSE.enumLock; - this.btnsComment = Common.Utils.injectButtons(this.toolbar.$el.find('.slot-comment'), 'tlbtn-addcomment-', 'toolbar__icon btn-menu-comments', this.toolbar.capBtnComment, [_set.lostConnect, _set.commentLock, _set.editCell], undefined, undefined, undefined, '1', 'bottom', 'small'); + this.btnsComment = Common.Utils.injectButtons(this.toolbar.$el.find('.slot-comment'), 'tlbtn-addcomment-', 'toolbar__icon btn-menu-comments', this.toolbar.capBtnComment, + [_set.lostConnect, _set.commentLock, _set.editCell, _set['Objects']], undefined, undefined, undefined, '1', 'bottom', 'small'); if ( this.btnsComment.length ) { var _comments = SSE.getController('Common.Controllers.Comments').getView(); From aad48853981432dd9a28032fe035c40ac081db09 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 10 Aug 2021 17:49:40 +0300 Subject: [PATCH 47/50] [SSE] Fix clear format on protected sheet --- .../main/app/controller/DocumentHolder.js | 7 ++++++- apps/spreadsheeteditor/main/app/controller/Main.js | 3 ++- apps/spreadsheeteditor/main/app/controller/Toolbar.js | 7 ++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index a54a0ba105..292291c02c 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -537,7 +537,12 @@ define([ }, onClear: function(menu, item, e) { - Common.NotificationCenter.trigger('protect:check', this.onClearCallback, this, [menu, item]); + if (item.value == Asc.c_oAscCleanOptions.Format && !this._state.wsProps['FormatCells'] || item.value == Asc.c_oAscCleanOptions.All && !this.api.asc_checkLockedCells()) + this.onClearCallback(menu, item); + else if (item.value == Asc.c_oAscCleanOptions.Comments) { + this._state.wsProps['Objects'] ? Common.NotificationCenter.trigger('showerror', Asc.c_oAscError.ID.ChangeOnProtectedSheet, Asc.c_oAscError.Level.NoCritical) : this.onClearCallback(menu, item); + } else + Common.NotificationCenter.trigger('protect:check', this.onClearCallback, this, [menu, item]); }, onClearCallback: function(menu, item) { diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 72b37c1099..bc87c09553 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -215,6 +215,7 @@ define([ Common.NotificationCenter.on('markfavorite', _.bind(this.markFavorite, this)); Common.NotificationCenter.on('protect:check', _.bind(this.checkProtectedRange, this)); Common.NotificationCenter.on('editing:disable', _.bind(this.onEditingDisable, this)); + Common.NotificationCenter.on('showerror', _.bind(this.onError, this)); this.stackLongActions = new Common.IrregularStack({ strongCompare : this._compareActionStrong, @@ -2176,7 +2177,7 @@ define([ }, checkProtectedRange: function(callback, scope, args) { - var result = this.api.asc_isProtectedSheet() ? this.api.asc_checkActiveCellProtectedRange() : false; + var result = this.api.asc_isProtectedSheet() ? this.api.asc_checkProtectedRange() : false; if (result===null) { this.onError(Asc.c_oAscError.ID.ChangeOnProtectedSheet, Asc.c_oAscError.Level.NoCritical); return; diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 94e5cbfa08..1c5ead2424 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -1462,7 +1462,12 @@ define([ }, onClearStyleMenu: function(menu, item, e) { - Common.NotificationCenter.trigger('protect:check', this.onClearStyleMenuCallback, this, [menu, item]); + if (item.value == Asc.c_oAscCleanOptions.Format && !this._state.wsProps['FormatCells'] || item.value == Asc.c_oAscCleanOptions.All && !this.api.asc_checkLockedCells()) + this.onClearStyleMenuCallback(menu, item); + else if (item.value == Asc.c_oAscCleanOptions.Comments) { + this._state.wsProps['Objects'] ? Common.NotificationCenter.trigger('showerror', Asc.c_oAscError.ID.ChangeOnProtectedSheet, Asc.c_oAscError.Level.NoCritical) : this.onClearStyleMenuCallback(menu, item); + } else + Common.NotificationCenter.trigger('protect:check', this.onClearStyleMenuCallback, this, [menu, item]); }, onClearStyleMenuCallback: function(menu, item, e) { From dea0fb93d5c848a8a0d04734a8bc4764a8913e93 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 11 Aug 2021 00:24:12 +0300 Subject: [PATCH 48/50] [SSE] Change check sorted range --- .../main/app/controller/DataTab.js | 67 +++++++++++++------ .../main/app/controller/DocumentHolder.js | 65 +++++++++++------- .../main/app/controller/Toolbar.js | 55 ++++++++++----- apps/spreadsheeteditor/main/locale/en.json | 2 + apps/spreadsheeteditor/mobile/locale/en.json | 5 +- .../mobile/src/controller/add/AddFilter.jsx | 37 ++++++++-- 6 files changed, 161 insertions(+), 70 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js index 2d6a123969..5e965b1cc0 100644 --- a/apps/spreadsheeteditor/main/app/controller/DataTab.js +++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js @@ -279,29 +279,52 @@ define([ }, onCustomSort: function() { + Common.NotificationCenter.trigger('protect:check', this.onCustomSortCallback, this); + }, + + onCustomSortCallback: function() { var me = this; if (this.api) { var res = this.api.asc_sortCellsRangeExpand(); - if (res) { - var config = { - width: 500, - title: this.toolbar.txtSorting, - msg: this.toolbar.txtExpandSort, - - buttons: [ {caption: this.toolbar.txtExpand, primary: true, value: 'expand'}, - {caption: this.toolbar.txtSortSelected, primary: true, value: 'sort'}, - 'cancel'], - callback: function(btn){ - if (btn == 'expand' || btn == 'sort') { - setTimeout(function(){ - me.showCustomSort(btn == 'expand'); - },1); + switch (res) { + case Asc.c_oAscSelectionSortExpand.showExpandMessage: + var config = { + width: 500, + title: this.toolbar.txtSorting, + msg: this.toolbar.txtExpandSort, + buttons: [ {caption: this.toolbar.txtExpand, primary: true, value: 'expand'}, + {caption: this.toolbar.txtSortSelected, primary: true, value: 'sort'}, + 'cancel'], + callback: function(btn){ + if (btn == 'expand' || btn == 'sort') { + setTimeout(function(){ + me.showCustomSort(btn == 'expand'); + },1); + } } - } - }; - Common.UI.alert(config); - } else - me.showCustomSort(res !== null); + }; + Common.UI.alert(config); + break; + case Asc.c_oAscSelectionSortExpand.showLockMessage: + var config = { + width: 500, + title: this.toolbar.txtSorting, + msg: this.toolbar.txtLockSort, + buttons: ['yes', 'no'], + primary: 'yes', + callback: function(btn){ + (btn == 'yes') && setTimeout(function(){ + me.showCustomSort(false); + },1); + } + }; + Common.UI.alert(config); + break; + case Asc.c_oAscSelectionSortExpand.expandAndNotShowMessage: + case Asc.c_oAscSelectionSortExpand.notExpandAndNotShowMessage: + me.showCustomSort(res === Asc.c_oAscSelectionSortExpand.expandAndNotShowMessage); + break; + } } }, @@ -326,7 +349,7 @@ define([ var me = this; if (this.api) { var res = this.api.asc_sortCellsRangeExpand(); - if (res) { + if (res===Asc.c_oAscSelectionSortExpand.showExpandMessage) { var config = { width: 500, title: this.txtRemDuplicates, @@ -343,8 +366,8 @@ define([ } }; Common.UI.alert(config); - } else - me.showRemDuplicates(res !== null); + } else if (res !== Asc.c_oAscSelectionSortExpand.showLockMessage) + me.showRemDuplicates(res===Asc.c_oAscSelectionSortExpand.expandAndNotShowMessage); } }, diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 292291c02c..9a5343f468 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -436,28 +436,46 @@ define([ } if (this.api) { var res = this.api.asc_sortCellsRangeExpand(); - if (res) { - var config = { - width: 500, - title: this.txtSorting, - msg: this.txtExpandSort, - buttons: [ {caption: this.txtExpand, primary: true, value: 'expand'}, - {caption: this.txtSortSelected, primary: true, value: 'sort'}, - 'cancel'], - callback: _.bind(function(btn){ - if (btn == 'expand' || btn == 'sort') { - this.api.asc_sortColFilter(item.value, '', undefined, (item.value==Asc.c_oAscSortOptions.ByColorFill) ? this.documentHolder.ssMenu.cellColor : this.documentHolder.ssMenu.fontColor, btn == 'expand'); - } - Common.NotificationCenter.trigger('edit:complete', this.documentHolder); - Common.component.Analytics.trackEvent('DocumentHolder', 'Sort Cells'); - }, this) - }; - Common.UI.alert(config); - } else { - this.api.asc_sortColFilter(item.value, '', undefined, (item.value==Asc.c_oAscSortOptions.ByColorFill) ? this.documentHolder.ssMenu.cellColor : this.documentHolder.ssMenu.fontColor, res !== null); - - Common.NotificationCenter.trigger('edit:complete', this.documentHolder); - Common.component.Analytics.trackEvent('DocumentHolder', 'Sort Cells'); + switch (res) { + case Asc.c_oAscSelectionSortExpand.showExpandMessage: + var config = { + width: 500, + title: this.txtSorting, + msg: this.txtExpandSort, + buttons: [ {caption: this.txtExpand, primary: true, value: 'expand'}, + {caption: this.txtSortSelected, primary: true, value: 'sort'}, + 'cancel'], + callback: _.bind(function(btn){ + if (btn == 'expand' || btn == 'sort') { + this.api.asc_sortColFilter(item.value, '', undefined, (item.value==Asc.c_oAscSortOptions.ByColorFill) ? this.documentHolder.ssMenu.cellColor : this.documentHolder.ssMenu.fontColor, btn == 'expand'); + } + Common.NotificationCenter.trigger('edit:complete', this.documentHolder); + Common.component.Analytics.trackEvent('DocumentHolder', 'Sort Cells'); + }, this) + }; + Common.UI.alert(config); + break; + case Asc.c_oAscSelectionSortExpand.showLockMessage: + var config = { + width: 500, + title: this.txtSorting, + msg: this.txtLockSort, + buttons: ['yes', 'no'], + primary: 'yes', + callback: _.bind(function(btn){ + (btn == 'yes') && this.api.asc_sortColFilter(item.value, '', undefined, (item.value==Asc.c_oAscSortOptions.ByColorFill) ? this.documentHolder.ssMenu.cellColor : this.documentHolder.ssMenu.fontColor, false); + Common.NotificationCenter.trigger('edit:complete', this.documentHolder); + Common.component.Analytics.trackEvent('DocumentHolder', 'Sort Cells'); + }, this) + }; + Common.UI.alert(config); + break; + case Asc.c_oAscSelectionSortExpand.expandAndNotShowMessage: + case Asc.c_oAscSelectionSortExpand.notExpandAndNotShowMessage: + this.api.asc_sortColFilter(item.value, '', undefined, (item.value==Asc.c_oAscSortOptions.ByColorFill) ? this.documentHolder.ssMenu.cellColor : this.documentHolder.ssMenu.fontColor, res === Asc.c_oAscSelectionSortExpand.expandAndNotShowMessage); + Common.NotificationCenter.trigger('edit:complete', this.documentHolder); + Common.component.Analytics.trackEvent('DocumentHolder', 'Sort Cells'); + break; } } }, @@ -3924,7 +3942,8 @@ define([ txtImportWizard: 'Text Import Wizard', textPasteSpecial: 'Paste special', textStopExpand: 'Stop automatically expanding tables', - textAutoCorrectSettings: 'AutoCorrect options' + textAutoCorrectSettings: 'AutoCorrect options', + txtLockSort: 'Data is found next to your selection, but you do not have sufficient permissions to change those cells.
Do you wish to continue with the current selection?' }, SSE.Controllers.DocumentHolder || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 1c5ead2424..66791b48a6 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -1202,25 +1202,43 @@ define([ } Common.NotificationCenter.trigger('edit:complete', this.toolbar); } else { + var me = this; var res = this.api.asc_sortCellsRangeExpand(); - if (res) { - var config = { - width: 500, - title: this.txtSorting, - msg: this.txtExpandSort, - - buttons: [ {caption: this.txtExpand, primary: true, value: 'expand'}, - {caption: this.txtSortSelected, primary: true, value: 'sort'}, - 'cancel'], - callback: _.bind(function(btn){ - if (btn == 'expand' || btn == 'sort') { - this.api.asc_sortColFilter(type, '', undefined, undefined, btn == 'expand'); + switch (res) { + case Asc.c_oAscSelectionSortExpand.showExpandMessage: + var config = { + width: 500, + title: this.txtSorting, + msg: this.txtExpandSort, + buttons: [ {caption: this.txtExpand, primary: true, value: 'expand'}, + {caption: this.txtSortSelected, primary: true, value: 'sort'}, + 'cancel'], + callback: function(btn){ + if (btn == 'expand' || btn == 'sort') { + me.api.asc_sortColFilter(type, '', undefined, undefined, btn == 'expand') + } } - }, this) - }; - Common.UI.alert(config); - } else - this.api.asc_sortColFilter(type, '', undefined, undefined, res !== null); + }; + Common.UI.alert(config); + break; + case Asc.c_oAscSelectionSortExpand.showLockMessage: + var config = { + width: 500, + title: this.txtSorting, + msg: this.txtLockSort, + buttons: ['yes', 'no'], + primary: 'yes', + callback: function(btn){ + (btn == 'yes') && me.api.asc_sortColFilter(type, '', undefined, undefined, false); + } + }; + Common.UI.alert(config); + break; + case Asc.c_oAscSelectionSortExpand.expandAndNotShowMessage: + case Asc.c_oAscSelectionSortExpand.notExpandAndNotShowMessage: + this.api.asc_sortColFilter(type, '', undefined, undefined, res === Asc.c_oAscSelectionSortExpand.expandAndNotShowMessage); + break; + } } } }, @@ -4403,7 +4421,8 @@ define([ textDirectional: 'Directional', textShapes: 'Shapes', textIndicator: 'Indicators', - textRating: 'Ratings' + textRating: 'Ratings', + txtLockSort: 'Data is found next to your selection, but you do not have sufficient permissions to change those cells.
Do you wish to continue with the current selection?' }, SSE.Controllers.Toolbar || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 03703ded1c..8f33a562fb 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -587,6 +587,7 @@ "SSE.Controllers.DocumentHolder.txtUndoExpansion": "Undo table autoexpansion", "SSE.Controllers.DocumentHolder.txtUseTextImport": "Use text import wizard", "SSE.Controllers.DocumentHolder.txtWidth": "Width", + "SSE.Controllers.DocumentHolder.txtLockSort": "Data is found next to your selection, but you do not have sufficient permissions to change those cells.
Do you wish to continue with the current selection?", "SSE.Controllers.FormulaDialog.sCategoryAll": "All", "SSE.Controllers.FormulaDialog.sCategoryCube": "Cube", "SSE.Controllers.FormulaDialog.sCategoryDatabase": "Database", @@ -1401,6 +1402,7 @@ "SSE.Controllers.Toolbar.txtTable_TableStyleMedium": "Table Style Medium", "SSE.Controllers.Toolbar.warnLongOperation": "The operation you are about to perform might take rather much time to complete.
Are you sure you want to continue?", "SSE.Controllers.Toolbar.warnMergeLostData": "Only the data from the upper-left cell will remain in the merged cell.
Are you sure you want to continue?", + "SSE.Controllers.Toolbar.txtLockSort": "Data is found next to your selection, but you do not have sufficient permissions to change those cells.
Do you wish to continue with the current selection?", "SSE.Controllers.Viewport.textFreezePanes": "Freeze Panes", "SSE.Controllers.Viewport.textFreezePanesShadow": "Show Frozen Panes Shadow", "SSE.Controllers.Viewport.textHideFBar": "Hide Formula Bar", diff --git a/apps/spreadsheeteditor/mobile/locale/en.json b/apps/spreadsheeteditor/mobile/locale/en.json index ad93cc4816..9211947d1d 100644 --- a/apps/spreadsheeteditor/mobile/locale/en.json +++ b/apps/spreadsheeteditor/mobile/locale/en.json @@ -333,7 +333,10 @@ "txtExpandSort": "The data next to the selection will not be sorted. Do you want to expand the selection to include the adjacent data or continue with sorting the currently selected cells only?", "txtNotUrl": "This field should be a URL in the format \"http://www.example.com\"", "txtSorting": "Sorting", - "txtSortSelected": "Sort selected" + "txtSortSelected": "Sort selected", + "txtLockSort": "Data is found next to your selection, but you do not have sufficient permissions to change those cells.
Do you wish to continue with the current selection?", + "txtYes": "Yes", + "txtNo": "No" }, "Edit": { "notcriticalErrorTitle": "Warning", diff --git a/apps/spreadsheeteditor/mobile/src/controller/add/AddFilter.jsx b/apps/spreadsheeteditor/mobile/src/controller/add/AddFilter.jsx index 634b8d32df..5a94bdccc7 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/add/AddFilter.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/add/AddFilter.jsx @@ -48,7 +48,9 @@ class AddFilterController extends Component { f7.popover.close('#add-popover'); let typeCheck = type == 'down' ? Asc.c_oAscSortOptions.Ascending : Asc.c_oAscSortOptions.Descending; - if( api.asc_sortCellsRangeExpand()) { + let res = api.asc_sortCellsRangeExpand(); + switch (res) { + case Asc.c_oAscSelectionSortExpand.showExpandMessage: f7.dialog.create({ title: _t.txtSorting, text: _t.txtExpandSort, @@ -63,18 +65,41 @@ class AddFilterController extends Component { { text: _t.txtSortSelected, bold: true, - onClick: () => { - api.asc_sortColFilter(typeCheck, '', undefined, undefined); + onClick: () => { + api.asc_sortColFilter(typeCheck, '', undefined, undefined); } }, { text: _t.textCancel } ], - verticalButtons: true, + verticalButtons: true }).open(); - } else - api.asc_sortColFilter(typeCheck, '', undefined, undefined, api.asc_sortCellsRangeExpand() !== null); + break; + case Asc.c_oAscSelectionSortExpand.showLockMessage: + f7.dialog.create({ + title: _t.txtSorting, + text: _t.txtLockSort, + buttons: [ + { + text: _t.txtYes, + bold: true, + onClick: () => { + api.asc_sortColFilter(typeCheck, '', undefined, undefined, false); + } + }, + { + text: _t.txtNo + } + ], + verticalButtons: true + }).open(); + break; + case Asc.c_oAscSelectionSortExpand.expandAndNotShowMessage: + case Asc.c_oAscSelectionSortExpand.notExpandAndNotShowMessage: + api.asc_sortColFilter(typeCheck, '', undefined, undefined, res === Asc.c_oAscSelectionSortExpand.expandAndNotShowMessage); + break; + } } onInsertFilter (checked) { From c1a400019c50d70d0892a85c4cd1d6762f9a7a2f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 11 Aug 2021 18:42:03 +0300 Subject: [PATCH 49/50] [SSE] Clear format for unlocked cells --- apps/spreadsheeteditor/main/app/controller/Toolbar.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 66791b48a6..46b529a597 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -1480,7 +1480,8 @@ define([ }, onClearStyleMenu: function(menu, item, e) { - if (item.value == Asc.c_oAscCleanOptions.Format && !this._state.wsProps['FormatCells'] || item.value == Asc.c_oAscCleanOptions.All && !this.api.asc_checkLockedCells()) + if (item.value == Asc.c_oAscCleanOptions.Format && (!this._state.wsProps['FormatCells'] || !this.api.asc_checkLockedCells()) || + item.value == Asc.c_oAscCleanOptions.All && !this.api.asc_checkLockedCells()) this.onClearStyleMenuCallback(menu, item); else if (item.value == Asc.c_oAscCleanOptions.Comments) { this._state.wsProps['Objects'] ? Common.NotificationCenter.trigger('showerror', Asc.c_oAscError.ID.ChangeOnProtectedSheet, Asc.c_oAscError.Level.NoCritical) : this.onClearStyleMenuCallback(menu, item); From eb93f3562ae0801d38475000f0bcd3885cd9e3a1 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 12 Aug 2021 01:42:14 +0300 Subject: [PATCH 50/50] [SSE] Fix getting protection options --- .../main/app/controller/WBProtection.js | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/WBProtection.js b/apps/spreadsheeteditor/main/app/controller/WBProtection.js index 7a6b8f69be..53ae60bd0c 100644 --- a/apps/spreadsheeteditor/main/app/controller/WBProtection.js +++ b/apps/spreadsheeteditor/main/app/controller/WBProtection.js @@ -91,7 +91,7 @@ define([ this.api = api; this.api.asc_registerCallback('asc_onChangeProtectWorkbook',_.bind(this.onChangeProtectWorkbook, this)); this.api.asc_registerCallback('asc_onChangeProtectWorksheet',_.bind(this.onChangeProtectSheet, this)); - this.api.asc_registerCallback('asc_onSheetsChanged', _.bind(this.onApiSheetChanged, this)); + this.api.asc_registerCallback('asc_onActiveSheetChanged', _.bind(this.onActiveSheetChanged, this)); this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onApiSelectionChanged, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); } @@ -290,7 +290,7 @@ define([ }, onChangeProtectSheet: function() { - var props = this.getWSProps(); + var props = this.getWSProps(true); this.view.btnProtectSheet.toggle(props.wsLock, true); //current sheet Common.Utils.lockControls(SSE.enumLock['Objects'], props.wsProps['Objects'], { array: [this.view.chLockedText, this.view.chLockedShape]}); @@ -298,26 +298,29 @@ define([ Common.NotificationCenter.trigger('protect:wslock', props); }, - onApiSheetChanged: function() { + onActiveSheetChanged: function() { this.onChangeProtectSheet(); //current sheet }, - getWSProps: function() { - var wsProtected = !!this.api.asc_isProtectedSheet(); - var arr = []; - if (wsProtected) { - arr = []; - var props = this.api.asc_getProtectedSheet(); - props && this.wsLockOptions.forEach(function(item){ - arr[item] = props['asc_get' + item] ? props['asc_get' + item]() : false; - }); - } else { - this.wsLockOptions.forEach(function(item){ - arr[item] = false; - }); + getWSProps: function(update) { + if (update || !this._state.protection) { + var wsProtected = !!this.api.asc_isProtectedSheet(); + var arr = []; + if (wsProtected) { + arr = []; + var props = this.api.asc_getProtectedSheet(); + props && this.wsLockOptions.forEach(function(item){ + arr[item] = props['asc_get' + item] ? props['asc_get' + item]() : false; + }); + } else { + this.wsLockOptions.forEach(function(item){ + arr[item] = false; + }); + } + this._state.protection = {wsLock: wsProtected, wsProps: arr}; } - return {wsLock: wsProtected, wsProps: arr}; + return this._state.protection; }, onApiSelectionChanged: function(info) {