Skip to content

Commit

Permalink
Issue 50: Store LSSS requests in an internal queue (UI)
Browse files Browse the repository at this point in the history
Work In Progress
  • Loading branch information
kaladay committed Apr 30, 2020
1 parent d333335 commit cdcd54b
Show file tree
Hide file tree
Showing 17 changed files with 715 additions and 0 deletions.
38 changes: 38 additions & 0 deletions app/config/apiMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,44 @@ var apiMapping = {
'controller': 'products'
}
},
InternalRequest: {
validations: true,
channel: '/channel/internal/request',
all: {
'endpoint': '/private/queue',
'controller': 'internal/request',
'method': '',
'httpMethod': 'GET'
},
create: {
'endpoint': '/private/queue',
'controller': 'internal/request',
'method': '',
'httpMethod': 'POST'
},
update: {
'endpoint': '/private/queue',
'controller': 'internal/request',
'method': '',
'httpMethod': 'PUT'
},
push: {
'endpoint': '/private/queue',
'controller': 'internal/request',
'method': '',
'httpMethod': 'PUT'
},
remove: {
'endpoint': '/private/queue',
'controller': 'internal/request',
'method': '',
'httpMethod': 'DELETE'
},
listen: {
'endpoint': '/channel',
'controller': 'internal/request'
}
},
User: {
lazy: true,
channel: '/channel/users',
Expand Down
117 changes: 117 additions & 0 deletions app/controllers/internalRequestController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
app.controller('InternalRequestController', function ($controller, $scope, ApiResponseActions, InternalRequestRepo, InternalRequestsService, RemoteProductManagerRepo, RemoteProductsService) {

angular.extend(this, $controller('AbstractController', {
$scope: $scope
}));

$scope.internalRequests = InternalRequestRepo.getAll();

$scope.internalRequestToEdit = {};
$scope.internalRequestToDelete = {};

$scope.featureRequestToPush = {};

$scope.resetInternalRequestForms = function () {
InternalRequestRepo.clearValidationResults();

for (var key in $scope.internalRequestForms) {
if ($scope.internalRequestForms[key] !== undefined && !$scope.internalRequestForms[key].$pristine && $scope.internalRequestForms[key].$setPristine) {
$scope.internalRequestForms[key].$setPristine();
}
}

$scope.closeModal();
};

$scope.resetInternalRequestForms();

if ($scope.isManager() || $scope.isAdmin()) {
$scope.remoteProductManagers = RemoteProductManagerRepo.getAll();

$scope.remoteProducts = RemoteProductsService.getRemoteProducts();

$scope.getRemoteProductManagerRemoteProducts = function (remoteProductManagerId) {
return $scope.remoteProducts[remoteProductManagerId];
};

$scope.pushInternalRequest = function (internalRequest) {
$scope.featureRequestToPush = {
title: internalRequest.title,
description: internalRequest.description,
profileId: null,
scopeId: null
};

$scope.openModal('#pushInternalRequestModal');
};

$scope.pushFeatureRequest = function () {
InternalRequestsService.push($scope.featureRequestToPush).then(function (res) {
if (angular.fromJson(res.body).meta.status === "SUCCESS") {
$scope.cancelPushFeatureRequest();
}
});
};

$scope.cancelPushFeatureRequest = function () {
$scope.featureRequestToPush = {};
$scope.resetInternalRequestForms();
};

$scope.editInternalRequest = function (internalRequest) {
$scope.internalRequestToEdit = angular.copy(internalRequest);
$scope.openModal('#editInternalRequestModal');
};

$scope.updateInternalRequest = function () {
$scope.internalRequestToEdit.dirty(true);
$scope.internalRequestToEdit.save().then(function () {
$scope.cancelEditInternalRequest();
});
};

$scope.cancelEditInternalRequest = function () {
$scope.internalRequestToEdit.refresh();
$scope.resetInternalRequestForms();
};

$scope.confirmDeleteInternalRequest = function (internalRequest) {
$scope.internalRequestToDelete = angular.copy(internalRequest);
$scope.openModal('#deleteInternalRequestModal');
};

$scope.cancelDeleteInternalRequest = function () {
$scope.internalRequestToDelete = {};
$scope.closeModal();
};

$scope.deleteInternalRequest = function (internalRequest) {
InternalRequestRepo.delete(internalRequest).then(function (res) {
if (angular.fromJson(res.body).meta.status === "SUCCESS") {
$scope.cancelDeleteInternalRequest();
}
});
};

RemoteProductManagerRepo.listen([ApiResponseActions.CREATE, ApiResponseActions.DELETE, ApiResponseActions.UPDATE], function () {
var remoteProductManagers = RemoteProductManagerRepo.getAll();

$scope.remoteProductManagers.length = 0;

for (var i in remoteProductManagers) {
$scope.remoteProductManagers.push(remoteProductManagers[i]);
}
});
}

InternalRequestRepo.listen([ApiResponseActions.CREATE, ApiResponseActions.DELETE, ApiResponseActions.UPDATE], function () {
var internalRequests = InternalRequestRepo.getAll();

$scope.internalRequests.length = 0;

for (var i in internalRequests) {
$scope.internalRequests.push(internalRequests[i]);
}
});

});
4 changes: 4 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
<!-- Services -->
<script src="services/remoteProductsService.js"></script>
<script src="services/productsStatsService.js"></script>
<script src="services/internalRequestsService.js"></script>
<script src="services/activeSprintsService.js"></script>

<!-- Factories -->
Expand All @@ -206,18 +207,21 @@

<!-- Repos -->
<script src="repo/abstractAppRepo.js"></script>
<script src="repo/internalRequestRepo.js"></script>
<script src="repo/productRepo.js"></script>
<script src="repo/userRepo.js"></script>
<script src="repo/remoteProductManagerRepo.js"></script>
<script src="repo/statusRepo.js"></script>

<!-- Models -->
<script src="model/abstractAppModel.js"></script>
<script src="model/internalRequest.js"></script>
<script src="model/product.js"></script>
<script src="model/remoteProductManager.js"></script>
<script src="model/status.js"></script>

<!-- Controllers -->
<script src="controllers/internalRequestController.js"></script>
<script src="controllers/productController.js"></script>
<script src="controllers/statusController.js"></script>
<script src="controllers/userRepoController.js"></script>
Expand Down
7 changes: 7 additions & 0 deletions app/model/internalRequest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
app.model("InternalRequest", function InternalRequest() {
return function InternalRequest() {
var internalRequest = this;

return internalRequest;
};
});
11 changes: 11 additions & 0 deletions app/repo/internalRequestRepo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
app.repo("InternalRequestRepo", function InternalRequestRepo() {
var internalRequestRepo = this;

internalRequestRepo.scaffold = {
title: '',
description: '',
timestamp: null
};

return internalRequestRepo;
});
8 changes: 8 additions & 0 deletions app/services/internalRequestsService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
app.service('InternalRequestsService', function ($q, InternalRequestRepo, WsApi) {
var internalRequestsService = this;

internalRequestsService.push = function (featureRequest) {
return WsApi.fetch(apiMapping.InternalRequest.push);
};

});
1 change: 1 addition & 0 deletions app/views/management.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<wvr-tab path="products" view="views/management/products.html" label="products">Products</wvr-tab>
<wvr-tab path="statuses" view="views/management/statuses.html" label="statuses">Statuses</wvr-tab>
<wvr-tab path="remoteProductManager" view="views/management/remoteProductManager.html" label="remoteProductManager">Remote Progect Managers</wvr-tab>
<wvr-tab path="internalRequests" view="views/management/internalRequests.html" label="internalRequests">Internal Requests</wvr-tab>
<wvr-tab path="users" view="views/management/users.html" label="users">Users</wvr-tab>
</wvr-tabs>

Expand Down
25 changes: 25 additions & 0 deletions app/views/management/internalRequests.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div class="management-table" ng-controller="InternalRequestController">

<table class="table table-bordered table-striped internalRequest-table">
<tr>
<th>Title</th>
<th>Description</th>
<th>Created On</th>
<th class="actions-column text-center">Actions</th>
</tr>
<tr ng-repeat="internalRequest in internalRequests">
<td title="'Title'">{{internalRequest.title}}</td>
<td title="'Description'">{{internalRequest.description}}</td>
<td title="'Created On'">{{internalRequest.createdOn | date : "medium"}}</td>
<td class="actions-column text-center" title="'Actions'">
<span class="glyphicon glyphicon-upload" title="Push" ng-click="pushInternalRequest(internalRequest)"></span>
<span class="glyphicon glyphicon-pencil" title="Edit" ng-click="editInternalRequest(internalRequest)"></span>
<span class="glyphicon glyphicon-trash" title="Delete" ng-click="confirmDeleteInternalRequest(internalRequest)"></span>
</td>
</tr>
</table>

<modal modal-id="pushInternalRequestModal" modal-view="views/modals/pushInternalRequestModal.html" modal-header-class="modal-header-primary" wvr-modal-backdrop="static"></modal>
<modal modal-id="editInternalRequestModal" modal-view="views/modals/editInternalRequestModal.html" modal-header-class="modal-header-primary" wvr-modal-backdrop="static"></modal>
<modal modal-id="deleteInternalRequestModal" modal-view="views/modals/deleteInternalRequestModal.html" modal-header-class="modal-header-danger" wvr-modal-backdrop="static"></modal>
</div>
14 changes: 14 additions & 0 deletions app/views/modals/deleteInternalRequestModal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<form name="internalRequestForm.create" ng-submit="deleteInternalRequest(internalRequestToDelete)" novalidate>
<div class="modal-header {{attr.modalHeaderClass}}">
<button type="button" class="close modal-close" aria-label="Close" ng-click="cancelDeleteInternalRequest()"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Confirm Removal</h4>
</div>
<div class="modal-body">
<h3>Are you sure you want to remove:</h3>
<p>{{internalRequestToDelete.title}}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="cancelDeleteInternalRequest()">Cancel</button>
<button type="submit" class="btn btn-danger">Confirm</button>
</div>
</form>
42 changes: 42 additions & 0 deletions app/views/modals/editInternalRequestModal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<div class="modal-header {{attr.modalHeaderClass}}">
<button type="button" class="close modal-close" aria-label="Close" ng-click="cancelEditInternalRequest()">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">Edit InternalRequest</h4>
</div>

<form name="internalRequestForms.edit" ng-submit="updateInternalRequest()" novalidate>

<validationmessage results="internalRequestForms.getResults()"></validationmessage>

<div class="modal-body">
<validatedinput
id="internalRequestTitle"
model="internalRequestToEdit"
property="title"
placeholder="Title of the Internal Request"
label="Title"
form="internalRequest.edit"
validations="internalRequestForms.validations"
results="internalRequestForms.getResults()"
autocomplete="off">
</validatedinput>

<validatedinput
id="internalRequestDescription"
model="internalRequestToEdit"
property="description"
placeholder="Description of the Internal Request"
label="Description"
form="internalRequest.edit"
validations="internalRequestForms.validations"
results="internalRequestForms.getResults()"
autocomplete="off">
</validatedinput>
</div>

<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="cancelEditInternalRequest()">Cancel</button>
<button type="submit" class="btn btn-success" ng-disabled="!internalRequestForms.edit.$dirty || internalRequestForms.edit.$invalid">Update</button>
</div>
</form>
59 changes: 59 additions & 0 deletions app/views/modals/pushInternalRequestModal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<div class="modal-header {{attr.modalHeaderClass}}">
<button type="button" class="close modal-close" aria-label="Close" ng-click="cancelPushFeatureRequest()">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">Push Internal Request (Feature Request)</h4>
</div>

<form name="internalRequestForms.push" ng-submit="pushFeatureRequest()" novalidate>

<validationmessage results="internalRequestForms.getResults()"></validationmessage>

<div class="modal-body">
<validatedinput
id="internalRequestTitle"
model="featureRequestToPush"
property="title"
placeholder="Title of the Feature Request"
label="Title"
disabled="'true'"
form="internalRequest.push"
validations="internalRequestForms.validations"
results="internalRequestForms.getResults()"
autocomplete="off">
</validatedinput>

<validatedinput
id="internalRequestDescription"
model="featureRequestToPush"
property="description"
placeholder="Description of the Feature Request"
label="Description"
disabled="'true'"
form="internalRequest.push"
validations="internalRequestForms.validations"
results="internalRequestForms.getResults()"
autocomplete="off">
</validatedinput>

<div class="form-group">
<label for="productId">Associate Remote Product Manager</label>
<select class="form-control" ng-options="remoteProductManager.id as remoteProductManager.name for remoteProductManager in remoteProductManagers" ng-model="featureRequestToPush.productId" name="productId">
<option value="" selected>None</option>
</select>
</div>

<div class="form-group" ng-if="featureRequestToPush.productId">
<label for="scopeId">Associate Version Product</label>
<select class="form-control" ng-options="projectScope.id as projectScope.name for projectScope in getRemoteProductManagerRemoteProducts(featureRequestToPush.productId) | orderBy:'name'"
ng-model="featureRequestToPush.scopeId" name="scopeId">
<option value="" selected>None</option>
</select>
</div>

</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="cancelPushFeatureRequest()">Cancel</button>
<button type="submit" class="btn btn-success" ng-disabled="!internalRequestForms.push.$dirty || internalRequestForms.push.$invalid">Push</button>
</div>
</form>
22 changes: 22 additions & 0 deletions tests/mock/model/mockFeatureRequest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var dataFeatureRequest1 = {
title: "Internal Request 1",
description: "description 1",
projectId: 1,
scopeId: "scope 1"
};

var dataFeatureRequest2 = {
title: "Internal Request 2",
description: "description 2",
projectId: 1,
scopeId: "scope 2"
};

var dataFeatureRequest3 = {
title: "Internal Request 3",
description: "description 3",
projectId: 2,
scopeId: "scope 3"
};

// There is no actual FeatureRequest model and only exists as data objects.

0 comments on commit cdcd54b

Please sign in to comment.