From 3a626bdef4e8a2265e61077c61e80c6ecc9fb26c Mon Sep 17 00:00:00 2001 From: "Julia.Radzhabova" Date: Mon, 29 Sep 2025 21:02:23 +0300 Subject: [PATCH] [Forms] Add finalize button --- .../main/app/controller/FormsTab.js | 40 +++++++++++++++---- apps/documenteditor/main/app/view/FormsTab.js | 24 +++++++++-- apps/documenteditor/main/app/view/Toolbar.js | 2 + apps/documenteditor/main/locale/en.json | 2 + 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/apps/documenteditor/main/app/controller/FormsTab.js b/apps/documenteditor/main/app/controller/FormsTab.js index 52d841ea3a..a1347ff456 100644 --- a/apps/documenteditor/main/app/controller/FormsTab.js +++ b/apps/documenteditor/main/app/controller/FormsTab.js @@ -126,7 +126,8 @@ define([ 'forms:clear': this.onClearClick, // 'forms:no-color': this.onNoControlsColor, // 'forms:select-color': this.onSelectControlsColor, - 'forms:mode': this.onModeClick, + 'forms:preview': this.onPreviewClick, + 'forms:final': this.onFinalClick, 'forms:goto': this.onGoTo, 'forms:submit': this.onSubmitClick, 'forms:save': this.onSaveFormClick, @@ -304,27 +305,52 @@ define([ onModeClick: function(state, lastViewRole) { if (this.api) { this.disableEditing(state); - this.view && this.view.setPreviewMode(state); // send role name - lastViewRole + this.view && this.view.setPreviewMode(state); var role = new AscCommon.CRestrictionSettings(); role.put_OFormRole(lastViewRole); this.api.asc_setRestriction(state ? Asc.c_oAscRestrictionType.OnlyForms : Asc.c_oAscRestrictionType.None, role); this.api.asc_SetPerformContentControlActionByClick(state); this.api.asc_SetHighlightRequiredFields(state); - state && (this._state.lastViewRole = lastViewRole); + state && lastViewRole && (this._state.lastViewRole = lastViewRole); this.toolbar.toolbar.clearActiveData(); this.toolbar.toolbar.processPanelVisible(null, true); + !state && this.view && Common.Utils.lockControls(Common.enumLock.viewFormFinal, false, {array: [this.view.btnViewFormRoles]}); + !state && this.view && Common.Utils.lockControls(Common.enumLock.viewFormNotFinal, false, {array: [this.view.btnFinal]}); } Common.NotificationCenter.trigger('doc:mode-changed', state ? 'view-form' : undefined); Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, - changeViewFormMode: function(state) { - if (this.view && this.view.btnViewFormRoles && (state !== this.view.btnViewFormRoles.isActive())) { - this.view.btnViewFormRoles.toggle(state, true); - this.onModeClick(state); + changeViewFormMode: function(state, finalize) { + if (this.view && (this.view.btnViewFormRoles && (state !== this.view.btnViewFormRoles.isActive()) || + this.view.btnFinal && (finalize || !state && (state !== this.view.btnFinal.isActive())))) { + var current, + btnview = this.view.btnViewFormRoles, + btnfinal = this.view.btnFinal; + btnview && !finalize && btnview.toggle(state, true); + btnfinal && (finalize || !state) && btnfinal.toggle(state, true); + if (state && !finalize && btnview && btnview.menu) { + current = btnview.menu.getChecked(); + if (current) { + current = current.caption; + } else if (this.view._state.roles && this.view._state.roles.length>0) { + current = this.view._state.roles[0].asc_getSettings().asc_getName(); + } + } + finalize ? this.onFinalClick(state) : this.onPreviewClick(state, current); } }, + onPreviewClick: function(state, lastViewRole) { + this.onModeClick(state, lastViewRole); + state && this.view && Common.Utils.lockControls(Common.enumLock.viewFormNotFinal, true, {array: [this.view.btnFinal]}); + }, + + onFinalClick: function(state) { + this.onModeClick(state); // role = undefined, forms can be filled out by anyone + state && this.view && Common.Utils.lockControls(Common.enumLock.viewFormFinal, true, {array: [this.view.btnViewFormRoles]}); + }, + onClearClick: function() { if (this.api) { this.api.asc_ClearAllSpecialForms(); diff --git a/apps/documenteditor/main/app/view/FormsTab.js b/apps/documenteditor/main/app/view/FormsTab.js index 4699a01c0c..0d8bced3a3 100644 --- a/apps/documenteditor/main/app/view/FormsTab.js +++ b/apps/documenteditor/main/app/view/FormsTab.js @@ -117,6 +117,7 @@ define([ '' + '
' + '' + + '' + '' + '' + '' + @@ -195,13 +196,13 @@ define([ item = me._state.roles[0].asc_getSettings().asc_getName(); } } - me.fireEvent('forms:mode', [b.pressed, item]); + me.fireEvent('forms:preview', [b.pressed, item]); }); if (this.btnViewFormRoles.menu) { this.btnViewFormRoles.menu.on('item:click', _.bind(function (menu, item) { if (!!item.checked) { me.btnViewFormRoles.toggle(true, true); - me.fireEvent('forms:mode', [true, item.caption]); + me.fireEvent('forms:preview', [true, item.caption]); } }, me)); this.btnViewFormRoles.menu.on('show:after', function (menu) { @@ -209,6 +210,9 @@ define([ }); } } + this.btnFinal && this.btnFinal.on('click', function (b, e) { + me.fireEvent('forms:final', [b.pressed]); + }); this.btnManager && this.btnManager.on('click', function (b, e) { me.fireEvent('forms:manager'); }); @@ -504,7 +508,7 @@ define([ this.btnViewFormRoles = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-big-sheet-view', - lock: [ _set.previewReviewMode, _set.formsNoRoles, _set.lostConnect, _set.disableOnStart, _set.docLockView, _set.docLockForms, _set.docLockComments, _set.viewMode], + lock: [ _set.previewReviewMode, _set.formsNoRoles, _set.viewFormFinal, _set.lostConnect, _set.disableOnStart, _set.docLockView, _set.docLockForms, _set.docLockComments, _set.viewMode], caption: this.capBtnView, split: Common.UI.FeaturesManager.isFeatureEnabled('roles', true), menu: Common.UI.FeaturesManager.isFeatureEnabled('roles', true) ? new Common.UI.Menu({ @@ -520,6 +524,18 @@ define([ }); this.paragraphControls.push(this.btnViewFormRoles); + this.btnFinal = new Common.UI.Button({ + cls: 'btn-toolbar x-huge icon-top', + iconCls: 'toolbar__icon btn-make-final', + lock: [ _set.previewReviewMode, _set.viewFormNotFinal, _set.lostConnect, _set.disableOnStart, _set.docLockView, _set.docLockForms, _set.docLockComments, _set.viewMode], + caption: this.capBtnFinal, + enableToggle: true, + dataHint: '1', + dataHintDirection: 'bottom', + dataHintOffset: 'small' + }); + this.paragraphControls.push(this.btnFinal); + // this.btnHighlight = new Common.UI.ButtonColored({ // cls : 'btn-toolbar', // iconCls : 'toolbar__icon btn-highlight', @@ -685,6 +701,7 @@ define([ me.btnImageField.updateHint(me.tipImageField); me.btnSignField.updateHint(me.tipSignField); me.btnViewFormRoles.updateHint(me.tipViewForm); + me.btnFinal.updateHint(me.tipFinalForm); me.btnManager.updateHint(me.tipManager); me.btnEmailField.updateHint(me.tipEmailField); me.btnPhoneField.updateHint(me.tipPhoneField); @@ -731,6 +748,7 @@ define([ this.btnImageField.render($host.find('#slot-btn-form-image')); this.btnSignField.render($host.find('#slot-btn-form-signature')); this.btnViewFormRoles.render($host.find('#slot-btn-form-view-roles')); + this.btnFinal.render($host.find('#slot-btn-form-final')); this.btnManager.render($host.find('#slot-btn-manager')); // this.btnHighlight.render($host.find('#slot-form-highlight')); this.btnEmailField.render($host.find('#slot-btn-form-email')); diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index b7dc676ac7..a2b100b68c 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -117,6 +117,8 @@ define([ disableOnStart: 'on-start', complexForm: 'complex-form', formsNoRoles: 'no-roles', + viewFinalForm: 'final-form', + viewFormNotFinal:'not-final-form', fixedForm: 'fixed-form', fileMenuOpened: 'file-menu-opened', changeModeLock: 'change-mode-lock', diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 54f74a64c6..5f51d012a6 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -2921,6 +2921,8 @@ "DE.Views.FormsTab.txtInlineText": "Inline", "DE.Views.FormsTab.txtSignedForm": "This document has been signed and cannot be edited.", "DE.Views.FormsTab.txtUntitled": "Untitled", + "DE.Views.FormsTab.capBtnFinal": "Mark as Final", + "DE.Views.FormsTab.tipFinalForm": "Mark as final", "DE.Views.HeaderFooterSettings.textBottomCenter": "Bottom center", "DE.Views.HeaderFooterSettings.textBottomLeft": "Bottom left", "DE.Views.HeaderFooterSettings.textBottomPage": "Bottom of page",