Added dynamic support for countries
This commit is contained in:
1 parent
381444a838
commit
47b9939ead
17 files changed
+296
-69
No files matched your search
@@ -17,6 +17,7 @@
|
||||
<nav>
|
||||
<section class="container">
|
||||
<a class="selected" href="#">Search</a>
|
||||
<a href="/admin/countries">Countries</a>
|
||||
<button data-type="dialog" data-trigger="#create-card" data-url="/admin/dialogs/add-holiday">Add new holiday</button>
|
||||
</section>
|
||||
</nav>
|
||||
@@ -27,23 +28,22 @@
|
||||
<section>
|
||||
<label for="country">Country:</label>
|
||||
<select id="country" name="country">
|
||||
<option value="HR" {{if eq .search.Country "HR"}}selected{{end}}>Croatia</option>
|
||||
<option value="GB" {{if eq .search.Country "GB"}}selected{{end}}>Great Britain</option>
|
||||
<option value="US" {{if eq .search.Country "US"}}selected{{end}}>USA</option>
|
||||
<option value="FR" {{if eq .search.Country "FR"}}selected{{end}}>France</option>
|
||||
{{range $entry := .Countries}}
|
||||
<option {{if eq $.Search.Country $entry.IsoName}}selected{{end}} value="{{$entry.IsoName}}">{{$entry.Name}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</section>
|
||||
<section>
|
||||
<label for="year">Year:</label>
|
||||
<select id="year" name="year">
|
||||
<option value="2020" {{if eq (deferint .search.Year) 2020}}selected{{end}}>2020</option>
|
||||
<option value="2021" {{if eq (deferint .search.Year) 2021}}selected{{end}}>2021</option>
|
||||
<option value="2022" {{if eq (deferint .search.Year) 2022}}selected{{end}}>2022</option>
|
||||
<option value="2023" {{if eq (deferint .search.Year) 2023}}selected{{end}}>2023</option>
|
||||
<option value="2024" {{if eq (deferint .search.Year) 2024}}selected{{end}}>2024</option>
|
||||
<option value="2025" {{if eq (deferint .search.Year) 2025}}selected{{end}}>2025</option>
|
||||
<option value="2026" {{if eq (deferint .search.Year) 2026}}selected{{end}}>2026</option>
|
||||
<option value="2027" {{if eq (deferint .search.Year) 2027}}selected{{end}}>2027</option>
|
||||
<option value="2020" {{if eq (deferint .Search.Year) 2020}}selected{{end}}>2020</option>
|
||||
<option value="2021" {{if eq (deferint .Search.Year) 2021}}selected{{end}}>2021</option>
|
||||
<option value="2022" {{if eq (deferint .Search.Year) 2022}}selected{{end}}>2022</option>
|
||||
<option value="2023" {{if eq (deferint .Search.Year) 2023}}selected{{end}}>2023</option>
|
||||
<option value="2024" {{if eq (deferint .Search.Year) 2024}}selected{{end}}>2024</option>
|
||||
<option value="2025" {{if eq (deferint .Search.Year) 2025}}selected{{end}}>2025</option>
|
||||
<option value="2026" {{if eq (deferint .Search.Year) 2026}}selected{{end}}>2026</option>
|
||||
<option value="2027" {{if eq (deferint .Search.Year) 2027}}selected{{end}}>2027</option>
|
||||
</select>
|
||||
</section>
|
||||
<section class="radio-group">
|
||||
@@ -53,7 +53,7 @@
|
||||
</label><input type="radio" value="false" name="sh" id="sh_false"><label for="sh_false">False
|
||||
</label><input type="radio" value="" name="sh" id="sh_any"><label for="sh_any">All</label>
|
||||
</div>
|
||||
<input type="hidden" value="{{.search.StateHoliday}}" name="state_holiday">
|
||||
<input type="hidden" value="{{.Search.StateHoliday}}" name="state_holiday">
|
||||
</section>
|
||||
<section class="radio-group">
|
||||
<label>Is religious holiday:</label>
|
||||
@@ -62,7 +62,7 @@
|
||||
</label><input type="radio" value="false" name="rh" id="rh_false"><label for="rh_false">False
|
||||
</label><input type="radio" value="" name="rh" id="rh_any"><label for="rh_any">All</label>
|
||||
</div>
|
||||
<input type="hidden" value="{{.search.ReligiousHoliday}}" name="religious_holiday">
|
||||
<input type="hidden" value="{{.Search.ReligiousHoliday}}" name="religious_holiday">
|
||||
</section>
|
||||
<section class="actions">
|
||||
<button class="icon primary" type="submit">
|
||||
@@ -86,7 +86,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{range $entry := .holidays.Holidays}}
|
||||
{{range $entry := .Holidays.Holidays}}
|
||||
<tr>
|
||||
<td>{{$entry.Name}}</td>
|
||||
<td>{{$entry.Date.Format "2006-01-02"}}</td>
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Holiday-api | Admin dashboard</title>
|
||||
<link rel="stylesheet" href="/assets/style.css">
|
||||
<script src="/assets/global.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="dialog-container"></div>
|
||||
<header>
|
||||
<section class="container">
|
||||
<h1><a href="/">Holiday-api | Countries</a></h1>
|
||||
</section>
|
||||
</header>
|
||||
<nav>
|
||||
<section class="container">
|
||||
<a href="/admin">Search</a>
|
||||
<a class="selected" href="#">Countries</a>
|
||||
<button data-type="dialog" data-trigger="#create-card" data-url="/admin/dialogs/add-holiday">Add new holiday</button>
|
||||
</section>
|
||||
</nav>
|
||||
<main>
|
||||
|
||||
<section style="margin: 1em; flex-grow: 1">
|
||||
<form action="/admin/countries" method="post">
|
||||
<table style="width: 100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Iso name</th>
|
||||
<th>Name</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td><section><input minlength="2" maxlength="2" required id="iso_name" type="text" name="iso_name"></section></td>
|
||||
<td><section><input minlength="1" maxlength="45" required id="name" type="text" name="name"></section></td>
|
||||
<td><button>Create country</button></td>
|
||||
</tr>
|
||||
|
||||
{{range $entry := .Countries}}
|
||||
<tr>
|
||||
<td>{{$entry.IsoName}}</td>
|
||||
<td>{{$entry.Name}}</td>
|
||||
<td>
|
||||
<button type="button" data-type="dialog" data-trigger="#update-card" data-url="/admin/dialogs/edit-country?id={{$entry.Id}}" class="clean icon"><img class="icon" src="/assets/images/edit.svg"></button>
|
||||
<button type="button" data-type="dialog" data-trigger="#delete-card" data-url="/admin/dialogs/delete-country?id={{$entry.Id}}" class="clean icon"><img class="icon" src="/assets/images/trash-delete.svg"></button>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -4,10 +4,9 @@
|
||||
<section>
|
||||
<label for="country">Country:</label>
|
||||
<select id="country" required name="country">
|
||||
<option value="HR">Croatia</option>
|
||||
<option value="US">United states</option>
|
||||
<option value="FR">France</option>
|
||||
<option value="GB">Great Britain</option>
|
||||
{{range $entry := .Countries}}
|
||||
<option value="{{$entry.IsoName}}">{{$entry.Name}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</section>
|
||||
<section>
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
<section>
|
||||
<label for="country">Country:</label>
|
||||
<select id="country" name="country">
|
||||
<option value="HR">Croatia</option>
|
||||
<option value="US">United states</option>
|
||||
<option value="FR">France</option>
|
||||
<option value="GB">Great Britain</option>
|
||||
{{range $entry := .Countries}}
|
||||
<option value="{{$entry.IsoName}}">{{$entry.Name}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</section>
|
||||
<section>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
<dialog class="card" id="delete-card">
|
||||
<h3 class="card-title">Delete country</h3>
|
||||
<p>Are you sure you want to delete "{{.Country.Name}}"?<br>All holidays for given country will be deleted!</p>
|
||||
<form method="post" action="/admin/countries/{{.Country.Id}}/delete">
|
||||
<section class="actions">
|
||||
<button type="submit">Delete</button>
|
||||
<button type="button" onclick="closeDialog('#delete-card')">Cancel</button>
|
||||
</section>
|
||||
</form>
|
||||
</dialog>
|
||||
@@ -0,0 +1,18 @@
|
||||
<dialog class="card" id="update-card">
|
||||
<h3 class="card-title">Edit country</h3>
|
||||
<form method="post" action="/admin/countries">
|
||||
<input type="hidden" name="id" value="{{.Country.Id}}">
|
||||
<section>
|
||||
<label for="name">Iso name:</label>
|
||||
<input required minlength="2" maxlength="2" id="iso_name" value="{{.Country.IsoName}}" name="iso_name" type="text">
|
||||
</section>
|
||||
<section>
|
||||
<label for="name">Name:</label>
|
||||
<input required minlength="1" maxlength="45" id="name" value="{{.Country.Name}}" name="name" type="text">
|
||||
</section>
|
||||
<section class="actions">
|
||||
<button type="submit">Update</button>
|
||||
<button type="button" onclick="closeDialog('#update-card')">Cancel</button>
|
||||
</section>
|
||||
</form>
|
||||
</dialog>
|
||||
@@ -5,10 +5,9 @@
|
||||
<section>
|
||||
<label for="country">Country:</label>
|
||||
<select id="country" required name="country">
|
||||
<option {{if eq .Holiday.Country "HR"}}selected{{end}} value="HR">Croatia</option>
|
||||
<option {{if eq .Holiday.Country "US"}}selected{{end}} value="US">United states</option>
|
||||
<option {{if eq .Holiday.Country "FR"}}selected{{end}} value="FR">France</option>
|
||||
<option {{if eq .Holiday.Country "GB"}}selected{{end}} value="GB">Great Britain</option>
|
||||
{{range $entry := .Countries}}
|
||||
<option {{if eq $.Holiday.Country $entry.IsoName}}selected{{end}} value="{{$entry.IsoName}}">{{$entry.Name}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</section>
|
||||
<section>
|
||||
|
||||
@@ -29,10 +29,9 @@
|
||||
<section>
|
||||
<label for="country">Country</label>
|
||||
<select id="country" name="country">
|
||||
<option value="HR">Croatia</option>
|
||||
<option value="GB">Great Britain</option>
|
||||
<option value="US">USA</option>
|
||||
<option value="FR">France</option>
|
||||
{{range $entry := .Countries}}
|
||||
<option value="{{$entry.IsoName}}">{{$entry.Name}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -28,10 +28,9 @@
|
||||
<section>
|
||||
<label for="country">Country:</label>
|
||||
<select id="country" name="country">
|
||||
<option {{if eq .Search.Country "HR"}}selected{{end}} value="HR">Croatia</option>
|
||||
<option {{if eq .Search.Country "US"}}selected{{end}} value="US">United states</option>
|
||||
<option {{if eq .Search.Country "FR"}}selected{{end}} value="FR">France</option>
|
||||
<option {{if eq .Search.Country "GB"}}selected{{end}} value="GB">Great Britain</option>
|
||||
{{range $entry := .Countries}}
|
||||
<option {{if eq $.Search.Country $entry.IsoName}}selected{{end}} value="{{$entry.IsoName}}">{{$entry.Name}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</section>
|
||||
<section>
|
||||
|
||||
@@ -29,10 +29,9 @@
|
||||
<section>
|
||||
<label for="country">Country:</label>
|
||||
<select id="country" name="country">
|
||||
<option {{if eq .Search.Country "HR"}}selected{{end}} value="HR">Croatia</option>
|
||||
<option {{if eq .Search.Country "US"}}selected{{end}} value="US">United states</option>
|
||||
<option {{if eq .Search.Country "FR"}}selected{{end}} value="FR">France</option>
|
||||
<option {{if eq .Search.Country "GB"}}selected{{end}} value="GB">Great Britain</option>
|
||||
{{range $entry := .Countries}}
|
||||
<option {{if eq $.Search.Country $entry.IsoName}}selected{{end}} value="{{$entry.IsoName}}">{{$entry.Name}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</section>
|
||||
<section>
|
||||
|
||||
Reference in new issue
Block a user