From 4c1c971f6da2a204fbc76ac9fe3e65d57ae881da Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Mon, 27 Jan 2020 19:19:09 +0100 Subject: [PATCH] Rename /stockedit and /stockdetail to match the "naming conventions" (references #421) --- controllers/StockController.php | 10 +- .../{stockdetail.js => stockentries.js} | 20 +-- .../{stockedit.js => stockentryform.js} | 32 ++-- routes.php | 4 +- views/stockdetail.blade.php | 170 ------------------ views/stockentries.blade.php | 169 +++++++++++++++++ ...dit.blade.php => stockentryform.blade.php} | 10 +- views/stockoverview.blade.php | 4 +- 8 files changed, 208 insertions(+), 211 deletions(-) rename public/viewjs/{stockdetail.js => stockentries.js} (94%) rename public/viewjs/{stockedit.js => stockentryform.js} (75%) delete mode 100644 views/stockdetail.blade.php create mode 100644 views/stockentries.blade.php rename views/{stockedit.blade.php => stockentryform.blade.php} (90%) diff --git a/controllers/StockController.php b/controllers/StockController.php index 788d7ae4..6a33a803 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -38,16 +38,16 @@ class StockController extends BaseController ]); } - public function Detail(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) + public function Stockentries(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) { $usersService = new UsersService(); $nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_expring_soon_days']; - return $this->AppContainer->view->render($response, 'stockdetail', [ + return $this->AppContainer->view->render($response, 'stockentries', [ 'products' => $this->Database->products()->orderBy('name'), 'quantityunits' => $this->Database->quantity_units()->orderBy('name'), 'locations' => $this->Database->locations()->orderBy('name'), - 'currentStockDetail' => $this->Database->stock()->orderBy('product_id'), + 'stockEntries' => $this->Database->stock()->orderBy('product_id'), 'currentStockLocations' => $this->StockService->GetCurrentStockLocations(), 'nextXDays' => $nextXDays, 'userfields' => $this->UserfieldsService->GetFields('products'), @@ -89,9 +89,9 @@ class StockController extends BaseController ]); } - public function StockEdit(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) + public function StockEntryEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) { - return $this->AppContainer->view->render($response, 'stockedit', [ + return $this->AppContainer->view->render($response, 'stockentryform', [ 'stockEntry' => $this->Database->stock()->where('id', $args['entryId'])->fetch(), 'products' => $this->Database->products()->orderBy('name'), 'locations' => $this->Database->locations()->orderBy('name') diff --git a/public/viewjs/stockdetail.js b/public/viewjs/stockentries.js similarity index 94% rename from public/viewjs/stockdetail.js rename to public/viewjs/stockentries.js index 8494758f..98fcd168 100644 --- a/public/viewjs/stockdetail.js +++ b/public/viewjs/stockentries.js @@ -1,11 +1,11 @@ -var stockDetailTable = $('#stock-detail-table').DataTable({ +var stockEntriesTable = $('#stockentries-table').DataTable({ 'order': [[2, 'asc']], 'columnDefs': [ { 'orderable': false, 'targets': 0 }, { 'searchable': false, "targets": 0 } ], }); -$('#stock-detail-table tbody').removeClass("d-none"); +$('#stockentries-table tbody').removeClass("d-none"); $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) { @@ -22,7 +22,7 @@ $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) Grocy.Components.ProductPicker.GetPicker().on('change', function(e) { - stockDetailTable.draw(); + stockEntriesTable.draw(); }); $(document).on('click', '.stock-consume-button', function(e) @@ -56,7 +56,7 @@ $(document).on('click', '.stock-consume-button', function(e) } Grocy.FrontendHelpers.EndUiBusy(); - RefreshStockDetailRow(stockRowId); + RefreshStockEntryRow(stockRowId); toastr.success(toastMessage); }, function(xhr) @@ -97,7 +97,7 @@ $(document).on('click', '.product-open-button', function(e) button.addClass("disabled"); Grocy.FrontendHelpers.EndUiBusy(); toastr.success(__t('Marked %1$s of %2$s as opened', 1 + " " + productQuName, productName) + '
' + __t("Undo") + ''); - RefreshStockDetailRow(stockRowId); + RefreshStockEntryRow(stockRowId); }, function(xhr) { @@ -110,10 +110,10 @@ $(document).on('click', '.product-open-button', function(e) $(document).on("click", ".stock-name-cell", function(e) { Grocy.Components.ProductCard.Refresh($(e.currentTarget).attr("data-stock-id")); - $("#stockdetail-productcard-modal").modal("show"); + $("#stockentry-productcard-modal").modal("show"); }); -function RefreshStockDetailRow(stockRowId) +function RefreshStockEntryRow(stockRowId) { Grocy.Api.Get("stock/entry/" + stockRowId, function(result) @@ -233,9 +233,9 @@ $(window).on("message", function(e) { var data = e.originalEvent.data; - if (data.Message === "StockDetailChanged") + if (data.Message === "StockEntryChanged") { - RefreshStockDetailRow(data.Payload); + RefreshStockEntryRow(data.Payload); } }); @@ -246,7 +246,7 @@ function UndoStockBookingEntry(bookingId, stockRowId) Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', { }, function(result) { - window.postMessage(WindowMessageBag("StockDetailChanged", stockRowId), Grocy.BaseUrl); + window.postMessage(WindowMessageBag("StockEntryChanged", stockRowId), Grocy.BaseUrl); toastr.success(__t("Booking successfully undone")); }, function(xhr) diff --git a/public/viewjs/stockedit.js b/public/viewjs/stockentryform.js similarity index 75% rename from public/viewjs/stockedit.js rename to public/viewjs/stockentryform.js index e33e5bc8..0492ee31 100644 --- a/public/viewjs/stockedit.js +++ b/public/viewjs/stockentryform.js @@ -1,9 +1,9 @@ -$('#save-stockedit-button').on('click', function(e) +$('#save-stockentry-button').on('click', function(e) { e.preventDefault(); - var jsonForm = $('#stockedit-form').serializeJSON(); - Grocy.FrontendHelpers.BeginUiBusy("stockedit-form"); + var jsonForm = $('#stockentry-form').serializeJSON(); + Grocy.FrontendHelpers.BeginUiBusy("stockentry-form"); if (!jsonForm.price.toString().isEmpty()) { @@ -31,61 +31,61 @@ { var successMessage = __t('Stock entry successfully updated') + '
' + __t("Undo") + ''; - window.parent.postMessage(WindowMessageBag("StockDetailChanged", Grocy.EditObjectId), Grocy.BaseUrl); + window.parent.postMessage(WindowMessageBag("StockEntryChanged", Grocy.EditObjectId), Grocy.BaseUrl); window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl); window.parent.postMessage(WindowMessageBag("Ready"), Grocy.BaseUrl); window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl); }, function(xhr) { - Grocy.FrontendHelpers.EndUiBusy("stockedit-form"); + Grocy.FrontendHelpers.EndUiBusy("stockentry-form"); console.error(xhr); } ); }); -Grocy.FrontendHelpers.ValidateForm('stockedit-form'); +Grocy.FrontendHelpers.ValidateForm('stockentry-form'); -$('#stockedit-form input').keyup(function (event) +$('#stockentry-form input').keyup(function (event) { - Grocy.FrontendHelpers.ValidateForm('stockedit-form'); + Grocy.FrontendHelpers.ValidateForm('stockentry-form'); }); -$('#stockedit-form input').keydown(function(event) +$('#stockentry-form input').keydown(function(event) { if (event.keyCode === 13) //Enter { event.preventDefault(); - if (document.getElementById('stockedit-form').checkValidity() === false) //There is at least one validation error + if (document.getElementById('stockentry-form').checkValidity() === false) //There is at least one validation error { return false; } else { - $('#save-stockedit-button').click(); + $('#save-stockentry-button').click(); } } }); Grocy.Components.DateTimePicker.GetInputElement().on('change', function(e) { - Grocy.FrontendHelpers.ValidateForm('stockedit-form'); + Grocy.FrontendHelpers.ValidateForm('stockentry-form'); }); Grocy.Components.DateTimePicker.GetInputElement().on('keypress', function(e) { - Grocy.FrontendHelpers.ValidateForm('stockedit-form'); + Grocy.FrontendHelpers.ValidateForm('stockentry-form'); }); Grocy.Components.DateTimePicker2.GetInputElement().on('change', function(e) { - Grocy.FrontendHelpers.ValidateForm('stockedit-form'); + Grocy.FrontendHelpers.ValidateForm('stockentry-form'); }); Grocy.Components.DateTimePicker2.GetInputElement().on('keypress', function(e) { - Grocy.FrontendHelpers.ValidateForm('stockedit-form'); + Grocy.FrontendHelpers.ValidateForm('stockentry-form'); }); Grocy.Api.Get('stock/products/' + Grocy.EditObjectProductId, @@ -129,4 +129,4 @@ $("#amount").on("focus", function(e) $(this).select(); }); $("#amount").focus(); -Grocy.FrontendHelpers.ValidateForm("stockedit-form"); +Grocy.FrontendHelpers.ValidateForm("stockentry-form"); diff --git a/routes.php b/routes.php index 490df37c..9a02f309 100644 --- a/routes.php +++ b/routes.php @@ -33,12 +33,12 @@ $app->group('', function() if (GROCY_FEATURE_FLAG_STOCK) { $this->get('/stockoverview', '\Grocy\Controllers\StockController:Overview'); - $this->get('/stockdetail', '\Grocy\Controllers\StockController:Detail'); + $this->get('/stockentries', '\Grocy\Controllers\StockController:Stockentries'); $this->get('/purchase', '\Grocy\Controllers\StockController:Purchase'); $this->get('/consume', '\Grocy\Controllers\StockController:Consume'); $this->get('/transfer', '\Grocy\Controllers\StockController:Transfer'); $this->get('/inventory', '\Grocy\Controllers\StockController:Inventory'); - $this->get('/stockedit/{entryId}', '\Grocy\Controllers\StockController:StockEdit'); + $this->get('/stockentry/{entryId}', '\Grocy\Controllers\StockController:StockEntryEditForm'); $this->get('/products', '\Grocy\Controllers\StockController:ProductsList'); $this->get('/product/{productId}', '\Grocy\Controllers\StockController:ProductEditForm'); $this->get('/stocksettings', '\Grocy\Controllers\StockController:StockSettings'); diff --git a/views/stockdetail.blade.php b/views/stockdetail.blade.php deleted file mode 100644 index cc42ef13..00000000 --- a/views/stockdetail.blade.php +++ /dev/null @@ -1,170 +0,0 @@ -@extends('layout.default') - -@section('title', $__t('Stock entries')) -@section('activeNav', 'stockdetail') -@section('viewJsName', 'stockdetail') - -@push('pageScripts') - - -@endpush - -@section('content') -
-
-

@yield('title')

-
-
- @include('components.productpicker', array( - 'products' => $products, - 'disallowAllProductWorkflows' => true - )) -
-
- -
-
- - - - - - - - - @if(GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)@endif - @if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)@endif - - - @include('components.userfields_thead', array( - 'userfields' => $userfields - )) - - - - @foreach($currentStockDetail as $currentStockEntry) - amount > 0) table-warning @endif"> - - - - - - @if(GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING) - - @endif - @if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) - - @endif - - - @endforeach - -
product_id {{ $__t('Product') }}{{ $__t('Amount') }}{{ $__t('Best before date') }}{{ $__t('Location') }}{{ $__t('Price') }}{{ $__t('Purchased date') }}
- - - - @if(GROCY_FEATURE_FLAG_STOCK_PRODUCT_OPENED_TRACKING) - - - - @endif - - - - - - {{ $currentStockEntry->product_id }} - - {{ $currentStockEntry->amount }} {{ $__n($currentStockEntry->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->qu_id_stock)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->qu_id_stock)->name_plural) }} - @if($currentStockEntry->open == 1){{ $__t('Opened') }}@endif - - {{ $currentStockEntry->best_before_date }} - - - {{ FindObjectInArrayByPropertyValue($locations, 'id', $currentStockEntry->location_id)->name }} - - {{ $currentStockEntry->price }} - - {{ $currentStockEntry->purchased_date }} - -
-
-
- - -@stop diff --git a/views/stockentries.blade.php b/views/stockentries.blade.php new file mode 100644 index 00000000..cc4c729e --- /dev/null +++ b/views/stockentries.blade.php @@ -0,0 +1,169 @@ +@extends('layout.default') + +@section('title', $__t('Stock entries')) +@section('viewJsName', 'stockentries') + +@push('pageScripts') + + +@endpush + +@section('content') +
+
+

@yield('title')

+
+
+ @include('components.productpicker', array( + 'products' => $products, + 'disallowAllProductWorkflows' => true + )) +
+
+ +
+
+ + + + + + + + + @if(GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)@endif + @if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)@endif + + + @include('components.userfields_thead', array( + 'userfields' => $userfields + )) + + + + @foreach($stockEntries as $stockEntry) + amount > 0) table-warning @endif"> + + + + + + @if(GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING) + + @endif + @if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) + + @endif + + + @endforeach + +
product_id {{ $__t('Product') }}{{ $__t('Amount') }}{{ $__t('Best before date') }}{{ $__t('Location') }}{{ $__t('Price') }}{{ $__t('Purchased date') }}
+ + + + @if(GROCY_FEATURE_FLAG_STOCK_PRODUCT_OPENED_TRACKING) + + + + @endif + + + + + + {{ $stockEntry->product_id }} + + {{ $stockEntry->amount }} {{ $__n($stockEntry->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->qu_id_stock)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $stockEntry->product_id)->qu_id_stock)->name_plural) }} + @if($stockEntry->open == 1){{ $__t('Opened') }}@endif + + {{ $stockEntry->best_before_date }} + + + {{ FindObjectInArrayByPropertyValue($locations, 'id', $stockEntry->location_id)->name }} + + {{ $stockEntry->price }} + + {{ $stockEntry->purchased_date }} + +
+
+
+ + +@stop diff --git a/views/stockedit.blade.php b/views/stockentryform.blade.php similarity index 90% rename from views/stockedit.blade.php rename to views/stockentryform.blade.php index 2fb21f2a..c763337b 100644 --- a/views/stockedit.blade.php +++ b/views/stockentryform.blade.php @@ -1,8 +1,7 @@ @extends('layout.default') @section('title', $__t('Edit stock entry')) -@section('activeNav', 'stockedit') -@section('viewJsName', 'stockedit') +@section('viewJsName', 'stockentryform') @section('content')