Skip to content

Commit

Permalink
gluon-web: empty contact/location needs user confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
rotanid committed Jun 13, 2020
1 parent 3ef69c9 commit c2c4afa
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions package/gluon-web-model/files/lib/gluon/web/view/model/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,40 @@
" />
<% end %>
</div>

<script type="text/javascript">
//<![CDATA[
function $ (selector, el) {
if (!el) {el = document;}
return el.querySelector(selector);
}
var inputContact = $("input[name$='contact']");
if (typeof(inputContact) != 'undefined' && inputContact != null) {
var form = $("form");
function isEmpty(elem) {
if (elem == null || elem.value == null || elem.value == "" || elem.value == "0")
return true
return false
}
form.addEventListener('submit', function formSubmit(evt) {
var inputLocation = $("input[name$='location']");
var inputLocLat = $("input[name$='latitude']");
var inputLocLong = $("input[name$='longitude']");
var confirmContact = true;
var confirmLocation = true;
if (isEmpty(inputContact))
confirmContact = confirm("Willst Du wirklich keine Kontaktinformation hinterlegen?");
if (isEmpty(inputLocation) || isEmpty(inputLocLat) || isEmpty(inputLocLong))
confirmLocation = confirm("Willst Du wirklich keinen Standort angeben?");
if (!confirmContact || !confirmLocation) {
evt.returnValue = false;
if (evt.preventDefault) evt.preventDefault();
return false;
}
return true;
}, false);
}
//]]>
</script>

</form>

0 comments on commit c2c4afa

Please sign in to comment.