|
- <% Flash().ShowErrorsIfPresent : Flash().ShowSuccessIfPresent %>
-
- <div class="d-flex justify-content-between align-items-center mb-3">
- <h1 class="h3 mb-0">Industries</h1>
- <span class="text-muted small"><%= list.Count %> industries</span>
- </div>
-
- <form method="post" action="/industries/create" class="card shadow-sm mb-3">
- <div class="card-body">
- <div class="row g-2 align-items-end">
- <div class="col-md-6">
- <label for="newName" class="form-label small mb-1">Add an industry</label>
- <input type="text" class="form-control form-control-sm" id="newName" name="name" maxlength="100" required />
- </div>
- <div class="col-md-3">
- <input type="hidden" name="csrf" value="<%= H(csrf) %>" />
- <button type="submit" class="btn btn-primary btn-sm">Add</button>
- </div>
- </div>
- </div>
- </form>
-
- <div class="card shadow-sm mb-3">
- <div class="table-responsive">
- <table class="table table-sm align-middle mb-0">
- <thead class="table-light">
- <tr><th style="width:34%">Name</th><th class="text-end" style="width:8%">Businesses</th><th>Rename</th><th>Merge into…</th><th></th></tr>
- </thead>
- <tbody>
- <% Dim ii, row, oi
- For ii = 0 To list.Count - 1
- Set row = list(ii)
- %>
- <tr>
- <td class="fw-semibold"><%= H(row("name")) %></td>
- <td class="text-end"><a href="/businesses?industry=<%= row("id") %>&status=all" class="text-decoration-none"><%= FormatNumber(row("n"), 0) %></a></td>
- <td>
- <form method="post" action="/industries/<%= row("id") %>/rename" class="d-flex gap-1">
- <input type="hidden" name="csrf" value="<%= H(csrf) %>" />
- <input type="text" class="form-control form-control-sm" name="name" value="<%= H(row("name")) %>" maxlength="100" aria-label="New name for <%= H(row("name")) %>" />
- <button type="submit" class="btn btn-outline-secondary btn-sm">Save</button>
- </form>
- </td>
- <td>
- <form method="post" action="/industries/<%= row("id") %>/merge" class="d-flex gap-1 js-confirm" data-confirm="Merge "<%= H(row("name")) %>" into the selected industry? This can't be undone.">
- <input type="hidden" name="csrf" value="<%= H(csrf) %>" />
- <select class="form-select form-select-sm" name="target_id" required aria-label="Merge <%= H(row("name")) %> into">
- <option value="">Choose…</option>
- <% For oi = 0 To list.Count - 1
- If list(oi)("id") <> row("id") Then %>
- <option value="<%= list(oi)("id") %>"><%= H(list(oi)("name")) %></option>
- <% End If
- Next %>
- </select>
- <button type="submit" class="btn btn-outline-warning btn-sm">Merge</button>
- </form>
- </td>
- <td class="text-end">
- <% If row("n") = 0 Then %>
- <form method="post" action="/industries/<%= row("id") %>/delete" class="d-inline js-confirm" data-confirm="Delete "<%= H(row("name")) %>"?">
- <input type="hidden" name="csrf" value="<%= H(csrf) %>" />
- <button type="submit" class="btn btn-outline-danger btn-sm">Delete</button>
- </form>
- <% End If %>
- </td>
- </tr>
- <% Next %>
- <% If uncategorized > 0 Then %>
- <tr class="table-light">
- <td class="fst-italic text-muted">(No industry)</td>
- <td class="text-end"><a href="/businesses?industry=0&status=all" class="text-decoration-none"><%= FormatNumber(uncategorized, 0) %></a></td>
- <td colspan="3"></td>
- </tr>
- <% End If %>
- </tbody>
- </table>
- </div>
- </div>
-
- <script>
- document.querySelectorAll('form.js-confirm').forEach(function (f) {
- f.addEventListener('submit', function (e) {
- if (!window.confirm(f.getAttribute('data-confirm'))) e.preventDefault();
- });
- });
- </script>
|