Skip to content

Commit

Permalink
VCST-1514: Routes for orders (#425)
Browse files Browse the repository at this point in the history
feat: Add routes for order. It helps manage orders better, makes it easier to search for order by ID, and allows us to copy order link.
  • Loading branch information
OlegoO authored Jul 18, 2024
1 parent 8b2aa21 commit 271d3ae
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
angular.module('virtoCommerce.orderModule')
.controller('virtoCommerce.orderModule.customerOrderListController', ['$rootScope','$scope', '$localStorage', 'virtoCommerce.orderModule.order_res_customerOrders', 'platformWebApp.bladeUtils', 'platformWebApp.dialogService', 'platformWebApp.authService', 'uiGridConstants', 'platformWebApp.uiGridHelper', 'platformWebApp.ui-grid.extension', 'virtoCommerce.orderModule.knownOperations', '$translate',
function ($rootScope, $scope, $localStorage, customerOrders, bladeUtils, dialogService, authService, uiGridConstants, uiGridHelper, gridOptionExtension, knownOperations, $translate) {
.controller('virtoCommerce.orderModule.customerOrderListController', ['$rootScope', '$scope', '$location', '$localStorage', 'virtoCommerce.orderModule.order_res_customerOrders', 'platformWebApp.bladeUtils', 'platformWebApp.dialogService', 'platformWebApp.authService', 'uiGridConstants', 'platformWebApp.uiGridHelper', 'platformWebApp.ui-grid.extension', 'virtoCommerce.orderModule.knownOperations', '$translate',
function ($rootScope, $scope, $location, $localStorage, customerOrders, bladeUtils, dialogService, authService, uiGridConstants, uiGridHelper, gridOptionExtension, knownOperations, $translate) {
var blade = $scope.blade;
var bladeNavigationService = bladeUtils.bladeNavigationService;
$scope.uiGridConstants = uiGridConstants;
Expand Down Expand Up @@ -99,6 +99,8 @@ function ($rootScope, $scope, $localStorage, customerOrders, bladeUtils, dialogS
newBlade.customerOrder = node;
bladeNavigationService.showBlade(newBlade, blade);
}

$location.search({ orderId: node.id });
};

$scope.copy = function (text) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
angular.module('virtoCommerce.orderModule')
.controller('virtoCommerce.orderModule.operationDetailController', ['$scope', 'platformWebApp.dialogService', 'platformWebApp.bladeNavigationService', 'virtoCommerce.orderModule.order_res_customerOrders', 'platformWebApp.objCompareService', '$timeout', 'focus', '$rootScope',
function ($scope,dialogService, bladeNavigationService, customerOrders, objCompareService, $timeout, focus, $rootScope) {
.controller('virtoCommerce.orderModule.operationDetailController', ['$scope', '$location', 'platformWebApp.dialogService', 'platformWebApp.bladeNavigationService', 'virtoCommerce.orderModule.order_res_customerOrders', 'platformWebApp.objCompareService', '$timeout', 'focus', '$rootScope',
function ($scope, $location, dialogService, bladeNavigationService, customerOrders, objCompareService, $timeout, focus, $rootScope) {
var blade = $scope.blade;
blade.updatePermission = 'order:update';

Expand Down Expand Up @@ -275,6 +275,10 @@ angular.module('virtoCommerce.orderModule')
}

blade.onClose = function (closeCallback) {
if (blade.currentEntity.operationType === "CustomerOrder") {
$location.search({ orderId: null });
}

bladeNavigationService.showConfirmationIfNeeded(isDirty(), canSave(), blade, $scope.saveChanges, closeCallback, "orders.dialogs.operation-save.title", "orders.dialogs.operation-save.message");
};

Expand Down
43 changes: 28 additions & 15 deletions src/VirtoCommerce.OrdersModule.Web/Scripts/order.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//Call this to register our module to main application
var moduleName = "virtoCommerce.orderModule";
const bladeNavigationServiceName = 'platformWebApp.bladeNavigationService';

if (AppDependencies !== undefined) {
AppDependencies.push(moduleName);
Expand All @@ -18,17 +17,31 @@ angular.module(moduleName, [
url: '/orders',
templateUrl: '$(Platform)/Scripts/common/templates/home.tpl.html',
controller: [
'$scope', bladeNavigationServiceName, function ($scope, bladeNavigationService) {
var blade = {
id: 'orders',
title: 'orders.blades.customerOrder-list.title',
//subtitle: 'Manage Orders',
controller: 'virtoCommerce.orderModule.customerOrderListController',
isExpandable: true,
template: 'Modules/$(VirtoCommerce.Orders)/Scripts/blades/customerOrder-list.tpl.html',
isClosingDisabled: true
};
bladeNavigationService.showBlade(blade);
'$scope', '$location', 'platformWebApp.bladeNavigationService', 'virtoCommerce.orderModule.knownOperations', function ($scope, $location, bladeNavigationService, knownOperations) {
var orderId = $location.search().orderId;

if (orderId) {
var foundTemplate = knownOperations.getOperation('CustomerOrder');
if (foundTemplate) {
var newBlade = angular.copy(foundTemplate.detailBlade);
newBlade.id = 'orders';
newBlade.customerOrder = { id: orderId, customerName: 'Customer' };
newBlade.isClosingDisabled = true;
bladeNavigationService.showBlade(newBlade);
}
}
else {
var blade = {
id: 'orders',
title: 'orders.blades.customerOrder-list.title',
//subtitle: 'Manage Orders',
controller: 'virtoCommerce.orderModule.customerOrderListController',
isExpandable: true,
template: 'Modules/$(VirtoCommerce.Orders)/Scripts/blades/customerOrder-list.tpl.html',
isClosingDisabled: true
};
bladeNavigationService.showBlade(blade);
}
//Need for isolate and prevent conflict module css to another modules
//it value included in bladeContainer as ng-class='moduleName'
$scope.moduleName = "vc-order";
Expand All @@ -38,7 +51,7 @@ angular.module(moduleName, [
}]
)
// define known Operations to be accessible platform-wide
.factory('virtoCommerce.orderModule.knownOperations', [bladeNavigationServiceName, function (bladeNavigationService) {
.factory('virtoCommerce.orderModule.knownOperations', ['platformWebApp.bladeNavigationService', function (bladeNavigationService) {
var map = {};

function registerOperation(op) {
Expand Down Expand Up @@ -79,7 +92,7 @@ angular.module(moduleName, [
'$compile',
'platformWebApp.mainMenuService',
'platformWebApp.widgetService',
bladeNavigationServiceName,
'platformWebApp.bladeNavigationService',
'$state',
'$localStorage',
'virtoCommerce.orderModule.order_res_customerOrders',
Expand Down Expand Up @@ -109,7 +122,7 @@ angular.module(moduleName, [
icon: 'fa fa-file-text',
title: 'orders.main-menu-title',
priority: 90,
action: function () { $state.go('workspace.orderModule'); },
action: function () { $state.go('workspace.orderModule', {}, { reload: true }); },
permission: 'order:access'
};
mainMenuService.addMenuItem(menuItem);
Expand Down

0 comments on commit 271d3ae

Please sign in to comment.