Skip to content

Commit abbe64f

Browse files
Do not require reason on needs attention status update
1 parent c8e489e commit abbe64f

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

src/cce-inventory-item-status/status-update-modal.controller.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
vm.$onInit = onInit;
4747
vm.isUnserviceable = isUnserviceable;
4848
vm.isFunctioning = isFunctioning;
49+
vm.isNeedsAttention = isNeedsAttention;
4950
vm.getStatusLabel = getStatusLabel;
5051
vm.getReasonLabel = getReasonLabel;
5152
vm.cancel = cancel;
@@ -166,6 +167,21 @@
166167
return (status === FUNCTIONAL_STATUS.UNSERVICEABLE);
167168
}
168169

170+
/**
171+
* @ngdoc method
172+
* @methodOf cce-inventory-item-status.controller:StatusUpdateModalController
173+
* @name isNeedsAttention
174+
*
175+
* @description
176+
* Checks whether the given status is needs attention.
177+
*
178+
* @param {String} status the status to be checked
179+
* @return {Boolean} true if the status is needs attention; false otherwise
180+
*/
181+
function isNeedsAttention(status) {
182+
return (status === FUNCTIONAL_STATUS.NEEDS_ATTENTION);
183+
}
184+
169185
/**
170186
* @ngdoc method
171187
* @methodOf cce-inventory-item-status.controller:StatusUpdateModalController
@@ -180,7 +196,8 @@
180196
var item = angular.copy(vm.inventoryItem);
181197

182198
item.functionalStatus = vm.newStatus;
183-
item.reasonNotWorkingOrNotInUse = isFunctioning(vm.newStatus) ? undefined : vm.reason;
199+
item.reasonNotWorkingOrNotInUse = isFunctioning(vm.newStatus) || isNeedsAttention(vm.status)
200+
? undefined : vm.reason;
184201
item.decommissionDate =
185202
isUnserviceable(vm.newStatus) ? vm.decommissionDate : undefined;
186203

src/cce-inventory-item-status/status-update-modal.controller.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,24 @@ describe('StatusUpdateModalController', function() {
152152

153153
});
154154

155+
describe('isNeedsAttention', function() {
156+
157+
beforeEach(function() {
158+
vm.$onInit();
159+
});
160+
161+
it('should return true for NEEDS_ATTENTION status', function() {
162+
expect(vm.isNeedsAttention(FUNCTIONAL_STATUS.NEEDS_ATTENTION)).toBe(true);
163+
});
164+
165+
it('should return false for status that is other than NEEDS_ATTENTION', function() {
166+
expect(vm.isNeedsAttention(FUNCTIONAL_STATUS.FUNCTIONING)).toBe(false);
167+
expect(vm.isNeedsAttention(FUNCTIONAL_STATUS.UNSERVICEABLE)).toBe(false);
168+
expect(vm.isNeedsAttention(FUNCTIONAL_STATUS.AWAITING_REPAIR)).toBe(false);
169+
});
170+
171+
});
172+
155173
describe('isUnserviceable', function() {
156174

157175
beforeEach(function() {

src/cce-inventory-item-status/status-update-modal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ <h3 class="title">{{'cceInventoryItemStatus.updateFunctionalStatus' | message}}<
5858
required>
5959
</select>
6060

61-
<fieldset ng-if="vm.newStatus && !vm.isFunctioning(vm.newStatus)">
61+
<fieldset ng-if="vm.newStatus && !vm.isFunctioning(vm.newStatus) && !vm.isNeedsAttention(vm.newStatus)">
6262
<label for="reason">
6363
{{'cceInventoryItemStatus.reasonNotWorkingOrNotInUse' | message}}
6464
</label>

0 commit comments

Comments
 (0)