NewSectionProjectController.$inject = [ 'TbUtils', 'projects', 'sectionProjects',
                                         'sectionId', 'projectIds', '$mdDialog', 'filterFilter' ];

function NewSectionProjectController (TbUtils, projects, sectionProjects, sectionId, 
	                                   projectIds, mdDialog, filterFilter) {
	const vm = this;

	vm.project = {
		SectiontId: sectionId,
		ProjectIds: projectIds,
		Description: '',
		Cost: 0
	};

	vm.selectedProject = null;

	vm.search = search;
	vm.submit = submit;

	vm.cancel = () => { mdDialog.cancel(); };
	
	vm.projectsLoading = false;
	vm.submitting = false;

	init();

	function init () {
		if (!projects.cached || projects.cached.length === 0) {		
			vm.projectsLoading = true;
			projects.cached = [];
			TbUtils.getAndLoad(projects.getProjects, projects.cached, () => { vm.projectsLoading = false; });
		}
	}

	function submit () {
		if (!vm.selectedProject) return;

		vm.submitting = true;

		vm.project.ProjectIds.push(vm.selectedProject.Id);

		sectionProjects.post(vm.project, assignProjects, close, 
			() => { vm.submitting = false; });
	}

	function close (resp) {
		TbUtils.showErrorMessage(resp.data); 
		mdDialog.cancel();
	}

	function assignProjects (response) {
		projects.assignProjectstoSection(vm.project.ProjectIds, sectionId, 
			resp => { mdDialog.hide(response.data.map(obj => obj.Project)); },
			close, () => { vm.submitting = false; });
	}

	function search (term) {
		return filterFilter(projects.cached, { Name: term });
	}

}

module.exports = { name: 'NewSectionProjectController', ctrl: NewSectionProjectController };
@@ -1023,54 +1023,93 @@
 %0A%0A%09%09
-sectionProjects.post(vm.project, assig
+projects.assignProjectstoSection(vm.project.ProjectIds, sectionId, postSectio
 nProject
 s, c
@@ -1108,22 +1108,20 @@
 ject
-s, 
+,%0A%09%09%09
 close, 
-%0A%09%09%09
 () =
@@ -1255,29 +1255,34 @@
 unction 
-assig
+postSectio
 nProject
 s (respo
@@ -1277,90 +1277,47 @@
 ject
-s
  (
-response) %7B%0A%09%09projects.assignProjectstoSection(vm.project.ProjectIds, sectionId
+) %7B%0A%09%09sectionProjects.post(vm.project
 , %0A%09
@@ -1350,12 +1350,8 @@
 resp
-onse
 .dat
@@ -1380,16 +1380,17 @@
 ct)); %7D,
+ 
 %0A%09%09%09clos

Fix form