diff --git a/src/app.js b/src/app.js index d25e1aa..8dea84b 100644 --- a/src/app.js +++ b/src/app.js @@ -134,6 +134,9 @@ app.post ('/:page?', function (req, res) { savePost (req, res); var redirectUrl = '/' + (typeof req.params.page === 'undefined' ? 'index' : req.params.page); + if (typeof req.body.redirectParams !== 'undefined') { + redirectUrl += '?'+req.body.redirectParams; + } res.redirect (redirectUrl) }); diff --git a/src/assets/js/deleteButton.js b/src/assets/js/deleteButton.js index 4dae400..5579572 100644 --- a/src/assets/js/deleteButton.js +++ b/src/assets/js/deleteButton.js @@ -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 (); }); \ No newline at end of file diff --git a/src/assets/js/program.js b/src/assets/js/program.js index a02775c..5837479 100644 --- a/src/assets/js/program.js +++ b/src/assets/js/program.js @@ -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); }); diff --git a/src/views/backend/budget.ejs b/src/views/backend/budget.ejs index abdd474..5deda76 100644 --- a/src/views/backend/budget.ejs +++ b/src/views/backend/budget.ejs @@ -1,172 +1,188 @@ -
-
- |
- Položka 1 | -1300 Kč | -
-
- |
- Položka 2 | -4500 Kč | -
-
- |
- Položka 3 | -340 Kč | -
|
+
+
+
+ |
+ Položka 1 | +1300 Kč | +
|
+
+
+
+ |
+ Položka 2 | +4500 Kč | +
|
+
+
+
+ |
+ Položka 3 | +3100 Kč | +
|
+
+
+
+ |
+ Položka 4 | +3400 Kč | +
|
+
+
+
+ |
+ Položka 5 | +2000 Kč | +
-
- |
- Položka 1 | -1300 Kč | -
-
- |
- Položka 2 | -4500 Kč | -
-
- |
- Položka 3 | -3100 Kč | -
-
- |
- Položka 4 | -3400 Kč | -
-
- |
- Položka 5 | -2000 Kč | -
-
- |
- Položka 1 | -540 Kč | -
-
- |
- Položka 2 | -1200 Kč | -