Fix setting image priority
Let's say there are 2 images, A and B. A has a priority of 0
and B has a priority of 50. Lowest priority is the image used
to boot from and appears at the top of the image tables
(A in this case). If the user wanted image B to be the image
with the lowest priority, they would have to hit the up arrow
50 times in the old logic.
Move to setting the priority based on the image above, for
the up arrow, or below, for the down arrow.
If 2 images have the same priority, the image whose priority is
being updated wins and the image who already has that priority
gets bumped up 1, this is why when moving an image down we set
to the below image's priority +1, but don't need this -1 when
moving an image up in the table.
Tested: Can still change the priority.
Change-Id: If87e1d863ab909c276247072cc45e40b67cf686b
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/app/common/directives/firmware-list.html b/app/common/directives/firmware-list.html
index 55dd22e..00fb8f2 100644
--- a/app/common/directives/firmware-list.html
+++ b/app/common/directives/firmware-list.html
@@ -25,11 +25,11 @@
<div class="table__cell">
<span class="table__cell-label">Boot priority:</span>
<div class="icon icon__up-arrow" aria-hidden="true" ng-class="{'icon-as-spacer':$first}"
- ng-click="!$first && changePriority(firmware.imageId, firmware.Version, firmware.Priority, firmware.Priority - 1)"
+ ng-click="!$first && changePriority(firmware.imageId, firmware.Version, firmware.Priority, imageList[$index-1].Priority)"
ng-show="firmware.activationStatus == 'Functional' || firmware.activationStatus == 'Active'">
<span class="accessible-text">firmware up in priority</span></div>
<div class="icon icon__down-arrow" aria-hidden="true" ng-class="{'icon-as-spacer':$last || !['Active', 'Functional'].includes(imageList[$index+1].activationStatus)}"
- ng-click="(!$last && ['Active', 'Functional'].includes(imageList[$index + 1].activationStatus)) && changePriority(firmware.imageId, firmware.Version, firmware.Priority, firmware.Priority + 2)"
+ ng-click="(!$last && ['Active', 'Functional'].includes(imageList[$index + 1].activationStatus)) && changePriority(firmware.imageId, firmware.Version, firmware.Priority, imageList[$index+1].Priority + 1)"
ng-show="firmware.activationStatus == 'Functional' || firmware.activationStatus == 'Active'">
<span class="accessible-text">firmware down in priority</span></div>
</div>