fixed legal and radio fields continue to next on key input bug

This commit is contained in:
David Baldwynn 2017-08-02 17:45:49 -04:00
parent 53828594ff
commit a3fb15d26d
16 changed files with 60 additions and 105 deletions

View file

@ -2788,9 +2788,6 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
$scope.update(false, $scope.myform, false, false, function(err){ $scope.update(false, $scope.myform, false, false, function(err){
}); });
}, },
start: function(e, ui) {
console.log(ui)
}
}; };
/* /*

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -24,7 +24,6 @@
ng-required="field.required" ng-required="field.required"
ng-disabled="field.disabled" ng-disabled="field.disabled"
placeholder="MM/DD/YYYY" placeholder="MM/DD/YYYY"
ng-focus="setActiveField(field._id, index, true)"
on-tab-key="nextField()" on-tab-key="nextField()"
on-tab-and-shift-key="prevField()" on-tab-and-shift-key="prevField()"
ng-change="$root.nextField()"> ng-change="$root.nextField()">

View file

@ -1,38 +0,0 @@
<div class="field row" ng-if="form.autofillPDFs" ng-click="setActiveField(field._id, index, true)">
<div class="col-xs-12 field-title" ng-style="{'color': design.colors.questionColor}">
<h3>
<small class="field-number">
{{index+1}}
<i class="fa fa-angle-double-right" aria-hidden="true"></i>
</small>
{{field.title}}
<span class="required-error" ng-show="!field.required">{{ 'OPTIONAL' | translate }}</span>
</h3>
</div>
<div class="col-sm-8 field-input">
<div class="input-group ">
<div tabindex="-1" class="form-control file-caption">
<span class="file-caption-ellipsis" ng-if="!form.pdf"></span>
<div class="file-caption-name" ng-if="form.pdf">
{{field.file.originalname}}
</div>
</div>
<div class="input-group-btn">
<button type="button" ng-if="field.file" ng-click="removeFile(field);" title="Clear selected files" class="btn btn-danger fileinput-remove fileinput-remove-button">
<i class="glyphicon glyphicon-trash" ></i>
{{ 'DELETE' | translate }}
</button>
<button type="button" ng-if="field.fileLoading" title="Abort ongoing upload" class="btn btn-default" ng-click="cancelFileUpload(field)">
<i class="glyphicon glyphicon-ban-circle"></i>
{{ 'CANCEL' | translate }}
</button>
<div class="btn btn-success btn-file" ngf-select ngf-change="uploadPDF($files)" ng-if="!field.file">
<i class="glyphicon glyphicon-upload"></i>
{{ UPLOAD_FILE | translate }}
</div>
</div>
</div>
</div>
</div>

View file

@ -1,6 +1,7 @@
<div class="field row radio legal" <div class="field row radio legal"
on-enter-or-tab-key="nextField()" on-enter-or-tab-key="nextField()"
key-to-truthy key-char-truthy="y" key-char-falsey="n" field="field"> on-tab-and-shift-key="prevField()"
key-to-truthy key-char-truthy="y" key-char-falsey="n" field="field" on-valid-key="nextField()">
<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>
<small class="field-number"> <small class="field-number">
@ -14,20 +15,17 @@
<p class="col-xs-12">{{field.description}}</p> <p class="col-xs-12">{{field.description}}</p>
</div> </div>
<div class="col-xs-12 field-input container"> <div class="col-xs-12 field-input container">
<div class="row-fluid" <div class="row-fluid">
on-enter-or-tab-key="nextField()"
on-tab-and-shift-key="prevField()">
<label class="btn col-md-5 col-xs-12" <label class="btn col-md-5 col-xs-12"
ng-class="{activeBtn: field.fieldValue == 'true'}"> ng-class="{activeBtn: field.fieldValue == 'true'}">
<input class="focusOn" <input class="focusOn"
ng-focus="setActiveField(field._id, index, true)"
ng-style="{'color': design.colors.answerColor, 'border-color': design.colors.answerColor}" ng-style="{'color': design.colors.answerColor, 'border-color': design.colors.answerColor}"
type="radio" value="true" type="radio" value="true"
ng-model="field.fieldValue" ng-model="field.fieldValue"
ng-model-options="{ debounce: 250 }" ng-model-options="{ debounce: 250 }"
ng-required="field.required" ng-required="field.required"
ng-disabled="field.disabled" ng-disabled="field.disabled"
ng-change="$root.nextField()"/> ng-change="nextField()"/>
<div class="letter" style="float:left"> <div class="letter" style="float:left">
Y Y
</div> </div>
@ -42,7 +40,7 @@
ng-model-options="{ debounce: 250 }" ng-model-options="{ debounce: 250 }"
ng-required="field.required" ng-required="field.required"
ng-disabled="field.disabled" ng-disabled="field.disabled"
ng-change="$root.nextField()"/> ng-change="nextField()"/>
<div class="letter" style="float:left"> <div class="letter" style="float:left">
N N
</div> </div>

View file

@ -26,7 +26,6 @@
</div> </div>
<input ng-style="{'color': design.colors.answerColor, 'border-color': design.colors.answerColor}" <input ng-style="{'color': design.colors.answerColor, 'border-color': design.colors.answerColor}"
type="radio" class="focusOn" type="radio" class="focusOn"
ng-focus="setActiveField(field._id, index, true)"
value="{{option.option_value}}" value="{{option.option_value}}"
ng-model="field.fieldValue" ng-model="field.fieldValue"
ng-model-options="{ debounce: 250 }" ng-model-options="{ debounce: 250 }"

View file

@ -28,7 +28,6 @@
ng-disabled="field.disabled" ng-disabled="field.disabled"
on-enter-or-tab-key="nextField()" on-enter-or-tab-key="nextField()"
on-tab-and-shift-key="prevField()" on-tab-and-shift-key="prevField()"
ng-focus="setActiveField(field._id, index, true)"
class="angular-input-stars focusOn"> class="angular-input-stars focusOn">
</input-stars> </input-stars>
</div> </div>

View file

@ -1,7 +1,6 @@
<div class="statement field row" <div class="statement field row"
on-enter-or-tab-key="nextField()" on-enter-or-tab-key="nextField()"
on-tab-and-shift-key="prevField()" on-tab-and-shift-key="prevField()">
ng-focus="setActiveField(field._id, index, true)">
<div class="row field-title field-title"> <div class="row field-title field-title">
<div class="col-xs-1"><i class="fa fa-quote-left fa-1"></i></div> <div class="col-xs-1"><i class="fa fa-quote-left fa-1"></i></div>
<h2 class="text-left col-xs-9">{{field.title}}</h2> <h2 class="text-left col-xs-9">{{field.title}}</h2>
@ -13,10 +12,9 @@
<p class="col-xs-12" ng-if="field.description.length">{{field.description}} </p> <p class="col-xs-12" ng-if="field.description.length">{{field.description}} </p>
<br> <br>
<div class="col-xs-offset-1 col-xs-11"> <div class="col-xs-offset-1 col-xs-11">
<button class="btn focusOn" <button class="btn focusOn">
ng-style="{'font-size': '1.3em', 'background-color':design.colors.buttonColor, 'color':design.colors.buttonTextColor}" ng-style="{'font-size': '1.3em', 'background-color':design.colors.buttonColor, 'color':design.colors.buttonTextColor}"
ng-focused="setActiveField(field._id, index, true)" ng-click="nextField()">
ng-click="$root.nextField()">
{{ 'CONTINUE' | translate }} {{ 'CONTINUE' | translate }}
</button> </button>
</div> </div>

View file

@ -22,7 +22,6 @@
value="{{field.fieldValue}}" value="{{field.fieldValue}}"
ng-required="field.required" ng-required="field.required"
ng-disabled="field.disabled" ng-disabled="field.disabled"
ng-focus="setActiveField(field._id, index, true)"
on-enter-or-tab-key="nextField()" on-enter-or-tab-key="nextField()"
on-tab-and-shift-key="prevField()" on-tab-and-shift-key="prevField()"
style="border: none; border-left: lightgrey dashed 2px;"> style="border: none; border-left: lightgrey dashed 2px;">

View file

@ -29,7 +29,6 @@
ng-model="field.fieldValue" ng-model="field.fieldValue"
ng-model-options="{ debounce: 250 }" ng-model-options="{ debounce: 250 }"
value="field.fieldValue" value="field.fieldValue"
ng-focus="setActiveField(field._id, index, true)"
on-enter-or-tab-key="nextField()" on-enter-or-tab-key="nextField()"
on-tab-and-shift-key="prevField()" on-tab-and-shift-key="prevField()"
ng-required="field.required" ng-required="field.required"

View file

@ -1,7 +1,9 @@
<div class="field row radio" <div class="field row radio"
ng-click="setActiveField(field._id, index, true)" ng-click="setActiveField(field._id, index, true)"
on-tab-and-shift-key="prevField()" on-tab-and-shift-key="prevField()"
key-to-truthy key-char-truthy="y" key-char-falsey="n" field="field"> key-to-truthy key-char-truthy="y" key-char-falsey="n" field="field"
on-valid-key="nextField()"
ng-show="!field.disabled">
<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 class="row"> <h3 class="row">
<small class="field-number"> <small class="field-number">
@ -26,11 +28,9 @@
class="focusOn" class="focusOn"
style="opacity: 0; margin-left: 0px;" style="opacity: 0; margin-left: 0px;"
ng-model="field.fieldValue" ng-model="field.fieldValue"
ng-focus="setActiveField(field._id, index, true)"
ng-model-options="{ debounce: 250 }" ng-model-options="{ debounce: 250 }"
ng-required="field.required" ng-required="field.required"
ng-click="nextField()" ng-change="nextField()"/>
ng-disabled="field.disabled" />
<div class="letter"> <div class="letter">
{{ 'Y' | translate }} {{ 'Y' | translate }}
</div> </div>
@ -48,14 +48,12 @@
ng-model="field.fieldValue" ng-model="field.fieldValue"
ng-model-options="{ debounce: 250 }" ng-model-options="{ debounce: 250 }"
ng-required="field.required" ng-required="field.required"
ng-change="$root.nextField()" ng-change="nextField()"/>
ng-disabled="field.disabled"/> <div class="letter">
{{ 'N' | translate }}
<div class="letter"> </div>
{{ 'N' | translate }} <span>{{ 'NO' | translate }}</span>
</div> <i ng-show="field.fieldValue === 'false'" class="fa fa-check" aria-hidden="true"></i>
<span>{{ 'NO' | translate }}</span>
<i ng-show="field.fieldValue === 'false'" class="fa fa-check" aria-hidden="true"></i>
</label> </label>
</div> </div>
</div> </div>

View file

@ -4,24 +4,31 @@ angular.module('view-form').directive('keyToTruthy', ['$rootScope', function($ro
return { return {
restrict: 'A', restrict: 'A',
scope: { scope: {
field: '=' field: '=',
nextField: '&'
}, },
link: function($scope, $element, $attrs) { link: function($scope, $element, $attrs) {
$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 truthyKeyCode = $attrs.keyCharTruthy.charCodeAt(0) - 32; var truthyKeyCode = $attrs.keyCharTruthy.charCodeAt(0) - 32;
var falseyKeyCode = $attrs.keyCharFalsey.charCodeAt(0) - 32; var falseyKeyCode = $attrs.keyCharFalsey.charCodeAt(0) - 32;
console.log($scope);
if(keyCode === truthyKeyCode ) { if(keyCode === truthyKeyCode ) {
event.preventDefault(); event.preventDefault();
$scope.$apply(function() { $scope.$apply(function() {
$scope.field.fieldValue = 'true'; $scope.field.fieldValue = 'true';
if($attrs.onValidKey){
$scope.$root.$eval($attrs.onValidKey);
}
}); });
}else if(keyCode === falseyKeyCode){ }else if(keyCode === falseyKeyCode){
event.preventDefault(); event.preventDefault();
$scope.$apply(function() { $scope.$apply(function() {
$scope.field.fieldValue = 'false'; $scope.field.fieldValue = 'false';
}); if($attrs.onValidKey){
$scope.$root.$eval($attrs.onValidKey);
}
});
} }
}); });
} }

View file

@ -26,9 +26,6 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
$scope.update(false, $scope.myform, false, false, function(err){ $scope.update(false, $scope.myform, false, false, function(err){
}); });
}, },
start: function(e, ui) {
console.log(ui)
}
}; };
/* /*