Upravy v backendu aplikace

This commit is contained in:
Michal Kváček
2018-11-27 23:43:16 +01:00
parent 10e931fd7a
commit 89f19c3931
17 changed files with 816 additions and 559 deletions
+6 -1
View File
@@ -13,7 +13,12 @@ $ (document).on ('click', '.delete-button a', function () {
if (modalHeader)
$modal.find ('.modal-title').text (modalHeader);
$ ('#delete-modal-form').attr ('action', action);
$modal.modal ('show');
});
$ (document).on ('click', '.js-delete-button', function () {
var target = $ (this).data ('target');
$ (this).closest (target).remove ();
});
+21 -21
View File
@@ -1,7 +1,7 @@
$ (document).on ('click', '.js-add-program', function () {
var templateSelector = $ (this).data ('template') + ":last";
var $template = $ (templateSelector);
var $templateContainer = $ ($ (this).data ('template-container'));
var $template = $templateContainer.find (templateSelector);
var $copy = $template.clone ().removeClass ('template');
@@ -9,10 +9,11 @@ $ (document).on ('click', '.js-add-program', function () {
$copy.find ('input').each (function () {
var name = $ (this).attr ('name');
$ (this).attr ('name', name.replace (/\[0\]/g, '[' + itemsCount + ']'));
if (typeof name !== 'undefined')
$ (this).attr ('name', name.replace (/\[0\]/g, '[' + itemsCount + ']'));
});
$copy.appendTo ($templateContainer);
$copy.removeAttr ('hidden').appendTo ($templateContainer);
$ ('.select-time').datetimepicker ({
format: 'LT',
@@ -37,40 +38,39 @@ function renameInputs() {
});
}
$(document).on('click', '.js-sort-events', function ( ){
$ (document).on ('click', '.js-sort-events', function () {
var $templateContainer = $ ($ (this).data ('template-container'));
var $templates = $ ($ (this).data ('template'));
sortEvents($templateContainer, $templates);
sortEvents ($templateContainer, $templates);
$(this).fadeOut();
$ (this).fadeOut ();
});
function sortEvents($container, $templates) {
var elements = $templates.get();
var elements = $templates.get ();
elements.sort(function (a, b) {
elements.sort (function (a, b) {
console.log(a);
console.log (a);
var timeA = $(a).find('.select-time').val();
var timeB = $(b).find('.select-time').val();
var timeA = $ (a).find ('.select-time').val ();
var timeB = $ (b).find ('.select-time').val ();
return timeA > timeB;
});
$container.append(elements);
$container.append (elements);
renameInputs();
renameInputs ();
}
function checkEvents($container, $templates) {
var lastTime = null;
var orderCorrect = true;
$templates.each(function() {
var time = $(this).find('.select-time').val();
$templates.each (function () {
var time = $ (this).find ('.select-time').val ();
if (time < lastTime) {
orderCorrect = false;
@@ -79,19 +79,19 @@ function checkEvents($container, $templates) {
});
if (!orderCorrect) {
$('.js-sort-events').fadeIn();
$ ('.js-sort-events').fadeIn ();
} else {
$('.js-sort-events').fadeOut();
$ ('.js-sort-events').fadeOut ();
}
}
$(document).ready(function () {
$ (document).ready (function () {
setInterval(function () {
setInterval (function () {
var $templateContainer = $ ('.template-container');
var $templates = $ ('.template');
checkEvents($templateContainer, $templates);
checkEvents ($templateContainer, $templates);
}, 1000);
});