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 #75 from AppliedIS/feature-autosave
Browse files Browse the repository at this point in the history
auto-save and landing page updates
  • Loading branch information
jefferey committed Oct 25, 2016
2 parents 930cc0c + b920aa2 commit fbf97b7
Show file tree
Hide file tree
Showing 19 changed files with 211 additions and 83 deletions.
2 changes: 1 addition & 1 deletion DOL.WHD.Section14c.Web/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html ng-app="14c">
<html ng-app="14c" lang="en">
<head>
<title>DOL WHD Section 14c</title>
</head>
Expand Down
3 changes: 2 additions & 1 deletion DOL.WHD.Section14c.Web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@
"dependencies": {
"angular": "^1.5.8",
"angular-animate": "^1.5.8",
"angular-moment": "^1.0.0",
"angular-recaptcha": "^3.0.4",
"angular-resource": "^1.5.8",
"angular-route": "^1.5.8",
"angular-sanitize": "^1.5.8",
"jquery": "^3.1.1",
"lodash": "^4.16.1",
"moment": "^2.15.1"
"moment": "^2.15.2"
}
}
9 changes: 8 additions & 1 deletion DOL.WHD.Section14c.Web/src/modules/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import ngResource from 'angular-resource';
import ngRoute from 'angular-route';
import ngSanitize from 'angular-sanitize';
import vcRecaptcha from 'angular-recaptcha';
import angularMoment from 'angular-moment';

// Styles
import '../styles/main.scss';
Expand All @@ -25,7 +26,8 @@ let app = angular.module('14c', [
ngResource,
ngRoute,
ngSanitize,
'vcRecaptcha'
'vcRecaptcha',
'angularMoment'
]);

