From 0245a925b764256f09bb02c8e5b052f2d7e7b5c2 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Wed, 11 Nov 2020 21:11:17 +0100 Subject: [PATCH] Make it possible to hide columns (closes #1058) Hide new overview page columns by default --- changelog/60_UNRELEASED_2020-xx-xx.md | 56 ++++++++++---------- localization/strings.pot | 3 ++ public/js/grocy.js | 74 +++++++++++++++++++++++++++ public/viewjs/stockoverview.js | 4 +- views/batteries.blade.php | 8 ++- views/batteriesjournal.blade.php | 8 ++- views/batteriesoverview.blade.php | 8 ++- views/chores.blade.php | 8 ++- views/choresjournal.blade.php | 8 ++- views/choresoverview.blade.php | 8 ++- views/equipment.blade.php | 8 ++- views/locations.blade.php | 8 ++- views/manageapikeys.blade.php | 8 ++- views/productform.blade.php | 16 +++++- views/productgroups.blade.php | 8 ++- views/products.blade.php | 8 ++- views/quantityunitform.blade.php | 8 ++- views/quantityunits.blade.php | 8 ++- views/recipeform.blade.php | 18 +++++-- views/recipes.blade.php | 8 ++- views/shoppinglist.blade.php | 10 +++- views/shoppinglocations.blade.php | 8 ++- views/stockentries.blade.php | 8 ++- views/stockjournal.blade.php | 8 ++- views/stockoverview.blade.php | 8 ++- views/taskcategories.blade.php | 8 ++- views/tasks.blade.php | 8 ++- views/userentities.blade.php | 8 ++- views/userfields.blade.php | 8 ++- views/users.blade.php | 8 ++- 30 files changed, 307 insertions(+), 58 deletions(-) diff --git a/changelog/60_UNRELEASED_2020-xx-xx.md b/changelog/60_UNRELEASED_2020-xx-xx.md index 75377997..50277ece 100644 --- a/changelog/60_UNRELEASED_2020-xx-xx.md +++ b/changelog/60_UNRELEASED_2020-xx-xx.md @@ -94,6 +94,35 @@ - New Userfield type "File" to attach any file, will be rendered as a link to the file in tables (if enabled) (thanks @fipwmaqzufheoxq92ebc) - New Userfield type "Picture" to attach a picture, the picture will be rendered (small) in tables (if enabled) (thanks @fipwmaqzufheoxq92ebc) +### General & other improvements/fixes +- UI refresh / style improvements (thanks @zsarnett for the idea and initial work on this) +- Improved mobile views (thanks @4lloyd for the idea and initial work on this) + - The buttons on the top of each page and the filter row is now collapsed (use the ellipsis/filter button to show them, this also superseded the shopping list compact view) + - Tables are horizontally scrollable (instead of collapsing columns which don't fit) +- Table columns can now be shown/hidden (new little eye icon on the top left corner on each table) + - There are also new columns on some pages, hidden by default +- Dialogs are now used everywhere where appropriate instead of jumping between pages (for exampel when adding/editing shopping list items) +- Added a "Clear filter"-button on all pages (with filters) to quickly reset applied filters +- The data path (previously fixed to the `data` folder) is now configurable, making it possible to run multiple grocy instances from the same directory (with different `config.php` files / different database, etc.) (thanks @fgrsnau) + - Via an environment variable `GROCY_DATAPATH` (higher priority) + - Via an FastCGI parameter `GROCY_DATAPATH` (lower priority) +- The language can now be set per user (see the new user settings page / top right corner settings menu) (thanks @fipwmaqzufheoxq92ebc) + - Additionally, the language is now also auto-guessed based on the browser locale (HTTP-Header `Accept-Language`) + - The `config.php` option `CULTURE` was renamed to `DEFAULT_LOCALE` + - So the used language is based on (in that order) + - The user setting + - If not set, then based on browser locale + - If no matching localizaton was found, `DEFAULT_LOCALE` from `config.php` is used +- Performance improvements (page loading time) of the stock overview page (thanks @fipwmaqzufheoxq92ebc) +- The prerequisites checker now also checks for the minimum required SQLite version (thanks @Forceu) +- Replaced (again, added before in v2.7.0, then reverted in v2.7.1 due to some problems) [QuaggaJS](https://github.com/serratus/quaggaJS) (seems to be unmaintained) by [Quagga2](https://github.com/ericblade/quagga2) +- More `config.php` settings (see the section `Component configuration for Quagga2`) to tweak Quagga2 (this is the component used for device camera for barcode scanning) (thanks @andrelam) +- Some localization string fixes (thanks @duckfullstop) +- Fixed that XSS / HTML injection was possible through some user input fields (low severity / not really a problem as this could not be abused unauthenticated) +- New translations: (thanks all the translators) + - Greek (demo available at https://el.demo.grocy.info) + - Korean (demo available at https://ko.demo.grocy.info) + ### API improvements/fixes - Breaking changes: - All prices are now related to the products **stock** quantity unit (instead of the purchase QU) @@ -133,30 +162,3 @@ - Fixed that the endpoint `/stock/consume` returned the response code `200` and an empty response body when `stock_entry_id` was set (consuming a specific stock entry) but invalid (now returns the response code `400`) (thanks @fipwmaqzufheoxq92ebc) - Endpoint `/calendar/ical`: Fixed that "Track date only"-chores were always set to happen at 12am (are treated as all-day events now) - Fixed (again) that CORS was broken - -### General & other improvements/fixes -- UI refresh / style improvements (thanks @zsarnett for the idea and initial work on this) -- Improved mobile views (thanks @4lloyd for the idea and initial work on this) - - The buttons on the top of each page and the filter row is now collapsed (use the ellipsis/filter button to show them, this also superseded the shopping list compact view) - - Tables are horizontally scrollable (instead of collapsing columns which don't fit) -- Dialogs are now used everywhere where appropriate instead of jumping between pages (for exampel when adding/editing shopping list items) -- Added a "Clear filter"-button on all pages (with filters) to quickly reset applied filters -- The data path (previously fixed to the `data` folder) is now configurable, making it possible to run multiple grocy instances from the same directory (with different `config.php` files / different database, etc.) (thanks @fgrsnau) - - Via an environment variable `GROCY_DATAPATH` (higher priority) - - Via an FastCGI parameter `GROCY_DATAPATH` (lower priority) -- The language can now be set per user (see the new user settings page / top right corner settings menu) (thanks @fipwmaqzufheoxq92ebc) - - Additionally, the language is now also auto-guessed based on the browser locale (HTTP-Header `Accept-Language`) - - The `config.php` option `CULTURE` was renamed to `DEFAULT_LOCALE` - - So the used language is based on (in that order) - - The user setting - - If not set, then based on browser locale - - If no matching localizaton was found, `DEFAULT_LOCALE` from `config.php` is used -- Performance improvements (page loading time) of the stock overview page (thanks @fipwmaqzufheoxq92ebc) -- The prerequisites checker now also checks for the minimum required SQLite version (thanks @Forceu) -- Replaced (again, added before in v2.7.0, then reverted in v2.7.1 due to some problems) [QuaggaJS](https://github.com/serratus/quaggaJS) (seems to be unmaintained) by [Quagga2](https://github.com/ericblade/quagga2) -- More `config.php` settings (see the section `Component configuration for Quagga2`) to tweak Quagga2 (this is the component used for device camera for barcode scanning) (thanks @andrelam) -- Some localization string fixes (thanks @duckfullstop) -- Fixed that XSS / HTML injection was possible through some user input fields (low severity / not really a problem as this could not be abused unauthenticated) -- New translations: (thanks all the translators) - - Greek (demo available at https://el.demo.grocy.info) - - Korean (demo available at https://ko.demo.grocy.info) diff --git a/localization/strings.pot b/localization/strings.pot index 9d12f3c0..a8383021 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -1942,3 +1942,6 @@ msgstr "" msgid "Price per stock unit" msgstr "" + +msgid "Hide/view columns" +msgstr "" diff --git a/public/js/grocy.js b/public/js/grocy.js index cfcd279e..c83134ed 100644 --- a/public/js/grocy.js +++ b/public/js/grocy.js @@ -661,6 +661,16 @@ $.extend(true, $.fn.dataTable.defaults, { { column.search.search = ""; }); + }, + 'stateSaveCallback': function(settings, data) + { + // TODO: Save/load this server side + localStorage.setItem('datatables_state_' + settings.sTableId, JSON.stringify(data)); + }, + 'stateLoadCallback': function(settings, data) + { + // TODO: Save/load this server side + return JSON.parse(localStorage.getItem('datatables_state_' + settings.sTableId)); } }); @@ -751,3 +761,67 @@ $(window).on("message", function(e) window.location.reload(); } }); + +$("#change-table-columns-visibility").on("click", function(e) +{ + var dataTableSelector = $(e.currentTarget).attr("data-table-selector"); + var dataTable = $(dataTableSelector).DataTable(); + + var columnCheckBoxesHtml = ""; + dataTable.columns().every(function() + { + var index = this.index(); + var title = $(this.header()).text(); + var visible = this.visible(); + + if (title.isEmpty() || title.startsWith("Hidden")) + { + return; + } + + var checked = "checked"; + if (!visible) + { + checked = ""; + } + + columnCheckBoxesHtml += '
\ +
\ + \ + \ +
\ +
' + }); + + bootbox.dialog({ + message: '
' + __t('Hide/view columns') + '

' + columnCheckBoxesHtml + '
', + size: 'small', + backdrop: true, + closeButton: false, + buttons: { + cancel: { + label: __t('OK'), + className: 'btn-primary responsive-button', + callback: function() + { + bootbox.hideAll(); + } + } + } + }); +}); +$(document).on("click", ".change-table-columns-visibility-toggle", function() +{ + var dataTableSelector = $(this).attr("data-table-selector"); + var columnIndex = $(this).attr("data-column-index"); + var dataTable = $(dataTableSelector).DataTable(); + + dataTable.columns(columnIndex).visible(this.checked); +}); diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js index 83915f24..74a03c8d 100755 --- a/public/viewjs/stockoverview.js +++ b/public/viewjs/stockoverview.js @@ -7,7 +7,9 @@ { 'searchable': false, "targets": 0 }, { 'visible': false, 'targets': 6 }, { 'visible': false, 'targets': 7 }, - { 'visible': false, 'targets': 8 } + { 'visible': false, 'targets': 8 }, + { 'visible': false, 'targets': 2 }, + { 'visible': false, 'targets': 4 } ], }); diff --git a/views/batteries.blade.php b/views/batteries.blade.php index bdbad775..a7222692 100644 --- a/views/batteries.blade.php +++ b/views/batteries.blade.php @@ -70,7 +70,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Name') }} {{ $__t('Description') }} {{ $__t('Used in') }} diff --git a/views/batteriesjournal.blade.php b/views/batteriesjournal.blade.php index f887e569..5d898811 100644 --- a/views/batteriesjournal.blade.php +++ b/views/batteriesjournal.blade.php @@ -65,7 +65,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Battery') }} {{ $__t('Tracked time') }} diff --git a/views/batteriesoverview.blade.php b/views/batteriesoverview.blade.php index 1d178072..c8a3a9ed 100644 --- a/views/batteriesoverview.blade.php +++ b/views/batteriesoverview.blade.php @@ -87,7 +87,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Battery') }} {{ $__t('Used in') }} {{ $__t('Last charged') }} diff --git a/views/chores.blade.php b/views/chores.blade.php index 0e230b2f..c3756d29 100644 --- a/views/chores.blade.php +++ b/views/chores.blade.php @@ -70,7 +70,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Name') }} {{ $__t('Period type') }} {{ $__t('Description') }} diff --git a/views/choresjournal.blade.php b/views/choresjournal.blade.php index 644dd5cb..bd0ca3be 100644 --- a/views/choresjournal.blade.php +++ b/views/choresjournal.blade.php @@ -65,7 +65,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Chore') }} {{ $__t('Tracked time') }} @if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS) diff --git a/views/choresoverview.blade.php b/views/choresoverview.blade.php index 6d03bca8..2c4ab8c4 100644 --- a/views/choresoverview.blade.php +++ b/views/choresoverview.blade.php @@ -109,7 +109,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Chore') }} {{ $__t('Next estimated tracking') }} {{ $__t('Last tracked') }} diff --git a/views/equipment.blade.php b/views/equipment.blade.php index 45846920..be927f12 100644 --- a/views/equipment.blade.php +++ b/views/equipment.blade.php @@ -61,7 +61,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Name') }} @include('components.userfields_thead', array( diff --git a/views/locations.blade.php b/views/locations.blade.php index 0bf016b9..697b4d44 100644 --- a/views/locations.blade.php +++ b/views/locations.blade.php @@ -70,7 +70,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Name') }} {{ $__t('Description') }} diff --git a/views/manageapikeys.blade.php b/views/manageapikeys.blade.php index 87190a67..e9b3b1b8 100644 --- a/views/manageapikeys.blade.php +++ b/views/manageapikeys.blade.php @@ -75,7 +75,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('API key') }} {{ $__t('User') }} {{ $__t('Expires') }} diff --git a/views/productform.blade.php b/views/productform.blade.php index 53a8003d..5a0e56d4 100644 --- a/views/productform.blade.php +++ b/views/productform.blade.php @@ -393,7 +393,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Barcode') }} @if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) {{ $__t('Store') }} @@ -478,7 +484,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Quantity unit from') }} {{ $__t('Quantity unit to') }} {{ $__t('Factor') }} diff --git a/views/productgroups.blade.php b/views/productgroups.blade.php index e9f9449d..4949fe6a 100644 --- a/views/productgroups.blade.php +++ b/views/productgroups.blade.php @@ -70,7 +70,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Name') }} {{ $__t('Description') }} {{ $__t('Product count') }} diff --git a/views/products.blade.php b/views/products.blade.php index 6c737789..a0711287 100644 --- a/views/products.blade.php +++ b/views/products.blade.php @@ -88,7 +88,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Name') }} {{ $__t('Location') }} {{ $__t('Min. stock amount') }} diff --git a/views/quantityunitform.blade.php b/views/quantityunitform.blade.php index a7730acc..8ee8a648 100644 --- a/views/quantityunitform.blade.php +++ b/views/quantityunitform.blade.php @@ -126,7 +126,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Factor') }} {{ $__t('Unit') }} diff --git a/views/quantityunits.blade.php b/views/quantityunits.blade.php index 9da5b91c..3929b8c9 100644 --- a/views/quantityunits.blade.php +++ b/views/quantityunits.blade.php @@ -70,7 +70,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Name') }} {{ $__t('Description') }} diff --git a/views/recipeform.blade.php b/views/recipeform.blade.php index 61ad863c..0fb2b838 100644 --- a/views/recipeform.blade.php +++ b/views/recipeform.blade.php @@ -145,11 +145,17 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Product') }} {{ $__t('Amount') }} {{ $__t('Note') }} - Hiden ingredient group + Hidden ingredient group @@ -242,7 +248,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Recipe') }} {{ $__t('Servings') }} diff --git a/views/recipes.blade.php b/views/recipes.blade.php index d01e6733..3283cbd7 100644 --- a/views/recipes.blade.php +++ b/views/recipes.blade.php @@ -99,7 +99,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Name') }} {{ $__t('Desired servings') }} {{ $__t('Requirements fulfilled') }} diff --git a/views/shoppinglist.blade.php b/views/shoppinglist.blade.php index 37b8e8bf..faa434e8 100644 --- a/views/shoppinglist.blade.php +++ b/views/shoppinglist.blade.php @@ -175,10 +175,16 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Product') }} / {{ $__t('Note') }} {{ $__t('Amount') }} - Hiden product group + Hidden product group Hidden status @include('components.userfields_thead', array( diff --git a/views/shoppinglocations.blade.php b/views/shoppinglocations.blade.php index 72d1c926..463a670d 100644 --- a/views/shoppinglocations.blade.php +++ b/views/shoppinglocations.blade.php @@ -70,7 +70,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Name') }} {{ $__t('Description') }} diff --git a/views/stockentries.blade.php b/views/stockentries.blade.php index 156c18b4..21769a29 100644 --- a/views/stockentries.blade.php +++ b/views/stockentries.blade.php @@ -36,7 +36,13 @@ class="table table-sm table-striped nowrap w-100"> - + + product_id {{ $__t('Product') }} {{ $__t('Amount') }} diff --git a/views/stockjournal.blade.php b/views/stockjournal.blade.php index 3e120b4f..1d2a2b34 100644 --- a/views/stockjournal.blade.php +++ b/views/stockjournal.blade.php @@ -76,7 +76,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Product') }} {{ $__t('Amount') }} {{ $__t('Booking time') }} diff --git a/views/stockoverview.blade.php b/views/stockoverview.blade.php index affc0ffa..8c04975e 100755 --- a/views/stockoverview.blade.php +++ b/views/stockoverview.blade.php @@ -145,7 +145,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Product') }} {{ $__t('Product group') }} {{ $__t('Amount') }} diff --git a/views/taskcategories.blade.php b/views/taskcategories.blade.php index d0edcf03..6566d0e2 100644 --- a/views/taskcategories.blade.php +++ b/views/taskcategories.blade.php @@ -70,7 +70,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Name') }} {{ $__t('Description') }} diff --git a/views/tasks.blade.php b/views/tasks.blade.php index 37dc4b35..2d809075 100644 --- a/views/tasks.blade.php +++ b/views/tasks.blade.php @@ -105,7 +105,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Task') }} {{ $__t('Due') }} Hidden category diff --git a/views/userentities.blade.php b/views/userentities.blade.php index 822a4668..80a63f6c 100644 --- a/views/userentities.blade.php +++ b/views/userentities.blade.php @@ -66,7 +66,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Name') }} {{ $__t('Caption') }} diff --git a/views/userfields.blade.php b/views/userfields.blade.php index 3449a615..9fc52b45 100644 --- a/views/userfields.blade.php +++ b/views/userfields.blade.php @@ -80,7 +80,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Entity') }} {{ $__t('Name') }} {{ $__t('Caption') }} diff --git a/views/users.blade.php b/views/users.blade.php index 8acbd4c7..71c6553e 100644 --- a/views/users.blade.php +++ b/views/users.blade.php @@ -66,7 +66,13 @@ class="table table-sm table-striped nowrap w-100"> - + + {{ $__t('Username') }} {{ $__t('First name') }} {{ $__t('Last name') }}