-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathcustomerOrder-list-widget.js
More file actions
58 lines (48 loc) · 2.29 KB
/
customerOrder-list-widget.js
File metadata and controls
58 lines (48 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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;
}
}
}
const memberId = searchCriteria.organizationId || searchCriteria.customerId;
function refresh() {
$scope.ordersCount = '...';
if (!memberId) {
return;
}
var countSearchCriteria = {
responseGroup: "Default",
take: 0
};
angular.extend(countSearchCriteria, searchCriteria);
customerOrders.search(countSearchCriteria, function (data) {
$scope.ordersCount = data.totalCount;
});
}
$scope.openBlade = function () {
if (!memberId) {
return;
}
var newBlade = {
id: 'orders',
navigationGroup: memberId,
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()
}]);