'use strict'; angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope', '$http', function ($rootScope, $http) { return { templateUrl: 'modules/forms/views/directiveViews/form/edit-submissions-form.client.view.html', restrict: 'E', scope: { myform:'=', user:'=' }, controller: function($scope){ $scope.table = { masterChecker: false, rows: [] }; /* ** Table Functions */ $scope.isAtLeastOneChecked = function(){ for(var i=0; i<$scope.table.rows.length; i++){ if($scope.table.rows[i].selected) return true; } return false; }; $scope.toggleAllCheckers = function(){ for(var i=0; i<$scope.table.rows.length; i++){ $scope.table.rows[i].selected = $scope.table.masterChecker; } }; $scope.toggleObjSelection = function($event, description) { $event.stopPropagation(); }; $scope.rowClicked = function(row_index) { $scope.table.rows[row_index].selected = !$scope.table.rows[row_index].selected; }; /* * Form Submission Methods */ //Fetch and display submissions of Form $scope.initFormSubmissions = function(){ $http.get('/forms/'+$scope.myform._id+'/submissions') .success(function(data, status, headers){ var _tmpSubFormFields, defaultFormFields = _.cloneDeep($scope.myform.form_fields); // console.log('before textField2: '+data[0].form_fields[1].fieldValue); //Iterate through form's submissions for(var i=0; i