<commit_before>app.controller('FunctionalSpendController', ['BudgetFactory', function (BudgetFactory) {
	console.log('Functional Spend controller started');

	var self = this;

	var budgetFactory = BudgetFactory;

	self.newCategory = {};

	budgetFactory.getFunctionalItems().then(function(result) {
		self.itemArray = result;
		setToggles();
		resetZeroValues();
		console.log("functional self.itemArray ", self.itemArray);
	});

	// toggles activeItem value for each item
	self.toggleActive = function(item) {
		if (item.activeItem === false) {
			item.activeItem = true;
		} else {
			item.activeItem = false;
		}
	};

	// removes all active values in individual flow categories
  function setToggles() {
    for (var i = 0; i < self.itemArray.length; i++) {
      var category = self.itemArray[i];
      if(category.item_amount === undefined || category.item_amount === 0 || category.item_amount === null) {
        category.activeItem  = false;
      } else {
        category.activeItem = true;
      }
    }
  }; // end setToggles

	// function to ensure zero values show up as placeholder in inputs
	function resetZeroValues() {
		for (var i = 0; i < self.itemArray.length; i++) {
			if(self.itemArray[i].item_amount == 0) {
				self.itemArray[i].item_amount = null;
			}
		}
	}; // end resetZeroValues

	self.getFunctionalItems = function() {
		console.log("getFunctionalItems is clicked");
		budgetFactory.getFunctionalItems(self.itemArray);
	};

	self.updateFunctionalItems = function() {
		console.log("update functional clicked");
		budgetFactory.updateFunctionalItems(self.itemArray);
	};

	self.addFunctionalItem = function() {
		if(self.newCategory.item_name === null || self.newCategory.item_amount === null) {
			alert('Please enter an additional category before submitting.');
		} else {
			console.log(self.newCategory);
			self.newCategory.activeItem = true;
			self.newCategory.item_img_src = 'additional.svg';
			self.newCategory.item_sort_sequence = self.itemArray.length + 2;
			self.newCategory.budget_template_category_id = 4;
			self.itemArray.push(self.newCategory);
		}
	};


}]);
<commit_msg>added clear at the end of add category function<commit_after>app.controller('FunctionalSpendController', ['BudgetFactory', function (BudgetFactory) {
	console.log('Functional Spend controller started');

	var self = this;

	var budgetFactory = BudgetFactory;

	self.newCategory = {};

	budgetFactory.getFunctionalItems().then(function(result) {
		self.itemArray = result;
		setToggles();
		resetZeroValues();
		console.log("functional self.itemArray ", self.itemArray);
	});

	// toggles activeItem value for each item
	self.toggleActive = function(item) {
		if (item.activeItem === false) {
			item.activeItem = true;
		} else {
			item.activeItem = false;
		}
	};

	// removes all active values in individual flow categories
  function setToggles() {
    for (var i = 0; i < self.itemArray.length; i++) {
      var category = self.itemArray[i];
      if(category.item_amount === undefined || category.item_amount === 0 || category.item_amount === null) {
        category.activeItem  = false;
      } else {
        category.activeItem = true;
      }
    }
  }; // end setToggles

	// function to ensure zero values show up as placeholder in inputs
	function resetZeroValues() {
		for (var i = 0; i < self.itemArray.length; i++) {
			if(self.itemArray[i].item_amount == 0) {
				self.itemArray[i].item_amount = null;
			}
		}
	}; // end resetZeroValues

	self.getFunctionalItems = function() {
		console.log("getFunctionalItems is clicked");
		budgetFactory.getFunctionalItems(self.itemArray);
	};

	self.updateFunctionalItems = function() {
		console.log("update functional clicked");
		budgetFactory.updateFunctionalItems(self.itemArray);
	};

	self.addFunctionalItem = function() {
		if(self.newCategory.item_name === null || self.newCategory.item_amount === null) {
			alert('Please enter an additional category before submitting.');
		} else {
			console.log(self.newCategory);
			self.newCategory.activeItem = true;
			self.newCategory.item_img_src = 'additional.svg';
			self.newCategory.item_sort_sequence = self.itemArray.length + 2;
			self.newCategory.budget_template_category_id = 4;
			self.itemArray.push(self.newCategory);
			self.newCategory = {};
		}
	};


}]);

{'fraction_non_alphanumeric': 0.13080855018587362, 'fraction_numerical': 0.0027881040892193307, 'mean_word_length': 3.925629290617849, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '413387', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1318, 'n_words': 279}