<commit_before>app.controller('itemCtrl',function($scope, $http) {  
    $.ajaxPrefilter(function( options, originalOptions, jqXHR ) {
    options.async = true;
});

	$scope.master = {}; 
	$scope.editItem = {};
	$scope.showMe = {};
       $scope.new_item = { 
                name : "",
                category : "",
                subCategory : "",
                description : "",
                price :"",
                location : "",
                quantities: []
            }
console.log("new_item",$scope.new_item);
	$scope.showAllItems=function(){
		 console.log("request all items");
		$http.get('/admin/showAllItems')
						.success(function(data){
							$scope.items = data;
							console.log("Succeed loading");
							console.log("data"+data);
							for (var i = 0, length = $scope.items.length; i < length; i++) {
								$scope.showMe[$scope.items[i]._id] = true;
							}
						})
						.error(function(data){
							console.log("Error: "+data);
			 });
	}


        $scope.add = function () {
          $scope.new_item.quantities.push({
          name:"",
          quantity:"",
          minQuantity:"",
          image:"" 
          });
          console.log($scope.new_item);
        };
$scope.addItem=function(item){
// use $.param jQuery function to serialize data from JSON 
            var data = $.param({
                name : item.name,
                category : item.category,
                subCategory : item.subCategory,
                description : item.description,
				price : item.price,
                location : item.location,
				quantities: item.quantities
            });
        
            var config = {
                headers : {
                    'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
                }
            }

            $http.post('/admin/addItem', data, config)<commit_msg>send quantity as an object<commit_after>app.controller('itemCtrl',function($scope, $http) {  
    $.ajaxPrefilter(function( options, originalOptions, jqXHR ) {
    options.async = true;
});

	$scope.master = {}; 
	$scope.editItem = {};
	$scope.showMe = {};
       $scope.new_item = { 
                name : "",
                category : "",
                subCategory : "",
                description : "",
                price :"",
                location : "",
                quantities: []
            }
console.log("new_item",$scope.new_item);
	$scope.showAllItems=function(){
		 console.log("request all items");
		$http.get('/admin/showAllItems')
						.success(function(data){
							$scope.items = data;
							console.log("Succeed loading");
							console.log("data"+data);
							for (var i = 0, length = $scope.items.length; i < length; i++) {
								$scope.showMe[$scope.items[i]._id] = true;
							}
						})
						.error(function(data){
							console.log("Error: "+data);
			 });
	}


        $scope.add = function () {
          $scope.new_item.quantities.push({
          name:"",
          quantity:"",
          minQuantity:"",
          image:"" 
          });
          console.log($scope.new_item);
        };
$scope.addItem=function(item){
// use $.param jQuery function to serialize data from JSON 
            var data = $.param({
                name : item.name,
                category : item.category,
                subCategory : item.subCategory,
                description : item.description,
				price : item.price,
                location : item.location,
				quantitiesName: item.quantities.name,
                quantitiesQuantity:item.quantities.quantity,
                quantitiesMinQuantity:item.quantities.minQuantity,
                quantitiesImage:item.quantities.image
            });
        
            var config = {
                headers : {
                    'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
                }
            }

            $http.post('/admin/addItem', data, config)
{'fraction_non_alphanumeric': 0.14473351856529426, 'fraction_numerical': 0.0010103561505430665, 'mean_word_length': 1.6312292358803986, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '666783', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1075, 'n_words': 182}