Skip to content

Commit

Permalink
VCST-2334: Discounts blade and widget. A bit of refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Ljutyj committed Dec 4, 2024
1 parent 53aed15 commit f826422
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,19 @@
"descr": {
"no-configuration": "This product does not support configuration."
}
},
"customerOrder-item-discounts": {
"title": "Discounts",
"labels": {
"name": "Name",
"coupon": "Coupon",
"discountAmount": "Discount amount",
"discountAmountWithTax": "Discount amount with tax",
"currency": "Currency"
},
"descr": {
"no-discounts": "This entity doesn't have any discounts yet."
}
}
},
"widgets": {
Expand Down Expand Up @@ -349,6 +362,9 @@
},
"configuration": {
"title": "Configuration"
},
"customerOrder-item-discounts": {
"title": "Discounts"
}
},
"dialogs": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
angular.module('virtoCommerce.orderModule')
.controller('virtoCommerce.orderModule.itemConfigurationDetailController', [
.controller('virtoCommerce.orderModule.customerOrderItemConfigurationController', [
'$scope', 'platformWebApp.uiGridHelper', 'platformWebApp.bladeNavigationService',
function ($scope, uiGridHelper, bladeNavigationService) {
var blade = $scope.blade;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
angular.module('virtoCommerce.orderModule')
.controller('virtoCommerce.orderModule.customerOrderItemDiscountController', [
'$scope', 'platformWebApp.uiGridHelper',
function ($scope, uiGridHelper) {
var blade = $scope.blade;
blade.title = 'orders.blades.customerOrder-item-discounts.title';
blade.headIcon = 'fa fa-area-chart';

$scope.setGridOptions = function (gridOptions) {
uiGridHelper.initialize($scope, gridOptions, function (gridApi) {
$scope.gridApi = gridApi;
});
};

function initialize() {
blade.isLoading = false;
}

initialize();
}]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="blade-content __medium-wide">
<div class="blade-inner">
<div class="inner-block" ng-init="setGridOptions({
rowTemplate: 'discounts-list.row.html',
data: 'blade.currentEntity.discounts',
enableSorting: false,
columnDefs: [
{ name: 'name', displayName: 'orders.blades.customerOrder-item-discounts.labels.name'},
{ name: 'coupon', displayName: 'orders.blades.customerOrder-item-discounts.labels.coupon' },
{ name: 'discountAmount', displayName: 'orders.blades.customerOrder-item-discounts.labels.discountAmount' },
{ name: 'discountAmountWithTax', displayName: 'orders.blades.customerOrder-item-discounts.labels.discountAmountWithTax' },
{ name: 'currency', displayName: 'orders.blades.customerOrder-item-discounts.labels.currency' }
]})">
<div class="table-wrapper" ng-if="blade.currentEntity.discounts.length" style="margin: 0 -21px 0;">
<div ui-grid="gridOptions" ui-grid-auto-resize ui-grid-save-state ui-grid-resize-columns ui-grid-move-columns ui-grid-pinning ui-grid-height></div>
</div>
<div class="note" ng-if="!blade.currentEntity.discounts.length">{{ 'orders.blades.customerOrder-item-discounts.descr.no-discounts' | translate }}</div>
</div>
</div>
</div>

<script type="text/ng-template" id="discounts-list.row.html">
<div ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid" ui-grid-one-bind-id-grid="rowRenderIndex + '-' + col.uid + '-cell'" class="ui-grid-cell" ng-class="{'ui-grid-row-header-cell': col.isRowHeader, '__hovered': grid.appScope.contextMenuEntity === row.entity}" role="{{col.isRowHeader ? 'rowheader' : 'gridcell' }}" ui-grid-cell></div>
</script>
14 changes: 10 additions & 4 deletions src/VirtoCommerce.OrdersModule.Web/Scripts/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,10 +767,16 @@ angular.module(moduleName, [
}
});

var itemConfigurationWidget = {
controller: 'virtoCommerce.orderModule.itemConfigurationWidgetController',
template: 'Modules/$(VirtoCommerce.Orders)/Scripts/widgets/item-configuration-widget.tpl.html',
var customerOrderItemDiscountWidget = {
controller: 'virtoCommerce.orderModule.customerOrderItemDiscountWidgetController',
template: 'Modules/$(VirtoCommerce.Orders)/Scripts/widgets/customerOrder-item-discounts-widget.tpl.html'
};
widgetService.registerWidget(customerOrderItemDiscountWidget, 'customerOrderItemDetailWidgets');

var customerOrderItemConfigurationWidget = {
controller: 'virtoCommerce.orderModule.customerOrderItemConfigurationWidgetController',
template: 'Modules/$(VirtoCommerce.Orders)/Scripts/widgets/customerOrder-item-configuration-widget.tpl.html',
isVisible: function (blade) { return blade.currentEntity.configurationItems.length && authService.checkPermission('catalog:configurations:read'); }
};
widgetService.registerWidget(itemConfigurationWidget, 'customerOrderItemDetailWidgets');
widgetService.registerWidget(customerOrderItemConfigurationWidget, 'customerOrderItemDetailWidgets');
}]);
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
angular.module('virtoCommerce.orderModule')
.controller('virtoCommerce.orderModule.itemConfigurationWidgetController', ['$scope', 'platformWebApp.bladeNavigationService', function ($scope, bladeNavigationService) {
.controller('virtoCommerce.orderModule.customerOrderItemConfigurationWidgetController', ['$scope', 'platformWebApp.bladeNavigationService', function ($scope, bladeNavigationService) {
var blade = $scope.blade;

$scope.openBlade = function () {
var newBlade = {
id: "itemConfiguration",
controller: 'virtoCommerce.orderModule.itemConfigurationDetailController',
template: 'Modules/$(VirtoCommerce.Orders)/Scripts/blades/item-configuration-detail.tpl.html',
controller: 'virtoCommerce.orderModule.customerOrderItemConfigurationController',
template: 'Modules/$(VirtoCommerce.Orders)/Scripts/blades/customerOrder-item-configuration.tpl.html',
currentEntity: blade.currentEntity,
};
bladeNavigationService.showBlade(newBlade, blade);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
angular.module('virtoCommerce.orderModule')
.controller('virtoCommerce.orderModule.customerOrderItemDiscountWidgetController', ['$scope', 'platformWebApp.bladeNavigationService', function ($scope, bladeNavigationService) {
var blade = $scope.blade;

$scope.openBlade = function () {
var newBlade = {
id: "itemDiscounts",
controller: 'virtoCommerce.orderModule.customerOrderItemDiscountController',
template: 'Modules/$(VirtoCommerce.Orders)/Scripts/blades/customerOrder-item-dicsounts.tpl.html',
currentEntity: blade.currentEntity,
};
bladeNavigationService.showBlade(newBlade, blade);
};
}]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="gridster-cnt" ng-click="openBlade()">
<div class="cnt-inner">
<div class="list-count">{{blade.currentEntity.discounts.length | number:0}}</div>
<div class="list-t">{{ 'orders.widgets.customerOrder-item-discounts.title' | translate }}</div>
</div>
</div>

0 comments on commit f826422

Please sign in to comment.