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,10 +16,11 @@ 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;
}; };
}; };
}; };
return formData; return formData;
}; };

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,34 +237,65 @@
<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="form-group"> <div class="row align-items-start">
<label for="days">Days</label> <div class="col">
<select class="form-control" id="days" name="days"> <div class="form-group">
</select> <label for="days">Days</label>
</div> <select class="form-control form-select" id="days" name="days">
<div class="form-group"> </select>
<label for="hours">Hours</label> </div>
<select class="form-control" id="hours" name="hours"> <div class="form-group">
</select> <label for="hours">Hours</label>
</div> <select class="form-control form-select" id="hours" name="hours">
<div class="form-group"> </select>
<label for="minutes">Minutes</label> </div>
<select class="form-control" id="minutes" name="minutes"> <div class="form-group">
</select> <label for="minutes">Minutes</label>
</div> <select class="form-control form-select" id="minutes" name="minutes">
{% if email_enabled %} </select>
<div class="form-group">
<label for="send_to_address">Send invite to address</label>
<div class="input-group">
<div class="input-group-text">
<input class="form-check-input" type="checkbox" onchange="document.getElementById('send_to_address').disabled = !this.checked;" aria-label="Checkbox to allow input of email address" id="send_to_address_enabled">
</div>
<input type="email" class="form-control" placeholder="example@example.com" id="send_to_address" disabled>
</div> </div>
</div> </div>
{% endif %} <div class="col">
<button type="submit" id="generateSubmit" class="btn btn-primary" style="margin-top: 1rem;">Generate</button> <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 %}
<div class="form-group">
<label for="send_to_address">Send invite to address</label>
<div class="input-group">
<div class="input-group-text">
<input class="form-check-input" type="checkbox" onchange="document.getElementById('send_to_address').disabled = !this.checked;" aria-label="Checkbox to allow input of email address" id="send_to_address_enabled">
</div>
<input type="email" class="form-control" placeholder="example@example.com" id="send_to_address" disabled>
</div>
</div>
{% endif %}
</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