(function() {
	'use strict';

	window.app.directive('inventoryList', inventoryList);
	function inventoryList() {
		return {
			scope: {"inventories" : "="},
			templateUrl: '/inventory/template/inventoryList.tmpl.cshtml',
			controller: controller,
			controllerAs: 'vm'
		}
	}

	controller.$inject = ['$scope', '$uibModal'];
	function controller($scope, $uibModal) {
		var vm = this;

		vm.inventories = $scope.inventories;
		vm.edit = edit;
		vm.remove = remove;

		function edit(inventory) {
			$uibModal.open({
				template: '<edit-inventory inventory="inventory" />',
				scope: angular.extend($scope.$new(true), { inventory: inventory })
			});
		}

		function remove(inventory) {
			$uibModal.open({
				template: '<inventory-remove inventory="inventory" />',
				scope: angular.extend($scope.$new(true), { inventory: inventory })
			});
		}
	}
})();