Skip to content

Instantly share code, notes, and snippets.

@ayushghosh
Created September 27, 2014 16:11
Show Gist options
  • Save ayushghosh/32123972d240b13d1822 to your computer and use it in GitHub Desktop.
Save ayushghosh/32123972d240b13d1822 to your computer and use it in GitHub Desktop.
$scope.addFieldset = function(fieldset){
// alert('afs');
// console.log($scope.schema.sections[0].fieldset);
var count=0;
var sco_sch= {};
angular.forEach($scope.schema.fields, function(value, key) {
if(value.fieldIsUserInput){
sco_sch[value.fieldId]=value.fieldDefault;
}
});
angular.forEach($scope.schema.sections, function(value, key) {
sco_sch[value.label]=[];
$scope.section = value.label;
sco_sch[$scope.section]= new Array();
angular.forEach(value.fieldset, function(value1, key1) {
$scope.key1 = key1;
sco_sch[$scope.section][key1]={};
sco_sch[$scope.section][key1]['label']= value1.legend;
sco_sch[$scope.section][key1]['data'] = new Array();
angular.forEach(value1.fields, function(value2, key2) {
$scope.value2 = value2;
$scope.key2 = key2;
sco_sch[$scope.section][key1]['data'][key2] = new Array();
angular.forEach(value2, function(value3, key3) {
sco_sch[$scope.section][$scope.key1]['data'][key2][value3.fieldLabel]=value3.fieldDefault;
});
});
},value);
});
console.log(sco_sch);
// console.log($scope.schema);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment