refactor admin.js, add initial ui elements for multi-use invites

multi-use invites will have a set limit of how many times they can be
used. They can also be set to have no limit. An additional menu is
planned for multi use invites to see when they have been used, and by
who.
This commit is contained in:
Harvey Tindall 2020-07-09 23:00:59 +01:00
parent 89c132e92e
commit db3b992857
3 changed files with 437 additions and 423 deletions

View File

@ -16,6 +16,7 @@ function serializeForm(id) {
case 'password': case 'password':
case 'select-one': case 'select-one':
case 'email': case 'email':
case 'number':
formData[name] = el.value; formData[name] = el.value;
break; break;
}; };

View File

@ -31,9 +31,9 @@
return ""; return "";
}; };
{% if bs5 %} {% if bs5 %}
var bsVersion = 5; const bsVersion = 5;
{% else %} {% else %}
var bsVersion = 4; const bsVersion = 4;
{% endif %} {% endif %}
console.log('create'); console.log('create');
var css = document.createElement('link'); var css = document.createElement('link');
@ -237,22 +237,43 @@
<div class="card mb-3"> <div class="card mb-3">
<div class="card-header">Generate Invite</div> <div class="card-header">Generate Invite</div>
<div class="card-body"> <div class="card-body">
<form action="#" method="POST" id="inviteForm"> <form action="#" method="POST" id="inviteForm" class="container">
<div class="row align-items-start">
<div class="col">
<div class="form-group"> <div class="form-group">
<label for="days">Days</label> <label for="days">Days</label>
<select class="form-control" id="days" name="days"> <select class="form-control form-select" id="days" name="days">
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="hours">Hours</label> <label for="hours">Hours</label>
<select class="form-control" id="hours" name="hours"> <select class="form-control form-select" id="hours" name="hours">
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="minutes">Minutes</label> <label for="minutes">Minutes</label>
<select class="form-control" id="minutes" name="minutes"> <select class="form-control form-select" id="minutes" name="minutes">
</select> </select>
</div> </div>
</div>
<div class="col">
<div class="form-group">
<label for="multiUseCount">
Multiple uses
</label>
<div class="input-group">
<div class="input-group-text">
<input class="form-check-input" type="checkbox" onchange="document.getElementById('multiUseCount').disabled = !this.checked; document.getElementById('noUseLimit').disabled = !this.checked; document.getElementById('noUseLimit').checked = false;" aria-label="Checkbox to allow choice of invite usage limit" name="multiple-uses" id="multiUseEnabled">
</div>
<input type="number" class="form-control" name="remaining-uses" id="multiUseCount">
</div>
</div>
<div class="form-group form-check" style="margin-top: 1rem; margin-bottom: 1rem;">
<input class="form-check-input" type="checkbox" value="" name="no-limit" id="noUseLimit" onchange="document.getElementById('multiUseCount').disabled = this.checked;">
<label class="form-check-label" for="noUseLimit">
No limit
</label>
</div>
{% if email_enabled %} {% if email_enabled %}
<div class="form-group"> <div class="form-group">
<label for="send_to_address">Send invite to address</label> <label for="send_to_address">Send invite to address</label>
@ -264,7 +285,17 @@
</div> </div>
</div> </div>
{% endif %} {% endif %}
<button type="submit" id="generateSubmit" class="btn btn-primary" style="margin-top: 1rem;">Generate</button> </div>
</div>
<div class="row">
<div class="col">
<div class="form-group d-flex float-right">
<button type="submit" id="generateSubmit" class="btn btn-primary" style="margin-top: 1rem;">
Generate
</button>
</div>
</div>
</div>
</form> </form>
</div> </div>
</div> </div>

File diff suppressed because it is too large Load Diff