From b22c4cb56a7093372bfe7da41c2807830afdcaf5 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Wed, 8 Oct 2014 10:00:44 -0400 Subject: [PATCH] removed routes for old unused survey controllers for survemakeradd and surverymakeredit, these controllers are not being used anymore and have been replaced by the surver helper class. i'm taking out the routes for these html pages/controllers as they are no longer relavant --- awx/ui/static/js/app.js | 16 +- awx/ui/static/js/controllers/Survey.js.old.js | 1253 +++++++++++++++++ 2 files changed, 1261 insertions(+), 8 deletions(-) create mode 100644 awx/ui/static/js/controllers/Survey.js.old.js diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index 1e8f49cebe..204df59d6d 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -166,15 +166,15 @@ angular.module('Tower', [ controller: 'JobTemplatesEdit' }). - when('/job_templates/:template_id/survey/add', { - templateUrl: urlPrefix + 'partials/survey_maker.html', - controller: 'SurveyMakerAdd' - }). + // when('/job_templates/:template_id/survey/add', { + // templateUrl: urlPrefix + 'partials/survey_maker.html', + // controller: 'SurveyMakerAdd' + // }). - when('/job_templates/:template_id/survey/edit', { - templateUrl: urlPrefix + 'partials/survey_maker.html', - controller: 'SurveyMakerEdit' - }). + // when('/job_templates/:template_id/survey/edit', { + // templateUrl: urlPrefix + 'partials/survey_maker.html', + // controller: 'SurveyMakerEdit' + // }). when('/job_templates/:id/schedules', { templateUrl: urlPrefix + 'partials/schedule_detail.html', diff --git a/awx/ui/static/js/controllers/Survey.js.old.js b/awx/ui/static/js/controllers/Survey.js.old.js new file mode 100644 index 0000000000..33ba72833a --- /dev/null +++ b/awx/ui/static/js/controllers/Survey.js.old.js @@ -0,0 +1,1253 @@ +// /************************************ +// * Copyright (c) 2014 AnsibleWorks, Inc. +// * +// * +// * SurveyMaker.js +// * +// * Controller functions for the survey maker +// * +// */ +// /** +// * @ngdoc function +// * @name controllers.function:SurveyMaker +// * @description This controller's for the survey maker page. +// * The survey maker interacts with the job template page, and the two go hand in hand. The scenarios are: +// * New job template - add new survey +// * New job template - edit new survey +// * Edit existing job template - add new survey +// * Edit Existing job template - edit existing survey +// * +// * Adding a new survey to any page takes the user to the Add New Survey page +// * Adding a new survey to a new job template saves the survey to session memory (navigating to survey maker forces us to save JT in memory temporarily) +// * Adding a new survey to an existing job template send the survey to the API +// * Editing an existing survey takes the user to the Edit Survey page +// * Editing a survey attached to a new job template saves the survey to session memory (saves the job template in session memory) +// * Editing a survey attached to an existing job template saves the survey to the API +// * +// * The variables in local memory are cleaned out whenever the user navigates to a page (other than the Survey Maker page) +// */ +// 'use strict'; + +// function SurveyController($scope, $rootScope, $compile, $location, $log, $routeParams, SurveyMakerForm, +// GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath, +// ReturnToCaller, Wait, SurveyQuestionForm, Store) { + + +// angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', 'SearchHelper', 'PaginationHelpers', 'ListGenerator', 'ModalDialog', +// 'GeneratorHelpers']) + +// .factory('ShowSurveyModal', ['Wait', 'CreateDialog', 'Empty', '$compile' , +// function(Wait, CreateDialog, Empty, $compile) { +// return function(params) { +// // Set modal dimensions based on viewport width + +// var scope = params.scope, +// callback = params.callback, +// mode = (params.mode) ? params.mode : "survey-maker", +// title = params.title, +// element, +// target = (mode==='survey-taker') ? 'password-modal' : "survey-modal-dialog", +// buttons = [{ +// "label": "Cancel", +// "onClick": function() { +// $(this).dialog('close'); +// }, +// "icon": "fa-times", +// "class": "btn btn-default", +// "id": "survey-close-button" +// },{ +// "label": (mode==='survey-taker') ? "Launch" : "Save" , +// "onClick": function() { +// setTimeout(function(){ +// scope.$apply(function(){ +// if(mode==='survey-taker'){ +// scope.$emit('SurveyTakerCompleted'); +// } else{ +// scope.saveSurvey(); +// } +// }); +// }); +// }, +// "icon": (mode==='survey-taker') ? "fa-rocket" : "fa-check", +// "class": "btn btn-primary", +// "id": "survey-save-button" +// }]; + +// CreateDialog({ +// id: target, +// title: title, +// scope: scope, +// buttons: buttons, +// width: 700, +// height: 725, +// minWidth: 400, +// onClose: function() { +// $('#'+target).empty(); +// }, +// onOpen: function() { +// Wait('stop'); +// if(mode!=="survey-taker"){ +// $('#survey-save-button').attr('ng-disabled', "survey_questions.length<1 "); +// element = angular.element(document.getElementById('survey-save-button')); +// $compile(element)(scope); + +// } +// if(mode==="survey-taker"){ +// $('#survey-save-button').attr('ng-disabled', "survey_taker_form.$invalid"); +// element = angular.element(document.getElementById('survey-save-button')); +// $compile(element)(scope); + +// } + +// }, +// callback: callback +// }); +// }; +// }]) + +// .factory('EditSurvey', ['$routeParams','SchedulerInit', 'ShowSurveyModal', 'Wait', 'Rest', 'ProcessErrors', 'GetBasePath', 'GenerateForm', 'SurveyMakerForm', +// 'Empty', 'AddSurvey', +// function($routeParams, SchedulerInit, ShowSurveyModal, Wait, Rest, ProcessErrors, GetBasePath, GenerateForm,SurveyMakerForm, +// Empty, AddSurvey) { +// return function(params) { +// var scope = params.scope, +// id = params.id, +// // callback = params.callback, +// tempSurv = {}, +// generator = GenerateForm, +// form = SurveyMakerForm, +// // labels={ +// // "type": "Type", +// // "question_name": "Question Text", +// // "question_description": "Question Description", +// // "variable": "Answer Varaible Name", +// // "choices": "Choices", +// // "min": "Min", +// // "max": "Max", +// // "required": "Required", +// // "default": "Default Answer" +// // }, +// url = GetBasePath('job_templates') + id + '/survey_spec/', i; + +// if (scope.removeDialogReady) { +// scope.removeDialogReady(); +// } +// scope.removeDialogReady = scope.$on('DialogReady', function() { +// $('#survey-modal-dialog').dialog('open'); +// }); + + +// Wait('start'); +// if(scope.mode === 'add'){ +// tempSurv.survey_name = scope.survey_name; +// tempSurv.survey_description = scope.survey_description; +// generator.inject(form, { id: 'survey-modal-dialog' , mode: 'edit', related: false, scope: scope, breadCrumbs: false }); + +// ShowSurveyModal({ title: "Edit Survey", scope: scope, callback: 'DialogReady' }); + +// scope.survey_name = tempSurv.survey_name; +// scope.survey_description = tempSurv.survey_description; +// // scope.survey_questions = data.spec; +// for(i=0; i0){ +// // $('#survey-save-button').removeAttr('disabled') +// // } + +// question.index = index; + +// if(!$('#question_'+question.index+':eq(0)').is('div')){ +// html+='
'; +// $('#finalized_questions').append(html); +// } + +// required = (question.required===true) ? "prepend-asterisk" : ""; +// html = '
'+question.question_name+'
\n'; +// if(!Empty(question.question_description)){ +// html += '
'+question.question_description+'
\n'; +// } +// defaultValue = (question.default) ? question.default : ""; + +// if(question.type === 'text' ){ +// html+='
'+ +// '
'+ +// ''+ +// '
'; +// } +// if(question.type === "textarea"){ +// html+='
'+ +// '
'+ +// ''+ +// '
'; +// } +// if(question.type === 'multiplechoice' || question.type === "multiselect"){ +// choices = question.choices.split(/\n/); +// element = (question.type==="multiselect") ? "checkbox" : 'radio'; + +// for( i = 0; i'+ +// '' +choices[i]+ +// ''; +// } + +// } +// if(question.type === 'integer' || question.type === "float"){ +// min = (question.min) ? question.min : ""; +// max = (question.max) ? question.max : "" ; +// numberValidation = (question.type==="integer") ? "integer" : 'float'; +// html+='
'+ +// '
'+ +// ''+ +// '
'; + +// } +// html += '
'; +// html += ' '; +// html += ' '; +// html += ' '; +// html += ' '; +// html+='
'; + +// $('#question_'+question.index).append(html); + +// element = angular.element(document.getElementById('question_'+question.index)); +// // element.html(html); +// element.css('opacity', 0.7); +// $compile(element)(scope); +// // var questionScope = scope.$new; + +// $('#add_question_btn').show(); +// $('#add_question_btn').removeAttr('disabled'); +// $('#add_question_btn').focus(); +// $('#survey_maker_save_btn').removeAttr('disabled'); + +// $('#delete-question_'+question.index+'').on('click', function($event){ +// scope.deleteQuestion($event.target.parentElement.parentElement.parentElement.id.split('_')[1]); +// }); +// $('#edit-question_'+question.index+'').on('click', function($event){ +// scope.editQuestion($event.target.parentElement.parentElement.parentElement.id.split('_')[1]); +// }); +// $('#question-up_'+question.index+'').on('click', function($event){ +// scope.questionUp($event.target.parentElement.parentElement.parentElement.id.split('_')[1]); +// }); +// $('#question-down_'+question.index+'').on('click', function($event){ +// scope.questionDown($event.target.parentElement.parentElement.parentElement.id.split('_')[1]); +// }); +// }; +// }]) + +// .factory('SurveyTakerQuestion', ['GetBasePath','Rest', 'Wait', 'ProcessErrors', '$compile', 'Empty', +// function(GetBasePath, Rest, Wait, ProcessErrors, $compile, Empty) { +// return function(params) { + +// var scope = params.scope, +// // id = params.id, +// question = params.question, +// index = params.index, +// requiredAsterisk, +// requiredClasses, +// element, choices, i, checked, +// max, min, defaultValue, numberValidation + +// html = ""; + +// // if(scope.survey_questions.length>0){ +// // $('#survey-save-button').removeAttr('disabled') +// // } + +// question.index = index; +// question[question.variable] = question.default; +// scope[question.variable] = question.default; + + +// if(!$('#question_'+question.index+':eq(0)').is('div')){ +// html+='
'; +// $('#survey_taker_finalized_questions').append(html); +// } + +// requiredAsterisk = (question.required===true) ? "prepend-asterisk" : ""; +// requiredClasses = (question.required===true) ? "ng-pristine ng-invalid-required ng-invalid" : ""; + +// html = '
'+question.question_name+'
\n'; +// if(!Empty(question.question_description)){ +// html += '
'+question.question_description+'
\n'; +// } +// defaultValue = (question.default) ? question.default : ""; + +// if(question.type === 'text' ){ +// html+='
'+ +// '
'+ +// ''+ +// '
'; +// } +// if(question.type === "textarea"){ +// html+='
'+ +// '
'+ +// ''+ +// '
'; +// } +// if(question.type === 'multiplechoice' || question.type === "multiselect"){ +// choices = question.choices.split(/\n/); +// element = (question.type==="multiselect") ? "checkbox" : 'radio'; + +// for( i = 0; i'+ +// '' +choices[i]+ +// ''; +// } + +// } +// if(question.type === 'integer' || question.type === "float"){ +// min = (question.min) ? question.min : ""; +// max = (question.max) ? question.max : "" ; +// numberValidation = (question.type==="integer") ? "integer" : 'float'; +// html+='
'+ +// '
'+ +// ''+ +// '
'; + +// } +// $('#question_'+question.index).append(html); + +// element = angular.element(document.getElementById('question_'+question.index)); +// $compile(element)(scope); + +// }; +// }]) + +// .factory('EditQuestion', ['GetBasePath','Rest', 'Wait', 'ProcessErrors', '$compile', 'GenerateForm', 'SurveyQuestionForm', +// function(GetBasePath, Rest, Wait, ProcessErrors, $compile, GenerateForm, SurveyQuestionForm) { +// return function(params) { + +// var scope = params.scope, +// index = params.index, +// element, fld, i, +// form = SurveyQuestionForm; + +// $('#add_question_btn').hide(); +// $('#new_question .aw-form-well').remove(); +// element = $('.question_final:eq('+index+')'); +// element.css('opacity', 1.0); +// element.empty(); +// // $('#new_question .aw-form-well').remove(); +// GenerateForm.inject(form, { id: 'question_'+index, mode: 'edit' , scope:scope, breadCrumbs: false}); +// for(fld in form.fields){ +// if( fld === 'answer_options_number'){ +// $('#answer_min').val(scope.survey_questions[index].min); +// $('#answer_max').val(scope.survey_questions[index].max); +// } +// if( fld === 'default_int' || fld === 'default_float'){ +// $("#"+fld ).val(scope.survey_questions[index].default); +// } +// if(form.fields[fld].type === 'select'){ +// for (i = 0; i < scope.answer_types.length; i++) { +// if (scope.survey_questions[index][fld] === scope.answer_types[i].type) { +// scope[fld] = scope.answer_types[i]; +// } +// } +// } else { +// scope[fld] = scope.survey_questions[index][fld]; +// } +// } +// }; +// }]) + +// .factory('DeleteQuestion' , +// function() { +// return function(params) { + +// var scope = params.scope, +// index = params.index, +// element; + +// element = $('.question_final:eq('+index+')'); +// element.remove(); +// scope.survey_questions.splice(index, 1); +// scope.reorder(); +// if(scope.survey_questions.length<1){ +// $('#survey-save-button').attr('disabled', 'disabled'); +// } +// }; +// }) + +// .factory('SurveyControllerInit', ['$location', 'DeleteSurvey', 'EditSurvey', 'AddSurvey', 'GenerateForm', 'SurveyQuestionForm', 'Wait', 'Alert', +// 'GetBasePath', 'Rest', 'ProcessErrors' , '$compile', 'FinalizeQuestion', 'EditQuestion', 'DeleteQuestion', 'SurveyTakerQuestion', +// function($location, DeleteSurvey, EditSurvey, AddSurvey, GenerateForm, SurveyQuestionForm, Wait, Alert, +// GetBasePath, Rest, ProcessErrors, $compile, FinalizeQuestion, EditQuestion, DeleteQuestion, SurveyTakerQuestion) { +// return function(params) { +// var scope = params.scope, +// id = params.id, +// i, url; + +// scope.survey_questions = []; +// scope.answer_types=[ +// {name: 'Text' , type: 'text'}, +// {name: 'Textarea', type: 'textarea'}, +// {name: 'Multiple Choice (single select)', type: 'multiplechoice'}, +// {name: 'Multiple Choice (multiple select)', type: 'multiselect'}, +// {name: 'Integer', type: 'integer'}, +// {name: 'Float', type: 'float'} +// ]; + +// scope.deleteSurvey = function() { +// DeleteSurvey({ +// scope: scope, +// id: id, +// // callback: 'SchedulesRefresh' +// }); +// }; + +// scope.editSurvey = function() { +// EditSurvey({ +// scope: scope, +// id: id, +// // callback: 'SchedulesRefresh' +// }); +// }; + +// scope.addSurvey = function() { +// AddSurvey({ +// scope: scope, +// // callback: 'SchedulesRefresh' +// }); +// }; +// scope.addQuestion = function(){ +// GenerateForm.inject(SurveyQuestionForm, { id:'new_question', mode: 'add' , scope:scope, breadCrumbs: false}); +// scope.required = true; //set the required checkbox to true via the ngmodel attached to scope.required. + +// }; + +// scope.addNewQuestion = function(){ +// // $('#add_question_btn').on("click" , function(){ +// scope.addQuestion(); +// $('#survey_question_question_name').focus(); +// $('#add_question_btn').attr('disabled', 'disabled'); +// $('#add_question_btn').hide(); +// // }); +// }; +// scope.editQuestion = function(index){ +// EditQuestion({ +// index: index, +// scope: scope +// }); +// }; + +// scope.deleteQuestion = function(index){ +// DeleteQuestion({ +// index:index, +// scope: scope +// }); +// }; + +// scope.questionUp = function(index){ +// var animating = false, +// clickedDiv = $('#question_'+index), +// prevDiv = clickedDiv.prev(), +// distance = clickedDiv.outerHeight(); + +// if (animating) { +// return; +// } + +// if (prevDiv.length) { +// animating = true; +// $.when(clickedDiv.animate({ +// top: -distance +// }, 600), +// prevDiv.animate({ +// top: distance +// }, 600)).done(function () { +// prevDiv.css('top', '0px'); +// clickedDiv.css('top', '0px'); +// clickedDiv.insertBefore(prevDiv); +// animating = false; +// i = scope.survey_questions[index]; +// scope.survey_questions[index] = scope.survey_questions[index-1]; +// scope.survey_questions[index-1] = i; +// scope.reorder(); +// }); +// } +// }; + +// scope.questionDown = function(index){ +// var clickedDiv = $('#question_'+index), +// nextDiv = clickedDiv.next(), +// distance = clickedDiv.outerHeight(), +// animating = false; + +// if (animating) { +// return; +// } + +// if (nextDiv.length) { +// animating = true; +// $.when(clickedDiv.animate({ +// top: distance +// }, 600), +// nextDiv.animate({ +// top: -distance +// }, 600)).done(function () { +// nextDiv.css('top', '0px'); +// clickedDiv.css('top', '0px'); +// nextDiv.insertBefore(clickedDiv); +// animating = false; +// i = scope.survey_questions[index]; +// scope.survey_questions[index] = scope.survey_questions[Number(index)+1]; +// scope.survey_questions[Number(index)+1] = i; +// scope.reorder(); +// }); +// } +// }; + +// scope.reorder = function(){ +// for(i=0; i'+data[key]+'\n'; +// // } + +// // html+=''; + +// // $('#finalized_questions').before(html); +// // $('#add_question_btn').show(); +// // $('#add_question_btn').removeAttr('disabled'); +// // $('#survey_maker_save_btn').removeAttr('disabled'); +// // }; + +// // $('#add_question_btn').on("click" , function(){ +// // $scope.addQuestion(); +// // $('#add_question_btn').attr('disabled', 'disabled'); +// // }); + +// // $scope.submitQuestion = function(){ +// // var form = SurveyQuestionForm, +// // data = {}, +// // labels={}, +// // min= "min", +// // max = "max", +// // fld; +// // //generator.clearApiErrors(); +// // Wait('start'); + +// // try { +// // for (fld in form.fields) { +// // if($scope[fld]){ +// // if(fld === "type"){ +// // data[fld] = $scope[fld].type; +// // if($scope[fld].type==="integer" || $scope[fld].type==="float"){ +// // data[min] = $('#answer_min').val(); +// // data[max] = $('#answer_max').val(); +// // labels[min]= "Min"; +// // labels[max]= "Max"; +// // } +// // } +// // else{ +// // data[fld] = $scope[fld]; +// // } +// // labels[fld] = form.fields[fld].label; +// // } +// // } +// // Wait('stop'); +// // $scope.survey_questions.push(data); +// // $('#new_question .aw-form-well').remove(); +// // // for(fld in form.fields){ +// // // $scope[fld] = ''; +// // // } +// // $scope.finalizeQuestion(data , labels); + +// // } catch (err) { +// // Wait('stop'); +// // Alert("Error", "Error parsing extra variables. Parser returned: " + err); +// // } +// // }; + +// // $scope.formSave = function () { +// // generator.clearApiErrors(); +// // Wait('start'); +// // var url; +// // if(!$scope.Store("survey_for_new_job_template") && $scope.Store("survey_for_new_job_template")!==false){ +// // $scope.Store('survey_for_new_job_template', { +// // // survey_created: true, +// // name: $scope.survey_name, +// // description: $scope.survey_description, +// // spec:$scope.survey_questions +// // }); +// // Wait('stop'); +// // $location.path("/job_templates/add/"); +// // } +// // else { +// // url = GetBasePath(base)+ id + '/survey_spec/'; + +// // Rest.setUrl(url); +// // Rest.post({ name: $scope.survey_name, description: $scope.survey_description, spec:$scope.survey_questions }) +// // .success(function () { +// // Wait('stop'); +// // $location.path("/job_templates/"+id); +// // }) +// // .error(function (data, status) { +// // ProcessErrors($scope, data, status, form, { hdr: 'Error!', +// // msg: 'Failed to add new survey. Post returned status: ' + status }); +// // }); +// // } +// // }; + +// // // Save +// // $scope.formSave = function () { +// // generator.clearApiErrors(); +// // Wait('start'); +// // if($scope.Store("saved_job_template_for_survey")){ +// // $scope.Store('survey_for_new_job_template', { +// // // survey_created: true, +// // name: $scope.survey_name, +// // description: $scope.survey_description, +// // spec:$scope.survey_questions +// // }); +// // Wait('stop'); +// // $location.path("/job_templates/add/"); +// // } +// // else{ +// // var url = GetBasePath(base)+ id + '/survey_spec/'; +// // Rest.setUrl(url); +// // Rest.post({ name: $scope.survey_name, description: $scope.survey_description, spec:$scope.survey_questions }) +// // .success(function () { +// // Wait('stop'); +// // $location.path("/job_templates/"+id); +// // }) +// // .error(function (data, status) { +// // ProcessErrors($scope, data, status, form, { hdr: 'Error!', +// // msg: 'Failed to add new survey. Post returned status: ' + status }); +// // }); +// // } + +// // }; + +// // // Cancel +// // $scope.formReset = function () { +// // $rootScope.flashMessage = null; +// // generator.reset(); +// // }; +// // } + +// // SurveyMakerAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'SurveyMakerForm', +// // 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'Wait', 'SurveyQuestionForm', 'Store' +// // ]; + +// // function SurveyMakerEdit($scope, $rootScope, $compile, $location, $log, $routeParams, SurveyMakerForm, +// // GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath, +// // ReturnToCaller, Wait, SurveyQuestionForm, Store) { + +// // ClearScope(); + +// // // Inject dynamic view +// // var generator = GenerateForm, +// // form = SurveyMakerForm, +// // base = $location.path().replace(/^\//, '').split('/')[0], +// // id = $location.path().replace(/^\//, '').split('/')[1], +// // i, data; + +// // $scope.survey_questions=[]; + +// // $scope.answer_types=[ +// // {name: 'Text' , type: 'text'}, +// // {name: 'Textarea', type: 'textarea'}, +// // {name: 'Multiple Choice (single select)', type: 'multiplechoice'}, +// // {name: 'Multiple Choice (multiple select)', type: 'multiselect'}, +// // {name: 'JSON', type: 'json'}, +// // {name: 'Integer', type: 'integer'}, +// // {name: 'Float', type: 'number'} +// // ]; + +// // $scope.Store = Store; + +// // generator.inject(form, { mode: 'edit', related: false, scope: $scope}); +// // generator.reset(); +// // // LoadBreadCrumbs(); +// // // LoadBreadCrumbs({ +// // // path: '/job_templates/' + id + '/survey', +// // // title: 'jared rocks', // $scope.job_id + ' - ', //+ data.summary_fields.job_template.name, +// // // altPath: '/job_templates/' + id + '/survey', +// // // }); + +// // $scope.addQuestion = function(){ + +// // GenerateForm.inject(SurveyQuestionForm, {mode:'add', id:'new_question', scope:$scope, breadCrumbs: false}); +// // }; +// // // $scope.addQuestion(); + +// // // $('#question_shadow').mouseenter(function(){ +// // // $('#question_shadow').css({ +// // // "opacity": "1", +// // // "border": "1px solid", +// // // "border-color": "rgb(204,204,204)", +// // // "border-radius": "4px" +// // // }); +// // // $('#question_add_btn').show(); +// // // }); + +// // // $('#question_shadow').mouseleave(function(){ +// // // $('#question_shadow').css({ +// // // "opacity": ".4", +// // // "border": "1px dashed", +// // // "border-color": "rgb(204,204,204)", +// // // "border-radius": "4px" +// // // }); +// // // $('#question_add_btn').hide(); +// // // }) + + +// // // $('#question_shadow').on("click" , function(){ +// // // // var survey_width = $('#survey_maker_question_area').width()-10, +// // // // html = ""; + +// // // // $('#add_question_btn').attr('disabled', 'disabled') +// // // // $('#survey_maker_question_area').append(html); +// // // addQuestion(); +// // // $('#question_shadow').hide(); +// // // $('#question_shadow').css({ +// // // "opacity": ".4", +// // // "border": "1px dashed", +// // // "border-color": "rgb(204,204,204)", +// // // "border-radius": "4px" +// // // }); +// // // }); +// // $scope.finalizeQuestion= function(data){ +// // var key, +// // labels={ +// // "type": "Type", +// // "question_name": "Question Text", +// // "question_description": "Question Description", +// // "variable": "Answer Varaible Name", +// // "choices": "Choices", +// // "min": "Min", +// // "max": "Max", +// // "required": "Required", +// // "default": "Default Answer" +// // }, +// // html = '
'; + +// // for (key in data) { +// // html+='
'+data[key]+'
\n'; +// // } + +// // html+='
'; + +// // $('#finalized_questions').before(html); +// // $('#add_question_btn').show(); +// // $('#add_question_btn').removeAttr('disabled'); +// // $('#survey_maker_save_btn').removeAttr('disabled'); +// // }; + +// // $('#add_question_btn').on("click" , function(){ +// // $scope.addQuestion(); +// // $('#add_question_btn').attr('disabled', 'disabled'); +// // }); + +// // Wait('start'); + +// // if($scope.Store("saved_job_template_for_survey") && $scope.Store("saved_job_template_for_survey").editing_survey===true){ +// // data = $scope.Store("survey_for_new_job_template"); +// // $scope.survey_name = data.name; +// // $scope.survey_description = data.description; +// // $scope.survey_questions = data.spec; +// // for(i=0; i<$scope.survey_questions.length; i++){ +// // $scope.finalizeQuestion($scope.survey_questions[i]); +// // } +// // Wait('stop'); +// // } +// // else{ +// // Rest.setUrl(GetBasePath(base)+ id + '/survey_spec/'); +// // Rest.get() +// // .success(function (data) { +// // var i; +// // $scope.survey_name = data.name; +// // $scope.survey_description = data.description; +// // $scope.survey_questions = data.spec; +// // for(i=0; i<$scope.survey_questions.length; i++){ +// // $scope.finalizeQuestion($scope.survey_questions[i]); +// // } +// // Wait('stop'); +// // // LoadBreadCrumbs({ path: '/organizations/' + id, title: data.name }); +// // // for (fld in form.fields) { +// // // if (data[fld]) { +// // // $scope[fld] = data[fld]; +// // // master[fld] = data[fld]; +// // // } +// // // } + +// // // related = data.related; +// // // for (set in form.related) { +// // // if (related[set]) { +// // // relatedSets[set] = { +// // // url: related[set], +// // // iterator: form.related[set].iterator +// // // }; +// // // } +// // // } + +// // // Initialize related search functions. Doing it here to make sure relatedSets object is populated. +// // // RelatedSearchInit({ scope: $scope, form: form, relatedSets: relatedSets }); +// // // RelatedPaginateInit({ scope: $scope, relatedSets: relatedSets }); +// // // $scope.$emit('organizationLoaded'); +// // }) +// // .error(function (data, status) { +// // ProcessErrors($scope, data, status, form, { hdr: 'Error!', +// // msg: 'Failed to retrieve organization: ' + $routeParams.id + '. GET status: ' + status }); +// // }); +// // } +// // $scope.submitQuestion = function(){ +// // var form = SurveyQuestionForm, +// // data = {}, +// // labels={}, +// // min= "min", +// // max = "max", +// // fld; +// // //generator.clearApiErrors(); +// // Wait('start'); + +// // try { +// // for (fld in form.fields) { +// // if($scope[fld]){ +// // if(fld === "type"){ +// // data[fld] = $scope[fld].type; +// // if($scope[fld].type==="integer" || $scope[fld].type==="float"){ +// // data[min] = $('#answer_min').val(); +// // data[max] = $('#answer_max').val(); +// // labels[min]= "Min"; +// // labels[max]= "Max"; +// // } +// // } +// // else{ +// // data[fld] = $scope[fld]; +// // } +// // labels[fld] = form.fields[fld].label; +// // } +// // } +// // Wait('stop'); +// // $scope.survey_questions.push(data); +// // $('#new_question .aw-form-well').remove(); +// // // for(fld in form.fields){ +// // // $scope[fld] = ''; +// // // } +// // $scope.finalizeQuestion(data , labels); + +// // } catch (err) { +// // Wait('stop'); +// // Alert("Error", "Error parsing extra variables. Parser returned: " + err); +// // } +// // }; +// // // Save +// // $scope.formSave = function () { +// // generator.clearApiErrors(); +// // Wait('start'); +// // var url; +// // if($scope.Store("survey_for_new_job_template") && $scope.Store("survey_for_new_job_template")!==false){ +// // $scope.Store('survey_for_new_job_template', { +// // // survey_created: true, +// // name: $scope.survey_name, +// // description: $scope.survey_description, +// // spec:$scope.survey_questions +// // }); +// // Wait('stop'); +// // $location.path("/job_templates/add/"); +// // } +// // else { +// // url = GetBasePath(base)+ id + '/survey_spec/'; + +// // Rest.setUrl(url); +// // Rest.post({ name: $scope.survey_name, description: $scope.survey_description, spec:$scope.survey_questions }) +// // .success(function () { +// // Wait('stop'); +// // $location.path("/job_templates/"+id); +// // }) +// // .error(function (data, status) { +// // ProcessErrors($scope, data, status, form, { hdr: 'Error!', +// // msg: 'Failed to add new survey. Post returned status: ' + status }); +// // }); +// // } +// // }; + +// // // Cancel +// // $scope.formReset = function () { +// // $rootScope.flashMessage = null; +// // generator.reset(); +// // }; +// // }