From 9cfe8ca3dc8a0539a75394b2af7db16181e5466a Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 1 Mar 2024 19:08:44 +0300 Subject: [PATCH] [DE] Show full header for pdf-form files --- apps/common/main/lib/view/Header.js | 20 ++++---- .../main/app/controller/FormsTab.js | 47 ++++++++++++++----- .../main/app/controller/Main.js | 18 +++---- .../main/app/controller/Toolbar.js | 12 ++++- .../main/app/controller/Viewport.js | 10 ++-- apps/documenteditor/main/app/view/FormsTab.js | 34 +++++++++----- apps/documenteditor/main/locale/en.json | 1 + 7 files changed, 95 insertions(+), 47 deletions(-) diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index 2152728c54..3126a0e819 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -225,7 +225,7 @@ define([ function updateDocNamePosition(config) { if ( $labelDocName && config) { var $parent = $labelDocName.parent(); - if (!(config.isEdit || isPDFEditor && config.isRestrictedEdit)) { + if (!(config.isEdit || (isPDFEditor || config.isPDFForm && config.canFillForms) && config.isRestrictedEdit)) { var _left_width = $parent.position().left, _right_width = $parent.next().outerWidth(); $parent.css('padding-left', _left_width < _right_width ? Math.max(2, _right_width - _left_width) : 2); @@ -245,7 +245,7 @@ define([ } } - if (!(config.customization && config.customization.toolbarHideFileName) && (!(config.isEdit || isPDFEditor && config.isRestrictedEdit) || config.customization && config.customization.compactHeader)) { + if (!(config.customization && config.customization.toolbarHideFileName) && (!(config.isEdit || (isPDFEditor || config.isPDFForm && config.canFillForms) && config.isRestrictedEdit) || config.customization && config.customization.compactHeader)) { var basis = parseFloat($parent.css('padding-left') || 0) + parseFloat($parent.css('padding-right') || 0) + parseInt($labelDocName.css('min-width') || 50); // 2px - box-shadow config.isCrypted && (basis += 20); $parent.css('flex-basis', Math.ceil(basis) + 'px'); @@ -285,7 +285,7 @@ define([ } function onResize() { - if (appConfig && (appConfig.isEdit || isPDFEditor && appConfig.isRestrictedEdit) && !(appConfig.customization && appConfig.customization.compactHeader)) { + if (appConfig && (appConfig.isEdit || (isPDFEditor || appConfig.isPDFForm && appConfig.canFillForms) && appConfig.isRestrictedEdit) && !(appConfig.customization && appConfig.customization.compactHeader)) { updateDocNamePosition(appConfig); } } @@ -413,7 +413,7 @@ define([ }); } - if ( !(mode.isEdit || isPDFEditor && mode.isRestrictedEdit) ) { + if ( !(mode.isEdit || (isPDFEditor || mode.isPDFForm && mode.canFillForms) && mode.isRestrictedEdit) ) { if ( me.btnDownload ) { me.btnDownload.updateHint(me.tipDownload); me.btnDownload.on('click', function (e) { @@ -505,7 +505,7 @@ define([ Common.NotificationCenter.trigger('doc:mode-apply', item.value, true); }); } - if ((appConfig.isEdit || isPDFEditor && appConfig.isRestrictedEdit) && !(appConfig.customization && appConfig.customization.compactHeader)) + if ((appConfig.isEdit || (isPDFEditor || appConfig.isPDFForm && appConfig.canFillForms) && appConfig.isRestrictedEdit) && !(appConfig.customization && appConfig.customization.compactHeader)) Common.NotificationCenter.on('window:resize', onResize); } @@ -706,7 +706,7 @@ define([ $html.find('#slot-btn-favorite').hide(); } - if ( !(config.isEdit || isPDFEditor && config.isRestrictedEdit)) { + if ( !(config.isEdit || (isPDFEditor || config.isPDFForm && config.canFillForms) && config.isRestrictedEdit)) { if ( (config.canDownload || config.canDownloadOrigin) && !config.isOffline ) this.btnDownload = createTitleButton('toolbar__icon icon--inverse btn-download', $html.findById('#slot-hbtn-download'), undefined, 'bottom', 'big'); @@ -721,7 +721,7 @@ define([ } me.btnSearch.render($html.find('#slot-btn-search')); - if (!(config.isEdit || isPDFEditor && config.isRestrictedEdit) || config.customization && !!config.customization.compactHeader) { + if (!(config.isEdit || (isPDFEditor || config.isPDFForm && config.canFillForms) && config.isRestrictedEdit) || config.customization && !!config.customization.compactHeader) { if (config.user.guest && config.canRenameAnonymous) { me.btnUserName = new Common.UI.Button({ el: $html.findById('.slot-btn-user-name'), @@ -823,13 +823,13 @@ define([ if ( config.canCloseEditor ) me.btnClose = createTitleButton('toolbar__icon icon--inverse btn-close', $html.findById('#slot-btn-close'), false, 'left', '10, 10'); - if ( config.canPrint && (config.isEdit || isPDFEditor && config.isRestrictedEdit) ) { + if ( config.canPrint && (config.isEdit || (isPDFEditor || config.isPDFForm && config.canFillForms) && config.isRestrictedEdit) ) { me.btnPrint = createTitleButton('toolbar__icon icon--inverse btn-print', $html.findById('#slot-btn-dt-print'), true, undefined, undefined, 'P'); } - if ( config.canQuickPrint && (config.isEdit || isPDFEditor && config.isRestrictedEdit) ) + if ( config.canQuickPrint && (config.isEdit || (isPDFEditor || config.isPDFForm && config.canFillForms) && config.isRestrictedEdit) ) me.btnPrintQuick = createTitleButton('toolbar__icon icon--inverse btn-quick-print', $html.findById('#slot-btn-dt-print-quick'), true, undefined, undefined, 'Q'); - if (!isPDFEditor || !config.isForm) + if (!isPDFEditor && !(config.isPDFForm && config.canFillForms && config.isRestrictedEdit) || isPDFEditor && !config.isForm) me.btnSave = createTitleButton('toolbar__icon icon--inverse btn-save', $html.findById('#slot-btn-dt-save'), true, undefined, undefined, 'S'); me.btnUndo = createTitleButton('toolbar__icon icon--inverse btn-undo', $html.findById('#slot-btn-dt-undo'), true, undefined, undefined, 'Z', [Common.enumLock.undoLock, Common.enumLock.fileMenuOpened]); diff --git a/apps/documenteditor/main/app/controller/FormsTab.js b/apps/documenteditor/main/app/controller/FormsTab.js index 87a4844dd9..352ce379e3 100644 --- a/apps/documenteditor/main/app/controller/FormsTab.js +++ b/apps/documenteditor/main/app/controller/FormsTab.js @@ -80,7 +80,7 @@ define([ this.api.asc_registerCallback('asc_onError', _.bind(this.onError, this)); this.api.asc_registerCallback('asc_onDownloadUrl', _.bind(this.onDownloadUrl, this)); this.api.asc_registerCallback('asc_onUpdateOFormRoles', _.bind(this.onRefreshRolesList, this)); - + this.api.asc_registerCallback('sync_onAllRequiredFormsFilled', _.bind(this.onFillRequiredFields, this)); // this.api.asc_registerCallback('asc_onShowContentControlsActions',_.bind(this.onShowContentControlsActions, this)); // this.api.asc_registerCallback('asc_onHideContentControlsActions',_.bind(this.onHideContentControlsActions, this)); } @@ -98,14 +98,20 @@ define([ config: config.config }); var dirRight = Common.UI.isRTL() ? 'left' : 'right', - dirLeft = Common.UI.isRTL() ? 'right' : 'left'; + dirLeft = Common.UI.isRTL() ? 'right' : 'left', + me = this; this._helpTips = { 'create': {name: 'de-form-tip-create', placement: 'bottom-' + dirRight, text: this.view.tipCreateField, link: false, target: '#slot-btn-form-field'}, 'key': {name: 'de-form-tip-settings-key', placement: dirLeft + '-bottom', text: this.view.tipFormKey, link: {text: this.view.tipFieldsLink, src: 'UsageInstructions\/CreateFillableForms.htm'}, target: '#form-combo-key'}, 'group-key': {name: 'de-form-tip-settings-group', placement: dirLeft + '-bottom', text: this.view.tipFormGroupKey, link: false, target: '#form-combo-group-key'}, 'settings': {name: 'de-form-tip-settings', placement: dirLeft + '-top', text: this.view.tipFieldSettings, link: {text: this.view.tipFieldsLink, src: 'UsageInstructions\/CreateFillableForms.htm'}, target: '#id-right-menu-form'}, 'roles': {name: 'de-form-tip-roles', placement: 'bottom-' + dirLeft, text: this.view.tipHelpRoles, link: {text: this.view.tipRolesLink, src: 'UsageInstructions\/CreateFillableForms.htm#managing_roles'}, target: '#slot-btn-manager'}, - 'save': this.appConfig.canDownloadForms ? {name: 'de-form-tip-save', placement: 'bottom-' + dirLeft, text: this.view.tipSaveFile, link: false, target: '#slot-btn-form-save'} : undefined + 'save': this.appConfig.canDownloadForms ? {name: 'de-form-tip-save', placement: 'bottom-' + dirLeft, text: this.view.tipSaveFile, link: false, target: '#slot-btn-form-save'} : undefined, + 'submit': this.appConfig.isRestrictedEdit ? {name: 'de-form-tip-submit', placement: 'bottom-' + dirRight, text: this.view.textRequired, link: false, target: '#slot-btn-form-submit', + callback: function() { + me.api.asc_MoveToFillingForm(true, true, true); + me.view.btnSubmit.updateHint(me.view.textRequired); + }} : undefined }; !Common.localStorage.getItem(this._helpTips['key'].name) && this.addListeners({'RightMenu': {'rightmenuclick': this.onRightMenuClick}}); this.addListeners({ @@ -352,12 +358,20 @@ define([ onSaveFormClick: function() { this.closeHelpTip('save', true); - this.showRolesList(function() { - this.isFromFormSaveAs = this.appConfig.canRequestSaveAs || !!this.appConfig.saveAsUrl; - var options = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF, this.isFromFormSaveAs); - options.asc_setIsSaveAs(this.isFromFormSaveAs); - this.api.asc_DownloadAs(options); - }); + var me = this, + callback = function() { + if (me.appConfig.isOffline) + me.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF)); + else { + me.isFromFormSaveAs = me.appConfig.canRequestSaveAs || !!me.appConfig.saveAsUrl; + var options = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF, me.isFromFormSaveAs); + options.asc_setIsSaveAs(me.isFromFormSaveAs); + me.api.asc_DownloadAs(options); + } + }; + if (this.api && this.appConfig.canDownload) { + this.appConfig.isRestrictedEdit && this.appConfig.canFillForms ? callback() : this.showRolesList(callback); + } }, onDownloadUrl: function(url, fileType) { @@ -430,13 +444,13 @@ define([ if (id==Asc.c_oAscAsyncAction['Submit'] && this.view.btnSubmit) { this._submitFail = false; this.submitedTooltip && this.submitedTooltip.hide(); - this.view.btnSubmit.setDisabled(true); + Common.Utils.lockControls(Common.enumLock.submit, true, {array: [this.view.btnSubmit]}) } }, onLongActionEnd: function(type, id) { if (id==Asc.c_oAscAsyncAction['Submit'] && this.view.btnSubmit) { - this.view.btnSubmit.setDisabled(false); + Common.Utils.lockControls(Common.enumLock.submit, false, {array: [this.view.btnSubmit]}) if (!this.submitedTooltip) { this.submitedTooltip = new Common.UI.SynchronizeTip({ text: this.view.textSubmited, @@ -472,6 +486,10 @@ define([ // } config.isEdit && config.canFeatureContentControl && config.isFormCreator && !config.isOForm && me.showHelpTip('create'); // show tip only when create form in docxf + if (config.isRestrictedEdit && me.view && me.view.btnSubmit && me.api && !me.api.asc_IsAllRequiredFormsFilled()) { + Common.Utils.lockControls(Common.enumLock.requiredNotFilled, true, {array: [me.view.btnSubmit]}); + me.showHelpTip('submit'); + } me.onRefreshRolesList(); me.onChangeProtectDocument(); }); @@ -521,6 +539,7 @@ define([ }, 'close': function() { Common.localStorage.setItem(props.name, 1); + props.callback && props.callback(); } }); props.tip.show(); @@ -600,7 +619,11 @@ define([ this.closeHelpTip('group-key'); this.closeHelpTip('settings'); } - } + }, + + onFillRequiredFields: function(isFilled) { + this.appConfig.isRestrictedEdit && this.appConfig.canFillForms && this.view.btnSubmit && Common.Utils.lockControls(Common.enumLock.requiredNotFilled, !isFilled, {array: [this.view.btnSubmit]}); + }, }, DE.Controllers.FormsTab || {})); }); \ No newline at end of file diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 2c13d20ffb..8809f22c0c 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -462,6 +462,7 @@ define([ this.appOptions.uiRtl = !(Common.Controllers.Desktop.isActive() && Common.Controllers.Desktop.uiRtlSupported()) && !Common.Utils.isIE; this.appOptions.disableNetworkFunctionality = !!(window["AscDesktopEditor"] && window["AscDesktopEditor"]["isSupportNetworkFunctionality"] && false === window["AscDesktopEditor"]["isSupportNetworkFunctionality"]()); this.appOptions.mentionShare = !((typeof (this.appOptions.customization) == 'object') && (this.appOptions.customization.mentionShare==false)); + this.appOptions.isPDFForm = !!window.isPDFForm; this.appOptions.user.guest && this.appOptions.canRenameAnonymous && Common.NotificationCenter.on('user:rename', _.bind(this.showRenameUserDialog, this)); @@ -549,13 +550,13 @@ define([ // docInfo.put_Review(this.permissions.review); var type = /^(?:(pdf|djvu|xps|oxps))$/.exec(data.doc.fileType); - var coEditMode = (type && typeof type[1] === 'string' && !window.isPDFForm) ? 'strict' : // offline viewer for pdf|djvu|xps|oxps + var coEditMode = (type && typeof type[1] === 'string' && !this.appOptions.isPDFForm) ? 'strict' : // offline viewer for pdf|djvu|xps|oxps !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object') ? 'fast' : // fast by default this.editorConfig.mode === 'view' && this.editorConfig.coEditing.change!==false ? 'fast' : // if can change mode in viewer - set fast for using live viewer this.editorConfig.coEditing.mode || 'fast'; docInfo.put_CoEditingMode(coEditMode); - if (type && typeof type[1] === 'string' && !window.isPDFForm) { + if (type && typeof type[1] === 'string' && !this.appOptions.isPDFForm) { this.permissions.edit = this.permissions.review = false; } } @@ -569,7 +570,7 @@ define([ } var type = data.doc ? /^(?:(docxf|oform)|(pdf))$/.exec(data.doc.fileType) : false; - this.appOptions.isFormCreator = !!(type && (typeof type[1] === 'string' || typeof type[2] === 'string' && window.isPDFForm)) && this.appOptions.canFeatureForms; // show forms only for docxf or oform + this.appOptions.isFormCreator = !!(type && (typeof type[1] === 'string' || typeof type[2] === 'string' && this.appOptions.isPDFForm)) && this.appOptions.canFeatureForms; // show forms only for docxf or oform type = data.doc ? /^(?:(oform))$/.exec(data.doc.fileType) : false; this.appOptions.isOForm = !!(type && typeof type[1] === 'string'); @@ -642,7 +643,7 @@ define([ Asc.c_oAscFileType.PNG ]; var type = /^(?:(pdf|djvu|xps|oxps))$/.exec(this.document.fileType); - if (type && typeof type[1] === 'string' && !window.isPDFForm) { + if (type && typeof type[1] === 'string' && !this.appOptions.isPDFForm) { if (!(format && (typeof format == 'string')) || type[1]===format.toLowerCase()) { var options = new Asc.asc_CDownloadOptions(); options.asc_setIsDownloadEvent(true); @@ -1418,7 +1419,9 @@ define([ } }, 50); } else { + me.appOptions.isRestrictedEdit && me.appOptions.canFillForms && me.api.asc_SetHighlightRequiredFields(true); documentHolderController.getView().createDelayedElementsViewer(); + toolbarController.createDelayedElementsViewer(); Common.Utils.injectSvgIcons(); Common.NotificationCenter.trigger('document:ready', 'main'); me.applyLicense(); @@ -1564,7 +1567,7 @@ define([ if ( this.onServerVersion(params.asc_getBuildVersion()) || !this.onLanguageLoaded()) return; - var isPDFViewer = /^(?:(pdf|djvu|xps|oxps))$/.test(this.document.fileType) && !window.isPDFForm; + var isPDFViewer = /^(?:(pdf|djvu|xps|oxps))$/.test(this.document.fileType) && !this.appOptions.isPDFForm; this.permissions.review = (this.permissions.review === undefined) ? (this.permissions.edit !== false) : this.permissions.review; @@ -1633,12 +1636,12 @@ define([ this.appOptions.canProtect = (this.permissions.protect!==false); this.appOptions.canEditContentControl = (this.permissions.modifyContentControl!==false); this.appOptions.canHelp = !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.help===false); - this.appOptions.canSubmitForms = false; // this.appOptions.canLicense && (typeof (this.editorConfig.customization) == 'object') && !!this.editorConfig.customization.submitForm; this.appOptions.canFillForms = this.appOptions.canLicense && (this.appOptions.isEdit ? true : 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 this.appOptions.canComments = false; this.appOptions.canSwitchMode = this.appOptions.isEdit; + this.appOptions.canSubmitForms = this.appOptions.isRestrictedEdit && this.appOptions.canFillForms && this.appOptions.canLicense && (typeof (this.editorConfig.customization) == 'object') && !!this.editorConfig.customization.submitForm && !this.appOptions.isOffline; if ( this.appOptions.isLightVersion ) { this.appOptions.canUseHistory = @@ -1654,7 +1657,7 @@ define([ this.appOptions.canDownloadOrigin = false; this.appOptions.canDownload = this.permissions.download !== false; this.appOptions.canUseSelectHandTools = this.appOptions.canUseThumbnails = this.appOptions.canUseViwerNavigation = isPDFViewer; - this.appOptions.canDownloadForms = this.appOptions.canLicense && this.appOptions.canDownload; + this.appOptions.canDownloadForms = this.appOptions.canLicense && this.appOptions.canDownload && this.appOptions.isRestrictedEdit && this.appOptions.canFillForms; // don't show download form button in edit mode this.appOptions.fileKey = this.document.key; @@ -1710,7 +1713,6 @@ define([ this.api.asc_setViewMode(!this.appOptions.isEdit && !this.appOptions.isRestrictedEdit); this.appOptions.isRestrictedEdit && this.appOptions.canComments && this.api.asc_setRestriction(Asc.c_oAscRestrictionType.OnlyComments); this.appOptions.isRestrictedEdit && this.appOptions.canFillForms && this.api.asc_setRestriction(Asc.c_oAscRestrictionType.OnlyForms); - this.appOptions.isRestrictedEdit && this.appOptions.canFillForms && this.api.asc_SetHighlightRequiredFields(true); this.api.asc_LoadDocument(); }, diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 0c931ad6d2..000f66f917 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -461,6 +461,10 @@ define([ this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObjectRestrictedEdit, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onApiCoAuthoringDisconnect, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this)); + if (this.mode.isPDFForm && this.mode.canFillForms) { + this.api.asc_registerCallback('asc_onCanUndo', _.bind(this.onApiCanRevert, this, 'undo')); + this.api.asc_registerCallback('asc_onCanRedo', _.bind(this.onApiCanRevert, this, 'redo')); + } } this.api.asc_registerCallback('asc_onDownloadUrl', _.bind(this.onDownloadUrl, this)); Common.NotificationCenter.on('protect:doclock', _.bind(this.onChangeProtectDocument, this)); @@ -549,12 +553,12 @@ define([ onApiCanRevert: function(which, can) { if (which=='undo') { if (this._state.can_undo !== can) { - this.toolbar.lockToolbar(Common.enumLock.undoLock, !can, {array: [this.toolbar.btnUndo]}); + this.toolbar.btnUndo ? this.toolbar.lockToolbar(Common.enumLock.undoLock, !can, {array: [this.toolbar.btnUndo]}) : this.onBtnChangeState('undo:disabled', null, !can); this._state.can_undo = can; } } else { if (this._state.can_redo !== can) { - this.toolbar.lockToolbar(Common.enumLock.redoLock, !can, {array: [this.toolbar.btnRedo]}); + this.toolbar.btnRedo ? this.toolbar.lockToolbar(Common.enumLock.redoLock, !can, {array: [this.toolbar.btnRedo]}) : this.onBtnChangeState('redo:disabled', null, !can); this._state.can_redo = can; } } @@ -3388,6 +3392,10 @@ define([ Common.Utils.injectSvgIcons(); }, + createDelayedElementsViewer: function() { + this.onBtnChangeState('print:disabled', null, !this.mode.canPrint); + }, + onAppShowed: function (config) { var me = this, application = this.getApplication(); diff --git a/apps/documenteditor/main/app/controller/Viewport.js b/apps/documenteditor/main/app/controller/Viewport.js index 871e49bca8..6c8f1c39f2 100644 --- a/apps/documenteditor/main/app/controller/Viewport.js +++ b/apps/documenteditor/main/app/controller/Viewport.js @@ -77,7 +77,7 @@ define([ 'render:before' : function (toolbar) { var config = DE.getController('Main').appOptions; toolbar.setExtra('right', me.header.getPanel('right', config)); - if (!config.isEdit || config.customization && !!config.customization.compactHeader) + if (!config.isEdit && !(config.isPDFForm && config.canFillForms && config.isRestrictedEdit) || config.customization && !!config.customization.compactHeader) toolbar.setExtra('left', me.header.getPanel('left', config)); var value = Common.localStorage.getBool("de-settings-quick-print-button", true); @@ -181,7 +181,7 @@ define([ me.viewport.vlayout.getItem('toolbar').el.addClass('style-skip-docname'); } - if ( config.isEdit && (!(config.customization && config.customization.compactHeader))) { + if ( (config.isEdit || config.isPDFForm && config.canFillForms && config.isRestrictedEdit) && (!(config.customization && config.customization.compactHeader))) { var $title = me.viewport.vlayout.getItem('title').el; $title.html(me.header.getPanel('title', config)).show(); $title.find('.extra').html(me.header.getPanel('left', config)); @@ -197,8 +197,10 @@ define([ $filemenu.css('top', (Common.UI.LayoutManager.isElementVisible('toolbar') ? _tabs_new_height : 0) + _intvars.get('document-title-height')); - toolbar = me.getApplication().getController('Toolbar').getView(); - toolbar.btnCollabChanges = me.header.btnSave; + if (config.isEdit) { + toolbar = me.getApplication().getController('Toolbar').getView(); + toolbar.btnCollabChanges = me.header.btnSave; + } } me.header.btnSearch.on('toggle', me.onSearchToggle.bind(this)); diff --git a/apps/documenteditor/main/app/view/FormsTab.js b/apps/documenteditor/main/app/view/FormsTab.js index 80b4b40a5b..0e4df3dd1c 100644 --- a/apps/documenteditor/main/app/view/FormsTab.js +++ b/apps/documenteditor/main/app/view/FormsTab.js @@ -45,6 +45,19 @@ define([ ], function () { 'use strict'; + if (!Common.enumLock) + Common.enumLock = {}; + + var enumLock = { + requiredNotFilled: 'required-not-filled', + submit: 'submit' + }; + for (var key in enumLock) { + if (enumLock.hasOwnProperty(key)) { + Common.enumLock[key] = enumLock[key]; + } + } + DE.Views.FormsTab = Common.UI.BaseView.extend(_.extend((function(){ var template = '
' + @@ -393,7 +406,7 @@ define([ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-clear-style', caption: this.textClear, - visible: this.appConfig.isRestrictedEdit && this.appConfig.canFillForms && window.isPDFForm, + visible: this.appConfig.isRestrictedEdit && this.appConfig.canFillForms && this.appConfig.isPDFForm, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'small' @@ -404,7 +417,7 @@ define([ iconCls: 'toolbar__icon btn-previous-field', lock: [ _set.previewReviewMode, _set.lostConnect, _set.disableOnStart, _set.docLockView, _set.docLockComments, _set.viewMode], caption: this.capBtnPrev, - visible: this.appConfig.isRestrictedEdit && this.appConfig.canFillForms && window.isPDFForm, + visible: this.appConfig.isRestrictedEdit && this.appConfig.canFillForms && this.appConfig.isPDFForm, // disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode dataHint: '1', dataHintDirection: 'bottom', @@ -417,7 +430,7 @@ define([ iconCls: 'toolbar__icon btn-next-field', lock: [ _set.previewReviewMode, _set.lostConnect, _set.disableOnStart, _set.docLockView, _set.docLockComments, _set.viewMode], caption: this.capBtnNext, - visible: this.appConfig.isRestrictedEdit && this.appConfig.canFillForms && window.isPDFForm, + visible: this.appConfig.isRestrictedEdit && this.appConfig.canFillForms && this.appConfig.isPDFForm, // disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode, dataHint: '1', dataHintDirection: 'bottom', @@ -429,7 +442,7 @@ define([ this.btnSubmit = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-submit-form', - lock: [_set.lostConnect, _set.disableOnStart], + lock: [_set.lostConnect, _set.disableOnStart, _set.requiredNotFilled, _set.submit], caption: this.capBtnSubmit, // disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode, dataHint: '1', @@ -437,13 +450,12 @@ define([ dataHintOffset: 'small' }); !(this.appConfig.isRestrictedEdit && this.appConfig.canFillForms) && this.paragraphControls.push(this.btnSubmit); - } - if (this.appConfig.canDownloadForms) { + } else if (this.appConfig.canDownloadForms) { this.btnSaveForm = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', lock: [_set.lostConnect, _set.disableOnStart], iconCls: 'toolbar__icon btn-save-form', - caption: this.appConfig.canRequestSaveAs || !!this.appConfig.saveAsUrl || this.appConfig.isOffline ? this.capBtnSaveForm : this.capBtnDownloadForm, + caption: this.appConfig.canRequestSaveAs || !!this.appConfig.saveAsUrl ? this.capBtnSaveForm : (this.appConfig.isOffline ? this.capBtnSaveFormDesktop : this.capBtnDownloadForm), // disabled: this.appConfig.isEdit && this.appConfig.canFeatureContentControl && this.appConfig.canFeatureForms, // disable only for edit mode, dataHint: '1', dataHintDirection: 'bottom', @@ -538,8 +550,8 @@ define([ this.$el = $(_.template(template)( {} )); var $host = this.$el; - this.appConfig.canSubmitForms && this.btnSubmit.render($host.find('#slot-btn-form-submit')); - this.appConfig.canDownloadForms && this.btnSaveForm.render($host.find('#slot-btn-form-save')); + this.btnSubmit && this.btnSubmit.render($host.find('#slot-btn-form-submit')); + this.btnSaveForm && this.btnSaveForm.render($host.find('#slot-btn-form-save')); if (this.appConfig.isRestrictedEdit && this.appConfig.canFillForms) { } else { @@ -696,8 +708,8 @@ define([ tipHelpRoles: 'Use the Manage Roles feature to group fields by purpose and assign the responsible team members.', tipSaveFile: 'Click “Save as pdf” to save the form in the format ready for filling.', tipRolesLink: 'Learn more about roles', - tipFieldsLink: 'Learn more about field parameters' - + tipFieldsLink: 'Learn more about field parameters', + capBtnSaveFormDesktop: 'Save as...' } }()), 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 e54d9b91fa..51dfe03d20 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -2305,6 +2305,7 @@ "DE.Views.FormsTab.txtInlineDesc": "Insert inline text field", "DE.Views.FormsTab.txtInlineText": "Inline", "DE.Views.FormsTab.txtUntitled": "Untitled", + "DE.Views.FormsTab.capBtnSaveFormDesktop": "Save As...", "DE.Views.HeaderFooterSettings.textBottomCenter": "Bottom center", "DE.Views.HeaderFooterSettings.textBottomLeft": "Bottom left", "DE.Views.HeaderFooterSettings.textBottomPage": "Bottom of page",