diff --git a/CHANGELOG.md b/CHANGELOG.md index 01a08b7..285d108 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,13 @@ # Commerce Widgets Changelog +## 2.0.11 - 2019-01-07 +### Added +- Added `Order Status` setting to the Top Products Widget. + ## 2.0.10 - 2019-01-04 ### Fixed - `groupBy` issue with MySQL 5.7 on some widgets -- Week was showing incorrectly in the Goal widget +- Week was showing incorrectly in the Goal widget - Installing the plugin now populates the cache setting by default ### Changed diff --git a/composer.json b/composer.json index c8353d8..8dd42cf 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "bymayo/commerce-widgets", "description": "Insightful dashboard widgets for your Craft Commerce 2 store.", "type": "craft-plugin", - "version": "2.0.10", + "version": "2.0.11", "keywords": [ "craft", "cms", diff --git a/src/assetbundles/commercewidgets/CommerceWidgetsAsset.php b/src/assetbundles/commercewidgets/CommerceWidgetsAsset.php index 6ba7102..85bd80c 100755 --- a/src/assetbundles/commercewidgets/CommerceWidgetsAsset.php +++ b/src/assetbundles/commercewidgets/CommerceWidgetsAsset.php @@ -37,7 +37,7 @@ public function init() $this->js = [ 'js/plugins/Chart.min.js', - 'js/CommerceWidgets.js', + 'js/CommerceWidgets.js', ]; $this->css = [ diff --git a/src/assetbundles/commercewidgets/dist/js/CommerceWidgets.js b/src/assetbundles/commercewidgets/dist/js/CommerceWidgets.js index e69de29..ba4b253 100755 --- a/src/assetbundles/commercewidgets/dist/js/CommerceWidgets.js +++ b/src/assetbundles/commercewidgets/dist/js/CommerceWidgets.js @@ -0,0 +1,48 @@ +if (typeof CommerceWidgets === typeof undefined) { + CommerceWidgets = {}; +} + +/** + * Class CommerceWidgets.OrderStatuses + */ +CommerceWidgets.OrderStatuses = Garnish.Base.extend( + { + init: function(id, settings) { + this.$container = $('#' + id); + this.$menuBtn = $('.menubtn', this.$container); + this.$statusInput = $('.status-input', this.$container); + + this.menuBtn = new Garnish.MenuBtn(this.$menuBtn, { + onOptionSelect: $.proxy(this, 'onSelectStatus') + }); + + var statusId = this.$statusInput.val(); + + var $currentStatus = $('[data-id="' + statusId + '"]', this.menuBtn.menu.$container); + + $currentStatus.trigger('click'); + + }, + + onSelectStatus: function(status) { + this.deselectStatus(); + + var $status = $(status); + $status.addClass('sel'); + + this.selectedStatus = $status; + + this.$statusInput.val($status.data('id')); + + // clone selected status item to menu menu + var $label = $('.commerceStatusLabel', $status); + this.$menuBtn.empty(); + $label.clone().appendTo(this.$menuBtn); + }, + + deselectStatus: function() { + if (this.selectedStatus) { + this.selectedStatus.removeClass('sel'); + } + } + }); diff --git a/src/templates/widgets/ProductsTop/settings.twig b/src/templates/widgets/ProductsTop/settings.twig index a5f5b46..b5aa174 100644 --- a/src/templates/widgets/ProductsTop/settings.twig +++ b/src/templates/widgets/ProductsTop/settings.twig @@ -2,27 +2,59 @@ {% do view.registerAssetBundle("bymayo\\commercewidgets\\assetbundles\\commercewidgets\\CommerceWidgetsAsset") %} -{{ - forms.selectField( - { - label: 'Order By', - name: 'orderBy', - value: widget['orderBy'], - options: [ - { label: 'Ordered Total', value: 'totalOrdered' }, - { label: 'Revenue Total', value: 'totalRevenue' } - ] - } - ) -}} +