Skip to content

Commit

Permalink
Merge pull request #55 from versx/ensure-location-area-selected
Browse files Browse the repository at this point in the history
Ensure a location or area is selected
  • Loading branch information
versx authored May 29, 2021
2 parents 6d07b5c + 45ebe68 commit 75bf6c6
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/views/gyms/edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</div>
<div class="form-group">
{{Location}}
<select name="location" class="custom-select" required>
<select name="location" class="custom-select">
<option value="">{{None}}</option>
{{#locations}}
<option value="{{name}}" {{#selected}}selected{{/selected}}>{{name}}</option>
Expand Down
2 changes: 1 addition & 1 deletion src/views/gyms/new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</div>
<div class="form-group">
{{Location}}
<select id="location" name="location" class="custom-select" required>
<select id="location" name="location" class="custom-select">
<option value="">{{None}}</option>
</select>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/views/invasions/edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</div>
<div class="form-group">
{{Location}}
<select name="location" class="custom-select" required>
<select name="location" class="custom-select">
<option value="">{{None}}</option>
{{#locations}}
<option value="{{name}}" {{#selected}}selected{{/selected}}>{{name}}</option>
Expand All @@ -56,6 +56,10 @@
<input type="hidden" id="guild_id" name="guild_id" required>
<button type="submit" class="btn btn-primary">{{Save}}</button>
<br>
<br>
<div id="error-div" class="alert alert-danger" style="float: none; margin: 0 auto;" hidden>
</div>
<br>
</form>
<form action="/api/invasions/delete/{{id}}" method="post">
<button type="submit" class="btn btn-danger" onclick="return confirm('{{Are you sure that you want to delete invasion subscription}} {{id}}?');">{{Delete}}</button>
Expand Down
6 changes: 5 additions & 1 deletion src/views/invasions/new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,18 @@
</div>
<div class="form-group">
{{Location}}
<select id="location" name="location" class="custom-select" required>
<select id="location" name="location" class="custom-select">
<option value="">{{None}}</option>
</select>
</div>
<br>
<input type="hidden" id="guild_id" name="guild_id" required>
<button type="submit" class="btn btn-primary">{{Create}}</button>
<br>
<br>
<div id="error-div" class="alert alert-danger" style="float: none; margin: 0 auto;" hidden>
</div>
<br>
</form>
</div>

Expand Down
6 changes: 5 additions & 1 deletion src/views/lures/edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</div>
<div class="form-group">
{{Location}}
<select name="location" class="custom-select" required>
<select name="location" class="custom-select">
<option value="">{{None}}</option>
{{#locations}}
<option value="{{name}}" {{#selected}}selected{{/selected}}>{{name}}</option>
Expand All @@ -42,6 +42,10 @@
<input type="hidden" id="guild_id" name="guild_id">
<button type="submit" class="btn btn-primary">{{Save}}</button>
<br>
<br>
<div id="error-div" class="alert alert-danger" style="float: none; margin: 0 auto;" hidden>
</div>
<br>
</form>
<form action="/api/lures/delete/{{id}}" method="post">
<button type="submit" class="btn btn-danger" onclick="return confirm('{{Are you sure that you want to delete lure subscription}} {{id}}?');">{{Delete}}</button>
Expand Down
6 changes: 5 additions & 1 deletion src/views/lures/new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@
</div>
<div class="form-group">
{{Location}}
<select id="location" name="location" class="custom-select" required>
<select id="location" name="location" class="custom-select">
<option value="">{{None}}</option>
</select>
</div>
<br>
<input type="hidden" id="guild_id" name="guild_id">
<button type="submit" class="btn btn-primary">{{Create}}</button>
<br>
<br>
<div id="error-div" class="alert alert-danger" style="float: none; margin: 0 auto;" hidden>
</div>
<br>
</form>
</div>

Expand Down
6 changes: 5 additions & 1 deletion src/views/pokemon/edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
</div>
<div class="form-group">
{{Location}}
<select name="location" class="custom-select" required>
<select id="location" name="location" class="custom-select">
<option value="">{{None}}</option>
{{#locations}}
<option value="{{name}}" {{#selected}}selected{{/selected}}>{{name}}</option>
Expand All @@ -84,6 +84,10 @@
<input type="hidden" id="guild_id" name="guild_id">
<button type="submit" class="btn btn-primary">{{Save}}</button>
<br>
<br>
<div id="error-div" class="alert alert-danger" style="float: none; margin: 0 auto;" hidden>
</div>
<br>
</form>
<form action="/api/pokemon/delete/{{id}}" method="post">
<button type="submit" class="btn btn-danger" onclick="return confirm('{{Are you sure that you want to delete pokemon subscription}} {{id}}?');">{{Delete}}</button>
Expand Down
6 changes: 5 additions & 1 deletion src/views/pokemon/new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,18 @@
</div>
<div class="form-group">
{{Location}}
<select id="location" name="location" class="custom-select" required>
<select id="location" name="location" class="custom-select">
<option value="">{{None}}</option>
</select>
</div>
<br>
<input type="hidden" id="guild_id" name="guild_id">
<button type="submit" class="btn btn-primary">{{Create}}</button>
<br>
<br>
<div id="error-div" class="alert alert-danger" style="float: none; margin: 0 auto;" hidden>
</div>
<br>
</form>
</div>

Expand Down
6 changes: 5 additions & 1 deletion src/views/pvp/edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</div>
<div class="form-group">
{{Location}}
<select name="location" class="custom-select" required>
<select name="location" class="custom-select">
<option value="">{{None}}</option>
{{#locations}}
<option value="{{name}}" {{#selected}}selected{{/selected}}>{{name}}</option>
Expand All @@ -71,6 +71,10 @@
<input type="hidden" id="guild_id" name="guild_id">
<button type="submit" class="btn btn-primary">{{Save}}</button>
<br>
<br>
<div id="error-div" class="alert alert-danger" style="float: none; margin: 0 auto;" hidden>
</div>
<br>
</form>
<form action="/api/pvp/delete/{{id}}" method="post">
<button type="submit" class="btn btn-danger" onclick="return confirm('{{Are you sure that you want to delete PVP subscription}} {{id}}?');">{{Delete}}</button>
Expand Down
6 changes: 5 additions & 1 deletion src/views/pvp/new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,18 @@
</div>
<div class="form-group">
{{Location}}
<select id="location" name="location" class="custom-select" required>
<select id="location" name="location" class="custom-select">
<option value="">{{None}}</option>
</select>
</div>
<br>
<input type="hidden" id="guild_id" name="guild_id">
<button type="submit" class="btn btn-primary">{{Create}}</button>
<br>
<br>
<div id="error-div" class="alert alert-danger" style="float: none; margin: 0 auto;" hidden>
</div>
<br>
</form>
</div>

Expand Down
6 changes: 5 additions & 1 deletion src/views/quests/edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</div>
<div class="form-group">
{{Location}}
<select name="location" class="custom-select" required>
<select name="location" class="custom-select">
<option value="">{{None}}</option>
{{#locations}}
<option value="{{name}}" {{#selected}}selected{{/selected}}>{{name}}</option>
Expand All @@ -42,6 +42,10 @@
<input type="hidden" id="guild_id" name="guild_id">
<button type="submit" class="btn btn-primary">{{Save}}</button>
<br>
<br>
<div id="error-div" class="alert alert-danger" style="float: none; margin: 0 auto;" hidden>
</div>
<br>
</form>
<form action="/api/quests/delete/{{id}}" method="post">
<button type="submit" class="btn btn-danger" onclick="return confirm('{{Are you sure that you want to delete quest subscription}} {{id}}?');">{{Delete}}</button>
Expand Down
6 changes: 5 additions & 1 deletion src/views/quests/new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@
</div>
<div class="form-group">
{{Location}}
<select id="location" name="location" class="custom-select" required>
<select id="location" name="location" class="custom-select">
<option value="">{{None}}</option>
</select>
</div>
<br>
<input type="hidden" id="guild_id" name="guild_id">
<button type="submit" class="btn btn-primary">{{Create}}</button>
<br>
<br>
<div id="error-div" class="alert alert-danger" style="float: none; margin: 0 auto;" hidden>
</div>
<br>
</form>
</div>

Expand Down
6 changes: 5 additions & 1 deletion src/views/raids/edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</div>
<div class="form-group">
{{Location}}
<select name="location" class="custom-select" required>
<select name="location" class="custom-select">
<option value="">{{None}}</option>
{{#locations}}
<option value="{{name}}" {{#selected}}selected{{/selected}}>{{name}}</option>
Expand All @@ -54,6 +54,10 @@
<input type="hidden" id="guild_id" name="guild_id">
<button type="submit" class="btn btn-primary">{{Save}}</button>
<br>
<br>
<div id="error-div" class="alert alert-danger" style="float: none; margin: 0 auto;" hidden>
</div>
<br>
</form>
<form action="/api/raids/delete/{{id}}" method="post">
<button type="submit" class="btn btn-danger" onclick="return confirm('{{Are you sure that you want to delete raid subscription}} {{id}}?');">{{Delete}}</button>
Expand Down
6 changes: 5 additions & 1 deletion src/views/raids/new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,18 @@
</div>
<div class="form-group">
{{Location}}
<select id="location" name="location" class="custom-select" required>
<select id="location" name="location" class="custom-select">
<option value="">{{None}}</option>
</select>
</div>
<br>
<input type="hidden" id="guild_id" name="guild_id">
<button type="submit" class="btn btn-primary">{{Create}}</button>
<br>
<br>
<div id="error-div" class="alert alert-danger" style="float: none; margin: 0 auto;" hidden>
</div>
<br>
</form>
</div>

Expand Down
14 changes: 14 additions & 0 deletions static/js/city-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ let geofenceDb = {};
let selectedGeofences = [];
let initialSelect = [];

$('form').submit(function(e) {
const city = $('#city').val();
const location = $('#location').val();
const result = city !== '' || location !== '';
console.log('result:', result);
if (!result) {
// TODO: Show error message about location/areas selection
$('#error-div').prop('hidden', false);
$('#error-div').html('<div><strong>Error!</strong> Please select either an area and/or location to receive the notification.</div>');
e.preventDefault();
}
return result;
});

function initMap(startLocation, startZoom, minZoom, maxZoom, tileserver, selected = []) {
const map = L.map('map', {
tap: false,
Expand Down

0 comments on commit 75bf6c6

Please sign in to comment.