<commit_before>'use strict';

angular
.module('app.controllers')
.controller('VenueAddCtrl', function($scope, $modalInstance, $http, Restangular) {
	// Get the list of all organizations, and unwrap the resulting promise
	// into a plain object that our view can use
	$scope.companies = Restangular.all('organizations').getList().$object;
	$scope.showAddCompanyForm = false;

	$scope.addCompany = function() {
		$scope.showAddCompanyForm = true;
	};

	function serializeData(data) {
		var result = {};
		result.links = {};
		result.links['venues.organization'] = {};
		result.links['venues.organization'].type = 'organizations';

		result.venues = {};

		for(var key in data) {
			result.venues[key] = data[key];
		}

		delete result.venues.organization;

		result.venues.links = {};
		result.venues.links.organization = data.organization;

		console.log('JSON Venue', result);
		return result;
	}

	$scope.formData = {};

	$scope.submitVenue = function() {
		var data = serializeData($scope.formData);
		Restangular.all('venues').post(data);
	};

	$scope.cancel = function() {
		$modalInstance.dismiss('cancel');
	};
});<commit_msg>Fixed issue with modal not closing and selection not updating when new venue is successfully created.<commit_after>'use strict';

angular
.module('app.controllers')
.controller('VenueAddCtrl', function($scope, $modalInstance, $http, Restangular) {
	// Get the list of all organizations, and unwrap the resulting promise
	// into a plain object that our view can use
	$scope.companies = Restangular.all('organizations').getList().$object;
	$scope.showAddCompanyForm = false;

	$scope.addCompany = function() {
		$scope.showAddCompanyForm = true;
	};

	function serializeData(data) {
		var result = {};
		result.links = {};
		result.links['venues.organization'] = {};
		result.links['venues.organization'].type = 'organizations';

		result.venues = {};

		for(var key in data) {
			result.venues[key] = data[key];
		}

		delete result.venues.organization;

		result.venues.links = {};
		result.venues.links.organization = data.organization;

		console.log('JSON Venue', result);
		return result;
	}

	$scope.formData = {};

	$scope.submitVenue = function() {
		var formData = serializeData($scope.formData);
		Restangular.all('venues').post(formData).then(function(createdObject) {
			$modalInstance.close(createdObject);
		});
	};

	$scope.cancel = function() {
		$modalInstance.dismiss('cancel');
	};
});
{'fraction_non_alphanumeric': 0.1539408866995074, 'fraction_numerical': 0.0, 'mean_word_length': 4.602298850574712, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7645720', 'n_tokens_mistral': 823, 'n_tokens_neox': 749, 'n_words': 160}