From 13f8303776832b6843944919f0ca27c403d3e7da Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 22 Sep 2021 19:17:14 +0300 Subject: [PATCH] Add Save form button --- .../main/app/controller/FormsTab.js | 7 ++++- .../main/app/controller/Main.js | 3 +- apps/documenteditor/main/app/view/FormsTab.js | 27 ++++++++++++++---- apps/documenteditor/main/locale/en.json | 2 ++ .../img/toolbar/1.25x/big/save-form.png | Bin 0 -> 440 bytes .../img/toolbar/1.5x/big/save-form.png | Bin 0 -> 471 bytes .../img/toolbar/1.75x/big/save-form.png | Bin 0 -> 485 bytes .../img/toolbar/1x/big/save-form.png | Bin 0 -> 424 bytes .../img/toolbar/2x/big/save-form.png | Bin 0 -> 682 bytes 9 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 apps/documenteditor/main/resources/img/toolbar/1.25x/big/save-form.png create mode 100644 apps/documenteditor/main/resources/img/toolbar/1.5x/big/save-form.png create mode 100644 apps/documenteditor/main/resources/img/toolbar/1.75x/big/save-form.png create mode 100644 apps/documenteditor/main/resources/img/toolbar/1x/big/save-form.png create mode 100644 apps/documenteditor/main/resources/img/toolbar/2x/big/save-form.png diff --git a/apps/documenteditor/main/app/controller/FormsTab.js b/apps/documenteditor/main/app/controller/FormsTab.js index 9f39fe260..ffda935a8 100644 --- a/apps/documenteditor/main/app/controller/FormsTab.js +++ b/apps/documenteditor/main/app/controller/FormsTab.js @@ -95,7 +95,8 @@ define([ 'forms:select-color': this.onSelectControlsColor, 'forms:mode': this.onModeClick, 'forms:goto': this.onGoTo, - 'forms:submit': this.onSubmitClick + 'forms:submit': this.onSubmitClick, + 'forms:save': this.onSaveFormClick } }); }, @@ -245,6 +246,10 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, + onSaveFormClick: function() { + this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.OFORM)); + }, + disableEditing: function(disable) { if (this._state.DisabledEditing != disable) { this._state.DisabledEditing = disable; diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 1bc219688..74e7cbdac 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1415,7 +1415,7 @@ define([ this.appOptions.canProtect = (this.appOptions.isSignatureSupport || this.appOptions.isPasswordSupport); this.appOptions.canEditContentControl = (this.permissions.modifyContentControl!==false); this.appOptions.canHelp = !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.help===false); - this.appOptions.canSubmitForms = this.appOptions.canLicense && (typeof (this.editorConfig.customization) == 'object') && !!this.editorConfig.customization.submitForm; + this.appOptions.canSubmitForms = false; // this.appOptions.canLicense && (typeof (this.editorConfig.customization) == 'object') && !!this.editorConfig.customization.submitForm; this.appOptions.canFillForms = this.appOptions.canLicense && ((this.permissions.fillForms===undefined) ? this.appOptions.isEdit : this.permissions.fillForms) && (this.editorConfig.mode !== 'view'); this.appOptions.isRestrictedEdit = !this.appOptions.isEdit && (this.appOptions.canComments || this.appOptions.canFillForms); if (this.appOptions.isRestrictedEdit && this.appOptions.canComments && this.appOptions.canFillForms) // must be one restricted mode, priority for filling forms @@ -1434,6 +1434,7 @@ define([ var type = /^(?:(pdf|djvu|xps))$/.exec(this.document.fileType); this.appOptions.canDownloadOrigin = this.permissions.download !== false && (type && typeof type[1] === 'string'); this.appOptions.canDownload = this.permissions.download !== false && (!type || typeof type[1] !== 'string'); + this.appOptions.canDownloadForms = this.appOptions.canLicense && this.appOptions.canDownload; this.appOptions.fileKey = this.document.key; diff --git a/apps/documenteditor/main/app/view/FormsTab.js b/apps/documenteditor/main/app/view/FormsTab.js index 665c90c4b..b43f30aba 100644 --- a/apps/documenteditor/main/app/view/FormsTab.js +++ b/apps/documenteditor/main/app/view/FormsTab.js @@ -75,6 +75,7 @@ define([ '' + ''; @@ -124,6 +125,9 @@ define([ this.btnSubmit && this.btnSubmit.on('click', function (b, e) { me.fireEvent('forms:submit'); }); + this.btnSaveForm && this.btnSaveForm.on('click', function (b, e) { + me.fireEvent('forms:save'); + }); } return { @@ -292,6 +296,17 @@ define([ }); this.paragraphControls.push(this.btnSubmit); } + if (this.appConfig.canDownloadForms) { + this.btnSaveForm = new Common.UI.Button({ + cls: 'btn-toolbar x-huge icon-top', + iconCls: 'toolbar__icon save-form', + caption: this.capBtnSaveForm, + dataHint: '1', + dataHintDirection: 'bottom', + dataHintOffset: 'small' + }); + this.paragraphControls.push(this.btnSaveForm); + } this._state = {disabled: false}; Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); @@ -331,6 +346,7 @@ define([ me.btnPrevForm.updateHint(me.tipPrevForm); me.btnNextForm.updateHint(me.tipNextForm); me.btnSubmit && me.btnSubmit.updateHint(me.tipSubmit); + me.btnSaveForm && me.btnSaveForm.updateHint(me.tipSaveForm); setEvents.call(me); }); @@ -340,13 +356,12 @@ define([ this.$el = $(_.template(template)( {} )); var $host = this.$el; - if (this.appConfig.canSubmitForms) { - this.btnSubmit.render($host.find('#slot-btn-form-submit')); - } + this.appConfig.canSubmitForms && this.btnSubmit.render($host.find('#slot-btn-form-submit')); + this.appConfig.canDownloadForms && this.btnSaveForm.render($host.find('#slot-btn-form-save')); if (this.appConfig.isRestrictedEdit && this.appConfig.canFillForms) { this.btnClear.render($host.find('#slot-btn-form-clear')); - this.btnSubmit && $host.find('.separator.submit').show().next('.group').show(); + (this.btnSubmit || this.btnSaveForm) && $host.find('.separator.submit').show().next('.group').show(); } else { this.btnTextField.render($host.find('#slot-btn-form-field')); this.btnComboBox.render($host.find('#slot-btn-form-combobox')); @@ -412,7 +427,9 @@ define([ tipNextForm: 'Go to the next field', tipSubmit: 'Submit form', textSubmited: 'Form submitted successfully', - textRequired: 'Fill all required fields to send form.' + textRequired: 'Fill all required fields to send form.', + capBtnSaveForm: 'Save as a Form', + tipSaveForm: 'Save a file as a fillable OFORM document' } }()), DE.Views.FormsTab || {})); }); \ No newline at end of file diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 2001e17cf..e229c530b 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -1822,6 +1822,8 @@ "DE.Views.FormsTab.tipSubmit": "Submit form", "DE.Views.FormsTab.tipTextField": "Insert text field", "DE.Views.FormsTab.tipViewForm": "View form", + "DE.Views.FormsTab.capBtnSaveForm": "Save as a Form", + "DE.Views.FormsTab.tipSaveForm": "Save a file as a fillable OFORM document", "DE.Views.HeaderFooterSettings.textBottomCenter": "Bottom center", "DE.Views.HeaderFooterSettings.textBottomLeft": "Bottom left", "DE.Views.HeaderFooterSettings.textBottomPage": "Bottom of Page", diff --git a/apps/documenteditor/main/resources/img/toolbar/1.25x/big/save-form.png b/apps/documenteditor/main/resources/img/toolbar/1.25x/big/save-form.png new file mode 100644 index 0000000000000000000000000000000000000000..9ddb17063e1ca08b1a407091954fef5d36442607 GIT binary patch literal 440 zcmeAS@N?(olHy`uVBq!ia0vp^Za}Qe!3-qjPWHqDDVB6cUq=Rpjs4tz5?O(K#^NA% zCx&(BWL^R}oCO|{#S9GG!XV7ZFl&wkP|z&EC&bmgz~}$}|3Ds)gfJj%APHwc#KH1V zm4%!79|ENXN`m}?85HKvZ?IRmf4{*#KK}iChx2Ur}lC-vh2=S&i!8Nu|+zAu;_!n*&UjjYrPjt*?1^nThBJA3uuK1~-#m3d{VHjYwVs+!;$P~>k z%Q;t5mn0jtE}nVf<~A{5i{E)UvyRxP@xAh$JmcL-#e+V3x3aT-mRe)0A^D=ZzcKNH z#JNjp7TL2I_e<>v;7!?V=^uJ>$;~;-R~5xwwEyN8{KEJPXK=2TVec}b$+0U8Z??WS z`17cE)+6!z{qwHK8~t29S@`yRKffLI7IXG6hP8{#%`{?C1_hg^tDnm{r-UW|)#0`o literal 0 HcmV?d00001 diff --git a/apps/documenteditor/main/resources/img/toolbar/1.5x/big/save-form.png b/apps/documenteditor/main/resources/img/toolbar/1.5x/big/save-form.png new file mode 100644 index 0000000000000000000000000000000000000000..a53bfdd3ef8b5dcd3534c220aef1221a85a13912 GIT binary patch literal 471 zcmeAS@N?(olHy`uVBq!ia0vp^AwaCf!3-p&=Jq%NDVB6cUq=Rpjs4tz5?O(K#^NA% zCx&(BWL^R}oCO|{#S9GG!XV7ZFl&wkP|z&EC&bmgzz4|u|NlQRBwX2clczg@8U#v$ z{DK)26zm%oEVzHa!9Ftn{d<4Gp1pU0*7JF~IEHu}e|zmUUy}h3>x0Ha%VKiw|4(HV zjFHXu_fa@lP$#GqpLPA<9P8p86m)5sg}Q3)`!?&;$I=~#G8V36(hUt=;1|sL zDrD+|cgFhyq!*pwF)(31{Mk6`%z+PodZLUS7u{8w;|=gEZK98sZ4rOA`Uvlu`4G}ouxl(X^?Ph)vFKltakqL@}C=1yLNe2EX)4T z?@pX&8&K%)dUWsJfc-Tq*X);{rhiqw_e$Fe3!goYCNe+OerVG#ujMZ} XLvm@gA@fXNs4;lD`njxgN@xNA2)@Nh literal 0 HcmV?d00001 diff --git a/apps/documenteditor/main/resources/img/toolbar/1.75x/big/save-form.png b/apps/documenteditor/main/resources/img/toolbar/1.75x/big/save-form.png new file mode 100644 index 0000000000000000000000000000000000000000..01147ba159749354d7f8b1adfe0c7d8dc3d96955 GIT binary patch literal 485 zcmeAS@N?(olHy`uVBq!ia0vp^NkDAK!3-qD5_?jC6id3JuOkD)#(wTUiL5|AV{wqX z6T`Z5GB1G~&H|6fVg?3oVGw3ym^DWNC}yagye2-E$eLmm#dzzYLPsZ6l>^$XxAApKCW%Ev&+m!jsR3R$enp{JO^`d$vLKxj4~l zF`eP9mf?1RJ)BBig-o2eB^-x8beKG^=@YIz_moLs_FI`g;lqV}7175V_fC1oRo6Wu z;1QSbZ(ENyWgi?vn_us{f7xb5mdD-i)jo^TxWWUAxxyV+bzPYKZ)2B0#B=tR_1@=Q^ik@c-p6UpUSI1TmOZc9KVRzB rf2A+igFKt|P4oKn>*mh1l{*=o`(zakEDW;(h9QHetDnm{r-UW|v#-i8 literal 0 HcmV?d00001 diff --git a/apps/documenteditor/main/resources/img/toolbar/1x/big/save-form.png b/apps/documenteditor/main/resources/img/toolbar/1x/big/save-form.png new file mode 100644 index 0000000000000000000000000000000000000000..f196711b32d56b0b8fdfc096652bd43298643fdd GIT binary patch literal 424 zcmeAS@N?(olHy`uVBq!ia0vp^7CaOmaisT$;e&$#;XN7i?f@e6BrxH&u6SJl215+)737ZRYq*&98 zYApM>M4mj?TFzp1ZPT0WQYPvbHeWM6KBe#Nfm4&G_T8O4ReiOQT$oepmT;!z>yAhD z0^eA9G*-M@@hrmPA5YZUptYg*@*OO_LhOwu$UL>zW7m>=c*{71vA{AKR>?VzJfyh`}Yl}>(2)W2pAXytlz)hzrSC3|Geoy z=Wg_LaSVw#{PxD}yk-L)wg&|o?I~+Ybgk9i|DUDZ%W-sLviQo&Q6KLYHri`$l8sur zEvItDlv{d>%NKo*dOXcg-^gHdpi9!zMJHUcA8z(3;j`mDDxu?=#Iw!FkZr0*kE5!v zV1SC!0-u%zCITYQ`44WCUw_c?^s~Y@$Fnz>AF6CgP@Ch<5q7Ea%M~6y{^?@2rp>1h z`*z6ePzFtvvT6!SSAJ;ex^bdeJw~Kqg$6_6$DmFBRs=uL zkTcxya+Ziim%2#J_Q<(RSNpHJv-~Luoy>G~yRkZt&70K)!SKvq&$;a%Q@eG#jRHbkrmO_5ru92%d>QPvvh zzUr453-ifkiSK+iW$v(^EW^#Fa=eN8