Merge pull request 'sorted crusade cards' (#9) from feature/sort-army-list into master
Reviewed-on: mitch/crusade-tracker#9
This commit is contained in:
commit
0e9e145715
@ -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}}:
|
||||
|
@ -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">
|
||||
|
@ -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']) {
|
||||
|
Loading…
Reference in New Issue
Block a user