Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VCST-1482: add orders widget to customer and organization blade #424

Merged
merged 4 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@
"revenue-per-customer": "Revenue per customer",
"title": "Order Statistics",
"not-authorized": "You do not currently have access to this feature. Please contact your account administrator for access."
},
"customerOrder-list": {
"title": "Orders"
}
},
"dialogs": {
Expand Down
10 changes: 10 additions & 0 deletions src/VirtoCommerce.OrdersModule.Web/Scripts/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,16 @@ angular.module(moduleName, [
};
widgetService.registerWidget(operationsTreeWidget, 'customerOrderDetailWidgets');

// register members widgets
var customerOrdersWidget = {
controller: 'virtoCommerce.orderModule.customerOrderListWidgetController',
template: 'Modules/$(VirtoCommerce.Orders)/Scripts/widgets/customerOrder-list-widget.tpl.html',
isVisible: function (blade) { return !blade.isNew; }
};

widgetService.registerWidget(customerOrdersWidget, 'customerDetail1');
widgetService.registerWidget(customerOrdersWidget, 'organizationDetail1');

// register dashboard widgets
var statisticsController = 'virtoCommerce.orderModule.dashboard.statisticsWidgetController';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
angular.module('virtoCommerce.orderModule')
.controller('virtoCommerce.orderModule.customerOrderListWidgetController',
['$scope', 'platformWebApp.bladeNavigationService', 'virtoCommerce.orderModule.order_res_customerOrders',
function ($scope, bladeNavigationService, customerOrders) {
var blade = $scope.widget.blade;

var searchCriteria = {};
if (blade.currentEntity) {
if (blade.currentEntity.memberType === "Organization") {
searchCriteria.organizationId = blade.currentEntityId;
}
else {
var account = _.first(blade.currentEntity.securityAccounts)
if (account) {
searchCriteria.customerId = account.id;
}
}
}

function refresh() {
$scope.ordersCount = '...';

var countSearchCriteria = {
responseGroup: "Default",
take: 0
};

angular.extend(countSearchCriteria, searchCriteria);

customerOrders.search(countSearchCriteria, function (data) {
$scope.ordersCount = data.totalCount;
});
}

$scope.openBlade = function () {
var newBlade = {
id: 'orders',
title: 'orders.blades.customerOrder-list.title',
searchCriteria: searchCriteria,
controller: 'virtoCommerce.orderModule.customerOrderListController',
template: 'Modules/$(VirtoCommerce.Orders)/Scripts/blades/customerOrder-list.tpl.html'
};
bladeNavigationService.showBlade(newBlade, blade);
};

refresh()
}]);
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">{{ordersCount | number:0}}</div>
<div class="list-t">{{'orders.widgets.customerOrder-list.title' | translate}}</div>
</div>
</div>
Loading