{"size": 1927, "ext": "js", "max_stars_repo_path": "PLATFORM/Modules/Order/VirtoCommerce.OrderModule.Web/Scripts/blades/shipment-items.js", "max_stars_repo_name": "VirtoCommerce-archieve/vc-integrations", "max_stars_repo_stars_event_min_datetime": "2021-03-24T23:06:46.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-24T06:11:00.000Z", "max_issues_repo_path": "PLATFORM/Modules/Order/VirtoCommerce.OrderModule.Web/Scripts/blades/shipment-items.js", "max_issues_repo_name": "VirtoCommerce-archieve/vc-integrations", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "PLATFORM/Modules/Order/VirtoCommerce.OrderModule.Web/Scripts/blades/shipment-items.js", "max_forks_repo_name": "VirtoCommerce-archieve/vc-integrations", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.109375, "max_line_length": 207, "alphanum_fraction": 0.6424494032}
﻿angular.module('virtoCommerce.orderModule')
.controller('virtoCommerce.orderModule.shipmentItemsController', ['$scope', 'platformWebApp.bladeNavigationService', 'platformWebApp.dialogService', function ($scope, bladeNavigationService, dialogService) {
    var blade = $scope.blade;
    blade.updatePermission = 'order:update';

	//pagination settings
	$scope.pageSettings = {};
	$scope.totals = {};
	$scope.pageSettings.totalItems = blade.currentEntity.items.length;
	$scope.pageSettings.currentPage = 1;
	$scope.pageSettings.numPages = 5;
	$scope.pageSettings.itemsPerPageCount = 4;

	var selectedNode = null;
	var selectedProducts = [];

	
	blade.refresh = function () {
		blade.isLoading = false;
		blade.selectedAll = false;
	};
        
	blade.toolbarCommands = [
        {
            name: "orders.commands.add-item", icon: 'fa fa-plus',
        	executeMethod: function () {
        		openAddEntityWizard();
        	},
        	canExecuteMethod: function () {
        		return false;
        	},
        	permission: blade.updatePermission
        },
        {
            name: "platform.commands.remove", icon: 'fa fa-trash-o',
        	executeMethod: function () {
        		var items = blade.currentEntity.items;
        		blade.currentEntity.items = _.difference(items, _.filter(items, function (x) { return x.selected }));

        	},
        	canExecuteMethod: function () {
        		return _.any(blade.currentEntity.items, function (x) { return x.selected; });;
        	},
        	permission: blade.updatePermission
        }
	];

	//$scope.$watch('pageSettings.currentPage', function (newPage) {
	//    blade.refresh();
	//});

	$scope.selectItem = function (node) {
		selectedNode = node;
		$scope.selectedNodeId = selectedNode.id;
	};

	$scope.checkAll = function (selected) {
		angular.forEach(blade.currentEntity.items, function (item) {
			item.selected = selected;
		});
	};

	blade.refresh();
}]);