// Environment config loaded from env.js
Expand Down Expand Up @@ -53,6 +55,11 @@ app.config(function($routeProvider, $compileProvider) {
controller: 'changePasswordPageController',
template: require('./pages/changePasswordPageTemplate.html')
})
.when('/forgotPassword', {
controller: 'forgotPasswordPageController',
template: require('./pages/forgotPasswordPageTemplate.html'),
public: true
})
.when('/login', {
controller: 'userLoginPageController',
template: require('./pages/userLoginPageTemplate.html'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

module.exports = function(ngModule) {
ngModule.controller('formFooterControlsController', function($scope, $location, $route, stateService, navService, apiService) {
ngModule.controller('formFooterControlsController', function($scope, $location, $route, navService, autoSaveService) {
'ngInject';
'use strict';

Expand Down Expand Up @@ -36,7 +36,7 @@ module.exports = function(ngModule) {
}

this.doSave = function() {
apiService.saveApplication(stateService.access_token, stateService.ein, stateService.formData);
autoSaveService.save();
}

this.onNextClick = function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

module.exports = function(ngModule) {
ngModule.controller('mainHeaderControlController', function($scope, $rootScope, $location, stateService, apiService) {
ngModule.controller('mainHeaderControlController', function($scope, $rootScope, $location, stateService, apiService, autoSaveService) {
'ngInject';
'use strict';

Expand All @@ -13,11 +13,14 @@ module.exports = function(ngModule) {
$scope.loadImage = $rootScope.loadImage;

this.userClick = function() {
//TODO
$location.path("/");
}

this.saveClick = function() {
//TODO
autoSaveService.save(function () {
stateService.logOut();
$location.path("/");
});
}
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ <h2>REVXX/20XX</h2>
<img ng-src="{{ loadImage('whd_logo.jpg') }}" />
</div>
</div>
<div class="header-status-bar">
<div class="header-status-bar" ng-show="vm.stateService.user.email">
<p class="pull-left">EIN: <span class="header-ein">{{ vm.stateService.ein ? vm.stateService.ein : "XX-XXXXXXX" }}</span></p>

<p class="pull-right"><a href="" ng-click="vm.userClick()">{{ vm.stateService.user.email ? vm.stateService.user.email : "Username" }}</a> | <a href="" ng-click="vm.saveClick()">Save Work & Sign Out</a></p>
</div>
<main-navigation-control></main-navigation-control>

<p class="pull-right" ng-show="vm.stateService.formData.lastSaved > 0">
Saved {{vm.stateService.formData.lastSaved | amUtc | amLocal | amDateFormat:'dddd, MMMM Do YYYY, h:mm:ss a'}}
<p>
<p class="pull-right" ng-show="vm.stateService.formData.lastSaved === 0">
Error Saving Form
<p>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

module.exports = function(ngModule) {
ngModule.controller('userLoginFormController', function($rootScope, $scope, $location, stateService, apiService) {
ngModule.controller('userLoginFormController', function($rootScope, $scope, $location, stateService, apiService, autoSaveService) {
'ngInject';
'use strict';

Expand All @@ -13,6 +13,8 @@ module.exports = function(ngModule) {
'pass': ''
};

$scope.inputType = 'password';

$scope.onSubmitClick = function() {
// Call Token Service
apiService.userLogin($scope.formVals.email, $scope.formVals.pass).then(function (result) {
Expand All @@ -34,6 +36,10 @@ module.exports = function(ngModule) {
}, function (error) {
handleError(error);
});


// start auto-save
autoSaveService.start();

}, function (error) {
handleError(error);
Expand All @@ -49,6 +55,19 @@ module.exports = function(ngModule) {
console.log(error.statusText + (error.data && error.data.error ? ': ' + error.data.error + ' - ' + error.data.error_description : ''));
$location.path("/");
}


$scope.forgotPassword = function() {
$location.path("/forgotPassword");
}

$scope.hideShowPassword = function(){
if ($scope.inputType === 'password')
$scope.inputType = 'text';
else
$scope.inputType = 'password';
};

});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<div class="login">
<h2>Log in</h2>
<div><label>Email</label><input name="email" type="text" placeholder="Email" ng-model="formVals.email" /></div>
<div><label>Password</label><input name="password" type="password" placeholder="Password" ng-model="formVals.pass" /><div class="showpass"><a>Show Password</a></div></div>
<div class="loginbtn"><button type="submit" ng-click="onSubmitClick()">Submit</button></div>
<div class="forgotpass"><a>Forgot Your Password?</a></div>
</div>
<form ng-submit="onSubmitClick()">
<div class="login">
<h2>Log in</h2>
<div><label for="userName">Email</label><input name="userName" id="userName" type="email" placeholder="Email" ng-model="formVals.email" /></div>
<div><label for="password">Password</label><input name="password" id="password" type="{{inputType}}" placeholder="Password" ng-model="formVals.pass" />
<div class="showpass">
<a href="" ng-click="hideShowPassword()"><span ng-show="inputType != 'password'">Hide</span><span ng-show="inputType === 'password'">Show</span> Password</a>
</div></div>
<div class="loginbtn"><button type="submit">Log in</button></div>
<div class="forgotpass"><a href="" ng-click="forgotPassword()">Forgot Your Password?</a></div>
</div>
<div class="login">
<div><strong>Questions?</strong></div>
<div>Contact the <a>Wage and Hour office closest to you</a></div>
</div>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module.exports = function(ngModule) {
'confirmPass': ''
};

$scope.inputType = 'password';

$scope.onSubmitClick = function() {
apiService.userRegister($scope.formVals.ein, $scope.formVals.email, $scope.formVals.pass, $scope.formVals.confirmPass, $scope.response).then(function (result) {
$location.path("/");
Expand Down Expand Up @@ -44,5 +46,12 @@ module.exports = function(ngModule) {
$scope.response = null;
};

$scope.hideShowPassword = function(){
if ($scope.inputType === 'password')
$scope.inputType = 'text';
else
$scope.inputType = 'password';
};

});
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
<div class="reghdr">
<h2>Section 14(c) Certificate Application</h2>
<p>We are now accepting Section 14(c) Certificate Applications electronically.</p>
<ul>
<li>All employers, including current Certificate Holders, previous Certificate Holders and new applicants,
will have to create an account in order to submit the form electronically.</li>
<li>The Employer's EIN is required to create an account.</li>
<li>Once the Employer's account is created, additional users can be added.</li>
<li>The electronic form includes both form WH-226 and WH-226A.</li>
<li>As of 12/31/2016, paper forms will no longer be accepted.</li>
</ul>
<p>Read our <a>FAQs for Electronic Section 14(c) Certificate Application</a></p>
<hr/>
</div>
<div class="createAcct">
<h2>Create an Account</h2>
<div><label>Employer Identification Number (EIN)</label><input class="ein" type="text" placeholder="EIN (XX-XXXXXXX)" ng-model="formVals.ein" /><div><a>Why do you need an EIN to create an account?</a></div></div>
<div><label>Email Address</label><input type="text" placeholder="Email" ng-model="formVals.email" /></div>
<div><label>Password</label><input type="password" placeholder="Password" ng-model="formVals.pass" /><div class="showpass"><a>Show Password</a></div></div>
<div><label>Confirm Password</label><input type="password" placeholder="Confirm Password" ng-model="formVals.confirmPass" /></div>
<div
vc-recaptcha
theme="'light'"
key="model.key"
on-create="setWidgetId(widgetId)"
on-success="setResponse(response)"
on-expire="cbExpiration()"
class="regcapt"></div>
<div class="regbtn"><button type="submit" ng-click="onSubmitClick()">Submit</button></div>
</div>
<form ng-submit="onSubmitClick()">
<p>We are now accepting Section 14(c) Certificate Applications electronically.</p>
<ul>
<li>All employers, including current Certificate Holders, previous Certificate Holders and new applicants,
will have to create an account in order to submit the form electronically.</li>
<li>The Employer's EIN is required to create an account.</li>
<li>Once the Employer's account is created, additional users can be added.</li>
<li>The electronic form includes both form WH-226 and WH-226A.</li>
<li>As of 12/31/2016, paper forms will no longer be accepted.</li>
</ul>
<p>Read our <a>FAQs for Electronic Section 14(c) Certificate Application</a></p>
<hr/>
</div>
<div class="createAcct">
<h2>Create an Account</h2>
<div><label for="EIN">Employer Identification Number (EIN)</label><input class="ein" name="EIN" id="EIN" type="text" placeholder="EIN (XX-XXXXXXX)" ng-model="formVals.ein" /><div><a>Why do you need an EIN to create an account?</a></div></div>
<div><label for="registerEmail">Email Address</label><input type="email" name="registerEmail" id="registerEmail" placeholder="Email" ng-model="formVals.email" /></div>
<div><label for="registerPassword">Password</label><input type="{{inputType}}" name="registerPassword" id="registerPassword" placeholder="Password" ng-model="formVals.pass" />
<div class="showpass">
<a href="" ng-click="hideShowPassword()"><span ng-show="inputType != 'password'">Hide</span><span ng-show="inputType === 'password'">Show</span> Password</a>
</div>
</div>
</div>
<div><label for="confirmPassword">Confirm Password</label><input type="password" name="confirmPassword" id="confirmPassword" placeholder="Confirm Password" ng-model="formVals.confirmPass" /></div>
<div
vc-recaptcha
theme="'light'"
key="model.key"
on-create="setWidgetId(widgetId)"
on-success="setResponse(response)"
on-expire="cbExpiration()"
class="regcapt"
title="reCaptcha"
></div>
<div class="regbtn"><button type="submit">Register</button></div>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

module.exports = function(ngModule) {
ngModule.controller('forgotPasswordPageController', function($scope, $location, stateService) {
'ngInject';
'use strict';
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Forgot Password
40 changes: 19 additions & 21 deletions DOL.WHD.Section14c.Web/src/modules/pages/landingPageTemplate.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
<div class="header-title-bar">
<div class="header-title">
<h1>Application for Authority to Employ Workers with Disabilities at Subminimum Wages</h1>
<h2>OMB NO: 1235-0001</h2>
<h2>REVXX/20XX</h2>
<div class="usa-grid">
<h2>Section 14(c) Certificate Application</h2>
<div ng-if="stateService.user.email">
<div ng-show="!stateService.formData.saved">
<button class="save-button"
onclick="window.location='#/section/assurances';">Start A New Application</button>
</div>
<div class="header-logo">
<img ng-src="{{ loadImage('dol_seal.svg') }}" />
<img ng-src="{{ loadImage('whd_logo.jpg') }}" />
</div>
</div>
<div class="header-status-bar">
<p class="pull-left">EIN: <span class="header-ein">{{ stateService.ein ? stateService.ein : "XX-XXXXXXX" }}</span></p>
<p class="pull-right"><a href="" ng-click="vm.userClick()">{{ stateService.user.email ? stateService.user.email : "Username" }}</a> | <a href="" ng-click="vm.saveClick()">Save Work & Sign Out</a></p>
</div>
<div ng-if="stateService.user.email">
<div>
<button onclick="window.location='#/section/assurances';" class="save-button">Start A New Application</button>
<div ng-show="stateService.formData.saved">
<button class="save-button"
onclick="window.location='#/section/assurances';">Continue Application</button>
</div>
<div>
<a href="#/changePassword">Change Password</a>
<a href="#/changePassword">Change Password</a>
</div>
</div>
</div>
<div ng-if="!stateService.user.email">
Welcome! Please <a href="#/login">login</a> or <a href="#/register">register</a>
<div class="usa-grid"
ng-if="!stateService.user.email">
<div class="usa-width-one-half">
<user-registration-form></user-registration-form>
</div>
<div class="usa-width-one-half">
<user-login></user-login>
</div>
</div>

6 changes: 6 additions & 0 deletions DOL.WHD.Section14c.Web/src/modules/services/apiService.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

var moment = require('moment');

module.exports = function(ngModule) {
ngModule.service('apiService', function($http, $q, _env) {
'ngInject';
Expand Down Expand Up @@ -91,6 +93,8 @@ module.exports = function(ngModule) {
this.saveApplication = function(access_token, ein, applicationData) {
let url = _env.api_url + '/api/save/' + ein;
let d = $q.defer();

applicationData.saved = moment.utc();

$http({
method: 'POST',
Expand All @@ -101,8 +105,10 @@ module.exports = function(ngModule) {
},
data: applicationData
}).then(function successCallback (data) {
applicationData.lastSaved = moment.utc();
d.resolve(data);
}, function errorCallback (error) {
applicationData.lastSaved = 0;
//console.log(error);
d.reject(error);
});
Expand Down
Loading

0 comments on commit fbf97b7

Please sign in to comment.