mirror of
https://github.com/aaronleetw/Attendance.git
synced 2024-11-14 19:11:39 -08:00
Homeroom edit functionality
This commit is contained in:
parent
9ae3fd8c2a
commit
94394334f4
2 changed files with 48 additions and 14 deletions
10
manage.py
10
manage.py
|
@ -269,6 +269,15 @@ def homeroom_abs_publish():
|
|||
homeroom = request.form['homeroom'].split('^')
|
||||
period = request.form['period']
|
||||
signature = request.form['signatureData']
|
||||
if (request.form['stype'] == 'edit'):
|
||||
oldData = list(db.child("Homerooms").child(homeroom[0]).child(homeroom[1]).child(
|
||||
"Absent").child(date).child(period).shallow().get(session['token']).val())
|
||||
print(oldData, type(oldData))
|
||||
for k in oldData:
|
||||
if k == 'name' or k == 'teacher':
|
||||
continue
|
||||
db.child("Homerooms").child(homeroom[0]).child(homeroom[1]).child(
|
||||
"Absent").child(date).child(period).child(k).remove(session['token'])
|
||||
formData = request.form.to_dict()
|
||||
notes = ""
|
||||
if "confirm" in db.child("Homerooms").child(homeroom[0]).child(homeroom[1]).child("Absent").child(date).get(session['token']).val():
|
||||
|
@ -288,6 +297,7 @@ def homeroom_abs_publish():
|
|||
formData.pop('date')
|
||||
formData.pop('homeroom')
|
||||
formData.pop('period')
|
||||
formData.pop('stype')
|
||||
for i in formData:
|
||||
i = i.split('^')
|
||||
db.child("Homerooms").child(homeroom[0]).child(
|
||||
|
|
|
@ -87,23 +87,23 @@
|
|||
<div class="col">{{ homeroomData[i]['name'] }}</div>
|
||||
<div class="col">{{ homeroomData[i]['eng_name'] }}</div>
|
||||
{% for j in periods %}
|
||||
<div class="col" {% if currPeriod==j %} style="background-color: #ffdf81;" {% endif %}>
|
||||
<div class="col view-{{j}}" {% if currPeriod==j %} style="background-color: #ffdf81;" {% endif %}>
|
||||
{% if 'signature' in absData[currDate][j] %}
|
||||
{% if i in absData[currDate][j] %}
|
||||
{% if absData[currDate][j][i] == 1 %}
|
||||
<p class="highlightAbs n-2">X</p>
|
||||
<p class="highlightAbs n-2 view-n-{{i}}">X</p>
|
||||
{% else %}
|
||||
<p class="highlightAbs n-3">𝜑</p>
|
||||
<p class="highlightAbs n-3 view-n-{{i}}">𝜑</p>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if absData[currDate][j]['name'] != 'GP' %}
|
||||
<p class="highlightAbs n-1">V</p>
|
||||
<p class="highlightAbs n-1 view-n-{{i}}">V</p>
|
||||
{% else %}
|
||||
{% if (homeroomData[i]['GP_Class'][absData[currDate][j]['teacher']] in
|
||||
absData[currDate][j]['signature'])%}
|
||||
<p class="highlightAbs n-1">V</p>
|
||||
<p class="highlightAbs n-1 view-n-{{i}}">V</p>
|
||||
{% else %}
|
||||
<p class="highlightAbs n-2"></p>
|
||||
<p class="highlightAbs n-2 view-n-{{i}}"></p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
@ -130,14 +130,15 @@
|
|||
<div class="col"></div>
|
||||
<div class="col"></div>
|
||||
{% for i in periods %}
|
||||
<div class="col" {% if currPeriod==i %} style="background-color: #ffdf81;" {% endif %}>
|
||||
{% if ('signature' in absData[currDate][i] or absData[currDate][i]['name'] == 'GP' or
|
||||
'confirm' in absData[currDate]) %}
|
||||
<button class="btn btn-primary afterSelButton" disabled="disabled"
|
||||
onclick="afterSelAbs('{{i|string}}')"></button>
|
||||
<div id="btns-{{i}}" class="col" {% if currPeriod==i %} style="background-color: #ffdf81;" {% endif %}>
|
||||
{% if (absData[currDate][i]['name'] == 'GP' or 'confirm' in absData[currDate]) %}
|
||||
<button class="btn btn-danger afterSelButton" disabled="disabled"></button>
|
||||
{% elif ('signature' in absData[currDate][i]) %}
|
||||
<button class="btn btn-danger afterSelButton" onclick="edit('{{i|string}}')">Edit
|
||||
<br>{{absData[currDate][i]['name']}}</button>
|
||||
{% else %}
|
||||
<button class="btn btn-primary afterSelButton"
|
||||
onclick="afterSelAbs('{{i|string}}')">Confirm<br>{{absData[currDate][i]['name']}}</button>
|
||||
onclick="afterSelAbs('{{i|string}}', 'newSubmit')">Confirm<br>{{absData[currDate][i]['name']}}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
@ -148,6 +149,7 @@
|
|||
<input type="text" id="HR-signatureData" name="signatureData" value="">
|
||||
<input type="text" id="HR-notes" name="notes" value="">
|
||||
<input type="text" id="HR-homeroom" name="homeroom" value="{{homeroomCode[0]}}^{{homeroomCode[1]}}">
|
||||
<input type="text" id="HR-type" name="stype" value="">
|
||||
</form>
|
||||
{% if 'confirm' in absData[currDate] %}
|
||||
<button class="btn btn-primary margin-top afterSelButton" onclick="homeroomCfrm()" disabled="disabled">
|
||||
|
@ -282,11 +284,12 @@
|
|||
resizeCanvas();
|
||||
$('html,body').unbind().animate({ scrollTop: $("#finalCheck").offset().top - $(".sticky-top").outerHeight() - 10 }, 'slow');
|
||||
}
|
||||
function afterSelAbs(period) {
|
||||
function afterSelAbs(period, typeofsubmit) {
|
||||
var tobeformArr = [];
|
||||
$("#postHomeroomAbs #HR-type").attr('value', typeofsubmit);
|
||||
$('#postHomeroomAbs #HR-period').attr('value', period);
|
||||
$('.tobeform').attr('disabled', 'disabled');
|
||||
$('.afterSelButton').attr('disabled', 'disabled');
|
||||
$('.afterSelButton, .editSaveButton').attr('disabled', 'disabled');
|
||||
$('#showSignPeriod').text(period);
|
||||
$('#showSignSubjectName').text(periodData[period]);
|
||||
var cnt = 0;
|
||||
|
@ -305,6 +308,27 @@
|
|||
// show signature pad
|
||||
showSignaturePad()
|
||||
}
|
||||
function edit(string) {
|
||||
$('.view-' + string).each(function (i, obj) {
|
||||
var num = $(this.firstElementChild).attr('class').split(' ')[2].replace('view-n-', '');
|
||||
if ($(this.firstElementChild).attr('class').split(' ')[1] == "n-1") {
|
||||
$(this).html("")
|
||||
$(this).append("<input type=\"checkbox\" class=\"tobeform 2^" + string + "^" + num + " late\" id=\"late^" + string + "^" + num + "\" onchange=\"unCheckAbs('" + string + "^" + num + "')\">");
|
||||
$(this).append("\n<input type=\"checkbox\" class=\"tobeform 1^" + string + "^" + num + " absent\" id=\"absent^" + string + "^" + num + "\" onchange=\"unCheckLate('" + string + "^" + num + "')\">");
|
||||
} else if ($(this.firstElementChild).attr('class').split(' ')[1] == "n-2") {
|
||||
$(this).html("")
|
||||
$(this).append("<input type=\"checkbox\" class=\"tobeform 2^" + string + "^" + num + " late\" id=\"late^" + string + "^" + num + "\" onchange=\"unCheckAbs('" + string + "^" + num + "')\">");
|
||||
$(this).append("\n<input type=\"checkbox\" class=\"tobeform 1^" + string + "^" + num + " absent\" id=\"absent^" + string + "^" + num + "\" onchange=\"unCheckLate('" + string + "^" + num + "')\" checked>");
|
||||
} else {
|
||||
$(this).html("")
|
||||
$(this).append("<input type=\"checkbox\" class=\"tobeform 2^" + string + "^" + num + " late\" id=\"late^" + string + "^" + num + "\" onchange=\"unCheckAbs('" + string + "^" + num + "')\" checked>");
|
||||
$(this).append("\n<input type=\"checkbox\" class=\"tobeform 1^" + string + "^" + num + " absent\" id=\"absent^" + string + "^" + num + "\" onchange=\"unCheckLate('" + string + "^" + num + "')\" checked>");
|
||||
}
|
||||
});
|
||||
$('#btns-' + string).html("")
|
||||
$('.afterSelButton').attr('disabled', 'disabled');
|
||||
$('#btns-' + string).append("<button class=\"btn btn-secondary editSaveButton\" onclick=\"afterSelAbs('" + string + "', 'edit')\">Save</button>");
|
||||
}
|
||||
function homeroomCfrm() {
|
||||
hrCfrm = true;
|
||||
$('.tobeform').attr('disabled', 'disabled');
|
||||
|
|
Loading…
Reference in a new issue