Skip to content

Commit

Permalink
[DE] Pdf form: add buttons to home tab in fill forms mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaRadzhabova committed Apr 4, 2024
1 parent 657ff16 commit f1964c1
Show file tree
Hide file tree
Showing 13 changed files with 304 additions and 17 deletions.
4 changes: 2 additions & 2 deletions apps/common/main/lib/view/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ define([
'</section>' +
'<section style="display: inherit;">' +
'<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 class="btn-slot margin-right-2" id="slot-btn-header-form-submit"></div>' +
'<div class="btn-slot margin-right-2" id="slot-btn-start-fill"></div>' +
'</div>' +
'<div class="hedset">' +
'<div class="btn-slot" id="slot-hbtn-edit"></div>' +
Expand Down
10 changes: 10 additions & 0 deletions apps/common/main/resources/less/toolbar.less
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,11 @@
left: 0;
}
}

#slot-btn-start-fill,
#slot-btn-header-form-submit {
padding: 2px 0;
}
}

.style-off-tabs {
Expand Down Expand Up @@ -646,6 +651,11 @@
}
}

#slot-btn-start-fill,
#slot-btn-header-form-submit {
padding: 4px 0;
}

#rib-doc-name {
color: @text-normal-ie;
color: @text-normal;
Expand Down
10 changes: 9 additions & 1 deletion apps/documenteditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,15 @@ define([
}
}, 50);
} else {
me.appOptions.isRestrictedEdit && me.appOptions.canFillForms && me.api.asc_SetHighlightRequiredFields(true);
if (me.appOptions.isRestrictedEdit && me.appOptions.canFillForms) {
me.api.asc_SetHighlightRequiredFields(true);
if (me.appOptions.isPDFForm) {
toolbarController.createDelayedElementsRestrictedEditForms();
toolbarController.activateControls();
me.api.UpdateInterfaceState();
}
}

documentHolderController.getView().createDelayedElementsViewer();
toolbarController.createDelayedElementsViewer();
Common.Utils.injectSvgIcons();
Expand Down
58 changes: 57 additions & 1 deletion apps/documenteditor/main/app/controller/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,25 @@ define([
this.toolbar.applyLayout(mode);
},

attachRestrictedEditFormsUIEvents: function(toolbar) {
toolbar.btnPrint.on('click', _.bind(this.onPrint, this));
toolbar.btnPrint.on('disabled', _.bind(this.onBtnChangeState, this, 'print:disabled'));
toolbar.btnSave.on('click', _.bind(this.onSave, this));
toolbar.btnUndo.on('click', _.bind(this.onUndo, this));
toolbar.btnUndo.on('disabled', _.bind(this.onBtnChangeState, this, 'undo:disabled'));
toolbar.btnRedo.on('click', _.bind(this.onRedo, this));
toolbar.btnRedo.on('disabled', _.bind(this.onBtnChangeState, this, 'redo:disabled'));
toolbar.btnCopy.on('click', _.bind(this.onCopyPaste, this, 'copy'));
toolbar.btnPaste.on('click', _.bind(this.onCopyPaste, this, 'paste'));
toolbar.btnCut.on('click', _.bind(this.onCopyPaste, this, 'cut'));
toolbar.btnSelectAll.on('click', _.bind(this.onSelectAll, this));
toolbar.btnSelectTool.on('toggle', _.bind(this.onSelectTool, this, 'select'));
toolbar.btnHandTool.on('toggle', _.bind(this.onSelectTool, this, 'hand'));

this.onBtnChangeState('undo:disabled', toolbar.btnUndo, toolbar.btnUndo.isDisabled());
this.onBtnChangeState('redo:disabled', toolbar.btnRedo, toolbar.btnRedo.isDisabled());
},

attachUIEvents: function(toolbar) {
/**
* UI Events
Expand Down Expand Up @@ -464,6 +483,8 @@ define([
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_onCanCopyCut', _.bind(this.onApiCanCopyCut, this));

}
}
this.api.asc_registerCallback('asc_onDownloadUrl', _.bind(this.onDownloadUrl, this));
Expand Down Expand Up @@ -3390,6 +3411,11 @@ define([
Common.Utils.injectSvgIcons();
},

createDelayedElementsRestrictedEditForms: function() {
this.toolbar.createDelayedElementsRestrictedEditForms();
this.attachRestrictedEditFormsUIEvents(this.toolbar);
},

createDelayedElementsViewer: function() {
this.onBtnChangeState('print:disabled', null, !this.mode.canPrint);
},
Expand Down Expand Up @@ -3472,11 +3498,29 @@ define([
Array.prototype.push.apply(me.toolbar.lockControls, links.getView('Links').getButtons());

me.toolbar.lockControls.push(application.getController('Viewport').getView('Common.Views.Header').getButton('mode'));
} else if (config.isRestrictedEdit && config.canFillForms && config.isPDFForm) {
me.toolbar.setMode(config);

me.toolbar.btnSave.on('disabled', _.bind(me.onBtnChangeState, me, 'save:disabled'));

if (!config.compactHeader) {
// hide 'print' and 'save' buttons group and next separator
me.toolbar.btnPrint.$el.parents('.group').hide().next().hide();

// hide 'undo' and 'redo' buttons and retrieve parent container
var $box = me.toolbar.btnUndo.$el.hide().next().hide().parent();

// move 'paste' button to the container instead of 'undo' and 'redo'
me.toolbar.btnPaste.$el.detach().appendTo($box);
me.toolbar.btnPaste.$el.find('button').attr('data-hint-direction', 'bottom');
me.toolbar.btnCopy.$el.removeClass('split');
me.toolbar.processPanelVisible(null, true);
}
}

if ( config.isEdit && config.canFeatureContentControl && config.canFeatureForms || config.isRestrictedEdit && config.canFillForms ) {
if (config.isFormCreator) {
tab = {caption: me.textTabForms, action: 'forms', dataHintTitle: 'M'};
tab = {caption: config.isRestrictedEdit && config.canFillForms && config.isPDFForm ? me.toolbar.textTabHome : me.textTabForms, action: 'forms', dataHintTitle: 'M'};
var forms = application.getController('FormsTab');
forms.setApi(me.api).setConfig({toolbar: me, config: config});
$panel = forms.createToolbarPanel();
Expand Down Expand Up @@ -3550,6 +3594,11 @@ define([
me.controllers.pageLayout.onLaunch(me.toolbar)
.setApi(me.api)
.onAppReady(config);
} else if (config.isRestrictedEdit && config.canFillForms && config.isPDFForm) {
if (me.toolbar.btnHandTool) {
me.toolbar.btnHandTool.toggle(true, true);
me.api.asc_setViewerTargetType('hand');
}
}

config.isOForm && config.canDownloadForms && Common.UI.warning({
Expand Down Expand Up @@ -3716,6 +3765,13 @@ define([
}
},

onSelectTool: function (type, btn, state, e) {
if (this.api && state) {
this.api.asc_setViewerTargetType(type);
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
}
},

textEmptyImgUrl : 'You need to specify image URL.',
textWarning : 'Warning',
textFontSizeErr : 'The entered value is incorrect.<br>Please enter a numeric value between 1 and 300',
Expand Down
37 changes: 37 additions & 0 deletions apps/documenteditor/main/app/template/ToolbarView.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,43 @@
</div>
</div>
<section class="box-controls">
<% if ( typeof config !== "undefined" && config.isRestrictedEdit && config.canFillForms && config.isPDFForm) { %>
<section class="panel static ">
<div class="group no-mask small">
<div class="elset">
<span class="btn-slot" id="slot-btn-save" data-layout-name="toolbar-save"></span>
</div>
<div class="elset">
<span class="btn-slot" id="slot-btn-print"></span>
</div>
</div>
<div class="separator long"></div>
<div class="group small">
<div class="elset">
<span class="btn-slot split" id="slot-btn-copy"></span>
<span class="btn-slot" id="slot-btn-paste"></span>
</div>
<div class="elset">
<span class="btn-slot split" id="slot-btn-undo"></span>
<span class="btn-slot" id="slot-btn-redo"></span>
</div>
</div>
<div class="group small">
<div class="elset">
<span class="btn-slot" id="slot-btn-cut"></span>
</div>
<div class="elset">
<span class="btn-slot" id="slot-btn-select-all"></span>
</div>
</div>
<div class="separator long"></div>
<div class="group" data-layout-name="toolbar-view-navigation">
<span class="btn-slot text x-huge" id="slot-btn-hand-tool"></span>
<span class="btn-slot text x-huge" id="slot-btn-select-tool"></span>
</div>
<div class="separator long"></div>
</section>
<% } %>
<section class="box-panels">
</section>
</section>
Expand Down
6 changes: 3 additions & 3 deletions apps/documenteditor/main/app/view/FormsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ define([
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-clear-style',
caption: this.textClear,
lock: [ _set.lostConnect, _set.viewMode],
lock: [ _set.lostConnect, _set.viewMode, _set.disableOnStart],
visible: this.appConfig.isRestrictedEdit && this.appConfig.canFillForms && this.appConfig.isPDFForm,
dataHint: '1',
dataHintDirection: 'bottom',
Expand All @@ -428,7 +428,7 @@ define([
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
!(this.appConfig.isRestrictedEdit && this.appConfig.canFillForms) && this.paragraphControls.push(this.btnPrevForm);
this.paragraphControls.push(this.btnPrevForm);

this.btnNextForm = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
Expand All @@ -441,7 +441,7 @@ define([
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
!(this.appConfig.isRestrictedEdit && this.appConfig.canFillForms) && this.paragraphControls.push(this.btnNextForm);
this.paragraphControls.push(this.btnNextForm);

if (this.appConfig.canSubmitForms) {
if (this.appConfig.isRestrictedEdit && this.appConfig.canFillForms) {
Expand Down
Loading

0 comments on commit f1964c1

Please sign in to comment.