Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #77 from AppliedIS/feature-autosave
Browse files Browse the repository at this point in the history
Feature autosave
  • Loading branch information
jefferey committed Oct 25, 2016
2 parents 8e72148 + 1308661 commit ea2ccb5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,21 @@ module.exports = function(ngModule) {

$scope.formData = stateService.formData;

if(!$scope.formData.establishmentType) $scope.formData.establishmentType = [];

// multiple choice responses
let questionKeys = [ 'ApplicationType', 'EstablishmentType' ];
responsesService.getQuestionResponses(questionKeys).then((responses) => { $scope.responses = responses; });

$scope.toggleEstablishmentType = function(id) {
var idx = $scope.formData.establishmentType.indexOf(id);
if (idx > -1) {
$scope.formData.establishmentType.splice(idx, 1);
}
else {
$scope.formData.establishmentType.push(id);
}
}

});
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h2 class="form-section-header">Application Type</h2>
<div class="form-question-block">
<div class="form-question-text">What is the most recently held certificate number for the main establishment?</div>
<div class="form-question-answer">
<input id="certificateNumber" name="certificateNumber" type="text" class="sidelabeled certificateno">
<input id="certificateNumber" name="certificateNumber" type="text" class="sidelabeled certificateno" ng-model="formData.certificateNumber">
<label class="example">Example: 12-34567-H-890</label>
</div>
</div>
Expand All @@ -60,7 +60,7 @@ <h2 class="form-section-header">Application Type</h2>
<fieldset class="usa-fieldset-inputs form-question-answer">
<ul class="usa-unstyled-list">
<li ng-repeat="response in responses.EstablishmentType">
<input id="establishmentType_{{ response.id }}" type="checkbox" name="establishmentType" ng-value="response.id" ng-model="formData.establishmentType">
<input id="establishmentType_{{ response.id }}" type="checkbox" name="stablishmentType_{{ response.id }}" ng-value="response.id" ng-checked="formData.establishmentType.indexOf(response.id) > -1" ng-click="toggleEstablishmentType(response.id)">
<label for="establishmentType_{{ response.id }}">{{ response.display }}</label>
<div class="underlabel checkbox-indent">{{ response.subDisplay }}</div>
</li>
Expand All @@ -75,30 +75,30 @@ <h2 class="form-section-header">Application Contact Person</h2>
<div class="form-question-block">
<div class="form-question-answer">
<label for="contactName">Full Name</label>
<input id="contactName" name="contactName" type="text" ng-model="contactName"></input>
<input id="contactName" name="contactName" type="text" ng-model="formData.contactName"></input>
</div>
</div>

<div class="form-question-block">
<div class="form-question-answer">
<label for="contactPhone">Telephone Number</label>
<input id="contactPhone" name="contactPhone" type="tel" ng-model="contactPhone" class="sidelabeled phoneno"></input>
<input id="contactPhone" name="contactPhone" type="tel" ng-model="formData.contactPhone" class="sidelabeled phoneno"></input>
<label class="example">Example: 123-456-7890</label>
</div>
</div>

<div class="form-question-block">
<div class="form-question-answer">
<label for="contactFax">Fax Number</label>
<input id="contactFax" name="contactFax" type="tel" ng-model="contactFax" class="sidelabeled phoneno"></input>
<input id="contactFax" name="contactFax" type="tel" ng-model="formData.contactFax" class="sidelabeled phoneno"></input>
<label class="example">Example: 123-456-7890</label>
</div>
</div>

<div class="form-question-block">
<div class="form-question-answer">
<label for="contactEmail">Email Address</label>
<input id="contactEmail" name="contactEmail" type="email" ng-model="contactEmail" class="sidelabeled email"></input>
<input id="contactEmail" name="contactEmail" type="email" ng-model="formData.contactEmail" class="sidelabeled email"></input>
<label class="example">Example: contact.name@company.com</label>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ module.exports = function(ngModule) {

$scope.formData = stateService.formData;


if(!$scope.formData.employerInfo) {
$scope.formData.employerInfo = { providingFacilitiesDeductionType: [] };
}

// multiple choice responses
let questionKeys = [ 'EmployerStatus', 'SCA', 'EO13658', 'ProvidingFacilitiesDeductionType' ];
responsesService.getQuestionResponses(questionKeys).then((responses) => { $scope.responses = responses; });
Expand Down Expand Up @@ -44,5 +49,15 @@ module.exports = function(ngModule) {
$scope.formData.employerInfo.SCAAttachment = undefined;
})
}

this.toggleProvidingFacilitiesDeductionType = function(id) {
var idx = $scope.formData.employerInfo.providingFacilitiesDeductionType.indexOf(id);
if (idx > -1) {
$scope.formData.employerInfo.providingFacilitiesDeductionType.splice(idx, 1);
}
else {
$scope.formData.employerInfo.providingFacilitiesDeductionType.push(id);
}
}
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ <h2 class="form-section-header">Label for Section?</h2>
<fieldset class="usa-fieldset-inputs form-question-answer">
<ul class="usa-unstyled-list">
<li ng-repeat="response in responses.ProvidingFacilitiesDeductionType">
<input id="deductionType_{{ response.id }}" type="checkbox" name="deductionType" ng-value="response.id" ng-model="formData.employerInfo.providingFacilitiesDeductionType">
<input id="deductionType_{{ response.id }}" type="checkbox" name="deductionType_{{ response.id }}" ng-value="response.id" ng-checked="formData.employerInfo.providingFacilitiesDeductionType.indexOf(response.id) > -1" ng-click="vm.toggleProvidingFacilitiesDeductionType(response.id)" >
<label for="deductionType_{{ response.id }}">{{ response.display }}</label>
</li>
</ul>
Expand Down

0 comments on commit ea2ccb5

Please sign in to comment.