Table options: Only allow columns to be grouped for which it makes sense (closes #1535)

This commit is contained in:
Bernd Bestel 2022-02-15 18:40:42 +01:00
parent e9a7b10730
commit 926b7d8aea
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
20 changed files with 86 additions and 57 deletions

View File

@ -989,7 +989,8 @@ $(".change-table-columns-visibility-button").on("click", function(e)
dataTable.columns().every(function() dataTable.columns().every(function()
{ {
var index = this.index(); var index = this.index();
var title = $(this.header()).text(); var headerCell = $(this.header());
var title = headerCell.text();
var visible = this.visible(); var visible = this.visible();
if (title.isEmpty() || title.startsWith("Hidden")) if (title.isEmpty() || title.startsWith("Hidden"))
@ -997,7 +998,7 @@ $(".change-table-columns-visibility-button").on("click", function(e)
return; return;
} }
var shadowColumnIndex = $(this.header()).attr("data-shadow-rowgroup-column"); var shadowColumnIndex = headerCell.attr("data-shadow-rowgroup-column");
if (shadowColumnIndex) if (shadowColumnIndex)
{ {
index = shadowColumnIndex; index = shadowColumnIndex;
@ -1022,7 +1023,7 @@ $(".change-table-columns-visibility-button").on("click", function(e)
</label> \ </label> \
</div>'; </div>';
if (rowGroupDefined) if (rowGroupDefined && headerCell.hasClass("allow-grouping"))
{ {
var rowGroupChecked = ""; var rowGroupChecked = "";
if (dataTable.rowGroup().enabled() && dataTable.rowGroup().dataSrc() == index) if (dataTable.rowGroup().enabled() && dataTable.rowGroup().dataSrc() == index)
@ -1046,10 +1047,25 @@ $(".change-table-columns-visibility-button").on("click", function(e)
} }
}); });
var message = '<div class="text-center"><h5>' + __t('Table options') + '</h5><hr><h5 class="mb-0">' + __t('Hide/view columns') + '</h5><div class="text-left form-group">' + columnCheckBoxesHtml + '</div></div>'; var message = '\
<div class="text-center"> \
<h5>' + __t('Table options') + '</h5> \
<hr> \
<h5 class="mb-0">' + __t('Hide/view columns') + '</h5> \
<div class="text-left form-group"> \
' + columnCheckBoxesHtml + ' \
</div> \
</div>';
if (rowGroupDefined) if (rowGroupDefined)
{ {
message += '<div class="text-center mt-1"><h5 class="pt-3 mb-0">' + __t('Group by') + '</h5><div class="text-left form-group">' + rowGroupRadioBoxesHtml + '</div></div>'; message += ' \
<div class="text-center mt-1"> \
<h5 class="pt-3 mb-0">' + __t('Group by') + '</h5> \
<div class="text-left form-group"> \
' + rowGroupRadioBoxesHtml + ' \
</div> \
</div>';
} }
bootbox.dialog({ bootbox.dialog({

View File

@ -89,8 +89,8 @@
</th> </th>
<th>{{ $__t('Name') }}</th> <th>{{ $__t('Name') }}</th>
<th>{{ $__t('Description') }}</th> <th>{{ $__t('Description') }}</th>
<th>{{ $__t('Used in') }}</th> <th class="allow-grouping">{{ $__t('Used in') }}</th>
<th>{{ $__t('Charge cycle interval (days)') }}</th> <th class="allow-grouping">{{ $__t('Charge cycle interval (days)') }}</th>
@include('components.userfields_thead', array( @include('components.userfields_thead', array(
'userfields' => $userfields 'userfields' => $userfields

View File

@ -88,7 +88,7 @@
data-table-selector="#batteries-journal-table" data-table-selector="#batteries-journal-table"
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th>{{ $__t('Battery') }}</th> <th class="allow-grouping">{{ $__t('Battery') }}</th>
<th>{{ $__t('Tracked time') }}</th> <th>{{ $__t('Tracked time') }}</th>
</tr> </tr>
</thead> </thead>

View File

@ -101,7 +101,7 @@
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th>{{ $__t('Battery') }}</th> <th>{{ $__t('Battery') }}</th>
<th>{{ $__t('Used in') }}</th> <th class="allow-grouping">{{ $__t('Used in') }}</th>
<th>{{ $__t('Last charged') }}</th> <th>{{ $__t('Last charged') }}</th>
<th>{{ $__t('Next planned charge cycle') }}</th> <th>{{ $__t('Next planned charge cycle') }}</th>
<th class="d-none">Hidden status</th> <th class="d-none">Hidden status</th>

View File

@ -89,7 +89,7 @@
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th>{{ $__t('Name') }}</th> <th>{{ $__t('Name') }}</th>
<th>{{ $__t('Period type') }}</th> <th class="allow-grouping">{{ $__t('Period type') }}</th>
<th>{{ $__t('Description') }}</th> <th>{{ $__t('Description') }}</th>
@include('components.userfields_thead', array( @include('components.userfields_thead', array(

View File

@ -88,10 +88,10 @@
data-table-selector="#chores-journal-table" data-table-selector="#chores-journal-table"
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th>{{ $__t('Chore') }}</th> <th class="allow-grouping">{{ $__t('Chore') }}</th>
<th>{{ $__t('Tracked time') }}</th> <th>{{ $__t('Tracked time') }}</th>
@if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS) @if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS)
<th>{{ $__t('Done by') }}</th> <th class="allow-grouping">{{ $__t('Done by') }}</th>
@endif @endif
@include('components.userfields_thead', array( @include('components.userfields_thead', array(

View File

@ -125,7 +125,7 @@
<th>{{ $__t('Chore') }}</th> <th>{{ $__t('Chore') }}</th>
<th>{{ $__t('Next estimated tracking') }}</th> <th>{{ $__t('Next estimated tracking') }}</th>
<th>{{ $__t('Last tracked') }}</th> <th>{{ $__t('Last tracked') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS) d-none @endif">{{ $__t('Assigned to') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS) d-none @endif allow-grouping">{{ $__t('Assigned to') }}</th>
<th class="d-none">Hidden status</th> <th class="d-none">Hidden status</th>
<th class="d-none">Hidden assigned to user id</th> <th class="d-none">Hidden assigned to user id</th>

View File

@ -3,7 +3,7 @@
@foreach($userfields as $userfield) @foreach($userfields as $userfield)
@if($userfield->show_as_column_in_tables == 1) @if($userfield->show_as_column_in_tables == 1)
<th>{{ $userfield->caption }}</th> <th class="allow-grouping">{{ $userfield->caption }}</th>
@endif @endif
@endforeach @endforeach

View File

@ -83,11 +83,11 @@
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th>{{ $__t('API key') }}</th> <th>{{ $__t('API key') }}</th>
<th>{{ $__t('User') }}</th> <th class="allow-grouping">{{ $__t('User') }}</th>
<th>{{ $__t('Expires') }}</th> <th>{{ $__t('Expires') }}</th>
<th>{{ $__t('Last used') }}</th> <th>{{ $__t('Last used') }}</th>
<th>{{ $__t('Created') }}</th> <th>{{ $__t('Created') }}</th>
<th>{{ $__t('Key type') }}</th> <th class="allow-grouping">{{ $__t('Key type') }}</th>
</tr> </tr>
</thead> </thead>
<tbody class="d-none"> <tbody class="d-none">

View File

@ -557,8 +557,8 @@
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th>{{ $__t('Barcode') }}</th> <th>{{ $__t('Barcode') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Store') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif allow-grouping">{{ $__t('Store') }}</th>
<th>{{ $__t('Quantity unit') }}</th> <th class="allow-grouping">{{ $__t('Quantity unit') }}</th>
<th>{{ $__t('Amount') }}</th> <th>{{ $__t('Amount') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Last price') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Last price') }}</th>
<th>{{ $__t('Note') }}</th> <th>{{ $__t('Note') }}</th>
@ -693,10 +693,10 @@
data-table-selector="#qu-conversions-table-products" data-table-selector="#qu-conversions-table-products"
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th>{{ $__t('Quantity unit from') }}</th> <th class="allow-grouping">{{ $__t('Quantity unit from') }}</th>
<th>{{ $__t('Quantity unit to') }}</th> <th class="allow-grouping">{{ $__t('Quantity unit to') }}</th>
<th>{{ $__t('Factor') }}</th> <th>{{ $__t('Factor') }}</th>
<th>{{ $__t('Group')}}</th> <th class="allow-grouping">{{ $__t('Group')}}</th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>

View File

@ -118,12 +118,12 @@
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th>{{ $__t('Name') }}</th> <th>{{ $__t('Name') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING) d-none @endif">{{ $__t('Location') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING) d-none @endif allow-grouping">{{ $__t('Location') }}</th>
<th>{{ $__t('Min. stock amount') }}</th> <th class="allow-grouping">{{ $__t('Min. stock amount') }}</th>
<th>{{ $__t('Default quantity unit purchase') }}</th> <th class="">{{ $__t('Default quantity unit purchase') }}</th>
<th>{{ $__t('Quantity unit stock') }}</th> <th class="allow-grouping">{{ $__t('Quantity unit stock') }}</th>
<th>{{ $__t('Product group') }}</th> <th class="">{{ $__t('Product group') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Default store') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif allow-grouping">{{ $__t('Default store') }}</th>
@include('components.userfields_thead', array( @include('components.userfields_thead', array(
'userfields' => $userfields 'userfields' => $userfields
@ -246,7 +246,18 @@
<label for="merge-products-remove">{{ $__t('Product to remove') }}&nbsp;<i class="fas fa-question-circle text-muted" <label for="merge-products-remove">{{ $__t('Product to remove') }}&nbsp;<i class="fas fa-question-circle text-muted"
data-toggle="tooltip" data-toggle="tooltip"
data-trigger="hover click" data-trigger="hover click"
title="{{ $__t('After merging, all occurences of this product will be replaced by "Product to keep" (means this product will not exist anymore)') }}"></i> title="{{ $__t('After merging, all occurences of this product will be replaced by "
Product
to
keep"
(means
this
product
will
not
exist
anymore)')
}}"></i>
</label> </label>
<select class="custom-control custom-select" <select class="custom-control custom-select"
id="merge-products-remove"> id="merge-products-remove">

View File

@ -147,7 +147,7 @@
<th>{{ $__t('Product') }}</th> <th>{{ $__t('Product') }}</th>
<th>{{ $__t('Amount') }}</th> <th>{{ $__t('Amount') }}</th>
<th class="fit-content">{{ $__t('Note') }}</th> <th class="fit-content">{{ $__t('Note') }}</th>
<th>{{ $__t('Ingredient group') }}</th> <th class="allow-grouping">{{ $__t('Ingredient group') }}</th>
</tr> </tr>
</thead> </thead>
<tbody class="d-none"> <tbody class="d-none">

View File

@ -117,9 +117,9 @@
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th>{{ $__t('Name') }}</th> <th>{{ $__t('Name') }}</th>
<th>{{ $__t('Desired servings') }}</th> <th class="allow-grouping">{{ $__t('Desired servings') }}</th>
<th data-shadow-rowgroup-column="7" <th data-shadow-rowgroup-column="7"
class="@if(!GROCY_FEATURE_FLAG_STOCK) d-none @endif">{{ $__t('Requirements fulfilled') }}</th> class="@if(!GROCY_FEATURE_FLAG_STOCK) d-none @endif allow-grouping">{{ $__t('Requirements fulfilled') }}</th>
<th class="d-none">Hidden status for sorting of "Requirements fulfilled" column</th> <th class="d-none">Hidden status for sorting of "Requirements fulfilled" column</th>
<th class="d-none">Hidden status for filtering by status</th> <th class="d-none">Hidden status for filtering by status</th>
<th class="d-none">Hidden recipe ingredient product names</th> <th class="d-none">Hidden recipe ingredient product names</th>

View File

@ -170,13 +170,13 @@
data-table-selector="#shoppinglist-table" data-table-selector="#shoppinglist-table"
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th>{{ $__t('Product') }} / <em>{{ $__t('Note') }}</em></th> <th class="allow-grouping">{{ $__t('Product') }} / <em>{{ $__t('Note') }}</em></th>
<th>{{ $__t('Amount') }}</th> <th>{{ $__t('Amount') }}</th>
<th>{{ $__t('Product group') }}</th> <th class="allow-grouping">{{ $__t('Product group') }}</th>
<th class="d-none">Hidden status</th> <th class="d-none">Hidden status</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Last price (Unit)') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Last price (Unit)') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Last price (Total)') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Last price (Total)') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Default store') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif allow-grouping">{{ $__t('Default store') }}</th>
<th>{{ $__t('Barcodes') }}</th> <th>{{ $__t('Barcodes') }}</th>
@include('components.userfields_thead', array( @include('components.userfields_thead', array(

View File

@ -63,13 +63,14 @@
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th class="d-none">Hidden product_id</th> <!-- This must be in the first column for searching --> <th class="d-none">Hidden product_id</th> <!-- This must be in the first column for searching -->
<th>{{ $__t('Product') }}</th> <th class="allow-grouping">{{ $__t('Product') }}</th>
<th>{{ $__t('Amount') }}</th> <th>{{ $__t('Amount') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING) d-none @endif">{{ $__t('Due date') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING) d-none @endif allow-grouping">{{ $__t('Due date') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING) d-none @endif">{{ $__t('Location') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING) d-none @endif allow-grouping">{{ $__t('Location') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Store') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif allow-grouping">{{ $__t('Store') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Price') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Price') }}</th>
<th data-shadow-rowgroup-column="9">{{ $__t('Purchased date') }}</th> <th class="allow-grouping"
data-shadow-rowgroup-column="9">{{ $__t('Purchased date') }}</th>
<th class="d-none">Hidden purchased_date</th> <th class="d-none">Hidden purchased_date</th>
<th>{{ $__t('Timestamp') }}</th> <th>{{ $__t('Timestamp') }}</th>

View File

@ -141,12 +141,12 @@
data-table-selector="#stock-journal-table" data-table-selector="#stock-journal-table"
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th>{{ $__t('Product') }}</th> <th class="allow-grouping">{{ $__t('Product') }}</th>
<th>{{ $__t('Amount') }}</th> <th>{{ $__t('Amount') }}</th>
<th>{{ $__t('Transaction time') }}</th> <th>{{ $__t('Transaction time') }}</th>
<th>{{ $__t('Transaction type') }}</th> <th class="allow-grouping">{{ $__t('Transaction type') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING) d-none @endif">{{ $__t('Location') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING) d-none @endif allow-grouping">{{ $__t('Location') }}</th>
<th>{{ $__t('Done by') }}</th> <th class="allow-grouping">{{ $__t('Done by') }}</th>
</tr> </tr>
</thead> </thead>
<tbody class="d-none"> <tbody class="d-none">

View File

@ -100,9 +100,9 @@
data-table-selector="#stock-journal-summary-table" data-table-selector="#stock-journal-summary-table"
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th>{{ $__t('Product') }}</th> <th class="allow-grouping">{{ $__t('Product') }}</th>
<th>{{ $__t('Transaction type') }}</th> <th class="allow-grouping">{{ $__t('Transaction type') }}</th>
<th>{{ $__t('User') }}</th> <th class="allow-grouping">{{ $__t('User') }}</th>
<th>{{ $__t('Amount') }}</th> <th>{{ $__t('Amount') }}</th>
</tr> </tr>
</thead> </thead>

View File

@ -158,21 +158,21 @@
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th>{{ $__t('Product') }}</th> <th>{{ $__t('Product') }}</th>
<th>{{ $__t('Product group') }}</th> <th class="allow-grouping">{{ $__t('Product group') }}</th>
<th>{{ $__t('Amount') }}</th> <th>{{ $__t('Amount') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Value') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Value') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING) d-none @endif">{{ $__t('Next due date') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING) d-none @endif allow-grouping">{{ $__t('Next due date') }}</th>
<th class="d-none">Hidden location</th> <th class="d-none">Hidden location</th>
<th class="d-none">Hidden status</th> <th class="d-none">Hidden status</th>
<th class="d-none">Hidden product group</th> <th class="d-none">Hidden product group</th>
<th>{{ $__t('Calories') }} ({{ $__t('Per stock quantity unit') }})</th> <th>{{ $__t('Calories') }} ({{ $__t('Per stock quantity unit') }})</th>
<th>{{ $__t('Calories') }}</th> <th>{{ $__t('Calories') }}</th>
<th>{{ $__t('Last purchased') }}</th> <th class="allow-grouping">{{ $__t('Last purchased') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Last price') }}</th> <th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Last price') }}</th>
<th>{{ $__t('Min. stock amount') }}</th> <th class="allow-grouping">{{ $__t('Min. stock amount') }}</th>
<th>{{ $__t('Product description') }}</th> <th>{{ $__t('Product description') }}</th>
<th>{{ $__t('Parent product') }}</th> <th class="allow-grouping">{{ $__t('Parent product') }}</th>
<th>{{ $__t('Default location') }}</th> <th class="allow-grouping">{{ $__t('Default location') }}</th>
<th>{{ $__t('Product picture') }}</th> <th>{{ $__t('Product picture') }}</th>
<th>{{ $__t('Average price') }}</th> <th>{{ $__t('Average price') }}</th>

View File

@ -112,9 +112,10 @@
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th>{{ $__t('Task') }}</th> <th>{{ $__t('Task') }}</th>
<th>{{ $__t('Due') }}</th> <th class="allow-grouping">{{ $__t('Due') }}</th>
<th data-shadow-rowgroup-column="6">{{ $__t('Category') }}</th> <th class="allow-grouping"
<th>{{ $__t('Assigned to') }}</th> data-shadow-rowgroup-column="6">{{ $__t('Category') }}</th>
<th class="allow-grouping">{{ $__t('Assigned to') }}</th>
<th class="d-none">Hidden status</th> <th class="d-none">Hidden status</th>
<th class="d-none">Hidden category_id</th> <th class="d-none">Hidden category_id</th>

View File

@ -88,10 +88,10 @@
data-table-selector="#userfields-table" data-table-selector="#userfields-table"
href="#"><i class="fas fa-eye"></i></a> href="#"><i class="fas fa-eye"></i></a>
</th> </th>
<th>{{ $__t('Entity') }}</th> <th class="allow-grouping">{{ $__t('Entity') }}</th>
<th>{{ $__t('Name') }}</th> <th>{{ $__t('Name') }}</th>
<th>{{ $__t('Caption') }}</th> <th>{{ $__t('Caption') }}</th>
<th>{{ $__t('Type') }}</th> <th class="allow-grouping">{{ $__t('Type') }}</th>
<th>{{ $__t('Sort number') }}</th> <th>{{ $__t('Sort number') }}</th>
</tr> </tr>
</thead> </thead>