sorted crusade cards

This commit is contained in:
mitch 2022-03-05 17:02:04 -05:00
parent 50bbb6a54d
commit e6557fade3
3 changed files with 13 additions and 3 deletions

View File

@ -69,7 +69,7 @@
<div class="col-md-1" style="border: 1px solid black; background: whitesmoke; color: #0f0f0f;">CRUSADE POINTS</div>
<div class="col-md-1" style="border: 1px solid black; background: whitesmoke; color: #0f0f0f;">ADD TO FORCE</div>
</div>
<div *ngFor="let unit of army.units; let rowIndex=index">
<div *ngFor="let unit of sortUnits(army.units); let rowIndex=index">
<div class="row">
<div class="col-md-3" style="border: 1px solid black;">
Unit {{rowIndex + 1}}:

View File

@ -35,7 +35,8 @@
</div>
</div>
<div *ngFor="let unit of army.units; let rowIndex=index">
<div *ngFor="let unit of sortUnits(army.units); let rowIndex=index">
<!-- <div *ngFor="let unit of army.units; let rowIndex=index">-->
<br/>
<div class="crusade-cards" style="padding-top: 10px">

View File

@ -4,7 +4,7 @@ import { JhiDataUtils } from 'ng-jhipster';
import { LocalStorage } from 'ngx-webstorage';
import { IArmy } from 'app/shared/model/army.model';
import { UnitArmy } from '../../shared/model/unit-army.model';
import {IUnitArmy, UnitArmy} from '../../shared/model/unit-army.model';
import {DomSanitizer} from "@angular/platform-browser";
import {ResponsiveService} from "../../responsive.service";
@ -46,6 +46,15 @@ export class ArmyDetailComponent implements OnInit {
console.log(msg);
}
sortUnits(unitArmy: IUnitArmy[] | undefined): Array<UnitArmy> | undefined {
if (unitArmy) {
// @ts-ignore
unitArmy.sort((a,b) => a.unitName.localeCompare(b.unitName));
return unitArmy
}
return unitArmy
}
calculatePoints(armylocal: IArmy): Number {
let total = 0;
if (armylocal['units']) {