fixed multiple choice field

This commit is contained in:
David Baldwynn 2016-05-20 15:08:59 -07:00
parent e8d8e0e61f
commit 220643de1e
3 changed files with 5 additions and 10 deletions

View file

@ -25,7 +25,7 @@
"ref" : "origin/master", "ref" : "origin/master",
"repo" : "git@github.com:whitef0x0/tellform.git", "repo" : "git@github.com:whitef0x0/tellform.git",
"path" : "/opt/deploy", "path" : "/opt/deploy",
"post-deploy" : "npm install && pm2 startOrRestart ecosystem.json --env production", "post-deploy" : "npm install && pm2 startOrGracefulReload ecosystem.json --env production",
"env" : { "env" : {
"NODE_ENV": "production", "NODE_ENV": "production",
"BASE_URL": "admin.tellform.com" "BASE_URL": "admin.tellform.com"

View file

@ -2,26 +2,21 @@
angular.module('forms').directive('keyToOption', function(){ angular.module('forms').directive('keyToOption', function(){
return { return {
restrict: 'AE', restrict: 'A',
transclude: true,
scope: { scope: {
field: '&' field: '='
}, },
link: function($scope, $element, $attrs, $select) { link: function($scope, $element, $attrs, $select) {
$element.bind('keydown keypress', function(event) { $element.bind('keydown keypress', function(event) {
var keyCode = event.which || event.keyCode; var keyCode = event.which || event.keyCode;
var index = parseInt(String.fromCharCode(keyCode))-1; var index = parseInt(String.fromCharCode(keyCode))-1;
console.log($scope.field); //console.log($scope.field);
if (index < $scope.field.fieldOptions.length) { if (index < $scope.field.fieldOptions.length) {
event.preventDefault(); event.preventDefault();
$scope.$apply(function () { $scope.$apply(function () {
$scope.field.fieldValue = $scope.field.fieldOptions[index].option_value; $scope.field.fieldValue = $scope.field.fieldOptions[index].option_value;
if($attrs.type === 'dropdown'){
$select.selected.option_value = $scope.field.fieldOptions[index].option_value;
}
console.log($scope);
}); });
} }

View file

@ -1,6 +1,6 @@
<div class="field row radio" <div class="field row radio"
on-enter-key="nextField()" on-enter-key="nextField()"
key-to-option field="field"
ng-if="field.fieldOptions.length > 0"> ng-if="field.fieldOptions.length > 0">
<div class="col-xs-12 field-title" ng-style="{'color': design.colors.questionColor}"> <div class="col-xs-12 field-title" ng-style="{'color': design.colors.questionColor}">
<h3> <h3>