Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

editor: prevent the enter key to submit the form #1772

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@
"minLength": 1,
"form": {
"templateOptions": {
"itemCssClass": "col-lg-6"
"itemCssClass": "col-lg-6",
"doNotSubmitOnEnter": true
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,12 @@
},
"identifier": {
"type": "string",
"title": "Identifier"
"title": "Identifier",
"form": {
"templateOptions": {
"doNotSubmitOnEnter": true
}
}
},
"source": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h4 class="alert-heading">{{ _('Caution!') }}</h4>
<p class="mb-0">{{ _('A well detailed request is more likely to be satisfied') }}</p>
</div>

<form action="{{ url_for('ill_requests.ill_request_form') }}" method="POST" class="form" role="form" novalidate>
<form id="ill-public-form" action="{{ url_for('ill_requests.ill_request_form') }}" method="POST" class="form" role="form" novalidate>
{{ form.hidden_tag() }}
{%- if form.csrf_token and form.csrf_token.errors %}
<div class="alert alert-danger" role="alert">
Expand Down Expand Up @@ -62,8 +62,28 @@ <h3>{{ _('Request information') }}</h3>
</section>
<div class="row pt-3">
<div class="col text-right">
<input type="submit" id="submit" class="btn btn-primary" value="{{ _('Create request') }}"/>
<input type="submit" id="submit" class="btn btn-primary" value="{{ _('Submit') }}"/>
</div>
</div>
</form>

<div id="ill-modal-confirmation" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{{ _('Confirmation') }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p>{{ _('Costs may apply. By confirming, you agree to the interlibrary loan conditions of the pick-up library.') }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-danger" data-dismiss="modal">{{ _('Cancel') }}</button>
<button id="ill-modal-confirmation-btn" type="button" class="btn btn-primary">{{ _('Confirm') }}</button>
</div>
</div>
</div>
</div>
{%- endblock body %}
3 changes: 2 additions & 1 deletion rero_ils/modules/items/jsonschemas/items/item-v0.0.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"form": {
"focus": true,
"templateOptions": {
"labelClasses": "col-2 text-right"
"labelClasses": "col-2 text-right",
"doNotSubmitOnEnter": true
},
"navigation": {
"essential": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@
"type": "string",
"minLength": 6,
"form": {
"templateOptions": {
"doNotSubmitOnEnter": true
},
"validation": {
"validators": {
"valueAlreadyExists": {
Expand Down Expand Up @@ -377,6 +380,9 @@
},
"form": {
"hideExpression": "!field.parent.model.roles.some(v => v === 'patron')",
"expressionProperties": {
"templateOptions.required": "true"
},
"templateOptions": {
"wrappers": [
"card"
Expand Down
36 changes: 36 additions & 0 deletions rero_ils/theme/assets/js/reroils/ills_request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*

RERO ILS
Copyright (C) 2019 RERO

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

*/

import $ from 'jquery';

// show a confirmation modal dialog on form submission
$("#submit").on("click", function(event){
if($(this).data('confirmed') !== true) {
$("#ill-modal-confirmation").modal('show');
event.preventDefault();
}
});

// close the dialog, confirmed is true and trigger the submit click button
$("#ill-modal-confirmation-btn").on("click", function(event){
$( "#submit" ).data('confirmed', true);
$("#ill-modal-confirmation").modal('hide');
// form submit does not works
$("#submit").trigger('click');
});
2 changes: 1 addition & 1 deletion rero_ils/theme/assets/js/reroils/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

*/

import 'bootstrap';
import './tooltip';
import './toast';
import './login';
import './toggle';
import './ills_request';