2019-12-13 23:28:16 +01:00
|
|
|
$(document).ready(function(){
|
|
|
|
$('.add-mn-btn').on('click', function () {
|
2019-12-20 01:11:51 +01:00
|
|
|
$('.card-reader').toggleClass('open');
|
2019-12-13 23:28:16 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$('.add-subject-btn').on('click', function () {
|
|
|
|
$('.add-subject').toggleClass('open');
|
|
|
|
if ($('.add-subject').first().hasClass('open')) {
|
2019-12-20 14:09:16 +01:00
|
|
|
$(this).addClass('btn-danger');
|
|
|
|
$(this).html('<i class="fa fa-times"></i> Anuluj');
|
|
|
|
$(this).attr('title', 'Anuluj');
|
2019-12-13 23:28:16 +01:00
|
|
|
} else {
|
2019-12-20 14:09:16 +01:00
|
|
|
$(this).removeClass('btn-danger');
|
|
|
|
$(this).html('<i class="fa fa-plus"></i> Dodaj nowy przedmiot');
|
|
|
|
$(this).attr('title', 'Dodaj nowy przedmiot');
|
2019-12-13 23:28:16 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.add-attendance-btn').on('click', function () {
|
|
|
|
$('.add-attendance').toggleClass('open');
|
|
|
|
if ($('.add-attendance').first().hasClass('open')) {
|
2019-12-20 14:09:16 +01:00
|
|
|
$(this).addClass('btn-danger');
|
|
|
|
$(this).html('<i class="fa fa-times"></i> Anuluj');
|
|
|
|
$(this).attr('title', 'Anuluj');
|
2019-12-13 23:28:16 +01:00
|
|
|
} else {
|
2019-12-20 14:09:16 +01:00
|
|
|
$(this).removeClass('btn-danger');
|
|
|
|
$(this).html('<i class="fa fa-plus"></i> Dodaj nowy wpis');
|
|
|
|
$(this).attr('title', 'Dodaj nowy wpis');
|
2019-12-13 23:28:16 +01:00
|
|
|
}
|
|
|
|
});
|
2019-12-19 00:10:39 +01:00
|
|
|
|
|
|
|
$(".modal").on("hidden.bs.modal", function(){
|
2020-01-17 17:10:54 +01:00
|
|
|
const id = $(this).attr('id').split('-')[1];
|
|
|
|
const originalText = $(this).find(`#note_content_hidden-${id}`).first().val();
|
|
|
|
$(this).find(`#note_content-${id}`).first().val(originalText);
|
2019-12-19 00:10:39 +01:00
|
|
|
});
|
|
|
|
|
2020-03-01 23:30:37 +01:00
|
|
|
$('.edit-subject-btn').on('click', function () {
|
|
|
|
$(this).parents('tr.editable').next().toggleClass('d-none');
|
|
|
|
$(this).parents('tr.editable').toggleClass('d-none');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.edit-subject-btn-cancel').on('click', function () {
|
|
|
|
$(this).parents('tr.edit-subject-tr').prev().toggleClass('d-none');
|
|
|
|
$(this).parents('tr.edit-subject-tr').toggleClass('d-none');
|
|
|
|
});
|
|
|
|
|
|
|
|
if($('body').find('.invalid-feedback-alert').length > 0) {
|
|
|
|
if($('.add-subject').find('.invalid-feedback').length > 0) {
|
|
|
|
$('.add-subject-btn').first().click();
|
|
|
|
}
|
|
|
|
if($('.edit-subject-tr').find('.invalid-feedback').length > 0) {
|
|
|
|
let subject_id = $('#subject_id_redirected').val();
|
|
|
|
$(`#tr-editable-${subject_id}`).find('.edit-subject-btn').first().click();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-19 00:10:39 +01:00
|
|
|
$('#sort-select').on('change', function() {
|
|
|
|
$(location).attr('href', $(this).val())
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#group-select').on('change', function() {
|
|
|
|
$(location).attr('href', $(this).val())
|
|
|
|
});
|
|
|
|
|
|
|
|
function setSelectedOptionSortAttendances() {
|
|
|
|
const orderBy = $('#orderBy-hidden').first().val();
|
|
|
|
const orderDirection = $('#orderDirection-hidden').first().val();
|
|
|
|
const pattern = `/${orderBy}/${orderDirection}`;
|
|
|
|
const options = $('#sort-select').find('option');
|
|
|
|
options.each(function() {
|
|
|
|
if($(this).val().search(pattern) !== -1) {
|
|
|
|
$('#sort-select').val($(this).val());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
setSelectedOptionSortAttendances();
|
|
|
|
|
|
|
|
function setSelectedOptionGroup() {
|
|
|
|
const groupBy = $('#groupBy-hidden').first().val();
|
|
|
|
const pattern = `/${groupBy}`;
|
|
|
|
const options = $('#group-select').find('option');
|
|
|
|
options.each(function() {
|
|
|
|
if($(this).val().search(pattern) !== -1) {
|
|
|
|
$('#group-select').val($(this).val());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
setSelectedOptionGroup();
|
2019-12-20 15:46:32 +01:00
|
|
|
|
|
|
|
$('input[type="checkbox"]').on('change', function() {
|
|
|
|
$('input[type="checkbox"]').not(this).prop('checked', false);
|
|
|
|
});
|
2019-12-13 23:28:16 +01:00
|
|
|
});
|