diff --git a/localization/strings.pot b/localization/strings.pot
index b6951360..0cbae663 100644
--- a/localization/strings.pot
+++ b/localization/strings.pot
@@ -2008,3 +2008,12 @@ msgstr ""
msgid "Show on stock overview page"
msgstr ""
+
+msgid "None"
+msgstr ""
+
+msgid "Group by"
+msgstr ""
+
+msgid "Ingredient group"
+msgstr ""
diff --git a/public/js/grocy.js b/public/js/grocy.js
index 7684c0af..3097a0fa 100644
--- a/public/js/grocy.js
+++ b/public/js/grocy.js
@@ -709,6 +709,45 @@ $.extend(true, $.fn.dataTable.defaults, {
{
column.search.search = "";
});
+
+ var api = new $.fn.dataTable.Api(settings);
+
+ if (typeof api.rowGroup === "function")
+ {
+ var rowGroup = {
+ enable: api.rowGroup().enabled(),
+ };
+
+ if (api.rowGroup().enabled())
+ {
+ rowGroup.dataSrc = api.rowGroup().dataSrc()
+ }
+
+ data.rowGroup = rowGroup;
+ }
+ },
+ 'stateLoadParams': function(settings, data)
+ {
+ var api = new $.fn.dataTable.Api(settings);
+
+ if (typeof api.rowGroup === "function" && "rowGroup" in data)
+ {
+ api.rowGroup().enable(data.rowGroup.enable);
+
+ if ("dataSrc" in data.rowGroup)
+ {
+ api.rowGroup().dataSrc(data.rowGroup.dataSrc);
+
+ //apply fixed order for group column
+ var fixedOrder = {
+ pre: [data.rowGroup.dataSrc, 'asc']
+ };
+
+ api.order.fixed(fixedOrder);
+ }
+
+ delete data.rowGroup;
+ }
},
'stateSaveCallback': function(settings, data)
{
@@ -847,6 +886,28 @@ $(".change-table-columns-visibility-button").on("click", function(e)
var dataTable = $(dataTableSelector).DataTable();
var columnCheckBoxesHtml = "";
+ var rowGroupRadioBoxesHtml = "";
+
+ var rowGroupDefined = typeof dataTable.rowGroup === "function";
+
+ if (rowGroupDefined)
+ {
+ var rowGroupChecked = (dataTable.rowGroup().enabled()) ? "" : "checked";
+ rowGroupRadioBoxesHtml = ' \
+
\
+ \
+ ' + __t("None") + ' \
+ \
+
';
+ }
+
dataTable.columns().every(function()
{
var index = this.index();
@@ -864,7 +925,7 @@ $(".change-table-columns-visibility-button").on("click", function(e)
checked = "";
}
- columnCheckBoxesHtml += ''
+ ';
+
+ if (rowGroupDefined)
+ {
+ var rowGroupChecked = "";
+ if (dataTable.rowGroup().enabled() && dataTable.rowGroup().dataSrc() == index)
+ {
+ rowGroupChecked = "checked";
+ }
+
+ rowGroupRadioBoxesHtml += ' \
+ \
+ \
+ ' + title + ' \
+ \
+
';
+ }
});
+ var message = '' + __t('Hide/view columns') + ' ' + columnCheckBoxesHtml + '
';
+
+ if (rowGroupDefined)
+ {
+ message += '' + __t('Group by') + ' ' + rowGroupRadioBoxesHtml + '
';
+ }
+
bootbox.dialog({
- message: '' + __t('Hide/view columns') + ' ' + columnCheckBoxesHtml + '
',
+ message: message,
size: 'small',
backdrop: true,
closeButton: false,
@@ -896,6 +986,7 @@ $(".change-table-columns-visibility-button").on("click", function(e)
}
});
});
+
$(document).on("click", ".change-table-columns-visibility-toggle", function()
{
var dataTableSelector = $(this).attr("data-table-selector");
@@ -904,3 +995,32 @@ $(document).on("click", ".change-table-columns-visibility-toggle", function()
dataTable.columns(columnIndex).visible(this.checked);
});
+
+
+$(document).on("click", ".change-table-columns-rowgroup-toggle", function()
+{
+ var dataTableSelector = $(this).attr("data-table-selector");
+ var columnIndex = $(this).attr("data-column-index");
+ var dataTable = $(dataTableSelector).DataTable();
+
+ if (columnIndex == -1)
+ {
+ dataTable.rowGroup().enable(false);
+
+ //remove fixed order
+ dataTable.order.fixed({});
+ }
+ else
+ {
+ dataTable.rowGroup().enable(true);
+ dataTable.rowGroup().dataSrc(columnIndex);
+
+ //apply fixed order for group column
+ var fixedOrder = {
+ pre: [columnIndex, 'asc']
+ };
+ dataTable.order.fixed(fixedOrder);
+ }
+
+ dataTable.draw();
+});
diff --git a/views/productform.blade.php b/views/productform.blade.php
index bdc2d5c7..0e812096 100644
--- a/views/productform.blade.php
+++ b/views/productform.blade.php
@@ -580,7 +580,7 @@
{{ $__t('Quantity unit from') }}
{{ $__t('Quantity unit to') }}
{{ $__t('Factor') }}
- Hidden group
+ {{ $__('Group')}}
@@ -675,4 +675,4 @@
-@stop
+@stop
\ No newline at end of file
diff --git a/views/recipeform.blade.php b/views/recipeform.blade.php
index ad17f57a..c954dd93 100644
--- a/views/recipeform.blade.php
+++ b/views/recipeform.blade.php
@@ -156,7 +156,7 @@
{{ $__t('Product') }}
{{ $__t('Amount') }}
{{ $__t('Note') }}
- Hidden ingredient group
+ {{ $__t('Ingredient group') }}
@@ -380,4 +380,4 @@
-@stop
+@stop
\ No newline at end of file
diff --git a/views/shoppinglist.blade.php b/views/shoppinglist.blade.php
index 35b67cbe..e6d14cf4 100644
--- a/views/shoppinglist.blade.php
+++ b/views/shoppinglist.blade.php
@@ -20,7 +20,6 @@
tr.dtrg-group {
cursor: pointer;
}
-
@endpush
@@ -184,7 +183,7 @@
{{ $__t('Product') }} / {{ $__t('Note') }}
{{ $__t('Amount') }}
- Hidden product group
+ {{ $__t('Product group') }}
Hidden status
@include('components.userfields_thead', array(
@@ -251,7 +250,7 @@
@endif
{{ $listItem->amount }} @if(!empty($listItem->product_id)){{ $__n($listItem->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name_plural) }}@endif
-
+
@if(!empty(FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->product_group_id)) {{ FindObjectInArrayByPropertyValue($productGroups, 'id', FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->product_group_id)->name }} @else {{ $__t('Ungrouped') }} @endif
-@stop
+@stop
\ No newline at end of file
diff --git a/views/tasks.blade.php b/views/tasks.blade.php
index 93d841ac..223a5687 100644
--- a/views/tasks.blade.php
+++ b/views/tasks.blade.php
@@ -114,7 +114,7 @@
{{ $__t('Task') }}
{{ $__t('Due') }}
- Hidden category
+ {{ $__t('Category') }}
{{ $__t('Assigned to') }}
Hidden status
@@ -176,7 +176,7 @@
-
+
@if($task->category_id != null) {{ FindObjectInArrayByPropertyValue($taskCategories, 'id', $task->category_id)->name }} @else {{ $__t('Uncategorized') }} @endif
@@ -205,4 +205,4 @@
-@stop
+@stop
\ No newline at end of file