From bc3d399a5df6cabc4e90cec4c5cd2f0af5565535 Mon Sep 17 00:00:00 2001 From: "Julia.Radzhabova" Date: Tue, 30 Sep 2025 20:51:16 +0300 Subject: [PATCH] Use finalize sdk event/method --- .../main/app/controller/FormsTab.js | 53 ++++++++++++++----- .../main/app/controller/Main.js | 2 +- apps/documenteditor/main/app/view/FormsTab.js | 2 +- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/apps/documenteditor/main/app/controller/FormsTab.js b/apps/documenteditor/main/app/controller/FormsTab.js index fec120e677..82a72a6164 100644 --- a/apps/documenteditor/main/app/controller/FormsTab.js +++ b/apps/documenteditor/main/app/controller/FormsTab.js @@ -144,6 +144,7 @@ define([ }); this.appConfig.isRestrictedEdit && this.api && this.api.asc_registerCallback('asc_onDocumentModifiedChanged', _.bind(this.onDocumentModifiedChanged, this)); this.appConfig.isPDFSignatureSupport && this.appConfig.isRestrictedEdit && this.api && this.api.asc_registerCallback('asc_onUpdateSignatures', _.bind(this.onApiUpdateSignatures, this)); + this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.isFormCreator && !this.appConfig.isOForm && this.api && this.api.asc_registerCallback('asc_onOFormChangeFinal', _.bind(this.onOFormChangeFinal, this)) }, SetDisabled: function(state) { @@ -321,23 +322,26 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, - changeViewFormMode: function(state, finalize) { + changeViewFormMode: function(state, saveFlag) { 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, + this.view.btnFinal && this.view.btnFinal.isActive() && !state)) { + var 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(); + if (btnview && (state !== btnview.isActive())) { + btnview.toggle(state, true); + if (state && btnview.menu) { + var 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(); + } } + this.onPreviewClick(state, current); + } else if (btnfinal && btnfinal.isActive() && !state) { + btnfinal.toggle(state, true); + this.onFinalClick(state, saveFlag); } - finalize ? this.onFinalClick(state) : this.onPreviewClick(state, current); } }, @@ -346,11 +350,32 @@ define([ state && this.view && Common.Utils.lockControls(Common.enumLock.viewFormNotFinal, true, {array: [this.view.btnFinal]}); }, - onFinalClick: function(state) { + onFinalClick: function(state, saveFlag) { + saveFlag && this.api && this.api.asc_markAsFinal(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]}); }, + onOFormChangeFinal: function(isFinal) { + // off preview review changes + var review = this.getApplication().getController('Common.Controllers.ReviewChanges'); + if (review && review.isPreviewChangesMode()) { + var value = Common.Utils.InternalSettings.get("de-review-mode-editor") || 'markup'; + review.turnDisplayMode(value); + review.view && review.view.turnDisplayMode(value); + } + + if (this.view) { + if (this.view.btnViewFormRoles && this.view.btnViewFormRoles.isActive()) // off view form mode + this.changeViewFormMode(false); + + if (this.view.btnFinal) { + this.view.btnFinal.toggle(isFinal, true); + this.onFinalClick(isFinal, false); + } + } + }, + onClearClick: function() { if (this.api) { this.api.asc_ClearAllSpecialForms(); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 02d49b01c5..b26935ca6a 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1955,7 +1955,7 @@ define([ if (mode==='view-form' || !!this.stackDisableActions.get({type: 'forms'})) { var forms = this.getApplication().getController('FormsTab'); - forms && forms.changeViewFormMode(mode==='view-form'); + forms && forms.changeViewFormMode(mode==='view-form', true); } if (mode==='edit') { diff --git a/apps/documenteditor/main/app/view/FormsTab.js b/apps/documenteditor/main/app/view/FormsTab.js index 0d8bced3a3..c3d328e7d5 100644 --- a/apps/documenteditor/main/app/view/FormsTab.js +++ b/apps/documenteditor/main/app/view/FormsTab.js @@ -211,7 +211,7 @@ define([ } } this.btnFinal && this.btnFinal.on('click', function (b, e) { - me.fireEvent('forms:final', [b.pressed]); + me.fireEvent('forms:final', [b.pressed, true]); }); this.btnManager && this.btnManager.on('click', function (b, e) { me.fireEvent('forms:manager');