adding beginning of survey maker and portal mode

This commit is contained in:
Jared Tabor
2014-09-10 10:43:52 -04:00
parent b1463f056d
commit 64961f8504
13 changed files with 871 additions and 3 deletions

View File

@@ -240,6 +240,20 @@ angular.module('JobTemplateFormDefinition', ['SchedulesListDefinition', 'Complet
dataTitle: 'Prompt for Extra Variables',
dataContainer: "body"
},
enable_survey: {
type: 'custom',
column: 2,
control: '<div class="form-group">'+
'<div class="checkbox">'+
'<label><input type="checkbox" ng-model="enable_survey" name="enable_survey" id="job_templates_enable_survey_chbox" class="ng-valid ng-valid-api-error ng-dirty" ng-true-value="true" ng-false-value="false">'+
'<span class="label-text">Enable Survey</span><a id="awp-enable_survey" href="" aw-pop-over="<p>If checked, user will be prompted at job launch with a survey of questions related to the job.</p>'+
'<div class=&quot;popover-footer&quot;><span class=&quot;key&quot;>esc</span> or click to close</div>" data-placement="right" data-container="body" data-title="Enable Survey" class="help-link" data-original-title="" title="" tabindex="-1">'+
'<i class="fa fa-question-circle"></i></a> </label>'+
'<div class="error api-error ng-binding" id="job_templates-enable_survey-api-error" ng-bind="enable_survey_api_error"></div>'+
'<button type="button" class="btn btn-sm btn-default" id="job_templates_edit_survey_btn" ng-click="navigateToSurvey()"><i class="fa fa-pencil"></i> Edit Survey</button>'+
'</div>'+
'</div>'
},
allow_callbacks: {
label: 'Allow Provisioning Callbacks',
type: 'checkbox',

View File

@@ -0,0 +1,73 @@
/*********************************************
* Copyright (c) 2014 AnsibleWorks, Inc.
*
* SurveyMaker.js
* Form definition for survey maker model
*
*
*/
/**
* @ngdoc function
* @name forms.function:SurveyMaker
* @description This form is for adding/editing a survey
*/
angular.module('SurveyMakerFormDefinition', [])
.value('SurveyMakerForm', {
addTitle: 'Add Survey', //Title in add mode
editTitle: 'Edit Survey', //Title in edit mode
name: 'survey_maker', //entity or model name in singular form
well: true,
collapse: true,
collapseTitle: "Properties",
collapseMode: 'edit',
collapseOpen: true,
actions: {
stream: {
'class': "btn-primary btn-xs activity-btn",
ngClick: "showActivity()",
awToolTip: "View Activity Stream",
dataPlacement: "top",
icon: "icon-comments-alt",
mode: 'edit',
iconSize: 'large'
}
},
fields: {
name: {
label: 'Survey Name',
type: 'text',
addRequired: true,
editRequired: true,
capitalize: false
},
description: {
label: 'Survey Description',
type: 'text',
addRequired: false,
editRequired: false
},
questions: {
type: 'custom',
control: '<label for="survey"><span class="label-text prepend-asterisk">Questions</span></label>'+
'<div id="survey_maker_question_area"></div><div id="finalized_questions"></div>'+
'<button style="display:none" type="button" class="btn btn-sm btn-primary" id="add_question_btn" aw-tool-tip="Create a new question" data-placement="top" data-original-title="" title="" disabled><i class="fa fa-plus fa-lg"></i> Add Question</button>'+
'<div id="new_question"></div>'
}
},
buttons: { //for now always generates <button> tags
save: {
ngClick: 'formSave()', //$scope.function to call on click, optional
ngDisabled: true //Disable when $pristine or $invalid, optional
},
reset: {
ngClick: 'formReset()',
ngDisabled: true //Disabled when $pristine
}
}
});

View File

@@ -0,0 +1,183 @@
/*********************************************
* Copyright (c) 2014 AnsibleWorks, Inc.
*
* Inventories.js
* Form definition for question model
*
*
*/
/**
* @ngdoc function
* @name forms.function:Questions
* @description This form is for adding a question
*/
angular.module('SurveyQuestionFormDefinition', [])
.value('SurveyQuestionForm', {
addTitle: 'Add Question',
editTitle: '{{ inventory_name }}',
name: 'question_unique',
well: true,
twoColumns: true,
// actions: {
// stream: {
// 'class': "btn-primary btn-xs activity-btn",
// ngClick: "showActivity()",
// awToolTip: "View Activity Stream",
// dataPlacement: "top",
// icon: "icon-comments-alt",
// mode: 'edit',
// iconSize: 'large'
// }
// },
fields: {
question_text: {
realName: 'question_text',
label: 'Question Text',
type: 'text',
addRequired: true,
editRequired: true,
capitalize: true,
column: 1
},
question_description: {
realName: 'question_description',
label: 'Question Description',
type: 'textarea',
rows: 2,
addRequired: false,
editRequired: false,
column: 2
},
response_variable_name: {
label: 'Answer Variable Name',
type: 'text',
addRequired: true,
editRequired: true,
column: 2
// sourceModel: 'organization',
// sourceField: 'name',
// ngClick: 'lookUpOrganization()',
// awRequiredWhen: {
// variable: "organizationrequired",
// init: "true"
// }
},
answer_type: {
realName: 'answer_type',
label: 'Answer Type',
type: 'select',
ngOptions: 'answer_types.name for answer_types in answer_types',
addRequired: true,
editRequired: true,
column: 1
},
answer_options_text: {
realName: 'answer_options',
label: 'Answer Options',
type: 'text',
addRequired: true,
editRequired: true,
ngHide: 'answer_type.type!=="text" ',
column: 1
},
answer_options_multiple_choice: {
realName: 'answer_options',
label: 'Multiple Choice Options',
type: 'textarea',
rows: 3,
addRequired: true,
editRequired: true,
ngShow: 'answer_type.type==="mc" ',
awPopOver: '<p>Type an option on each line.</p>'+
'<p>For example the following input:<br><br>Apple<br>\n Banana<br>\n Cherry<br><br>would be displayed as:</p>\n'+
'<ol><li>Apple</li><li>Banana</li><li>Cherry</li><ol>',
dataTitle: 'Multiple Choice Options',
dataPlacement: 'right',
dataContainer: "body",
column: 1
},
answer_options_number: {
realName: 'answer_options',
// label: 'Answer Options',
type: 'custom',
control: '<div class="row">'+
'<div class="col-xs-6"><label for="minimum"><span class="label-text">Minimum</span></label><input id="answer_min" type="number" class="form-control"></div>'+
'<div class="col-xs-6"><label for="minimum"><span class="label-text">Maximum</span></label><input id="answer_max" type="number" class="form-control"></div></div>',
ngShow: 'answer_type.type==="number" ',
addRequired: true,
editRequired: true,
column: 1
},
answer_options_json: {
realName: 'answer_options',
label: 'Answer Options',
type: 'textarea',
rows: 3,
ngShow: 'answer_type.type==="json" ',
addRequired: true,
editRequired: true,
awPopOver: '<p>Insert some good JSON!</p>',
dataTitle: 'Answer Options',
dataPlacement: 'right',
dataContainer: "body",
column: 1
},
default_answer: {
realName: 'default_answer',
label: 'Default Answer',
type: 'text',
addRequired: false,
editRequired: false,
column: 1
},
is_required: {
label: 'Answer required or optional',
type: 'custom',
column: 2,
control: '<div><label for="required"><span class="label-text">Required</span></label><input id="answer_required" type="radio" checked=true></div>'+
'<div><label for="optional"><span class="label-text">Optional</span></label><input id="answer_optional" type="radio"></div>',
}
// answer_options: {
// label: 'Variables',
// type: 'textarea',
// 'class': 'span12',
// addRequired: false,
// editRequird: false,
// rows: 6,
// "default": "---",
// awPopOver: "<p>Enter inventory variables using either JSON or YAML syntax. Use the radio button to toggle between the two.</p>" +
// "JSON:<br />\n" +
// "<blockquote>{<br />\"somevar\": \"somevalue\",<br />\"password\": \"magic\"<br /> }</blockquote>\n" +
// "YAML:<br />\n" +
// "<blockquote>---<br />somevar: somevalue<br />password: magic<br /></blockquote>\n" +
// '<p>View JSON examples at <a href="http://www.json.org" target="_blank">www.json.org</a></p>' +
// '<p>View YAML examples at <a href="http://docs.ansible.com/YAMLSyntax.html" target="_blank">docs.ansible.com</a></p>',
// dataTitle: 'Inventory Variables',
// dataPlacement: 'right',
// dataContainer: 'body'
// }
// },
},
buttons: {
submit_quesiton: {
ngClick: 'submitQuestion()',
ngDisabled: true,
'class': 'btn btn-sm btn-primary',
label: 'Submit Question'
},
reset: {
ngClick: 'questionReset()',
ngDisabled: true
}
},
related: {
}
});