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

Commit

Permalink
admin summary section to change application status
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Linden committed Nov 22, 2016
1 parent e77dace commit 49d824c
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 1 deletion.
1 change: 1 addition & 0 deletions DOL.WHD.Section14c.Web/src/modules/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = function(ngModule) {
require('./sectionAdminAppInfo')(ngModule);
require('./sectionAdminAssurances')(ngModule);
require('./sectionAdminEmployer')(ngModule);
require('./sectionAdminSummary')(ngModule);
require('./sectionAdminWageData')(ngModule);
require('./sectionAdminWioa')(ngModule);
require('./sectionAdminWorkSites')(ngModule);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

module.exports = function(ngModule) {
require('./sectionAdminSummaryController')(ngModule);
require('./sectionAdminSummaryDirective')(ngModule);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

module.exports = function(ngModule) {
ngModule.controller('sectionAdminSummaryController', function($scope, stateService, statusesService, apiService) {
'ngInject';
'use strict';

var vm = this;

statusesService.getStatuses().then((data) => {
vm.statuses = data;
});

vm.updateStatus = () => {
apiService.changeApplicationStatus(stateService.access_token, $scope.appid, $scope.appData.statusId);
};
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

module.exports = function(ngModule) {
ngModule.directive('sectionAdminSummary', function() {

'use strict';

return {
restrict: 'EA',
template: require('./sectionAdminSummaryTemplate.html'),
controller: 'sectionAdminSummaryController',
controllerAs: 'vm'
};
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="admin-page">

<h1>Summary</h1>
<hr>

<div class="answer-block">
<div class="answer-question">Application Status</div>
<div class="answer-answer">
<select ng-model="appData.statusId" ng-options="status.id as status.name for status in vm.statuses"></select>
</div>
</div>

<button class="green-button nomargin" ng-click="vm.updateStatus()">Update Status</button>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div class="admin-page">
<h1>Work Sites &amp; Employees</h1>
<hr>

<div class="form-tabbed-section">
<div class="form-tab {{ vm.activeTab === 1 ? 'active' : '' }}" ng-click="vm.setActiveTab(1)"><div class="circle">1</div> Work Site</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div class="admin-page">
<h1>Work Sites &amp; Employees</h1>

<hr>

<answer-field answer="$parent.appData.totalNumWorkSites">
What is the total number of establishments and work sites to be covered by this certificate?
</answer-field>
Expand Down
17 changes: 17 additions & 0 deletions DOL.WHD.Section14c.Web/src/modules/services/apiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,5 +416,22 @@ module.exports = function(ngModule) {
return d.promise;
}

this.changeApplicationStatus = function(access_token, appId, newStatusId) {
const url = `${_env.api_url}/api/application/status?id=${appId}&statusId=${newStatusId}`;
const d = $q.defer();

$http({
method: 'POST',
url: url,
headers: {
'Authorization': 'bearer ' + access_token
}
}).then(function successCallback() {
d.resolve();
}, function errorCallback(error) {
d.reject(error);
});
}

});
}
1 change: 1 addition & 0 deletions DOL.WHD.Section14c.Web/src/modules/services/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ module.exports = function(ngModule) {
require('./autoSaveService')(ngModule);
require('./validationService')(ngModule);
require('./submissionService')(ngModule);
require('./statusesService')(ngModule);
};
41 changes: 41 additions & 0 deletions DOL.WHD.Section14c.Web/src/modules/services/statusesService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict';

import * as _ from 'lodash'

module.exports = function(ngModule) {
ngModule.service('statusesService', function($http, _env, $q) {
'ngInject';
'useStrict';

var statuses;
var url = `${_env.api_url}/api/status`;

this.getStatuses = function() {

let d = $q.defer();

if(statuses)
{
// load cached data
d.resolve(statuses);
}
else
{
// get data from server
$http({
method: 'GET',
url: url
}).then(function successCallback (data) {
// cache data
statuses = data.data;
d.resolve(data.data);
}, function errorCallback (error) {
d.reject(error);
});
}

return d.promise;
};
})
}

0 comments on commit 49d824c

Please sign in to comment.