diff --git a/composer.lock b/composer.lock index e1b7f8f8..b4a8a4a6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "42031c0b205b7ce7efb4b6eb95a0096a", + "content-hash": "131ab83ecb1ea3d1a431cc70b5092448", "packages": [ { "name": "container-interop/container-interop", @@ -158,16 +158,16 @@ }, { "name": "illuminate/container", - "version": "v5.6.17", + "version": "v5.6.27", "source": { "type": "git", "url": "https://github.com/illuminate/container.git", - "reference": "4a42d667a05ec6d31f05b532cdac7e8e68e5ea2a" + "reference": "1f0757cae8749400aeda730f6438a081fc3c082d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/container/zipball/4a42d667a05ec6d31f05b532cdac7e8e68e5ea2a", - "reference": "4a42d667a05ec6d31f05b532cdac7e8e68e5ea2a", + "url": "https://api.github.com/repos/illuminate/container/zipball/1f0757cae8749400aeda730f6438a081fc3c082d", + "reference": "1f0757cae8749400aeda730f6438a081fc3c082d", "shasum": "" }, "require": { @@ -198,20 +198,20 @@ ], "description": "The Illuminate Container package.", "homepage": "https://laravel.com", - "time": "2018-01-21T02:13:38+00:00" + "time": "2018-05-24T13:16:56+00:00" }, { "name": "illuminate/contracts", - "version": "v5.6.17", + "version": "v5.6.27", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", - "reference": "322ec80498b3bf85bc4025d028e130a9b50242b9" + "reference": "3dc639feabe0f302f574157a782ede323881a944" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/contracts/zipball/322ec80498b3bf85bc4025d028e130a9b50242b9", - "reference": "322ec80498b3bf85bc4025d028e130a9b50242b9", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/3dc639feabe0f302f574157a782ede323881a944", + "reference": "3dc639feabe0f302f574157a782ede323881a944", "shasum": "" }, "require": { @@ -242,11 +242,11 @@ ], "description": "The Illuminate Contracts package.", "homepage": "https://laravel.com", - "time": "2018-04-07T17:05:26+00:00" + "time": "2018-05-11T23:38:58+00:00" }, { "name": "illuminate/events", - "version": "v5.6.17", + "version": "v5.6.27", "source": { "type": "git", "url": "https://github.com/illuminate/events.git", @@ -291,16 +291,16 @@ }, { "name": "illuminate/filesystem", - "version": "v5.6.17", + "version": "v5.6.27", "source": { "type": "git", "url": "https://github.com/illuminate/filesystem.git", - "reference": "c9ab9376076cedd88a374d7281d62b619634d578" + "reference": "2677365f61c66fad13ff12a37cd4fa8aaeb048d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/filesystem/zipball/c9ab9376076cedd88a374d7281d62b619634d578", - "reference": "c9ab9376076cedd88a374d7281d62b619634d578", + "url": "https://api.github.com/repos/illuminate/filesystem/zipball/2677365f61c66fad13ff12a37cd4fa8aaeb048d2", + "reference": "2677365f61c66fad13ff12a37cd4fa8aaeb048d2", "shasum": "" }, "require": { @@ -339,20 +339,20 @@ ], "description": "The Illuminate Filesystem package.", "homepage": "https://laravel.com", - "time": "2018-04-06T13:15:37+00:00" + "time": "2018-07-07T14:54:27+00:00" }, { "name": "illuminate/support", - "version": "v5.6.17", + "version": "v5.6.27", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "cc8d6f5cef3a901de6bb7d1b362102a6db001085" + "reference": "97ca44c95392ce0a41749fa47b953734d88b94b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/cc8d6f5cef3a901de6bb7d1b362102a6db001085", - "reference": "cc8d6f5cef3a901de6bb7d1b362102a6db001085", + "url": "https://api.github.com/repos/illuminate/support/zipball/97ca44c95392ce0a41749fa47b953734d88b94b1", + "reference": "97ca44c95392ce0a41749fa47b953734d88b94b1", "shasum": "" }, "require": { @@ -367,6 +367,7 @@ }, "suggest": { "illuminate/filesystem": "Required to use the composer class (5.6.*).", + "ramsey/uuid": "Required to use Str::uuid() (^3.7).", "symfony/process": "Required to use the composer class (~4.0).", "symfony/var-dumper": "Required to use the dd function (~4.0)." }, @@ -396,20 +397,20 @@ ], "description": "The Illuminate Support package.", "homepage": "https://laravel.com", - "time": "2018-04-17T12:26:47+00:00" + "time": "2018-07-04T01:23:57+00:00" }, { "name": "illuminate/view", - "version": "v5.6.17", + "version": "v5.6.27", "source": { "type": "git", "url": "https://github.com/illuminate/view.git", - "reference": "54eaf45ee7946d8f8cde13d5e89c5ea2e997040d" + "reference": "625c35e8942f0ecd467acb8db8daf8449390d559" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/view/zipball/54eaf45ee7946d8f8cde13d5e89c5ea2e997040d", - "reference": "54eaf45ee7946d8f8cde13d5e89c5ea2e997040d", + "url": "https://api.github.com/repos/illuminate/view/zipball/625c35e8942f0ecd467acb8db8daf8449390d559", + "reference": "625c35e8942f0ecd467acb8db8daf8449390d559", "shasum": "" }, "require": { @@ -444,7 +445,7 @@ ], "description": "The Illuminate View package.", "homepage": "https://laravel.com", - "time": "2018-04-03T12:56:35+00:00" + "time": "2018-07-06T14:55:12+00:00" }, { "name": "morris/lessql", @@ -496,16 +497,16 @@ }, { "name": "neomerx/cors-psr7", - "version": "v1.0.12", + "version": "v1.0.13", "source": { "type": "git", "url": "https://github.com/neomerx/cors-psr7.git", - "reference": "24944f39483d1a89f66ae9d58cca9f82b8815b35" + "reference": "2556e2013f16a55532c95928455257d5b6bbc6e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/neomerx/cors-psr7/zipball/24944f39483d1a89f66ae9d58cca9f82b8815b35", - "reference": "24944f39483d1a89f66ae9d58cca9f82b8815b35", + "url": "https://api.github.com/repos/neomerx/cors-psr7/zipball/2556e2013f16a55532c95928455257d5b6bbc6e2", + "reference": "2556e2013f16a55532c95928455257d5b6bbc6e2", "shasum": "" }, "require": { @@ -514,7 +515,7 @@ "psr/log": "^1.0" }, "require-dev": { - "mockery/mockery": "^0.9.9", + "mockery/mockery": "^1.0", "phpunit/phpunit": "^5.7", "scrutinizer/ocular": "^1.1", "squizlabs/php_codesniffer": "^3.0" @@ -547,20 +548,20 @@ "w3.org", "www.w3.org" ], - "time": "2017-09-03T22:31:57+00:00" + "time": "2018-05-23T16:10:11+00:00" }, { "name": "nesbot/carbon", - "version": "1.26.4", + "version": "1.32.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "e3d9014279133a3cccc01f6a691322a2d5a6a87b" + "reference": "64563e2b9f69e4db1b82a60e81efa327a30ff343" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/e3d9014279133a3cccc01f6a691322a2d5a6a87b", - "reference": "e3d9014279133a3cccc01f6a691322a2d5a6a87b", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/64563e2b9f69e4db1b82a60e81efa327a30ff343", + "reference": "64563e2b9f69e4db1b82a60e81efa327a30ff343", "shasum": "" }, "require": { @@ -572,6 +573,13 @@ "phpunit/phpunit": "^4.8.35 || ^5.7" }, "type": "library", + "extra": { + "laravel": { + "providers": [ + "Carbon\\Laravel\\ServiceProvider" + ] + } + }, "autoload": { "psr-4": { "": "src/" @@ -595,7 +603,7 @@ "datetime", "time" ], - "time": "2018-04-17T15:35:42+00:00" + "time": "2018-07-05T06:59:26+00:00" }, { "name": "nikic/fast-route", @@ -1206,16 +1214,16 @@ }, { "name": "symfony/debug", - "version": "v4.0.8", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "5961d02d48828671f5d8a7805e06579d692f6ede" + "reference": "dbe0fad88046a755dcf9379f2964c61a02f5ae3d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/5961d02d48828671f5d8a7805e06579d692f6ede", - "reference": "5961d02d48828671f5d8a7805e06579d692f6ede", + "url": "https://api.github.com/repos/symfony/debug/zipball/dbe0fad88046a755dcf9379f2964c61a02f5ae3d", + "reference": "dbe0fad88046a755dcf9379f2964c61a02f5ae3d", "shasum": "" }, "require": { @@ -1231,7 +1239,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "4.1-dev" } }, "autoload": { @@ -1258,20 +1266,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2018-04-03T05:24:00+00:00" + "time": "2018-06-08T09:39:36+00:00" }, { "name": "symfony/finder", - "version": "v4.0.8", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "ca27c02b7a3fef4828c998c2ff9ba7aae1641c49" + "reference": "84714b8417d19e4ba02ea78a41a975b3efaafddb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/ca27c02b7a3fef4828c998c2ff9ba7aae1641c49", - "reference": "ca27c02b7a3fef4828c998c2ff9ba7aae1641c49", + "url": "https://api.github.com/repos/symfony/finder/zipball/84714b8417d19e4ba02ea78a41a975b3efaafddb", + "reference": "84714b8417d19e4ba02ea78a41a975b3efaafddb", "shasum": "" }, "require": { @@ -1280,7 +1288,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "4.1-dev" } }, "autoload": { @@ -1307,20 +1315,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2018-04-04T05:10:37+00:00" + "time": "2018-06-19T21:38:16+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.7.0", + "version": "v1.8.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b" + "reference": "3296adf6a6454a050679cde90f95350ad604b171" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/78be803ce01e55d3491c1397cf1c64beb9c1b63b", - "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171", + "reference": "3296adf6a6454a050679cde90f95350ad604b171", "shasum": "" }, "require": { @@ -1332,7 +1340,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } }, "autoload": { @@ -1366,20 +1374,20 @@ "portable", "shim" ], - "time": "2018-01-30T19:27:44+00:00" + "time": "2018-04-26T10:06:28+00:00" }, { "name": "symfony/translation", - "version": "v4.0.8", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "e20a9b7f9f62cb33a11638b345c248e7d510c938" + "reference": "b6d8164085ee0b6debcd1b7a131fd6f63bb04854" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/e20a9b7f9f62cb33a11638b345c248e7d510c938", - "reference": "e20a9b7f9f62cb33a11638b345c248e7d510c938", + "url": "https://api.github.com/repos/symfony/translation/zipball/b6d8164085ee0b6debcd1b7a131fd6f63bb04854", + "reference": "b6d8164085ee0b6debcd1b7a131fd6f63bb04854", "shasum": "" }, "require": { @@ -1394,20 +1402,21 @@ "require-dev": { "psr/log": "~1.0", "symfony/config": "~3.4|~4.0", + "symfony/console": "~3.4|~4.0", "symfony/dependency-injection": "~3.4|~4.0", "symfony/finder": "~2.8|~3.0|~4.0", "symfony/intl": "~3.4|~4.0", "symfony/yaml": "~3.4|~4.0" }, "suggest": { - "psr/log": "To use logging capability in translator", + "psr/log-implementation": "To use logging capability in translator", "symfony/config": "", "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "4.1-dev" } }, "autoload": { @@ -1434,7 +1443,7 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2018-02-22T10:50:29+00:00" + "time": "2018-06-22T08:59:39+00:00" }, { "name": "tuupola/callable-handler", @@ -1604,7 +1613,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.0" + "php": ">=7.2" }, "platform-dev": [] } diff --git a/controllers/BatteriesApiController.php b/controllers/BatteriesApiController.php index f8430b40..ed8ddb51 100644 --- a/controllers/BatteriesApiController.php +++ b/controllers/BatteriesApiController.php @@ -17,7 +17,7 @@ class BatteriesApiController extends BaseApiController public function TrackChargeCycle(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) { $trackedTime = date('Y-m-d H:i:s'); - if (isset($request->getQueryParams()['tracked_time']) && !empty($request->getQueryParams()['tracked_time'])) + if (isset($request->getQueryParams()['tracked_time']) && !empty($request->getQueryParams()['tracked_time']) && IsIsoDateTime($request->getQueryParams()['tracked_time'])) { $trackedTime = $request->getQueryParams()['tracked_time']; } diff --git a/controllers/HabitsApiController.php b/controllers/HabitsApiController.php index 6755fb3b..ad27516c 100644 --- a/controllers/HabitsApiController.php +++ b/controllers/HabitsApiController.php @@ -17,7 +17,7 @@ class HabitsApiController extends BaseApiController public function TrackHabitExecution(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) { $trackedTime = date('Y-m-d H:i:s'); - if (isset($request->getQueryParams()['tracked_time']) && !empty($request->getQueryParams()['tracked_time'])) + if (isset($request->getQueryParams()['tracked_time']) && !empty($request->getQueryParams()['tracked_time']) && IsIsoDateTime($request->getQueryParams()['tracked_time'])) { $trackedTime = $request->getQueryParams()['tracked_time']; } diff --git a/controllers/StockApiController.php b/controllers/StockApiController.php index 91d6519c..08ebd820 100644 --- a/controllers/StockApiController.php +++ b/controllers/StockApiController.php @@ -29,7 +29,7 @@ class StockApiController extends BaseApiController public function AddProduct(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) { $bestBeforeDate = date('Y-m-d'); - if (isset($request->getQueryParams()['bestbeforedate']) && !empty($request->getQueryParams()['bestbeforedate'])) + if (isset($request->getQueryParams()['bestbeforedate']) && !empty($request->getQueryParams()['bestbeforedate']) && IsIsoDate($request->getQueryParams()['bestbeforedate'])) { $bestBeforeDate = $request->getQueryParams()['bestbeforedate']; } @@ -79,7 +79,7 @@ class StockApiController extends BaseApiController public function InventoryProduct(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) { $bestBeforeDate = date('Y-m-d'); - if (isset($request->getQueryParams()['bestbeforedate']) && !empty($request->getQueryParams()['bestbeforedate'])) + if (isset($request->getQueryParams()['bestbeforedate']) && !empty($request->getQueryParams()['bestbeforedate']) && IsIsoDate($request->getQueryParams()['bestbeforedate'])) { $bestBeforeDate = $request->getQueryParams()['bestbeforedate']; } diff --git a/helpers/extensions.php b/helpers/extensions.php index ce439263..611b45a3 100644 --- a/helpers/extensions.php +++ b/helpers/extensions.php @@ -110,3 +110,15 @@ function IsAssociativeArray(array $array) $keys = array_keys($array); return array_keys($keys) !== $keys; } + +function IsIsoDate($dateString) +{ + $d = DateTime::createFromFormat('Y-m-d', $dateString); + return $d && $d->format('Y-m-d') === $dateString; +} + +function IsIsoDateTime($dateTimeString) +{ + $d = DateTime::createFromFormat('Y-m-d H:i:s', $dateTimeString); + return $d && $d->format('Y-m-d H:i:s') === $dateTimeString; +} diff --git a/localization/de.php b/localization/de.php index de51f17d..9e05e476 100644 --- a/localization/de.php +++ b/localization/de.php @@ -132,6 +132,15 @@ return array( 'Filter by location' => 'Nach Standort filtern', 'Search' => 'Suche', 'Not logged in' => 'Nicht angemeldet', + 'You have to select a product' => 'Ein Produkt muss ausgewählt werden', + 'You have to select a habit' => 'Eine Gewohnheit muss ausgewählt werden', + 'You have to select a battery' => 'Eine Batterie muss ausgewählt werden', + 'A name is required' => 'Ein Name ist erforderlich', + 'A location is required' => 'Ein Standort ist erforderlich', + 'The amount cannot be lower than #1' => 'Die Menge darf nicht kleiner als #1 sein', + 'This cannot be negative' => 'Dies darf nicht negativ sein', + 'A quantity unit is required' => 'Eine Mengeneinheit muss ausgewählt werden', + 'A period type is required' => 'Eine Periodentyp muss ausgewählt werden', //Constants 'manually' => 'Manuell', diff --git a/package.json b/package.json index 57934326..d4ad6283 100644 --- a/package.json +++ b/package.json @@ -2,26 +2,26 @@ "name": "grocy", "private": true, "dependencies": { - "bootstrap": "^4.1.1", - "startbootstrap-sb-admin": "^4.0.0", - "jquery": "^3.3.1", - "font-awesome": "^4.7.0", - "bootbox": "https://github.com/makeusabrew/bootbox.git#v5.x", - "jquery-serializejson": "^2.8.1", - "bootstrap-validator": "^0.11.9", - "bootstrap-datepicker": "^1.8.0", - "moment": "^2.18.1", "@danielfarrell/bootstrap-combobox": "https://github.com/pallidus-fintech/bootstrap-combobox.git#enhance/boostrap_4", + "@fortawesome/fontawesome-free": "^5.1.0", + "TagManager": "https://github.com/max-favilli/tagmanager.git#3.0.2", + "bootbox": "https://github.com/makeusabrew/bootbox.git#v5.x", + "bootstrap": "^4.1.1", + "bootstrap-datepicker": "^1.8.0", + "bootstrap-side-navbar": "https://github.com/samrayner/bootstrap-side-navbar.git#1.0.1", "datatables.net": "^1.10.19", "datatables.net-bs4": "^1.10.19", "datatables.net-responsive": "^2.2.3", "datatables.net-responsive-bs4": "^2.2.3", - "timeago": "^1.6.1", - "toastr": "^2.1.3", + "jquery": "^3.3.1", + "jquery-serializejson": "^2.8.1", + "jquery-ui-dist": "^1.12.1", + "moment": "^2.22.2", + "startbootstrap-sb-admin": "^4.0.0", + "swagger-ui-dist": "^3.17.3", "tagmanager": "https://github.com/max-favilli/tagmanager.git#3.0.2", "tempusdominus-bootstrap-4": "^5.0.1", - "swagger-ui-dist": "^3.13.4", - "jquery-ui-dist": "^1.12.1", - "bootstrap-side-navbar": "https://github.com/samrayner/bootstrap-side-navbar.git#1.0.1" + "timeago": "^1.6.3", + "toastr": "^2.1.4" } } diff --git a/public/css/grocy.css b/public/css/grocy.css index fa946ef1..c6ed8a77 100644 --- a/public/css/grocy.css +++ b/public/css/grocy.css @@ -45,6 +45,10 @@ a.discrete-link:focus { background-color: #e5e5e5; } +.content-text .invalid-feedback { + font-size: 95%; +} + /* Navigation style customizations */ #mainNav { background-color: #e5e5e5 !important; @@ -139,3 +143,16 @@ td { #toast-container > div { box-shadow: none; } + +/* Third party component customizations - SB Admin 2 */ +#mainNav .navbar-collapse .navbar-nav > .nav-item.dropdown > .nav-link:after, +#mainNav .navbar-collapse .navbar-sidenav .nav-link-collapse:after { + font-family: 'Font Awesome 5 Free'; + font-weight: 900; +} + +@media (max-width:992px) { + #mainNav .navbar-collapse .navbar-sidenav > .nav-item > .nav-link { + padding: 0.8em; + } +} diff --git a/public/js/grocy.js b/public/js/grocy.js index 8b556799..88c8d6c0 100644 --- a/public/js/grocy.js +++ b/public/js/grocy.js @@ -39,6 +39,10 @@ toastr.options = { extendedTimeOut: 5000 }; +window.FontAwesomeConfig = { + searchPseudoElements: true +} + Grocy.Api = { }; Grocy.Api.Get = function(apiFunction, success, error) { @@ -100,3 +104,19 @@ Grocy.Api.Post = function(apiFunction, jsonData, success, error) xhr.setRequestHeader('Content-type', 'application/json'); xhr.send(JSON.stringify(jsonData)); }; + +Grocy.FrontendHelpers = { }; +Grocy.FrontendHelpers.ValidateForm = function(formId) +{ + var form = document.getElementById(formId); + if (form.checkValidity() === true) + { + $(form).find(':submit').removeClass('disabled'); + } + else + { + $(form).find(':submit').addClass('disabled'); + } + + $(form).addClass('was-validated'); +} diff --git a/public/viewjs/batteryform.js b/public/viewjs/batteryform.js index 1a65d574..87e9b864 100644 --- a/public/viewjs/batteryform.js +++ b/public/viewjs/batteryform.js @@ -30,6 +30,26 @@ } }); +$('#battery-form input').keyup(function(event) +{ + Grocy.FrontendHelpers.ValidateForm('battery-form'); +}); + +$('#battery-form input').keydown(function(event) +{ + if (event.keyCode === 13) //Enter + { + if (document.getElementById('battery-form').checkValidity() === false) //There is at least one validation error + { + event.preventDefault(); + return false; + } + else + { + $('#save-battery-button').click(); + } + } +}); + $('#name').focus(); -$('#battery-form').validator(); -$('#battery-form').validator('validate'); +Grocy.FrontendHelpers.ValidateForm('battery-form'); diff --git a/public/viewjs/batterytracking.js b/public/viewjs/batterytracking.js index d5ae0459d..93d46f3f 100644 --- a/public/viewjs/batterytracking.js +++ b/public/viewjs/batterytracking.js @@ -7,18 +7,18 @@ Grocy.Api.Get('batteries/get-battery-details/' + jsonForm.battery_id, function (batteryDetails) { - Grocy.Api.Get('batteries/track-charge-cycle/' + jsonForm.battery_id + '?tracked_time=' + $('#tracked_time').val(), + Grocy.Api.Get('batteries/track-charge-cycle/' + jsonForm.battery_id + '?tracked_time=' + $('#tracked_time').find('input').val(), function(result) { - toastr.success(L('Tracked charge cylce of battery #1 on #2', batteryDetails.battery.name, $('#tracked_time').val())); + toastr.success(L('Tracked charge cylce of battery #1 on #2', batteryDetails.battery.name, $('#tracked_time').find('input').val())); $('#battery_id').val(''); $('#battery_id_text_input').focus(); $('#battery_id_text_input').val(''); - $('#tracked_time').val(moment().format('YYYY-MM-DD HH:mm:ss')); - $('#tracked_time').trigger('change'); + $('#tracked_time').find('input').val(moment().format('YYYY-MM-DD HH:mm:ss')); + $('#tracked_time').find('input').trigger('change'); $('#battery_id_text_input').trigger('change'); - $('#batterytracking-form').validator('validate'); + Grocy.FrontendHelpers.ValidateForm('batterytracking-form'); }, function(xhr) { @@ -40,26 +40,7 @@ $('#battery_id').on('change', function(e) if (batteryId) { Grocy.Components.BatteryCard.Refresh(batteryId); - $('#tracked_time').focus(); - } -}); - -$('.datetimepicker').datetimepicker( -{ - format: 'YYYY-MM-DD HH:mm:ss', - showTodayButton: true, - calendarWeeks: true, - maxDate: moment() -}); - -$('#tracked_time').val(moment().format('YYYY-MM-DD HH:mm:ss')); -$('#tracked_time').trigger('change'); - -$('#tracked_time').on('focus', function(e) -{ - if ($('#battery_id_text_input').val().length === 0) - { - $('#battery_id_text_input').focus(); + $('#tracked_time').find('input').focus(); } }); @@ -71,79 +52,31 @@ $('#battery_id').val(''); $('#battery_id_text_input').focus(); $('#battery_id_text_input').val(''); $('#battery_id_text_input').trigger('change'); +Grocy.FrontendHelpers.ValidateForm('batterytracking-form'); -$('#batterytracking-form').validator(); -$('#batterytracking-form').validator('validate'); +$('#batterytracking-form input').keyup(function (event) +{ + Grocy.FrontendHelpers.ValidateForm('batterytracking-form'); +}); $('#batterytracking-form input').keydown(function(event) { if (event.keyCode === 13) //Enter { - if ($('#batterytracking-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error + if (document.getElementById('batterytracking-form').checkValidity() === false) //There is at least one validation error { event.preventDefault(); return false; } + else + { + $('#save-batterytracking-button').click(); + } } }); -$('#tracked_time').on('change', function(e) +$('#tracked_time').find('input').on('keypress', function (e) { - var value = $('#tracked_time').val(); - var now = new Date(); - var centuryStart = Number.parseInt(now.getFullYear().toString().substring(0, 2) + '00'); - var centuryEnd = Number.parseInt(now.getFullYear().toString().substring(0, 2) + '99'); - - if (value === 'x' || value === 'X') { - value = '29991231'; - } - - if (value.length === 4 && !(Number.parseInt(value) > centuryStart && Number.parseInt(value) < centuryEnd)) - { - value = (new Date()).getFullYear().toString() + value; - } - - if (value.length === 8 && $.isNumeric(value)) - { - value = value.replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3'); - $('#tracked_time').val(value); - $('#batterytracking-form').validator('validate'); - } + Grocy.FrontendHelpers.ValidateForm('batterytracking-form'); }); -$('#tracked_time').on('keypress', function(e) -{ - var element = $(e.target); - var value = element.val(); - var dateObj = moment(element.val(), 'YYYY-MM-DD', true); - - $('.datepicker').datepicker('hide'); - - //If input is empty and any arrow key is pressed, set date to today - if (value.length === 0 && (e.keyCode === 38 || e.keyCode === 40 || e.keyCode === 37 || e.keyCode === 39)) - { - dateObj = moment(new Date(), 'YYYY-MM-DD', true); - } - - if (dateObj.isValid()) - { - if (e.keyCode === 38) //Up - { - element.val(dateObj.add(-1, 'days').format('YYYY-MM-DD')); - } - else if (e.keyCode === 40) //Down - { - element.val(dateObj.add(1, 'days').format('YYYY-MM-DD')); - } - else if (e.keyCode === 37) //Left - { - element.val(dateObj.add(-1, 'weeks').format('YYYY-MM-DD')); - } - else if (e.keyCode === 39) //Right - { - element.val(dateObj.add(1, 'weeks').format('YYYY-MM-DD')); - } - } - - $('#batterytracking-form').validator('validate'); -}); diff --git a/public/viewjs/components/datetimepicker.js b/public/viewjs/components/datetimepicker.js index 3a8cf9e6..93b35411 100644 --- a/public/viewjs/components/datetimepicker.js +++ b/public/viewjs/components/datetimepicker.js @@ -3,9 +3,25 @@ $(function() $('.datetimepicker').datetimepicker( { format: 'YYYY-MM-DD HH:mm:ss', - showTodayButton: true, + buttons: { + showToday: true, + showClose: true + }, calendarWeeks: true, maxDate: moment(), - locale: moment.locale() + locale: moment.locale(), + defaultDate: moment().format('YYYY-MM-DD HH:mm:ss'), + icons: { + time: 'far fa-clock', + date: 'far fa-calendar', + up: 'fas fa-arrow-up', + down: 'fas fa-arrow-down', + previous: 'fas fa-chevron-left', + next: 'fas fa-chevron-right', + today: 'fas fa-calendar-check', + clear: 'far fa-trash-alt', + close: 'far fa-times-circle' + }, + sideBySide: true }); }); diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js index 8b761aa2..2319343f 100644 --- a/public/viewjs/consume.js +++ b/public/viewjs/consume.js @@ -23,7 +23,7 @@ $('#product_id_text_input').focus(); $('#product_id_text_input').val(''); $('#product_id_text_input').trigger('change'); - $('#consume-form').validator('validate'); + Grocy.FrontendHelpers.ValidateForm('consume-form'); }, function(xhr) { @@ -50,26 +50,19 @@ $('#product_id').on('change', function(e) function (productDetails) { $('#amount').attr('max', productDetails.stock_amount); - $('#consume-form').validator('update'); $('#amount_qu_unit').text(productDetails.quantity_unit_stock.name); if ((productDetails.stock_amount || 0) === 0) { $('#product_id').val(''); $('#product_id_text_input').val(''); - $('#product_id_text_input').addClass('has-error'); - $('#product_id_text_input').parent('.input-group').addClass('has-error'); - $('#product_id_text_input').closest('.form-group').addClass('has-error'); + Grocy.FrontendHelpers.ValidateForm('consume-form'); $('#product-error').text(L('This product is not in stock')); - $('#product-error').show(); $('#product_id_text_input').focus(); } else { - $('#product_id_text_input').removeClass('has-error'); - $('#product_id_text_input').parent('.input-group').removeClass('has-error'); - $('#product_id_text_input').closest('.form-group').removeClass('has-error'); - $('#product-error').hide(); + Grocy.FrontendHelpers.ValidateForm('consume-form'); $('#amount').focus(); } }, @@ -104,9 +97,6 @@ $('#product_id_text_input').focus(); $('#product_id_text_input').val(''); $('#product_id_text_input').trigger('change'); -$('#consume-form').validator(); -$('#consume-form').validator('validate'); - $('#amount').on('focus', function(e) { if ($('#product_id_text_input').val().length === 0) @@ -119,14 +109,23 @@ $('#amount').on('focus', function(e) } }); +$('#consume-form input').keyup(function (event) +{ + Grocy.FrontendHelpers.ValidateForm('consume-form'); +}); + $('#consume-form input').keydown(function(event) { if (event.keyCode === 13) //Enter { - if ($('#consume-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error + if (document.getElementById('consume-form').checkValidity() === false) //There is at least one validation error { event.preventDefault(); return false; } + else + { + $('#save-consume-button').click(); + } } }); diff --git a/public/viewjs/habitform.js b/public/viewjs/habitform.js index c4f37df6..b844173b 100644 --- a/public/viewjs/habitform.js +++ b/public/viewjs/habitform.js @@ -30,9 +30,29 @@ } }); +$('#habit-form input').keyup(function(event) +{ + Grocy.FrontendHelpers.ValidateForm('habit-form'); +}); + +$('#habit-form input').keydown(function(event) +{ + if (event.keyCode === 13) //Enter + { + if (document.getElementById('habit-form').checkValidity() === false) //There is at least one validation error + { + event.preventDefault(); + return false; + } + else + { + $('#save-habit-button').click(); + } + } +}); + $('#name').focus(); -$('#habit-form').validator(); -$('#habit-form').validator('validate'); +Grocy.FrontendHelpers.ValidateForm('habit-form'); $('.input-group-habit-period-type').on('change', function(e) { @@ -42,10 +62,10 @@ $('.input-group-habit-period-type').on('change', function(e) if (periodType === 'dynamic-regular') { $('#habit-period-type-info').text(L('This means it is estimated that a new execution of this habit is tracked #1 days after the last was tracked', periodDays.toString())); - $('#habit-period-type-info').show(); + $('#habit-period-type-info').removeClass('d-none'); } else { - $('#habit-period-type-info').hide(); + $('#habit-period-type-info').addClass('d-none'); } }); diff --git a/public/viewjs/habittracking.js b/public/viewjs/habittracking.js index 46dbc8a5..8f742c49 100644 --- a/public/viewjs/habittracking.js +++ b/public/viewjs/habittracking.js @@ -7,18 +7,18 @@ Grocy.Api.Get('habits/get-habit-details/' + jsonForm.habit_id, function (habitDetails) { - Grocy.Api.Get('habits/track-habit-execution/' + jsonForm.habit_id + '?tracked_time=' + $('#tracked_time').val(), + Grocy.Api.Get('habits/track-habit-execution/' + jsonForm.habit_id + '?tracked_time=' + $('#tracked_time').find('input').val(), function(result) { - toastr.success(L('Tracked execution of habit #1 on #2', habitDetails.habit.name, $('#tracked_time').val())); + toastr.success(L('Tracked execution of habit #1 on #2', habitDetails.habit.name, $('#tracked_time').find('input').val())); $('#habit_id').val(''); $('#habit_id_text_input').focus(); $('#habit_id_text_input').val(''); - $('#tracked_time').val(moment().format('YYYY-MM-DD HH:mm:ss')); - $('#tracked_time').trigger('change'); + $('#tracked_time').find('input').val(moment().format('YYYY-MM-DD HH:mm:ss')); + $('#tracked_time').find('input').trigger('change'); $('#habit_id_text_input').trigger('change'); - $('#habittracking-form').validator('validate'); + Grocy.FrontendHelpers.ValidateForm('habittracking-form'); }, function(xhr) { @@ -40,18 +40,7 @@ $('#habit_id').on('change', function(e) if (habitId) { Grocy.Components.HabitCard.Refresh(habitId); - $('#tracked_time').focus(); - } -}); - -$('#tracked_time').val(moment().format('YYYY-MM-DD HH:mm:ss')); -$('#tracked_time').trigger('change'); - -$('#tracked_time').on('focus', function(e) -{ - if ($('#habit_id_text_input').val().length === 0) - { - $('#habit_id_text_input').focus(); + $('#tracked_time').find('input').focus(); } }); @@ -63,23 +52,30 @@ $('#habit_id').val(''); $('#habit_id_text_input').focus(); $('#habit_id_text_input').val(''); $('#habit_id_text_input').trigger('change'); +Grocy.FrontendHelpers.ValidateForm('habittracking-form'); -$('#habittracking-form').validator(); -$('#habittracking-form').validator('validate'); +$('#habittracking-form input').keyup(function (event) +{ + Grocy.FrontendHelpers.ValidateForm('habittracking-form'); +}); $('#habittracking-form input').keydown(function(event) { if (event.keyCode === 13) //Enter { - if ($('#habittracking-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error + if (document.getElementById('habittracking-form').checkValidity() === false) //There is at least one validation error { event.preventDefault(); return false; } + else + { + $('#save-habittracking-button').click(); + } } }); -$('#tracked_time').on('keypress', function(e) +$('#tracked_time').find('input').on('keypress', function(e) { - $('#habittracking-form').validator('validate'); + Grocy.FrontendHelpers.ValidateForm('habittracking-form'); }); diff --git a/public/viewjs/inventory.js b/public/viewjs/inventory.js index 843aa0cf..b56da31c 100644 --- a/public/viewjs/inventory.js +++ b/public/viewjs/inventory.js @@ -40,14 +40,14 @@ } else { - $('#inventory-change-info').hide(); + $('#inventory-change-info').addClass('d-none'); $('#new_amount').val(''); $('#best_before_date').val(''); $('#product_id').val(''); $('#product_id_text_input').focus(); $('#product_id_text_input').val(''); $('#product_id_text_input').trigger('change'); - $('#inventory-form').validator('validate'); + Grocy.FrontendHelpers.ValidateForm('inventory-form'); } }, function(xhr) @@ -170,33 +170,6 @@ $('#product_id_text_input').focus(); $('#product_id_text_input').val(''); $('#product_id_text_input').trigger('change'); -$('#inventory-form').validator({ - custom: { - 'isodate': function($el) - { - if ($el.val().length !== 0 && !moment($el.val(), 'YYYY-MM-DD', true).isValid()) - { - return 'Wrong date format, needs to be YYYY-MM-DD'; - } - else if (moment($el.val()).isValid()) - { - if (moment($el.val()).isBefore(moment(), 'day')) - { - return 'This value cannot be before today.'; - } - } - }, - 'notequal': function($el) - { - if ($el.val().length !== 0 && $el.val().toString() === $el.attr('not-equal').toString()) - { - return 'This value cannot be equal to ' + $el.attr('not-equal').toString(); - } - } - } -}); -$('#inventory-form').validator('validate'); - $('#new_amount').on('focus', function(e) { if ($('#product_id_text_input').val().length === 0) @@ -209,15 +182,24 @@ $('#new_amount').on('focus', function(e) } }); +$('#inventory-form input').keyup(function (event) +{ + Grocy.FrontendHelpers.ValidateForm('inventory-form'); +}); + $('#inventory-form input').keydown(function(event) { if (event.keyCode === 13) //Enter { - if ($('#inventory-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error + if (document.getElementById('inventory-form').checkValidity() === false) //There is at least one validation error { event.preventDefault(); return false; } + else + { + $('#save-inventory-button').click(); + } } }); @@ -254,12 +236,12 @@ $('#new_amount').on('keypress', function(e) $('#best_before_date').on('change', function(e) { - $('#inventory-form').validator('validate'); + Grocy.FrontendHelpers.ValidateForm('inventory-form'); }); $('#best_before_date').on('keypress', function(e) { - $('#inventory-form').validator('validate'); + Grocy.FrontendHelpers.ValidateForm('inventory-form'); }); $('#best_before_date').on('keydown', function(e) @@ -270,11 +252,11 @@ $('#best_before_date').on('keydown', function(e) } }); -$('#new_amount').on('change', function(e) +$('#new_amount').on('keyup', function(e) { if ($('#product_id').parent().hasClass('has-error')) { - $('#inventory-change-info').hide(); + $('#inventory-change-info').addClass('d-none'); return; } @@ -292,23 +274,22 @@ $('#new_amount').on('change', function(e) { var amountToAdd = newAmount - productDetails.stock_amount; $('#inventory-change-info').text(L('This means #1 will be added to stock', amountToAdd.toString() + ' ' + productDetails.quantity_unit_stock.name)); - $('#inventory-change-info').show(); + $('#inventory-change-info').removeClass('d-none') $('#best_before_date').attr('required', 'required'); } else if (newAmount < productStockAmount) { var amountToRemove = productStockAmount - newAmount; $('#inventory-change-info').text(L('This means #1 will be removed from stock', amountToRemove.toString() + ' ' + productDetails.quantity_unit_stock.name)); - $('#inventory-change-info').show(); + $('#inventory-change-info').removeClass('d-none') $('#best_before_date').removeAttr('required'); } else { - $('#inventory-change-info').hide(); + $('#inventory-change-info').addClass('d-none'); } - $('#inventory-form').validator('update'); - $('#inventory-form').validator('validate'); + Grocy.FrontendHelpers.ValidateForm('inventory-form'); }, function(xhr) { diff --git a/public/viewjs/locationform.js b/public/viewjs/locationform.js index 7244a5ea..0ae8e7bc 100644 --- a/public/viewjs/locationform.js +++ b/public/viewjs/locationform.js @@ -30,6 +30,26 @@ } }); +$('#location-form input').keyup(function (event) +{ + Grocy.FrontendHelpers.ValidateForm('location-form'); +}); + +$('#location-form input').keydown(function (event) +{ + if (event.keyCode === 13) //Enter + { + if (document.getElementById('location-form').checkValidity() === false) //There is at least one validation error + { + event.preventDefault(); + return false; + } + else + { + $('#save-location-button').click(); + } + } +}); + $('#name').focus(); -$('#location-form').validator(); -$('#location-form').validator('validate'); +Grocy.FrontendHelpers.ValidateForm('location-form'); diff --git a/public/viewjs/login.js b/public/viewjs/login.js index 97908729..59878e7d 100644 --- a/public/viewjs/login.js +++ b/public/viewjs/login.js @@ -1,10 +1,7 @@ -$('.logout-button').hide(); -$('.logout-button-divider').hide(); - -$('#username').focus(); +$('#username').focus(); if (GetUriParam('invalid') === 'true') { $('#login-error').text(L('Invalid credentials, please try again')); - $('#login-error').show(); + $('#login-error').removeClass('d-none'); } diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js index 4d65a447..9d4d0d14 100644 --- a/public/viewjs/productform.js +++ b/public/viewjs/productform.js @@ -82,15 +82,35 @@ $('.input-group-qu').on('change', function(e) if (factor > 1) { $('#qu-conversion-info').text(L('This means 1 #1 purchased will be converted into #2 #3 in stock', $("#qu_id_purchase option:selected").text(), (1 * factor).toString(), $("#qu_id_stock option:selected").text())); - $('#qu-conversion-info').show(); + $('#qu-conversion-info').removeClass('d-none'); } else { - $('#qu-conversion-info').hide(); + $('#qu-conversion-info').addClass('d-none'); + } +}); + +$('#product-form input').keyup(function(event) +{ + Grocy.FrontendHelpers.ValidateForm('product-form'); +}); + +$('#product-form input').keydown(function(event) +{ + if (event.keyCode === 13) //Enter + { + if (document.getElementById('product-form').checkValidity() === false) //There is at least one validation error + { + event.preventDefault(); + return false; + } + else + { + $('#save-product-button').click(); + } } }); $('#name').focus(); -$('#product-form').validator(); -$('#product-form').validator('validate'); $('.input-group-qu').trigger('change'); +Grocy.FrontendHelpers.ValidateForm('product-form'); diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js index 566c7706..0949a35d 100644 --- a/public/viewjs/purchase.js +++ b/public/viewjs/purchase.js @@ -48,7 +48,7 @@ $('#product_id_text_input').focus(); $('#product_id_text_input').val(''); $('#product_id_text_input').trigger('change'); - $('#purchase-form').validator('validate'); + Grocy.FrontendHelpers.ValidateForm('purchase-form'); } }, function(xhr) @@ -180,26 +180,6 @@ $('#product_id_text_input').focus(); $('#product_id_text_input').val(''); $('#product_id_text_input').trigger('change'); -$('#purchase-form').validator({ - custom: { - 'isodate': function($el) - { - if ($el.val().length !== 0 && !moment($el.val(), 'YYYY-MM-DD', true).isValid()) - { - return 'Wrong date format, needs to be YYYY-MM-DD'; - } - else if (moment($el.val()).isValid()) - { - if (moment($el.val()).isBefore(moment(), 'day')) - { - return 'This value cannot be before today.'; - } - } - } - } -}); -$('#purchase-form').validator('validate'); - $('#best_before_date').on('focus', function(e) { if ($('#product_id_text_input').val().length === 0) @@ -220,15 +200,24 @@ $('#amount').on('focus', function(e) } }); +$('#purchase-form input').keyup(function(event) +{ + Grocy.FrontendHelpers.ValidateForm('purchase-form'); +}); + $('#purchase-form input').keydown(function(event) { if (event.keyCode === 13) //Enter { - if ($('#purchase-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error + if (document.getElementById('purchase-form').checkValidity() === false) //There is at least one validation error { event.preventDefault(); return false; } + else + { + $('#save-purchase-button').click(); + } } }); @@ -260,10 +249,15 @@ if (addBarcode !== undefined) $('#best_before_date').on('change', function(e) { - $('#purchase-form').validator('validate'); + Grocy.FrontendHelpers.ValidateForm('purchase-form'); }); $('#best_before_date').on('keypress', function(e) { - $('#purchase-form').validator('validate'); + Grocy.FrontendHelpers.ValidateForm('purchase-form'); +}); + +$('#amount').on('change', function (e) +{ + Grocy.FrontendHelpers.ValidateForm('purchase-form'); }); diff --git a/public/viewjs/quantityunitform.js b/public/viewjs/quantityunitform.js index 677c82a9..efa859ac 100644 --- a/public/viewjs/quantityunitform.js +++ b/public/viewjs/quantityunitform.js @@ -30,6 +30,26 @@ } }); +$('#quantityunit-form input').keyup(function(event) +{ + Grocy.FrontendHelpers.ValidateForm('quantityunit-form'); +}); + +$('#quantityunit-form input').keydown(function(event) +{ + if (event.keyCode === 13) //Enter + { + if (document.getElementById('quantityunit-form').checkValidity() === false) //There is at least one validation error + { + event.preventDefault(); + return false; + } + else + { + $('#save-quantityunit-button').click(); + } + } +}); + $('#name').focus(); -$('#quantityunit-form').validator(); -$('#quantityunit-form').validator('validate'); +Grocy.FrontendHelpers.ValidateForm('quantityunit-form'); diff --git a/public/viewjs/shoppinglistform.js b/public/viewjs/shoppinglistform.js index e3bb0b50..7f2d0c2b 100644 --- a/public/viewjs/shoppinglistform.js +++ b/public/viewjs/shoppinglistform.js @@ -42,43 +42,6 @@ $('#product_id').on('change', function(e) function (productDetails) { $('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name); - - if ($('#product_id').hasClass('suppress-next-custom-validate-event')) - { - $('#product_id').removeClass('suppress-next-custom-validate-event'); - } - else - { - Grocy.Api.Get('get-objects/shopping_list', - function (currentShoppingListItems) - { - if (currentShoppingListItems.filter(function (e) { return e.product_id === productId; }).length > 0) - { - $('#product_id').val(''); - $('#product_id_text_input').val(''); - $('#product_id_text_input').addClass('has-error'); - $('#product_id_text_input').parent('.input-group').addClass('has-error'); - $('#product_id_text_input').closest('.form-group').addClass('has-error'); - $('#product-error').text('This product is already on the shopping list.'); - $('#product-error').show(); - $('#product_id_text_input').focus(); - } - else - { - $('#product_id_text_input').removeClass('has-error'); - $('#product_id_text_input').parent('.input-group').removeClass('has-error'); - $('#product_id_text_input').closest('.form-group').removeClass('has-error'); - $('#product-error').hide(); - - $('#amount').focus(); - } - }, - function(xhr) - { - console.error(xhr); - } - ); - } }, function(xhr) { @@ -113,8 +76,7 @@ if (Grocy.EditMode === 'edit') $('#product_id').trigger('change'); } -$('#shoppinglist-form').validator(); -$('#shoppinglist-form').validator('validate'); +Grocy.FrontendHelpers.ValidateForm('shoppinglist-form'); $('#amount').on('focus', function(e) { @@ -124,14 +86,23 @@ $('#amount').on('focus', function(e) } }); -$('#shoppinglist-form input').keydown(function(event) +$('#shoppinglist-form input').keyup(function (event) +{ + Grocy.FrontendHelpers.ValidateForm('shoppinglist-form'); +}); + +$('#shoppinglist-form input').keydown(function (event) { if (event.keyCode === 13) //Enter { - if ($('#shoppinglist-form').validator('validate').has('.has-error').length !== 0) //There is at least one validation error + if (document.getElementById('shoppinglist-form').checkValidity() === false) //There is at least one validation error { event.preventDefault(); return false; } + else + { + $('#save-shoppinglist-button').click(); + } } }); diff --git a/views/batteries.blade.php b/views/batteries.blade.php index 6c2cf4dc..c4a3189c 100644 --- a/views/batteries.blade.php +++ b/views/batteries.blade.php @@ -10,15 +10,15 @@

@yield('title') -  {{ $L('Add') }} +  {{ $L('Add') }}

-
- +
+
@@ -39,10 +39,10 @@ - + - + diff --git a/views/batteriesoverview.blade.php b/views/batteriesoverview.blade.php index c42b07bb..b2507690 100644 --- a/views/batteriesoverview.blade.php +++ b/views/batteriesoverview.blade.php @@ -18,8 +18,8 @@
-
- +
+
@@ -42,7 +42,7 @@ - + diff --git a/views/batteryform.blade.php b/views/batteryform.blade.php index b973c705..be3da8d0 100644 --- a/views/batteryform.blade.php +++ b/views/batteryform.blade.php @@ -19,12 +19,12 @@ @endif -
+
-
+
{{ $L('A name is required') }}
diff --git a/views/batterytracking.blade.php b/views/batterytracking.blade.php index 295cd14d..5c500b63 100644 --- a/views/batterytracking.blade.php +++ b/views/batterytracking.blade.php @@ -6,10 +6,10 @@ @section('content')
-
+

@yield('title')

- +
@@ -19,26 +19,20 @@ @endforeach -
+
{{ $L('You have to select a battery') }}
-
- -
- - - - -
-
-
+ @include('components.datetimepicker', array( + 'id' => 'tracked_time', + 'label' => 'Tracked time' + ))
-
+
@include('components.batterycard')
diff --git a/views/components/batterycard.blade.php b/views/components/batterycard.blade.php index 945079c3..fbd346a8 100644 --- a/views/components/batterycard.blade.php +++ b/views/components/batterycard.blade.php @@ -4,9 +4,10 @@
- {{ $L('Battery overview') }} + {{ $L('Battery overview') }}
+

{{ $L('Used in') }}:
{{ $L('Charge cycles count') }}:
{{ $L('Last charged') }}:
diff --git a/views/components/datepicker.blade.php b/views/components/datepicker.blade.php index 75d356a8..839677d3 100644 --- a/views/components/datepicker.blade.php +++ b/views/components/datepicker.blade.php @@ -5,9 +5,9 @@
- +
-
+
diff --git a/views/components/datetimepicker.blade.php b/views/components/datetimepicker.blade.php index b272cef2..c1d2d4f2 100644 --- a/views/components/datetimepicker.blade.php +++ b/views/components/datetimepicker.blade.php @@ -3,11 +3,11 @@ @endpush
- +
-
+
diff --git a/views/components/habitcard.blade.php b/views/components/habitcard.blade.php index 55e37631..d084f6f3 100644 --- a/views/components/habitcard.blade.php +++ b/views/components/habitcard.blade.php @@ -4,9 +4,10 @@
- {{ $L('Habit overview') }} + {{ $L('Habit overview') }}
+

{{ $L('Tracked count') }}:
{{ $L('Last tracked') }}:
diff --git a/views/components/productcard.blade.php b/views/components/productcard.blade.php index 955a96aa..81df9c6f 100644 --- a/views/components/productcard.blade.php +++ b/views/components/productcard.blade.php @@ -4,9 +4,10 @@
- {{ $L('Product overview') }} + {{ $L('Product overview') }}
+

{{ $L('Stock quantity unit') }}:
{{ $L('Stock amount') }}:
{{ $L('Last purchased') }}:
diff --git a/views/consume.blade.php b/views/consume.blade.php index e9c14c6b..132fcb8e 100644 --- a/views/consume.blade.php +++ b/views/consume.blade.php @@ -6,26 +6,26 @@ @section('content')
-
+

@yield('title')

-
+
- + -
+
{{ $L('You have to select a product') }}
-
+
{{ $L('The amount cannot be lower than #1', '0') }}
@@ -39,7 +39,7 @@
-
+
@include('components.productcard')
diff --git a/views/habitform.blade.php b/views/habitform.blade.php index 7cbab24d..09e99329 100644 --- a/views/habitform.blade.php +++ b/views/habitform.blade.php @@ -19,12 +19,12 @@ @endif -
+
-
+
{{ $L('A name is required') }}
@@ -39,16 +39,16 @@ @endforeach -
+
{{ $L('A period type is required') }}
- -
+ +
{{ $L('This cannot be negative') }}
-

+

diff --git a/views/habits.blade.php b/views/habits.blade.php index b682fd6e..984d713d 100644 --- a/views/habits.blade.php +++ b/views/habits.blade.php @@ -10,15 +10,15 @@

@yield('title') -  {{ $L('Add') }} +  {{ $L('Add') }}

-
- +
+
@@ -40,10 +40,10 @@ - + - + diff --git a/views/habitsoverview.blade.php b/views/habitsoverview.blade.php index eb57163f..c7baae09 100644 --- a/views/habitsoverview.blade.php +++ b/views/habitsoverview.blade.php @@ -18,8 +18,8 @@
-
- +
+
@@ -42,7 +42,7 @@ - + diff --git a/views/habittracking.blade.php b/views/habittracking.blade.php index d82a8297..7c7483e7 100644 --- a/views/habittracking.blade.php +++ b/views/habittracking.blade.php @@ -6,10 +6,10 @@ @section('content')
-
+

@yield('title')

- +
@@ -19,7 +19,7 @@ @endforeach -
+
{{ $L('You have to select a habit') }}
@include('components.datetimepicker', array( @@ -32,7 +32,7 @@
-
+
@include('components.habitcard')
diff --git a/views/inventory.blade.php b/views/inventory.blade.php index fcd6dc3c..f4be8120 100644 --- a/views/inventory.blade.php +++ b/views/inventory.blade.php @@ -6,28 +6,28 @@ @section('content')
-
+

@yield('title')

-
+
- + -
-
{{ $L('will be added to the list of barcodes for the selected product on submit') }}
+
{{ $L('You have to select a product') }}
+
{{ $L('will be added to the list of barcodes for the selected product on submit') }}
-
-
+
{{ $L('The amount cannot be lower than #1', '0') }}
+
@include('components.datepicker', array( @@ -41,7 +41,7 @@
-
+
@include('components.productcard')
diff --git a/views/layout/default.blade.php b/views/layout/default.blade.php index e42561c9..3b79c5d1 100644 --- a/views/layout/default.blade.php +++ b/views/layout/default.blade.php @@ -15,7 +15,7 @@ - + @@ -38,104 +38,104 @@
@@ -212,10 +218,9 @@ - @if(!empty($L('bootstrap_datepicker_locale')))@endif + @if(!empty($L('bootstrap_datepicker_locale')))@endif - @if(!empty($L('moment_locale')))@endif - + @if(!empty($L('moment_locale')))@endif diff --git a/views/locationform.blade.php b/views/locationform.blade.php index 0a0575f4..ce63b82d 100644 --- a/views/locationform.blade.php +++ b/views/locationform.blade.php @@ -19,12 +19,12 @@ @endif -
+
-
+
{{ $L('A name is required') }}
diff --git a/views/locations.blade.php b/views/locations.blade.php index 3f4d7470..bfdbc034 100644 --- a/views/locations.blade.php +++ b/views/locations.blade.php @@ -10,15 +10,15 @@

@yield('title') -  {{ $L('Add') }} +  {{ $L('Add') }}

-
- +
+
@@ -38,10 +38,10 @@ - + - + diff --git a/views/login.blade.php b/views/login.blade.php index 90cfe8e1..7e8d7293 100644 --- a/views/login.blade.php +++ b/views/login.blade.php @@ -8,7 +8,7 @@

@yield('title')

- +
@@ -19,7 +19,7 @@
-
+
diff --git a/views/manageapikeys.blade.php b/views/manageapikeys.blade.php index cc255fb9..db485c24 100644 --- a/views/manageapikeys.blade.php +++ b/views/manageapikeys.blade.php @@ -14,15 +14,15 @@

@yield('title') -  {{ $L('Add') }} +  {{ $L('Add') }}

-
- +
+
@@ -44,7 +44,7 @@ - + diff --git a/views/productform.blade.php b/views/productform.blade.php index 5d5f4d0f..a9fdb30b 100644 --- a/views/productform.blade.php +++ b/views/productform.blade.php @@ -19,12 +19,12 @@ @endif - +
-
+
{{ $L('A name is required') }}
@@ -33,7 +33,7 @@
- +
@@ -45,19 +45,19 @@ @endforeach -
+
{{ $L('A location is required') }}
-
+
{{ $L('The amount cannot be lower than #1', '0') }}
-
+
{{ $L('This cannot be negative') }}
@@ -67,7 +67,7 @@ @endforeach -
+
{{ $L('A quantity unit is required') }}
@@ -77,16 +77,16 @@ @endforeach -
+
{{ $L('A quantity unit is required') }}
-
+
{{ $L('The amount cannot be lower than #1', '1') }}
-

+

diff --git a/views/products.blade.php b/views/products.blade.php index 4c693765..74814dad 100644 --- a/views/products.blade.php +++ b/views/products.blade.php @@ -10,15 +10,15 @@

@yield('title') -  {{ $L('Add') }} +  {{ $L('Add') }}

-
- +
+
@@ -43,10 +43,10 @@ - + - + diff --git a/views/purchase.blade.php b/views/purchase.blade.php index 0bea355c..cea4012d 100644 --- a/views/purchase.blade.php +++ b/views/purchase.blade.php @@ -6,21 +6,21 @@ @section('content')
-
+

@yield('title')

-
+
- + -
-
{{ $L('will be added to the list of barcodes for the selected product on submit') }}
+
{{ $L('You have to select a product') }}
+
{{ $L('will be added to the list of barcodes for the selected product on submit') }}
@include('components.datepicker', array( @@ -31,7 +31,7 @@
-
+
{{ $L('The amount cannot be lower than #1', '1') }}
@@ -39,7 +39,7 @@
-
+
@include('components.productcard')
diff --git a/views/quantityunitform.blade.php b/views/quantityunitform.blade.php index 310ec2c4..7c364ace 100644 --- a/views/quantityunitform.blade.php +++ b/views/quantityunitform.blade.php @@ -19,12 +19,12 @@ @endif -
+
-
+
{{ $L('A name is required') }}
diff --git a/views/quantityunits.blade.php b/views/quantityunits.blade.php index 5fd49cde..f2e38ee6 100644 --- a/views/quantityunits.blade.php +++ b/views/quantityunits.blade.php @@ -10,15 +10,15 @@

@yield('title') -  {{ $L('Add') }} +  {{ $L('Add') }}

-
- +
+
@@ -38,10 +38,10 @@ - + - + diff --git a/views/shoppinglist.blade.php b/views/shoppinglist.blade.php index 480ab1e0..0a3b1f65 100644 --- a/views/shoppinglist.blade.php +++ b/views/shoppinglist.blade.php @@ -10,18 +10,18 @@

@yield('title') -  {{ $L('Add') }} +  {{ $L('Add') }} -  {{ $L('Add products that are below defined min. stock amount') }} +  {{ $L('Add products that are below defined min. stock amount') }}

-
- +
+
@@ -40,11 +40,11 @@ @foreach($listItems as $listItem) - - + + - - + + diff --git a/views/shoppinglistform.blade.php b/views/shoppinglistform.blade.php index 1a3ea891..bc1c26bc 100644 --- a/views/shoppinglistform.blade.php +++ b/views/shoppinglistform.blade.php @@ -10,7 +10,7 @@ @section('content')
-
+

@yield('title')

@@ -19,23 +19,22 @@ @endif - +
- + -
-
+
{{ $L('This cannot be negative') }}
@@ -48,7 +47,7 @@
-
+
@include('components.productcard')
diff --git a/views/stockoverview.blade.php b/views/stockoverview.blade.php index 7948cefb..8d6d7a26 100644 --- a/views/stockoverview.blade.php +++ b/views/stockoverview.blade.php @@ -19,8 +19,8 @@
-
- +
+
-
- +
+
@@ -55,14 +55,14 @@ data-product-name="{{ FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->name }}" data-product-qu-name="{{ FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->qu_id_stock)->name }}" data-consume-amount="1"> - 1 + 1 - {{ $L('All') }} + {{ $L('All') }} diff --git a/yarn.lock b/yarn.lock index 69157df2..06588e9d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6,6 +6,16 @@ version "1.1.8" resolved "https://github.com/pallidus-fintech/bootstrap-combobox.git#0bd1da781b99d390f1c75315b6025e7d8658b263" +"@fortawesome/fontawesome-free@^5.1.0": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.1.0.tgz#f35f5ba91366b7a58b0b6a4f22ff0907fe002219" + +"TagManager@https://github.com/max-favilli/tagmanager.git#3.0.2", "tagmanager@https://github.com/max-favilli/tagmanager.git#3.0.2": + version "3.0.1" + resolved "https://github.com/max-favilli/tagmanager.git#df9eb9935c8585a392dfc00602f890caf233fa94" + dependencies: + jquery "1" + "bootbox@https://github.com/makeusabrew/bootbox.git#v5.x": version "5.0.0" resolved "https://github.com/makeusabrew/bootbox.git#8d843602d6ba7a2367829e01feee399d5f0a3a07" @@ -20,10 +30,6 @@ bootstrap-datepicker@^1.8.0: version "0.0.0" resolved "https://github.com/samrayner/bootstrap-side-navbar.git#bda4883fd2b278df3a48db4add7dc4d994477734" -bootstrap-validator@^0.11.9: - version "0.11.9" - resolved "https://registry.yarnpkg.com/bootstrap-validator/-/bootstrap-validator-0.11.9.tgz#fb7058eef53623e78f5aa7967026f98f875a9404" - bootstrap@4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.0.0.tgz#ceb03842c145fcc1b9b4e15da2a05656ba68469a" @@ -101,7 +107,7 @@ datatables.net@1.10.19, datatables.net@^1.10.15, datatables.net@^1.10.19: dependencies: jquery ">=1.7" -font-awesome@4.7.0, font-awesome@^4.7.0: +font-awesome@4.7.0: version "4.7.0" resolved "https://registry.yarnpkg.com/font-awesome/-/font-awesome-4.7.0.tgz#8fa8cf0411a1a31afd07b06d2902bb9fc815a133" @@ -131,7 +137,7 @@ moment-timezone@^0.5.11: dependencies: moment ">= 2.9.0" -"moment@>= 2.9.0", moment@^2.18.1, moment@^2.22.2: +"moment@>= 2.9.0", moment@^2.22.2: version "2.22.2" resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66" @@ -154,16 +160,10 @@ startbootstrap-sb-admin@^4.0.0: jquery "3.3.1" jquery.easing "^1.4.1" -swagger-ui-dist@^3.13.4: +swagger-ui-dist@^3.17.3: version "3.17.3" resolved "https://registry.yarnpkg.com/swagger-ui-dist/-/swagger-ui-dist-3.17.3.tgz#dfb96408ccc46775155f7369190c5d4b2016fe5c" -"tagmanager@https://github.com/max-favilli/tagmanager.git#3.0.2": - version "3.0.1" - resolved "https://github.com/max-favilli/tagmanager.git#df9eb9935c8585a392dfc00602f890caf233fa94" - dependencies: - jquery "1" - tempusdominus-bootstrap-4@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/tempusdominus-bootstrap-4/-/tempusdominus-bootstrap-4-5.0.1.tgz#713d5d1547caf7784e510e480e32997ccbe7e511" @@ -174,13 +174,13 @@ tempusdominus-bootstrap-4@^5.0.1: moment-timezone "^0.5.11" popper.js "^1.12.9" -timeago@^1.6.1: +timeago@^1.6.3: version "1.6.3" resolved "https://registry.yarnpkg.com/timeago/-/timeago-1.6.3.tgz#162a1adae99356297df59339837d09f1b0f36465" dependencies: jquery ">=1.2.3" -toastr@^2.1.3: +toastr@^2.1.4: version "2.1.4" resolved "https://registry.yarnpkg.com/toastr/-/toastr-2.1.4.tgz#8b43be64fb9d0c414871446f2db8e8ca4e95f181" dependencies: