Skip to content

Commit

Permalink
[DE] Pdf form: fix submit button in fill forms mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaRadzhabova committed Apr 3, 2024
1 parent 913de69 commit 3da4583
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 39 deletions.
3 changes: 2 additions & 1 deletion apps/common/main/lib/controller/ReviewChanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,8 @@ define([
documentHolder: {clear: false, disable: true},
toolbar: true,
plugins: true,
protect: true
protect: true,
header: {docmode: true}
}, 'review');
},

Expand Down
1 change: 1 addition & 0 deletions apps/common/main/lib/view/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ define([
'<div class="btn-slot" id="slot-hbtn-download"></div>' +
'</div>' +
'<div class="hedset">' +
'<div class="btn-slot margin-right-2" id="slot-btn-header-form-submit" style="padding: 2px 0;"></div>' +
'<div class="btn-slot margin-right-2" id="slot-btn-start-fill" style="padding: 2px 0;"></div>' +
'</div>' +
'<div class="hedset">' +
Expand Down
36 changes: 21 additions & 15 deletions apps/documenteditor/main/app/controller/FormsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ define([
'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,
'submit': this.appConfig.isRestrictedEdit ? {name: 'de-form-tip-submit', placement: 'bottom-' + dirRight, text: this.view.textRequired, link: false, target: '#slot-btn-form-submit',
'submit': this.appConfig.isRestrictedEdit ? {name: 'de-form-tip-submit', placement: 'bottom-' + dirLeft, text: this.view.textRequired, link: false, target: '#slot-btn-header-form-submit',
callback: function() {
me.api.asc_MoveToFillingForm(true, true, true);
me.view.btnSubmit.updateHint(me.view.textRequired);
Expand Down Expand Up @@ -433,7 +433,8 @@ define([
documentHolder: {clear: false, disable: true},
toolbar: true,
plugins: true,
protect: true
protect: true,
header: {docmode: true}
}, 'forms');
// if (this.view)
// this.view.$el.find('.no-group-mask.form-view').css('opacity', 1);
Expand All @@ -450,20 +451,25 @@ define([

onLongActionEnd: function(type, id) {
if (id==Asc.c_oAscAsyncAction['Submit'] && this.view.btnSubmit) {
Common.Utils.lockControls(Common.enumLock.submit, false, {array: [this.view.btnSubmit]})
if (!this.submitedTooltip) {
this.submitedTooltip = new Common.UI.SynchronizeTip({
text: this.view.textSubmited,
extCls: 'no-arrow',
showLink: false,
target: $('.toolbar'),
placement: 'bottom'
});
this.submitedTooltip.on('closeclick', function () {
this.submitedTooltip.hide();
}, this);
Common.Utils.lockControls(Common.enumLock.submit, !this._submitFail, {array: [this.view.btnSubmit]})
if (!this._submitFail) {
this.view.btnSubmit.setCaption(this.view.textFilled);
this.view.btnSubmit.cmpEl.addClass('gray');
if (!this.submitedTooltip) {
this.submitedTooltip = new Common.UI.SynchronizeTip({
text: this.view.textSubmitOk,
extCls: 'no-arrow colored',
showLink: false,
target: $('.toolbar'),
placement: 'bottom'
});
this.submitedTooltip.on('closeclick', function () {
this.submitedTooltip.hide();
}, this);
}
this.submitedTooltip.show();
Common.NotificationCenter.trigger('doc:mode-apply', 'view', true, true);
}
!this._submitFail && this.submitedTooltip.show();
}
},

Expand Down
15 changes: 11 additions & 4 deletions apps/documenteditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,8 @@ define([
documentHolder: {clear: !temp, disable: true},
toolbar: true,
plugins: false,
protect: false
protect: false,
header: {docmode: true}
}, temp ? 'reconnect' : 'disconnect');
},

Expand Down Expand Up @@ -931,6 +932,11 @@ define([
app.getController('Common.Controllers.Protection').SetDisabled(disable, false);
}

if (options.header) {
if (options.header.docmode)
app.getController('Toolbar').getView('Toolbar').fireEvent('docmode:disabled', [disable]);
}

if (prev_options) {
this.onEditingDisable(prev_options.disable, prev_options.options, prev_options.type);
}
Expand Down Expand Up @@ -1776,15 +1782,15 @@ define([
Common.Utils.InternalSettings.set("de-settings-autosave", autosave);
},

onDocModeApply: function(mode, force, viewmode) {// force !== true - change mode only if not in view mode, viewmode: disable or not DocMode button in the header
onDocModeApply: function(mode, force, disableModeButton) {// force !== true - change mode only if not in view mode, disableModeButton: disable or not DocMode button in the header
if (!this.appOptions.canSwitchMode && !force) return;

var disable = mode==='view',
inViewMode = !!this.stackDisableActions.get({type: 'view'});

if (force) {
(disable || inViewMode) && Common.NotificationCenter.trigger('editing:disable', disable, {
viewMode: !!viewmode,
viewMode: false,
reviewMode: false,
fillFormMode: false,
viewDocMode: true,
Expand All @@ -1803,7 +1809,8 @@ define([
documentHolder: {clear: true, disable: true},
toolbar: true,
plugins: true,
protect: true
protect: true,
header: {docmode: !!disableModeButton}
}, 'view');

if (mode==='edit') {
Expand Down
4 changes: 1 addition & 3 deletions apps/documenteditor/main/app/controller/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3285,8 +3285,6 @@ define([
else if (viewDocMode)
toolbar.lockToolbar(Common.enumLock.viewMode, disable);

!viewDocMode && toolbar.fireEvent('docmode:disabled', [disable]);

if(disable) {
if (reviewmode || fillformmode || viewDocMode)
mask = $("<div class='toolbar-group-mask'>").appendTo(toolbar.$el.find('.toolbar'));
Expand Down Expand Up @@ -3485,7 +3483,7 @@ define([
if ($panel) {
me.toolbar.addTab(tab, $panel, 5);
me.toolbar.setVisible('forms', true);
config.isEdit && config.canFeatureContentControl && config.canFeatureForms && Array.prototype.push.apply(me.toolbar.lockControls, forms.getView('FormsTab').getButtons());
Array.prototype.push.apply(me.toolbar.lockControls, forms.getView('FormsTab').getButtons());
!compactview && (config.isFormCreator || config.isRestrictedEdit && config.canFillForms) && me.toolbar.setTab('forms');
}
}
Expand Down
45 changes: 31 additions & 14 deletions apps/documenteditor/main/app/view/FormsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,13 @@ define([
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-clear-style',
caption: this.textClear,
lock: [ _set.lostConnect, _set.viewMode],
visible: this.appConfig.isRestrictedEdit && this.appConfig.canFillForms && this.appConfig.isPDFForm,
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
this.paragraphControls.push(this.btnClear);

this.btnPrevForm = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
Expand Down Expand Up @@ -442,17 +444,29 @@ define([
!(this.appConfig.isRestrictedEdit && this.appConfig.canFillForms) && this.paragraphControls.push(this.btnNextForm);

if (this.appConfig.canSubmitForms) {
this.btnSubmit = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-submit-form',
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',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
!(this.appConfig.isRestrictedEdit && this.appConfig.canFillForms) && this.paragraphControls.push(this.btnSubmit);
if (this.appConfig.isRestrictedEdit && this.appConfig.canFillForms) {
this.btnSubmit = new Common.UI.Button({
cls: 'btn-text-default auto yellow',
caption: this.capBtnSubmit,
lock: [_set.lostConnect, _set.disableOnStart, _set.requiredNotFilled, _set.submit],
dataHint: '0',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
});
} else {
this.btnSubmit = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-submit-form',
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',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
this.paragraphControls.push(this.btnSubmit);
}

} else if (this.appConfig.canDownloadForms) {
this.btnSaveForm = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
Expand Down Expand Up @@ -554,6 +568,7 @@ define([
var $host = this.$el;

if (this.appConfig.isRestrictedEdit && this.appConfig.canFillForms) {
this.btnSubmit ? this.btnSubmit.render($('#slot-btn-header-form-submit')) : $('#slot-btn-header-form-submit').hide();
} else {
this.btnTextField.render($host.find('#slot-btn-form-field'));
this.btnComboBox.render($host.find('#slot-btn-form-combobox'));
Expand All @@ -570,16 +585,16 @@ define([
this.btnZipCode.render($host.find('#slot-btn-form-zipcode'));
this.btnCreditCard.render($host.find('#slot-btn-form-credit'));
this.btnDateTime.render($host.find('#slot-btn-form-datetime'));
this.btnSubmit && this.btnSubmit.render($host.find('#slot-btn-form-submit'));

$host.find('.forms-buttons').show();
}
this.btnClear.render($host.find('#slot-btn-form-clear'));
this.btnPrevForm.render($host.find('#slot-btn-form-prev'));
this.btnNextForm.render($host.find('#slot-btn-form-next'));

this.btnSubmit && this.btnSubmit.render($host.find('#slot-btn-form-submit'));
this.btnSaveForm && this.btnSaveForm.render($host.find('#slot-btn-form-save'));
(this.btnSubmit || this.btnSaveForm) && $host.find('.save-separator').show();
(this.btnSubmit && !(this.appConfig.isRestrictedEdit && this.appConfig.canFillForms) || this.btnSaveForm) && $host.find('.save-separator').show();

return this.$el;
},
Expand Down Expand Up @@ -713,7 +728,9 @@ define([
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',
capBtnSaveFormDesktop: 'Save as...'
capBtnSaveFormDesktop: 'Save as...',
textSubmitOk: 'Your PDF form has been saved in the Complete section. You can fill out this form again and send another result.',
textFilled: 'Filled'
}
}()), DE.Views.FormsTab || {}));
});
3 changes: 2 additions & 1 deletion apps/documenteditor/main/app/view/MailMergeSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,8 @@ define([
documentHolder: {clear: false, disable: true},
toolbar: true,
plugins: false,
protect: false
protect: false,
header: {docmode: true}
}, 'mailmerge');

this.lockControls(DE.enumLockMM.preview, disable, {array: [this.btnInsField, this.btnEditData]});
Expand Down
3 changes: 2 additions & 1 deletion apps/documenteditor/main/app/view/SignatureSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ define([
documentHolder: {clear: true, disable: true},
toolbar: true,
plugins: false,
protect: false
protect: false,
header: {docmode: true}
}, 'signature');
}
},
Expand Down

0 comments on commit 3da4583

Please sign in to comment.