Skip to content

Commit

Permalink
Merge 91790cc into 4e439de
Browse files Browse the repository at this point in the history
  • Loading branch information
kaladay committed Aug 15, 2018
2 parents 4e439de + 91790cc commit 4f5789c
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 30 deletions.
10 changes: 5 additions & 5 deletions app/config/apiMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ var apiMapping = {
'controller': 'feature-proposals',
'method': 'update'
},
reject: {
'endpoint': '/private/queue',
'controller': 'feature-proposals',
'method': 'reject'
},
remove: {
'endpoint': '/private/queue',
'controller': 'feature-proposals',
Expand All @@ -153,11 +158,6 @@ var apiMapping = {
'controller': 'feature-proposals',
'method': ':id/vote'
},
reject: {
'endpoint': '/private/queue',
'controller': 'feature-proposals',
'method': ':id/reject'
},
createListen: {
'endpoint': '/channel',
'controller': 'feature-proposals/create'
Expand Down
16 changes: 13 additions & 3 deletions app/controllers/featureProposalController.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,21 @@ app.controller('FeatureProposalController', function($controller, $scope, Idea,
});
};

$scope.rejectFeatureProposal = function (fp) {
$scope.fpRepo.reject($scope.fpData).then(function (res) {
if (angular.fromJson(res.body).meta.status === 'SUCCESS') {
$scope.confirmReject = function(fp) {
$scope.resetFeatureProposals();
$scope.openModal('#rejectFpModal');
$scope.fpToReject = fp;
};

$scope.rejectFeatureProposal = function () {
$scope.updating = true;
$scope.fpRepo.reject($scope.fpToReject).then(function(res) {
var result = angular.fromJson(res.body);
if (result.meta.status === 'SUCCESS') {
$scope.resetFeatureProposals();
$scope.fpToReject = {};
}
$scope.updating = false;
});
};

Expand Down
14 changes: 7 additions & 7 deletions app/repo/featureProposalRepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ app.repo("FeatureProposalRepo", function FeatureProposalRepo($q, WsApi, FeatureP
return WsApi.fetch(featureProposalRepo.mapping.elevate);
};

featureProposalRepo.reject = function (fp) {
angular.extend(featureProposalRepo.mapping.reject, {
'data': fp
});
return WsApi.fetch(featureProposalRepo.mapping.reject);
};

featureProposalRepo.vote = function (fp) {
angular.extend(featureProposalRepo.mapping.vote, {
'method': fp.id + "/vote"
});
return WsApi.fetch(featureProposalRepo.mapping.vote);
};

featureProposalRepo.reject = function (fp) {
angular.extend(featureProposalRepo.mapping.reject, {
'method': fp.id + "/reject"
});
return WsApi.fetch(featureProposalRepo.mapping.reject);
};

var table = TableFactory.buildTable({
pageNumber: sessionStorage.getItem('feature-proposals-page') ? sessionStorage.getItem('feature-proposals-page') : 1,
pageSize: sessionStorage.getItem('feature-proposals-size') ? sessionStorage.getItem('feature-proposals-size') : 10,
Expand Down
4 changes: 2 additions & 2 deletions app/views/detail/service/featureProposals.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<button class="btn btn-default view-action-button" ng-click="initCreateFeatureProposal()">Add Feature Proposal</button>
<hr>

<weaver-table weaver-table="weaverTableDetail" ng-init="useDetailTable()">
<weaver-table-controls>
<button class="btn btn-default view-action-button pull-right" ng-click="initCreateFeatureProposal()">Add Feature Proposal</button>
Expand All @@ -24,7 +24,7 @@
<td title="'Visible to Anonymous Users'">{{fp.isPublic}}</td>
<td class="actions-column text-center" title="'Actions'">
<span ng-if="!hasState('SUBMITTED', fp) && !hasState('REJECTED', fp)" class="toggle-href glyphicon glyphicon-upload" title="submit" ng-click="select(fp, '#submitFpModal');"></span>
<span ng-if="!hasState('SUBMITTED', fp) && !hasState('REJECTED', fp)" class="toggle-href glyphicon glyphicon-ban-circle" title="reject" ng-click="select(fp, '#rejectFpModal');"></span>
<span ng-if="!hasState('SUBMITTED', fp) && !hasState('REJECTED', fp)" class="toggle-href glyphicon glyphicon-ban-circle" title="reject" ng-click="confirmReject(fp)"></span>
<span class="toggle-href glyphicon glyphicon-pencil" title="edit" ng-click="editFeatureProposal(fp)"></span>
<span class="toggle-href glyphicon glyphicon-trash" title="delete" ng-if="fp.ideas.length === 0" ng-click="confirmDeleteFp(fp)"></span>
</td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/management/featureProposals.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<td title="'Visible to Anonymous Users'">{{fp.isPublic}}</td>
<td class="actions-column text-center" title="'Actions'">
<span ng-if="!hasState('SUBMITTED', fp) && !hasState('REJECTED', fp)" class="toggle-href glyphicon glyphicon-upload" title="submit" ng-click="select(fp, '#submitFpModal');"></span>
<span ng-if="!hasState('SUBMITTED', fp) && !hasState('REJECTED', fp)" class="toggle-href glyphicon glyphicon-ban-circle" title="reject" ng-click="select(fp, '#rejectFpModal');"></span>
<span ng-if="!hasState('SUBMITTED', fp) && !hasState('REJECTED', fp)" class="toggle-href glyphicon glyphicon-ban-circle" title="reject" ng-click="confirmReject(fp)"></span>
<span class="glyphicon glyphicon-pencil" title="edit" ng-click="editFeatureProposal(fp)"></span>
<span class="glyphicon glyphicon-trash" title="delete" ng-click="confirmDeleteFp(fp)"></span>
</td>
Expand Down
6 changes: 6 additions & 0 deletions app/views/modals/detail/service/editFpModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ <h3 class="modal-title">Edit Feature Proposal</h3>

<validatedselect model="fpData" property="state" label="State" form="forms.updateFp" validations="fpRepo.getValidations()" results="fpRepo.getValidationResults()" options="state" optionProperty="gloss" optionValue="value"></validatedselect>

<div ng-if="hasState('REJECTED', fpData)">
<label>Reason for Rejection</label>
<textarea required="hasState('REJECTED', fpData)" class="form-control" ng-model="fpData.feedback"></textarea>
<br>
</div>

<label>Feature Proposal Description</label>
<textarea class="form-control" ng-model="fpData.description"></textarea>

Expand Down
14 changes: 8 additions & 6 deletions app/views/modals/detail/service/rejectFpModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@
<button type="button" class="close" ng-click="closeModal()" aria-label="Close">
<span class="modal-close" aria-hidden="true">&times;</span>
</button>
<h3 class="modal-title">Are You Sure?</h3>
<h3 class="modal-title">Reject {{fpToReject.title}}</h3>
</div>

<form novalidate>
<validationmessage results="fpRepo.getValidationResults()"></validationmessage>
<alerts channel="/private/queue/feature-proposals/reject" types="WARNING, ERROR, INVALID"></alerts>

<div class="modal-body">
Confirm rejection of feature proposal {{fpData.title}}.
<validatedtextarea model="fpToReject" property="feedback" label="Reason for Rejection" form="forms.rejectFeatureProposal" validations="fpRepo.getValidations()" results="fpRepo.getValidationResults()"></validatedtextarea>
</div>

<div class="modal-footer">
<button ng-disabled="submitting" type="button" class="btn btn-default" ng-click="closeModal()">Cancel</button>
<button ng-disabled="submitting" type="button" class="btn btn-danger" ng-click="rejectFeatureProposal(fpData)">
<span ng-if="!submitting">Confirm</span>
<span ng-if="submitting">Submitting
<button ng-disabled="updating" type="button" class="btn btn-default" ng-click="closeModal()">Cancel</button>
<button ng-disabled="updating" type="button" class="btn btn-danger" ng-click="rejectFeatureProposal()">
<span ng-if="!updating">Confirm</span>
<span ng-if="updating">Rejecting
<span class="glyphicon glyphicon-refresh spinning"></span>
</span>
</button>
Expand Down
3 changes: 3 additions & 0 deletions tests/mocks/models/mockFeatureProposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var mockFeatureProposal1 = {
"notes": []
},
"description": "<p>This is <strong>Jack's</strong> feature Proposal.</p>",
"feedback": "",
"id": 123456789,
"lastModified": 1529618244432,
"service": {
Expand Down Expand Up @@ -45,6 +46,7 @@ var mockFeatureProposal2 = {
"notes": []
},
"description": "<p>This is <strong>Jill's</strong> feature Proposal.</p>",
"feedback": "",
"id": 987654321,
"lastModified": 1234567890120,
"service": {
Expand Down Expand Up @@ -80,6 +82,7 @@ var mockFeatureProposal3 = {
"notes": []
},
"description": "<p>This is <strong>Jacob's</strong> feature Proposal.</p>",
"feedback": "Unacceptable.",
"id": 192837465,
"lastModified": 1529679921989,
"service": {
Expand Down
3 changes: 3 additions & 0 deletions tests/mocks/models/mockIdea.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var mockIdea1 = {
},
"description": "<p>This is <strong>Jack's</strong> idea.</p>",
"elevated": false,
"feedback": "",
"id": 123456789,
"lastModified": 1529618244432,
"service": {
Expand Down Expand Up @@ -46,6 +47,7 @@ var mockIdea2 = {
},
"description": "<p>This is <strong>Jill's</strong> idea.</p>",
"elevated": false,
"feedback": "",
"id": 987654321,
"lastModified": 1234567890120,
"service": {
Expand Down Expand Up @@ -81,6 +83,7 @@ var mockIdea3 = {
},
"description": "<p>This is <strong>Jacob's</strong> idea.</p>",
"elevated": false,
"feedback": "",
"id": 192837465,
"lastModified": 1529679921989,
"service": {
Expand Down
12 changes: 8 additions & 4 deletions tests/mocks/repo/mockFeatureProposalRepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var mockFeatureProposals = [
"notes": []
},
"description": "<p>This is <strong>Jack's</strong> feature Proposal.</p>",
"feedback": "",
"id": 123456789,
"lastModified": 1529618244432,
"service": {
Expand Down Expand Up @@ -45,6 +46,7 @@ var mockFeatureProposals = [
"notes": []
},
"description": "<p>This is <strong>Jill's</strong> feature Proposal.</p>",
"feedback": "",
"id": 987654321,
"lastModified": 1234567890120,
"service": {
Expand Down Expand Up @@ -79,6 +81,7 @@ var mockFeatureProposals = [
"notes": []
},
"description": "<p>This is <strong>Jacob's</strong> feature Proposal.</p>",
"feedback": "Unacceptable.",
"id": 192837465,
"lastModified": 1529679921989,
"service": {
Expand Down Expand Up @@ -144,7 +147,7 @@ angular.module('mock.featureProposalRepo', []).service('FeatureProposalRepo', fu
var featureProposal = {};
for (var i in featureProposalRepo.list) {
if (featureProposalRepo.list[i].id === id) {
featureProposal = featureProposalRepo.list[i];
angular.copy(featureProposalRepo.list[i], featureProposal);
break;
}
}
Expand Down Expand Up @@ -188,13 +191,14 @@ angular.module('mock.featureProposalRepo', []).service('FeatureProposalRepo', fu
});
};

featureProposalRepo.reject = function (id) {
featureProposalRepo.reject = function (fp) {
return $q(function (resolve) {
var featureProposal = {};
for (var i in featureProposalRepo.list) {
if (featureProposalRepo.list[i].id === id) {
if (featureProposalRepo.list[i].id === fp.id) {
featureProposalRepo.list[i].state = "REJECTED";
featureProposalRepo.list[i].feedback = fp.feedback;
featureProposal = featureProposalRepo.list[i];
featureProposal.state = "REJECTED";
break;
}
}
Expand Down
3 changes: 3 additions & 0 deletions tests/mocks/repo/mockIdeaRepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var mockIdeas = [
},
"description": "<p>This is <strong>Jack's</strong> idea.</p>",
"elevated": false,
"feedback": "",
"id": 123456789,
"lastModified": 1529618244432,
"service": {
Expand Down Expand Up @@ -46,6 +47,7 @@ var mockIdeas = [
},
"description": "<p>This is <strong>Jill's</strong> idea.</p>",
"elevated": false,
"feedback": "",
"id": 987654321,
"lastModified": 1234567890120,
"service": {
Expand Down Expand Up @@ -80,6 +82,7 @@ var mockIdeas = [
},
"description": "<p>This is <strong>Jacob's</strong> idea.</p>",
"elevated": false,
"feedback": "",
"id": 192837465,
"lastModified": 1529679921989,
"service": {
Expand Down
10 changes: 8 additions & 2 deletions tests/unit/controllers/featureProposalControllerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,14 @@ describe('controller: FeatureProposalController', function () {
var id = 123456789;
var featureProposal = FeatureProposalRepo.fetchById(id);
featureProposal.state = "REJECTED";
scope.rejectFeatureProposal(id);
expect(FeatureProposalRepo.fetchById(id)).toEqual(featureProposal);
featureProposal.feedback = "Not wanted";
scope.fpToReject = featureProposal;
scope.rejectFeatureProposal();

var updatedFeatureProposal = FeatureProposalRepo.fetchById(id);
expect(updatedFeatureProposal).toEqual(featureProposal);
expect(updatedFeatureProposal.state).toEqual(featureProposal.state);
expect(updatedFeatureProposal.feedback).toEqual(featureProposal.feedback);
});
});
});

0 comments on commit 4f5789c

Please sign in to comment.